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

summaryrefslogtreecommitdiff
path: root/source
diff options
context:
space:
mode:
authorKae <80987908+Novaenia@users.noreply.github.com>2023-07-30 00:41:38 +1000
committerKae <80987908+Novaenia@users.noreply.github.com>2023-07-30 00:41:38 +1000
commitffd1507f725582bd51fe3064263b14ecd7db5edf (patch)
tree23856a19c61f8da76f53753a1a81ffcba4f804e3 /source
parent057f3727deb83a768a45ad3b91282166683e039d (diff)
ScriptPanes can specify paneLayer and interactive
Diffstat (limited to 'source')
-rw-r--r--source/frontend/StarBaseScriptPane.cpp5
-rw-r--r--source/frontend/StarBaseScriptPane.hpp4
-rw-r--r--source/frontend/StarJoinRequestDialog.cpp2
-rw-r--r--source/frontend/StarMainInterface.cpp8
-rw-r--r--source/windowing/StarPaneManager.cpp18
-rw-r--r--source/windowing/StarPaneManager.hpp3
6 files changed, 36 insertions, 4 deletions
diff --git a/source/frontend/StarBaseScriptPane.cpp b/source/frontend/StarBaseScriptPane.cpp
index 4164d9e..ca9a89c 100644
--- a/source/frontend/StarBaseScriptPane.cpp
+++ b/source/frontend/StarBaseScriptPane.cpp
@@ -24,7 +24,8 @@ BaseScriptPane::BaseScriptPane(Json config) : Pane(), m_rawConfig(config) {
} else {
m_config = assets->fetchJson(config);
}
-
+
+ m_interactive = config.getBool("interactive", true);
m_reader = make_shared<GuiReader>();
m_reader->registerCallback("close", [this](Widget*) { dismiss(); });
@@ -100,6 +101,8 @@ bool BaseScriptPane::sendEvent(InputEvent const& event) {
Json const& BaseScriptPane::config() const { return m_config; }
Json const& BaseScriptPane::rawConfig() const { return m_rawConfig; }
+bool BaseScriptPane::interactive() const { return m_interactive; }
+
PanePtr BaseScriptPane::createTooltip(Vec2I const& screenPosition) {
auto result = m_script.invoke<Json>("createTooltip", screenPosition);
if (result && !result.value().isNull()) {
diff --git a/source/frontend/StarBaseScriptPane.hpp b/source/frontend/StarBaseScriptPane.hpp
index df2d4c5..37070f1 100644
--- a/source/frontend/StarBaseScriptPane.hpp
+++ b/source/frontend/StarBaseScriptPane.hpp
@@ -29,6 +29,8 @@ public:
Json const& config() const;
Json const& rawConfig() const;
+ bool interactive() const override;
+
PanePtr createTooltip(Vec2I const& screenPosition) override;
Maybe<String> cursorOverride(Vec2I const& screenPosition) override;
protected:
@@ -41,6 +43,8 @@ protected:
Map<CanvasWidgetPtr, String> m_canvasClickCallbacks;
Map<CanvasWidgetPtr, String> m_canvasKeyCallbacks;
+ bool m_interactive;
+
bool m_callbacksAdded;
LuaUpdatableComponent<LuaBaseComponent> m_script;
};
diff --git a/source/frontend/StarJoinRequestDialog.cpp b/source/frontend/StarJoinRequestDialog.cpp
index 9d854df..1966265 100644
--- a/source/frontend/StarJoinRequestDialog.cpp
+++ b/source/frontend/StarJoinRequestDialog.cpp
@@ -9,7 +9,7 @@
namespace Star {
-JoinRequestDialog::JoinRequestDialog() {}
+JoinRequestDialog::JoinRequestDialog() : m_confirmed(false) {}
void JoinRequestDialog::displayRequest(String const& userName, function<void(P2PJoinRequestReply)> callback) {
auto assets = Root::singleton().assets();
diff --git a/source/frontend/StarMainInterface.cpp b/source/frontend/StarMainInterface.cpp
index 1497b8b..591f43f 100644
--- a/source/frontend/StarMainInterface.cpp
+++ b/source/frontend/StarMainInterface.cpp
@@ -1565,8 +1565,12 @@ void MainInterface::displayScriptPane(ScriptPanePtr& scriptPane, EntityId source
if (sourceEntity != NullEntityId)
m_interactionScriptPanes[sourceEntity] = scriptPane;
+ PaneLayer layer = PaneLayer::Window;
+ if (auto layerName = scriptPane->config().optString("paneLayer"))
+ layer = PaneLayerNames.getLeft(*layerName);
+
if (scriptPane->openWithInventory()) {
- m_paneManager.displayPane(PaneLayer::Window, scriptPane, [this](PanePtr const&) {
+ m_paneManager.displayPane(layer, scriptPane, [this](PanePtr const&) {
if (auto player = m_client->mainPlayer())
player->clearSwap();
m_paneManager.dismissRegisteredPane(MainInterfacePanes::Inventory);
@@ -1575,7 +1579,7 @@ void MainInterface::displayScriptPane(ScriptPanePtr& scriptPane, EntityId source
m_paneManager.bringPaneAdjacent(m_paneManager.registeredPane(MainInterfacePanes::Inventory),
scriptPane, Root::singleton().assets()->json("/interface.config:bringAdjacentWindowGap").toFloat());
} else {
- m_paneManager.displayPane(PaneLayer::Window, scriptPane);
+ m_paneManager.displayPane(layer, scriptPane);
}
}
diff --git a/source/windowing/StarPaneManager.cpp b/source/windowing/StarPaneManager.cpp
index 9dd7737..dcdace9 100644
--- a/source/windowing/StarPaneManager.cpp
+++ b/source/windowing/StarPaneManager.cpp
@@ -6,6 +6,14 @@
namespace Star {
+EnumMap<PaneLayer> const PaneLayerNames{
+ {PaneLayer::Tooltip, "Tooltip"},
+ {PaneLayer::ModalWindow, "ModalWindow"},
+ {PaneLayer::Window, "Window"},
+ {PaneLayer::Hud, "Hud"},
+ {PaneLayer::World, "World"}
+};
+
PaneManager::PaneManager()
: m_context(GuiContext::singletonPtr()), m_prevInterfaceScale(1) {
auto assets = Root::singleton().assets();
@@ -350,24 +358,34 @@ Vec2I PaneManager::calculateNewInterfacePosition(PanePtr const& pane, float inte
switch (pane->anchor()) {
case PaneAnchor::None:
scale = Mat3F::scaling(interfaceScaleRatio, Vec2F(windowSize()) / 2);
+ break;
case PaneAnchor::BottomLeft:
scale = Mat3F::scaling(interfaceScaleRatio);
+ break;
case PaneAnchor::BottomRight:
scale = Mat3F::scaling(interfaceScaleRatio, {size[0], 0});
+ break;
case PaneAnchor::TopLeft:
scale = Mat3F::scaling(interfaceScaleRatio, {0, size[1]});
+ break;
case PaneAnchor::TopRight:
scale = Mat3F::scaling(interfaceScaleRatio, size);
+ break;
case PaneAnchor::CenterTop:
scale = Mat3F::scaling(interfaceScaleRatio, {size[0] / 2, size[1]});
+ break;
case PaneAnchor::CenterBottom:
scale = Mat3F::scaling(interfaceScaleRatio, {size[0] / 2, 0});
+ break;
case PaneAnchor::CenterLeft:
scale = Mat3F::scaling(interfaceScaleRatio, {0, size[1] / 2});
+ break;
case PaneAnchor::CenterRight:
scale = Mat3F::scaling(interfaceScaleRatio, {size[0], size[1] / 2});
+ break;
case PaneAnchor::Center:
scale = Mat3F::scaling(interfaceScaleRatio, size / 2);
+ break;
default:
scale = Mat3F::scaling(interfaceScaleRatio, Vec2F(windowSize()) / 2);
}
diff --git a/source/windowing/StarPaneManager.hpp b/source/windowing/StarPaneManager.hpp
index e69f699..37634ea 100644
--- a/source/windowing/StarPaneManager.hpp
+++ b/source/windowing/StarPaneManager.hpp
@@ -3,6 +3,7 @@
#include "StarPane.hpp"
#include "StarOrderedMap.hpp"
+#include "StarBiMap.hpp"
namespace Star {
@@ -25,6 +26,8 @@ enum class PaneLayer {
// handled by GUI panes (such as wires)
World
};
+extern EnumMap<PaneLayer> const PaneLayerNames;
+
// This class handles a set of panes to be drawn as a collective windowing
// interface. It is a set of panes on separate distinct layers, where each