MCPcopy Create free account
hub / github.com/OpenStarbound/OpenStarbound / BaseScriptPane

Method BaseScriptPane

source/frontend/StarBaseScriptPane.cpp:18–43  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

16namespace Star {
17
18BaseScriptPane::BaseScriptPane(Json config, bool construct) : Pane(), m_rawConfig(config) {
19 auto& root = Root::singleton();
20 auto assets = root.assets();
21
22 if (config.type() == Json::Type::Object && config.contains("baseConfig")) {
23 auto baseConfig = assets->fetchJson(config.getString("baseConfig"));
24 m_config = jsonMerge(baseConfig, config);
25 } else {
26 m_config = assets->fetchJson(config);
27 }
28
29 m_interactive = m_config.getBool("interactive", true);
30 m_reader = make_shared<GuiReader>();
31 m_reader->registerCallback("close", [this](Widget*) { dismiss(); });
32
33 for (auto const& callbackName : jsonToStringList(m_config.get("scriptWidgetCallbacks", JsonArray{}))) {
34 m_reader->registerCallback(callbackName, [this, callbackName](Widget* widget) {
35 m_script.invoke(callbackName, widget->name(), widget->data());
36 });
37 }
38
39 if (construct)
40 this->construct(assets->fetchJson(m_config.get("gui")));
41
42 m_callbacksAdded = false;
43}
44
45void BaseScriptPane::show() {
46 Pane::show();

Callers

nothing calls this directly

Calls 15

constructMethod · 0.95
singletonClass · 0.85
jsonToStringListFunction · 0.85
assetsMethod · 0.80
fetchJsonMethod · 0.80
getStringMethod · 0.80
getBoolMethod · 0.80
jsonMergeFunction · 0.50
typeMethod · 0.45
containsMethod · 0.45
registerCallbackMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected