Веб-сайт самохостера Lotigara

summaryrefslogtreecommitdiff
path: root/source
diff options
context:
space:
mode:
Diffstat (limited to 'source')
-rw-r--r--source/core/StarLua.hpp7
-rw-r--r--source/core/StarLuaConverters.cpp12
-rw-r--r--source/core/StarLuaConverters.hpp6
-rw-r--r--source/frontend/CMakeLists.txt2
-rw-r--r--source/frontend/StarBaseScriptPane.cpp65
-rw-r--r--source/frontend/StarBaseScriptPane.hpp7
-rw-r--r--source/frontend/StarContainerInterface.cpp2
-rw-r--r--source/frontend/StarInterfaceLuaBindings.cpp12
-rw-r--r--source/frontend/StarMainInterfaceTypes.cpp26
-rw-r--r--source/frontend/StarMainInterfaceTypes.hpp2
-rw-r--r--source/frontend/StarScriptPane.cpp19
-rw-r--r--source/frontend/StarScriptPane.hpp3
-rw-r--r--source/windowing/CMakeLists.txt2
-rw-r--r--source/windowing/StarGuiReader.hpp1
-rw-r--r--source/windowing/StarListWidget.hpp1
-rw-r--r--source/windowing/StarPane.cpp131
-rw-r--r--source/windowing/StarPane.hpp7
-rw-r--r--source/windowing/StarRegisteredPaneManager.hpp10
-rw-r--r--source/windowing/StarWidgetLuaBindings.cpp (renamed from source/frontend/StarWidgetLuaBindings.cpp)5
-rw-r--r--source/windowing/StarWidgetLuaBindings.hpp (renamed from source/frontend/StarWidgetLuaBindings.hpp)2
20 files changed, 205 insertions, 117 deletions
diff --git a/source/core/StarLua.hpp b/source/core/StarLua.hpp
index 41310a3..500923d 100644
--- a/source/core/StarLua.hpp
+++ b/source/core/StarLua.hpp
@@ -526,6 +526,10 @@ public:
template <typename Return, typename... Args, typename Function>
LuaFunction createFunctionWithSignature(Function&& func);
+ LuaFunction createWrappedFunction(LuaDetail::LuaWrappedFunction function);
+
+ LuaFunction createRawFunction(lua_CFunction func);
+
LuaThread createThread();
template <typename T>
@@ -639,9 +643,6 @@ private:
int placeHandle();
- LuaFunction createWrappedFunction(LuaDetail::LuaWrappedFunction function);
- LuaFunction createRawFunction(lua_CFunction func);
-
void pushLuaValue(lua_State* state, LuaValue const& luaValue);
LuaValue popLuaValue(lua_State* state);
diff --git a/source/core/StarLuaConverters.cpp b/source/core/StarLuaConverters.cpp
index 9cd44e3..e170da5 100644
--- a/source/core/StarLuaConverters.cpp
+++ b/source/core/StarLuaConverters.cpp
@@ -39,4 +39,16 @@ Maybe<Color> LuaConverter<Color>::to(LuaEngine& engine, LuaValue const& v) {
return {};
}
+LuaValue LuaConverter<LuaCallbacks>::from(LuaEngine& engine, LuaCallbacks const& c) {
+ auto table = engine.createTable(0, c.callbacks().size());
+ for (auto& callback : c.callbacks())
+ table.set(callback.first, engine.createWrappedFunction(callback.second));
+
+ return table;
+}
+
+Maybe<LuaCallbacks> LuaConverter<LuaCallbacks>::to(LuaEngine& engine, LuaValue const& v) {
+ return {};
+}
+
}
diff --git a/source/core/StarLuaConverters.hpp b/source/core/StarLuaConverters.hpp
index c20442f..eb06e35 100644
--- a/source/core/StarLuaConverters.hpp
+++ b/source/core/StarLuaConverters.hpp
@@ -259,6 +259,12 @@ struct LuaConverter<Color> {
static Maybe<Color> to(LuaEngine& engine, LuaValue const& v);
};
+template <>
+struct LuaConverter<LuaCallbacks> {
+ static LuaValue from(LuaEngine& engine, LuaCallbacks const& c);
+ static Maybe<LuaCallbacks> to(LuaEngine& engine, LuaValue const& v);
+};
+
}
#endif
diff --git a/source/frontend/CMakeLists.txt b/source/frontend/CMakeLists.txt
index 4772aa0..ea6edc6 100644
--- a/source/frontend/CMakeLists.txt
+++ b/source/frontend/CMakeLists.txt
@@ -55,7 +55,6 @@ SET (star_frontend_HEADERS
StarSongbookInterface.hpp
StarStatusPane.hpp
StarTeleportDialog.hpp
- StarWidgetLuaBindings.hpp
StarWireInterface.hpp
)
@@ -104,7 +103,6 @@ SET (star_frontend_SOURCES
StarSongbookInterface.cpp
StarStatusPane.cpp
StarTeleportDialog.cpp
- StarWidgetLuaBindings.cpp
StarWireInterface.cpp
)
diff --git a/source/frontend/StarBaseScriptPane.cpp b/source/frontend/StarBaseScriptPane.cpp
index a174622..0254e46 100644
--- a/source/frontend/StarBaseScriptPane.cpp
+++ b/source/frontend/StarBaseScriptPane.cpp
@@ -24,15 +24,17 @@ BaseScriptPane::BaseScriptPane(Json config) : Pane() {
} else {
m_config = assets->fetchJson(config);
}
- m_reader.registerCallback("close", [this](Widget*) { dismiss(); });
+
+ m_reader = make_shared<GuiReader>();
+ m_reader->registerCallback("close", [this](Widget*) { dismiss(); });
for (auto const& callbackName : jsonToStringList(m_config.get("scriptWidgetCallbacks", JsonArray{}))) {
- m_reader.registerCallback(callbackName, [this, callbackName](Widget* widget) {
+ m_reader->registerCallback(callbackName, [this, callbackName](Widget* widget) {
m_script.invoke(callbackName, widget->name(), widget->data());
});
}
- m_reader.construct(assets->fetchJson(m_config.get("gui")), this);
+ m_reader->construct(assets->fetchJson(m_config.get("gui")), this);
for (auto pair : m_config.getObject("canvasClickCallbacks", {}))
m_canvasClickCallbacks.set(findChild<CanvasWidget>(pair.first), pair.second.toString());
@@ -53,7 +55,7 @@ void BaseScriptPane::displayed() {
Pane::displayed();
if (!m_callbacksAdded) {
m_script.addCallbacks("pane", makePaneCallbacks());
- m_script.addCallbacks("widget", LuaBindings::makeWidgetCallbacks(this, &m_reader));
+ m_script.addCallbacks("widget", LuaBindings::makeWidgetCallbacks(this, m_reader));
m_script.addCallbacks("config", LuaBindings::makeConfigCallbacks( [this](String const& name, Json const& def) {
return m_config.query(name, def);
}));
@@ -81,10 +83,6 @@ void BaseScriptPane::tick() {
m_script.invoke(p.second, (int)keyEvent.key, keyEvent.keyDown);
}
- m_playingSounds.filter([](pair<String, AudioInstancePtr> const& p) {
- return p.second->finished() == false;
- });
-
m_script.update(m_script.updateDt());
}
@@ -106,7 +104,7 @@ PanePtr BaseScriptPane::createTooltip(Vec2I const& screenPosition) {
return SimpleTooltipBuilder::buildTooltip(result->toString());
} else {
PanePtr tooltip = make_shared<Pane>();
- m_reader.construct(*result, tooltip.get());
+ m_reader->construct(*result, tooltip.get());
return tooltip;
}
} else {
@@ -131,53 +129,8 @@ Maybe<String> BaseScriptPane::cursorOverride(Vec2I const& screenPosition) {
return {};
}
-LuaCallbacks BaseScriptPane::makePaneCallbacks() {
- LuaCallbacks callbacks;
-
- callbacks.registerCallback("dismiss", [this]() { dismiss(); });
-
- callbacks.registerCallback("playSound",
- [this](String const& audio, Maybe<int> loops, Maybe<float> volume) {
- auto assets = Root::singleton().assets();
- auto config = Root::singleton().configuration();
- auto audioInstance = make_shared<AudioInstance>(*assets->audio(audio));
- audioInstance->setVolume(volume.value(1.0));
- audioInstance->setLoops(loops.value(0));
- auto& guiContext = GuiContext::singleton();
- guiContext.playAudio(audioInstance);
- m_playingSounds.append({audio, move(audioInstance)});
- });
-
- callbacks.registerCallback("stopAllSounds", [this](String const& audio) {
- m_playingSounds.filter([audio](pair<String, AudioInstancePtr> const& p) {
- if (p.first == audio) {
- p.second->stop();
- return false;
- }
- return true;
- });
- });
-
- callbacks.registerCallback("setTitle", [this](String const& title, String const& subTitle) {
- setTitleString(title, subTitle);
- });
-
- callbacks.registerCallback("setTitleIcon", [this](String const& image) {
- if (auto icon = as<ImageWidget>(titleIcon()))
- icon->setImage(image);
- });
-
- callbacks.registerCallback("addWidget", [this](Json const& newWidgetConfig, Maybe<String> const& newWidgetName) {
- String name = newWidgetName.value(strf("{}", Random::randu64()));
- WidgetPtr newWidget = m_reader.makeSingle(name, newWidgetConfig);
- this->addChild(name, newWidget);
- });
-
- callbacks.registerCallback("removeWidget", [this](String const& widgetName) {
- this->removeChild(widgetName);
- });
-
- return callbacks;
+GuiReaderPtr BaseScriptPane::reader() {
+ return m_reader;
}
}
diff --git a/source/frontend/StarBaseScriptPane.hpp b/source/frontend/StarBaseScriptPane.hpp
index f88cd40..b5aa502 100644
--- a/source/frontend/StarBaseScriptPane.hpp
+++ b/source/frontend/StarBaseScriptPane.hpp
@@ -12,6 +12,8 @@ STAR_CLASS(BaseScriptPane);
// A more 'raw' script pane that doesn't depend on a world being present.
// Requires a derived class to provide a Lua root.
+// Should maybe move into windowing?
+
class BaseScriptPane : public Pane {
public:
BaseScriptPane(Json config);
@@ -27,17 +29,16 @@ public:
PanePtr createTooltip(Vec2I const& screenPosition) override;
Maybe<String> cursorOverride(Vec2I const& screenPosition) override;
protected:
- virtual LuaCallbacks makePaneCallbacks();
+ virtual GuiReaderPtr reader();
Json m_config;
- GuiReader m_reader;
+ GuiReaderPtr m_reader;
Map<CanvasWidgetPtr, String> m_canvasClickCallbacks;
Map<CanvasWidgetPtr, String> m_canvasKeyCallbacks;
bool m_callbacksAdded;
LuaUpdatableComponent<LuaBaseComponent> m_script;
- List<pair<String, AudioInstancePtr>> m_playingSounds;
};
}
diff --git a/source/frontend/StarContainerInterface.cpp b/source/frontend/StarContainerInterface.cpp
index 9f80a94..10da82f 100644
--- a/source/frontend/StarContainerInterface.cpp
+++ b/source/frontend/StarContainerInterface.cpp
@@ -34,7 +34,7 @@ ContainerPane::ContainerPane(WorldClientPtr worldClient, PlayerPtr player, Conta
m_script.emplace();
m_script->setScripts(*scripts);
}
- m_script->addCallbacks("widget", LuaBindings::makeWidgetCallbacks(this, &m_reader));
+ m_script->addCallbacks("widget", LuaBindings::makeWidgetCallbacks(this));
m_script->addCallbacks("config", LuaBindings::makeConfigCallbacks( [guiConfig](String const& name, Json const& def) {
return guiConfig.query(name, def);
}));
diff --git a/source/frontend/StarInterfaceLuaBindings.cpp b/source/frontend/StarInterfaceLuaBindings.cpp
index a9257aa..65bcd68 100644
--- a/source/frontend/StarInterfaceLuaBindings.cpp
+++ b/source/frontend/StarInterfaceLuaBindings.cpp
@@ -3,6 +3,7 @@
#include "StarJsonExtra.hpp"
#include "StarLuaGameConverters.hpp"
#include "StarMainInterface.hpp"
+#include "StarGuiContext.hpp"
namespace Star {
@@ -15,6 +16,17 @@ LuaCallbacks LuaBindings::makeInterfaceCallbacks(MainInterface* mainInterface) {
return {};
});
+
+ callbacks.registerCallback("bindRegisteredPane", [mainInterface](String const& registeredPaneName) -> Maybe<LuaCallbacks> {
+ if (auto pane = mainInterface->paneManager()->maybeRegisteredPane(MainInterfacePanesNames.getLeft(registeredPaneName)))
+ return pane->makePaneCallbacks();
+ return {};
+ });
+
+ callbacks.registerCallback("scale", [mainInterface]() -> int {
+ return GuiContext::singleton().interfaceScale();
+ });
+
return callbacks;
}
diff --git a/source/frontend/StarMainInterfaceTypes.cpp b/source/frontend/StarMainInterfaceTypes.cpp
index 0731574..1d67292 100644
--- a/source/frontend/StarMainInterfaceTypes.cpp
+++ b/source/frontend/StarMainInterfaceTypes.cpp
@@ -6,6 +6,32 @@
namespace Star {
+EnumMap<MainInterfacePanes> const MainInterfacePanesNames{
+ {MainInterfacePanes::EscapeDialog, "EscapeDialog"},
+ {MainInterfacePanes::Inventory, "Inventory"},
+ {MainInterfacePanes::Codex, "Codex"},
+ {MainInterfacePanes::Cockpit, "Cockpit"},
+ {MainInterfacePanes::Tech, "Tech"},
+ {MainInterfacePanes::Songbook, "Songbook"},
+ {MainInterfacePanes::Ai, "Ai"},
+ {MainInterfacePanes::Popup, "Popup"},
+ {MainInterfacePanes::Confirmation, "Confirmation"},
+ {MainInterfacePanes::JoinRequest, "JoinRequest"},
+ {MainInterfacePanes::Options, "Options"},
+ {MainInterfacePanes::QuestLog, "QuestLog"},
+ {MainInterfacePanes::ActionBar, "ActionBar"},
+ {MainInterfacePanes::TeamBar, "TeamBar"},
+ {MainInterfacePanes::StatusPane, "StatusPane"},
+ {MainInterfacePanes::Chat, "Chat"},
+ {MainInterfacePanes::WireInterface, "WireInterface"},
+ {MainInterfacePanes::PlanetText, "PlanetText"},
+ {MainInterfacePanes::RadioMessagePopup, "RadioMessagePopup"},
+ {MainInterfacePanes::CraftingPlain, "CraftingPlain"},
+ {MainInterfacePanes::QuestTracker, "QuestTracker"},
+ {MainInterfacePanes::MmUpgrade, "MmUpgrade"},
+ {MainInterfacePanes::Collections, "Collections"}
+};
+
MainInterfaceConfigPtr MainInterfaceConfig::loadFromAssets() {
auto& root = Root::singleton();
auto assets = root.assets();
diff --git a/source/frontend/StarMainInterfaceTypes.hpp b/source/frontend/StarMainInterfaceTypes.hpp
index e09892c..70fdee1 100644
--- a/source/frontend/StarMainInterfaceTypes.hpp
+++ b/source/frontend/StarMainInterfaceTypes.hpp
@@ -37,6 +37,8 @@ enum class MainInterfacePanes {
Collections
};
+extern EnumMap<MainInterfacePanes> const MainInterfacePanesNames;
+
typedef RegisteredPaneManager<MainInterfacePanes> MainInterfacePaneManager;
struct MainInterfaceConfig {
diff --git a/source/frontend/StarScriptPane.cpp b/source/frontend/StarScriptPane.cpp
index b09211d..3de3c26 100644
--- a/source/frontend/StarScriptPane.cpp
+++ b/source/frontend/StarScriptPane.cpp
@@ -48,25 +48,10 @@ void ScriptPane::dismissed() {
}
void ScriptPane::tick() {
- BaseScriptPane::tick();
-
if (m_sourceEntityId != NullEntityId && !m_client->worldClient()->playerCanReachEntity(m_sourceEntityId))
dismiss();
- for (auto p : m_canvasClickCallbacks) {
- for (auto const& clickEvent : p.first->pullClickEvents())
- m_script.invoke(p.second, jsonFromVec2I(clickEvent.position), (uint8_t)clickEvent.button, clickEvent.buttonDown);
- }
- for (auto p : m_canvasKeyCallbacks) {
- for (auto const& keyEvent : p.first->pullKeyEvents())
- m_script.invoke(p.second, (int)keyEvent.key, keyEvent.keyDown);
- }
-
- m_playingSounds.filter([](pair<String, AudioInstancePtr> const& p) {
- return p.second->finished() == false;
- });
-
- m_script.update(m_script.updateDt());
+ BaseScriptPane::tick();
}
PanePtr ScriptPane::createTooltip(Vec2I const& screenPosition) {
@@ -76,7 +61,7 @@ PanePtr ScriptPane::createTooltip(Vec2I const& screenPosition) {
return SimpleTooltipBuilder::buildTooltip(result->toString());
} else {
PanePtr tooltip = make_shared<Pane>();
- m_reader.construct(*result, tooltip.get());
+ m_reader->construct(*result, tooltip.get());
return tooltip;
}
} else {
diff --git a/source/frontend/StarScriptPane.hpp b/source/frontend/StarScriptPane.hpp
index d994b68..229ebbb 100644
--- a/source/frontend/StarScriptPane.hpp
+++ b/source/frontend/StarScriptPane.hpp
@@ -22,9 +22,8 @@ public:
bool openWithInventory() const;
-private:
LuaCallbacks makePaneCallbacks() override;
-
+private:
UniverseClientPtr m_client;
EntityId m_sourceEntityId;
};
diff --git a/source/windowing/CMakeLists.txt b/source/windowing/CMakeLists.txt
index 18e035d..5db1ce6 100644
--- a/source/windowing/CMakeLists.txt
+++ b/source/windowing/CMakeLists.txt
@@ -38,6 +38,7 @@ SET (star_windowing_HEADERS
StarTextBoxWidget.hpp
StarVerticalLayout.hpp
StarWidget.hpp
+ StarWidgetLuaBindings.hpp
StarWidgetParsing.hpp
)
@@ -70,6 +71,7 @@ SET (star_windowing_SOURCES
StarTextBoxWidget.cpp
StarVerticalLayout.cpp
StarWidget.cpp
+ StarWidgetLuaBindings.cpp
StarWidgetParsing.cpp
)
diff --git a/source/windowing/StarGuiReader.hpp b/source/windowing/StarGuiReader.hpp
index f42a037..e031f62 100644
--- a/source/windowing/StarGuiReader.hpp
+++ b/source/windowing/StarGuiReader.hpp
@@ -6,6 +6,7 @@
namespace Star {
STAR_EXCEPTION(GUIBuilderException, StarException);
+STAR_CLASS(GuiReader);
class GuiReader : public WidgetParser {
public:
diff --git a/source/windowing/StarListWidget.hpp b/source/windowing/StarListWidget.hpp
index 8f511e3..8bb63db 100644
--- a/source/windowing/StarListWidget.hpp
+++ b/source/windowing/StarListWidget.hpp
@@ -6,7 +6,6 @@
namespace Star {
-STAR_CLASS(GuiReader);
STAR_CLASS(ListWidget);
class ListWidget : public Widget {
diff --git a/source/windowing/StarPane.cpp b/source/windowing/StarPane.cpp
index 69cbabf..a2d32ad 100644
--- a/source/windowing/StarPane.cpp
+++ b/source/windowing/StarPane.cpp
@@ -2,6 +2,10 @@
#include "StarRoot.hpp"
#include "StarJsonExtra.hpp"
#include "StarAssets.hpp"
+#include "StarWidgetLuaBindings.hpp"
+#include "StarLuaConverters.hpp"
+#include "StarImageWidget.hpp"
+#include "StarGuiReader.hpp"
namespace Star {
@@ -187,35 +191,6 @@ Pane* Pane::window() {
return this;
}
-void Pane::renderImpl() {
- if (m_bgFooter != "")
- m_context->drawInterfaceQuad(m_bgFooter, Vec2F(position()));
-
- if (m_bgBody != "")
- m_context->drawInterfaceQuad(m_bgBody, Vec2F(position()) + Vec2F(0, m_footerSize[1]));
-
- if (m_bgHeader != "") {
- auto headerPos = Vec2F(position()) + Vec2F(0, m_footerSize[1] + m_bodySize[1]);
- m_context->drawInterfaceQuad(m_bgHeader, headerPos);
-
- if (m_icon) {
- m_icon->setPosition(Vec2I(0, m_footerSize[1] + m_bodySize[1]) + m_iconOffset);
- m_icon->render(m_drawingArea);
- m_context->resetInterfaceScissorRect();
- }
-
- m_context->setFont(m_font);
- m_context->setFontSize(m_fontSize);
- m_context->setFontColor(m_titleColor.toRgba());
- m_context->setFontMode(FontMode::Shadow);
- m_context->renderInterfaceText(m_title, {headerPos + Vec2F(m_titleOffset)});
- m_context->setFontColor(m_subTitleColor.toRgba());
- m_context->renderInterfaceText(m_subTitle, {headerPos + Vec2F(m_subTitleOffset)});
- m_context->setFontMode(FontMode::Normal);
- m_context->setDefaultFont();
- }
-}
-
void Pane::update() {
if (m_visible) {
for (auto const& widget : m_members) {
@@ -228,7 +203,11 @@ void Pane::update() {
}
}
-void Pane::tick() {}
+void Pane::tick() {
+ m_playingSounds.filter([](pair<String, AudioInstancePtr> const& p) {
+ return p.second->finished() == false;
+ });
+}
bool Pane::dragActive() const {
return m_dragActive;
@@ -369,4 +348,96 @@ Maybe<String> Pane::cursorOverride(Vec2I const&) {
return {};
}
+LuaCallbacks Pane::makePaneCallbacks() {
+ LuaCallbacks callbacks;
+
+ callbacks.registerCallback("toWidget", [this]() -> LuaCallbacks {
+ return LuaBindings::makeWidgetCallbacks(this, reader());
+ });
+
+ callbacks.registerCallback("dismiss", [this]() { dismiss(); });
+
+ callbacks.registerCallback("playSound",
+ [this](String const& audio, Maybe<int> loops, Maybe<float> volume) {
+ auto assets = Root::singleton().assets();
+ auto config = Root::singleton().configuration();
+ auto audioInstance = make_shared<AudioInstance>(*assets->audio(audio));
+ audioInstance->setVolume(volume.value(1.0));
+ audioInstance->setLoops(loops.value(0));
+ auto& guiContext = GuiContext::singleton();
+ guiContext.playAudio(audioInstance);
+ m_playingSounds.append({audio, move(audioInstance)});
+ });
+
+ callbacks.registerCallback("stopAllSounds", [this](Maybe<String> const& audio) {
+ m_playingSounds.filter([audio](pair<String, AudioInstancePtr> const& p) {
+ if (!audio || p.first == *audio) {
+ p.second->stop();
+ return false;
+ }
+ return true;
+ });
+ });
+
+ callbacks.registerCallback("setTitle", [this](String const& title, String const& subTitle) {
+ setTitleString(title, subTitle);
+ });
+
+ callbacks.registerCallback("setTitleIcon", [this](String const& image) {
+ if (auto icon = as<ImageWidget>(titleIcon()))
+ icon->setImage(image);
+ });
+
+ callbacks.registerCallback("getPosition", [this]() -> Vec2I { return relativePosition(); });
+ callbacks.registerCallback("setPosition", [this](Vec2I const& position) { setPosition(position); });
+ callbacks.registerCallback("getSize", [this]() -> Vec2I { return size(); });
+ callbacks.registerCallback("setSize", [this](Vec2I const& size) { setSize(size); });
+
+ callbacks.registerCallback("addWidget", [this](Json const& newWidgetConfig, Maybe<String> const& newWidgetName) -> LuaCallbacks {
+ String name = newWidgetName.value(toString(Random::randu64()));
+ WidgetPtr newWidget = reader()->makeSingle(name, newWidgetConfig);
+ this->addChild(name, newWidget);
+ return LuaBindings::makeWidgetCallbacks(newWidget.get(), reader());
+ });
+
+ callbacks.registerCallback("removeWidget", [this](String const& widgetName) -> bool {
+ return this->removeChild(widgetName);
+ });
+
+ return callbacks;
+}
+
+GuiReaderPtr Pane::reader() {
+ return make_shared<GuiReader>();
+}
+
+void Pane::renderImpl() {
+ if (m_bgFooter != "")
+ m_context->drawInterfaceQuad(m_bgFooter, Vec2F(position()));
+
+ if (m_bgBody != "")
+ m_context->drawInterfaceQuad(m_bgBody, Vec2F(position()) + Vec2F(0, m_footerSize[1]));
+
+ if (m_bgHeader != "") {
+ auto headerPos = Vec2F(position()) + Vec2F(0, m_footerSize[1] + m_bodySize[1]);
+ m_context->drawInterfaceQuad(m_bgHeader, headerPos);
+
+ if (m_icon) {
+ m_icon->setPosition(Vec2I(0, m_footerSize[1] + m_bodySize[1]) + m_iconOffset);
+ m_icon->render(m_drawingArea);
+ m_context->resetInterfaceScissorRect();
+ }
+
+ m_context->setFont(m_font);
+ m_context->setFontSize(m_fontSize);
+ m_context->setFontColor(m_titleColor.toRgba());
+ m_context->setFontMode(FontMode::Shadow);
+ m_context->renderInterfaceText(m_title, {headerPos + Vec2F(m_titleOffset)});
+ m_context->setFontColor(m_subTitleColor.toRgba());
+ m_context->renderInterfaceText(m_subTitle, {headerPos + Vec2F(m_subTitleOffset)});
+ m_context->setFontMode(FontMode::Normal);
+ m_context->setDefaultFont();
+ }
+}
+
}
diff --git a/source/windowing/StarPane.hpp b/source/windowing/StarPane.hpp
index ce78337..7a466b4 100644
--- a/source/windowing/StarPane.hpp
+++ b/source/windowing/StarPane.hpp
@@ -7,6 +7,9 @@
namespace Star {
STAR_CLASS(Pane);
+STAR_CLASS(LuaCallbacks);
+STAR_CLASS(AudioInstance);
+STAR_CLASS(GuiReader);
enum class PaneAnchor {
None,
@@ -89,7 +92,9 @@ public:
virtual PanePtr createTooltip(Vec2I const& screenPosition);
virtual Maybe<String> cursorOverride(Vec2I const& screenPosition);
+ virtual LuaCallbacks makePaneCallbacks();
protected:
+ virtual GuiReaderPtr reader();
virtual void renderImpl();
String m_bgHeader;
@@ -124,6 +129,8 @@ protected:
PaneAnchor m_anchor;
Vec2I m_anchorOffset;
bool m_hasDisplayed;
+
+ List<pair<String, AudioInstancePtr>> m_playingSounds;
};
}
diff --git a/source/windowing/StarRegisteredPaneManager.hpp b/source/windowing/StarRegisteredPaneManager.hpp
index 4038525..ebb158d 100644
--- a/source/windowing/StarRegisteredPaneManager.hpp
+++ b/source/windowing/StarRegisteredPaneManager.hpp
@@ -19,6 +19,8 @@ public:
template <typename T = Pane>
shared_ptr<T> registeredPane(KeyT const& paneId) const;
+ template <typename T = Pane>
+ shared_ptr<T> maybeRegisteredPane(KeyT const& paneId) const;
// Displays a registred pane if it is not already displayed. Returns true
// if it is newly displayed.
@@ -54,6 +56,14 @@ shared_ptr<T> RegisteredPaneManager<KeyT>::registeredPane(KeyT const& paneId) co
}
template <typename KeyT>
+template <typename T>
+shared_ptr<T> RegisteredPaneManager<KeyT>::maybeRegisteredPane(KeyT const& paneId) const {
+ if (auto v = m_registeredPanes.ptr(paneId))
+ return convert<T>(v->pane);
+ return {};
+}
+
+template <typename KeyT>
void RegisteredPaneManager<KeyT>::registerPane(
KeyT paneId, PaneLayer paneLayer, PanePtr pane, DismissCallback onDismiss) {
if (!m_registeredPanes.insert(move(paneId), {move(paneLayer), move(pane), move(onDismiss)}).second)
diff --git a/source/frontend/StarWidgetLuaBindings.cpp b/source/windowing/StarWidgetLuaBindings.cpp
index fb84ff8..62d2be6 100644
--- a/source/frontend/StarWidgetLuaBindings.cpp
+++ b/source/windowing/StarWidgetLuaBindings.cpp
@@ -89,7 +89,10 @@ LuaMethods<CanvasWidgetPtr> LuaUserDataMethods<CanvasWidgetPtr>::make() {
return methods;
}
-LuaCallbacks LuaBindings::makeWidgetCallbacks(Widget* parentWidget, GuiReader* reader) {
+LuaCallbacks LuaBindings::makeWidgetCallbacks(Widget* parentWidget, GuiReaderPtr reader) {
+ if (!reader)
+ reader = make_shared<GuiReader>();
+
LuaCallbacks callbacks;
// a bit miscellaneous, but put this here since widgets have access to gui context
diff --git a/source/frontend/StarWidgetLuaBindings.hpp b/source/windowing/StarWidgetLuaBindings.hpp
index 48d6ab2..d133760 100644
--- a/source/frontend/StarWidgetLuaBindings.hpp
+++ b/source/windowing/StarWidgetLuaBindings.hpp
@@ -18,7 +18,7 @@ struct LuaUserDataMethods<CanvasWidgetPtr> {
};
namespace LuaBindings {
- LuaCallbacks makeWidgetCallbacks(Widget* parentWidget, GuiReader* reader);
+ LuaCallbacks makeWidgetCallbacks(Widget* parentWidget, GuiReaderPtr reader = {});
}
}