MCPcopy Create free account
hub / github.com/WolfireGames/overgrowth / Initialize

Method Initialize

Source/GUI/scriptable_ui.cpp:58–114  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

56} // Anonymous namespace
57
58void ScriptableUI::Initialize(const Path& script_path, const ASData& as_data, bool debug_break) {
59 mod_activation_change_ = false;
60 LOG_ASSERT(!as_context && !hud_images);
61 // Construct all the components
62 as_context = new ASContext("scriptable_ui", as_data);
63 if (debug_break)
64 as_context->dbg.Break();
65 hud_images = new HUDImages();
66 // Attach necessary script functionality
67 AttachTextCanvasTextureToASContext(as_context);
68 AttachStringConvert(as_context);
69 AttachIMUI(as_context);
70 AttachScreenWidth(as_context);
71 hud_images->AttachToContext(as_context);
72 AttachLevelSet(as_context);
73 AttachLevelXML(as_context);
74 AttachUIQueries(as_context);
75 AttachTokenIterator(as_context);
76 AttachScriptableUI(as_context, this);
77 AttachSimpleFile(as_context);
78 AttachLocale(as_context);
79 AttachIMGUI(as_context);
80 AttachIMGUIModding(as_context);
81 AttachInterlevelData(as_context);
82 AttachEngine(as_context);
83 AttachOnline(as_context);
84
85 AttachSaveFile(as_context, &Engine::Instance()->save_file_);
86
87 as_funcs.initialize = as_context->RegisterExpectedFunction("void Initialize()", true);
88 as_funcs.can_go_back = as_context->RegisterExpectedFunction("bool CanGoBack()", true);
89 as_funcs.dispose = as_context->RegisterExpectedFunction("void Dispose()", true);
90 as_funcs.draw_gui = as_context->RegisterExpectedFunction("void DrawGUI()", true);
91 as_funcs.update = as_context->RegisterExpectedFunction("void Update()", true);
92
93 as_funcs.mod_activation_reload = as_context->RegisterExpectedFunction("void ModActivationReload()", false);
94 as_funcs.resize = as_context->RegisterExpectedFunction("void Resize()", false);
95 as_funcs.script_reloaded = as_context->RegisterExpectedFunction("void ScriptReloaded()", false);
96
97 as_funcs.queue_basic_popup = as_context->RegisterExpectedFunction("void QueueBasicPopup(string title, string body)", false);
98
99 // Get screen dimensions so we can detect when things change
100 currentWindowDims[0] = Graphics::Instance()->window_dims[0];
101 currentWindowDims[1] = Graphics::Instance()->window_dims[1];
102
103 PROFILER_ENTER(g_profiler_ctx, "Exporting docs");
104 char path[kPathSize];
105 FormatString(path, kPathSize, "%sasscriptable_ui_docs.h", GetWritePath(CoreGameModID).c_str());
106 as_context->ExportDocs(path);
107 PROFILER_LEAVE(g_profiler_ctx);
108
109 // Load script and run init function
110 as_context->LoadScript(script_path);
111 as_context->CallScriptFunction(as_funcs.initialize);
112
113 ModLoading::Instance().RegisterCallback(this);
114}
115

Callers

nothing calls this directly

Calls 15

AttachStringConvertFunction · 0.85
AttachIMUIFunction · 0.85
AttachScreenWidthFunction · 0.85
AttachLevelSetFunction · 0.85
AttachLevelXMLFunction · 0.85
AttachUIQueriesFunction · 0.85
AttachTokenIteratorFunction · 0.85
AttachScriptableUIFunction · 0.85
AttachSimpleFileFunction · 0.85
AttachLocaleFunction · 0.85
AttachIMGUIFunction · 0.85

Tested by

no test coverage detected