* Constructor for the window. * @param desc The description of the window. * @param slot The company we're changing the Script for. * @param show_all Whether to show all available versions. */
| 69 | * @param show_all Whether to show all available versions. |
| 70 | */ |
| 71 | ScriptListWindow(WindowDesc &desc, CompanyID slot, bool show_all) : Window(desc), |
| 72 | slot(slot), show_all(show_all) |
| 73 | { |
| 74 | if (this->slot == OWNER_DEITY) { |
| 75 | this->info_list = this->show_all ? Game::GetInfoList() : Game::GetUniqueInfoList(); |
| 76 | } else { |
| 77 | this->info_list = this->show_all ? AI::GetInfoList() : AI::GetUniqueInfoList(); |
| 78 | } |
| 79 | |
| 80 | this->CreateNestedTree(); |
| 81 | this->vscroll = this->GetScrollbar(WID_SCRL_SCROLLBAR); |
| 82 | this->FinishInitNested(); // Initializes 'this->line_height' as side effect. |
| 83 | |
| 84 | this->vscroll->SetCount(this->info_list->size() + 1); |
| 85 | |
| 86 | /* Try if we can find the currently selected AI */ |
| 87 | if (GetConfig(this->slot)->HasScript()) { |
| 88 | ScriptInfo *info = GetConfig(this->slot)->GetInfo(); |
| 89 | int i = 0; |
| 90 | for (const auto &item : *this->info_list) { |
| 91 | if (item.second == info) { |
| 92 | this->selected = i; |
| 93 | break; |
| 94 | } |
| 95 | |
| 96 | i++; |
| 97 | } |
| 98 | } |
| 99 | } |
| 100 | |
| 101 | std::string GetWidgetString(WidgetID widget, StringID stringid) const override |
| 102 | { |
nothing calls this directly
no test coverage detected