MCPcopy Create free account
hub / github.com/OpenTTD/OpenTTD / ScriptListWindow

Method ScriptListWindow

src/script/script_gui.cpp:71–99  ·  view source on GitHub ↗

* 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. */

Source from the content-addressed store, hash-verified

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 {

Callers

nothing calls this directly

Calls 8

GetConfigFunction · 0.85
CreateNestedTreeMethod · 0.80
GetScrollbarMethod · 0.80
FinishInitNestedMethod · 0.80
SetCountMethod · 0.45
sizeMethod · 0.45
HasScriptMethod · 0.45
GetInfoMethod · 0.45

Tested by

no test coverage detected