From 39a6e900a4e5d000b975bfd2f24846489eb1aa82 Mon Sep 17 00:00:00 2001 From: Kae <80987908+Novaenia@users.noreply.github.com> Date: Mon, 17 Jun 2024 20:31:40 +1000 Subject: Inspecting now logs to the chat TODO: make configurable! --- source/frontend/StarMainInterface.cpp | 41 ++++++++++++++++++++--------------- 1 file changed, 24 insertions(+), 17 deletions(-) (limited to 'source/frontend/StarMainInterface.cpp') diff --git a/source/frontend/StarMainInterface.cpp b/source/frontend/StarMainInterface.cpp index f9e8d57..153ce07 100644 --- a/source/frontend/StarMainInterface.cpp +++ b/source/frontend/StarMainInterface.cpp @@ -760,23 +760,30 @@ void MainInterface::update(float dt) { m_chatBubbleManager->setCamera(m_worldPainter->camera()); if (auto worldClient = m_client->worldClient()) { auto chatActions = worldClient->pullPendingChatActions(); - auto portraitActions = chatActions.filtered([](ChatAction action) { return action.is(); }); - - for (auto action : portraitActions) { - PortraitChatAction portraitAction = action.get(); - - String name; - if (auto npc = as(worldClient->entity(portraitAction.entity))) - name = npc->name(); - - ChatReceivedMessage message = { - { MessageContext::World }, - ServerConnectionId, - Text::stripEscapeCodes(name), - Text::stripEscapeCodes(portraitAction.text), - Text::stripEscapeCodes(portraitAction.portrait.replace("", "0")) - }; - m_chat->addMessages({message}, false); + + for (auto& action : chatActions) { + if (action.is()) { + PortraitChatAction& portraitAction = action.get(); + + String name; + if (auto npc = as(worldClient->entity(portraitAction.entity))) + name = npc->name(); + + ChatReceivedMessage message = { + {MessageContext::World}, + ServerConnectionId, + Text::stripEscapeCodes(name), + Text::stripEscapeCodes(portraitAction.text), + Text::stripEscapeCodes(portraitAction.portrait.replace("", "0"))}; + m_chat->addMessages({message}, false); + } else if (action.is()) { + SayChatAction& sayAction = action.get(); + + if (sayAction.config) { + if (auto message = sayAction.config.opt("message")) + m_chat->addMessages({ChatReceivedMessage(*message)}, sayAction.config.getBool("showPane", false)); + } + } } m_chatBubbleManager->addChatActions(chatActions); -- cgit v1.2.3