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

summaryrefslogtreecommitdiff
path: root/source/frontend/StarMainInterface.cpp
diff options
context:
space:
mode:
authorKae <80987908+Novaenia@users.noreply.github.com>2024-06-17 20:31:40 +1000
committerKae <80987908+Novaenia@users.noreply.github.com>2024-06-17 20:31:40 +1000
commit39a6e900a4e5d000b975bfd2f24846489eb1aa82 (patch)
tree652aa5522bef39b85e961a0ea843c238b8787be6 /source/frontend/StarMainInterface.cpp
parentf7d2303fe0b6ca1198c23af7b8e1c809d803d142 (diff)
Inspecting now logs to the chat
TODO: make configurable!
Diffstat (limited to 'source/frontend/StarMainInterface.cpp')
-rw-r--r--source/frontend/StarMainInterface.cpp41
1 files changed, 24 insertions, 17 deletions
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<PortraitChatAction>(); });
-
- for (auto action : portraitActions) {
- PortraitChatAction portraitAction = action.get<PortraitChatAction>();
-
- String name;
- if (auto npc = as<Npc>(worldClient->entity(portraitAction.entity)))
- name = npc->name();
-
- ChatReceivedMessage message = {
- { MessageContext::World },
- ServerConnectionId,
- Text::stripEscapeCodes(name),
- Text::stripEscapeCodes(portraitAction.text),
- Text::stripEscapeCodes(portraitAction.portrait.replace("<frame>", "0"))
- };
- m_chat->addMessages({message}, false);
+
+ for (auto& action : chatActions) {
+ if (action.is<PortraitChatAction>()) {
+ PortraitChatAction& portraitAction = action.get<PortraitChatAction>();
+
+ String name;
+ if (auto npc = as<Npc>(worldClient->entity(portraitAction.entity)))
+ name = npc->name();
+
+ ChatReceivedMessage message = {
+ {MessageContext::World},
+ ServerConnectionId,
+ Text::stripEscapeCodes(name),
+ Text::stripEscapeCodes(portraitAction.text),
+ Text::stripEscapeCodes(portraitAction.portrait.replace("<frame>", "0"))};
+ m_chat->addMessages({message}, false);
+ } else if (action.is<SayChatAction>()) {
+ SayChatAction& sayAction = action.get<SayChatAction>();
+
+ if (sayAction.config) {
+ if (auto message = sayAction.config.opt("message"))
+ m_chat->addMessages({ChatReceivedMessage(*message)}, sayAction.config.getBool("showPane", false));
+ }
+ }
}
m_chatBubbleManager->addChatActions(chatActions);