diff options
author | Kae <80987908+Novaenia@users.noreply.github.com> | 2023-07-17 22:20:39 +1000 |
---|---|---|
committer | Kae <80987908+Novaenia@users.noreply.github.com> | 2023-07-17 22:20:39 +1000 |
commit | 34bb0b54222c1c0f3450c56e76f89f192d77374b (patch) | |
tree | 09e119625d066d16e3a81a8f6c0c424c4159f058 /source/frontend | |
parent | 848b11399f2e34d7f1e0523e214287bfdcc5816c (diff) |
Initial voice HUD indicator setup
Diffstat (limited to 'source/frontend')
-rw-r--r-- | source/frontend/StarInterfaceLuaBindings.cpp | 5 | ||||
-rw-r--r-- | source/frontend/StarMainInterface.cpp | 26 | ||||
-rw-r--r-- | source/frontend/StarMainInterface.hpp | 4 |
3 files changed, 26 insertions, 9 deletions
diff --git a/source/frontend/StarInterfaceLuaBindings.cpp b/source/frontend/StarInterfaceLuaBindings.cpp index 14b2e7c..d5e0960 100644 --- a/source/frontend/StarInterfaceLuaBindings.cpp +++ b/source/frontend/StarInterfaceLuaBindings.cpp @@ -27,6 +27,11 @@ LuaCallbacks LuaBindings::makeInterfaceCallbacks(MainInterface* mainInterface) { return GuiContext::singleton().interfaceScale(); }); + callbacks.registerCallback("queueMessage", [mainInterface](String const& message, Maybe<float> cooldown, Maybe<float> springState) { + mainInterface->queueMessage(message, cooldown, springState.value(0)); + }); + + return callbacks; } diff --git a/source/frontend/StarMainInterface.cpp b/source/frontend/StarMainInterface.cpp index 9f335b6..0dc3a01 100644 --- a/source/frontend/StarMainInterface.cpp +++ b/source/frontend/StarMainInterface.cpp @@ -62,8 +62,8 @@ namespace Star { GuiMessage::GuiMessage() : message(), cooldown(), springState() {} -GuiMessage::GuiMessage(String const& message, float cooldown) - : message(message), cooldown(cooldown), springState(0) {} +GuiMessage::GuiMessage(String const& message, float cooldown, float spring) + : message(message), cooldown(cooldown), springState(spring) {} MainInterface::MainInterface(UniverseClientPtr client, WorldPainterPtr painter, CinematicPtr cinematicOverlay) { m_state = Running; @@ -369,6 +369,9 @@ bool MainInterface::handleInputEvent(InputEvent const& event) { player->endTrigger(); } + for (auto& pair : m_canvases) + pair.second->sendEvent(event); + return true; } @@ -863,11 +866,15 @@ void MainInterface::doChat(String const& chat, bool addToHistory) { m_chat->addHistory(chat); } -void MainInterface::queueMessage(String const& message) { - auto guiMessage = make_shared<GuiMessage>(message, m_config->messageTime); +void MainInterface::queueMessage(String const& message, Maybe<float> cooldown, float spring) { + auto guiMessage = make_shared<GuiMessage>(message, cooldown.value(m_config->messageTime), spring); m_messages.append(guiMessage); } +void MainInterface::queueMessage(String const& message) { + queueMessage(message, m_config->messageTime, 0.0f); +} + void MainInterface::queueJoinRequest(pair<String, RpcPromiseKeeper<P2PJoinRequestReply>> request) { m_queuedJoinRequests.push_back(request); @@ -927,18 +934,21 @@ void MainInterface::warpTo(WarpAction const& warpAction) { } CanvasWidgetPtr MainInterface::fetchCanvas(String const& canvasName, bool ignoreInterfaceScale) { + CanvasWidgetPtr canvas; + if (auto canvasPtr = m_canvases.ptr(canvasName)) - return *canvasPtr; + canvas = *canvasPtr; else { - CanvasWidgetPtr canvas = m_canvases.emplace(canvasName, make_shared<CanvasWidget>()).first->second; + m_canvases.emplace(canvasName, canvas = make_shared<CanvasWidget>()); canvas->setPosition(Vec2I()); if (ignoreInterfaceScale) canvas->setSize(Vec2I(m_guiContext->windowSize())); else canvas->setSize(Vec2I(m_guiContext->windowInterfaceSize())); - canvas->setIgnoreInterfaceScale(ignoreInterfaceScale); - return canvas; } + + canvas->setIgnoreInterfaceScale(ignoreInterfaceScale); + return canvas; } PanePtr MainInterface::createEscapeDialog() { diff --git a/source/frontend/StarMainInterface.hpp b/source/frontend/StarMainInterface.hpp index d96779d..9cf2342 100644 --- a/source/frontend/StarMainInterface.hpp +++ b/source/frontend/StarMainInterface.hpp @@ -49,7 +49,7 @@ STAR_CLASS(MainInterface); struct GuiMessage { GuiMessage(); - GuiMessage(String const& message, float cooldown); + GuiMessage(String const& message, float cooldown, float spring = 0); String message; float cooldown; @@ -105,7 +105,9 @@ public: void doChat(String const& chat, bool addToHistory); + void queueMessage(String const& message, Maybe<float> cooldown, float spring); void queueMessage(String const& message); + void queueItemPickupText(ItemPtr const& item); void queueJoinRequest(pair<String, RpcPromiseKeeper<P2PJoinRequestReply>> request); |