| 16 | namespace Star { |
| 17 | |
| 18 | BaseScriptPane::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 | |
| 45 | void BaseScriptPane::show() { |
| 46 | Pane::show(); |
nothing calls this directly
no test coverage detected