From 9ed5d4366f0c8c6105347d86f1c26c71f242eb85 Mon Sep 17 00:00:00 2001 From: oznogon Date: Sat, 4 Apr 2026 13:58:37 -0700 Subject: [PATCH 1/2] Refactor chat and script comms overlay - Add a title bar to active player chats. - Add minimize button and move close button to title bar. - Consolidate script and chat comms implementations to share panel and title bar layout. - Indicate unread notification state on minimized chat by switching to toggled-on state. --- src/screenComponents/commsOverlay.cpp | 416 ++++++++++++++++++-------- src/screenComponents/commsOverlay.h | 18 +- 2 files changed, 300 insertions(+), 134 deletions(-) diff --git a/src/screenComponents/commsOverlay.cpp b/src/screenComponents/commsOverlay.cpp index 146d2a9dc2..2c5c321008 100644 --- a/src/screenComponents/commsOverlay.cpp +++ b/src/screenComponents/commsOverlay.cpp @@ -5,6 +5,7 @@ #include "gui/gui2_panel.h" #include "gui/gui2_progressbar.h" #include "gui/gui2_button.h" +#include "gui/gui2_togglebutton.h" #include "gui/gui2_label.h" #include "gui/gui2_scrolltext.h" #include "gui/gui2_listbox.h" @@ -16,138 +17,263 @@ #include "onScreenKeyboard.h" GuiCommsOverlay::GuiCommsOverlay(GuiContainer* owner) -: GuiElement(owner, "COMMS_OVERLAY"), - chat_open_last_update(false) +: GuiElement(owner, "COMMS_OVERLAY") { // Panel for reporting outgoing hails. opening_box = new GuiPanel(this, "COMMS_OPENING_BOX"); - opening_box->hide()->setSize(800, 100)->setPosition(0, -250, sp::Alignment::BottomCenter); - (new GuiLabel(opening_box, "COMMS_OPENING_LABEL", tr("Opening communications..."), 40))->setSize(GuiElement::GuiSizeMax, 50)->setPosition(0, 0, sp::Alignment::TopCenter); - opening_progress = new GuiProgressbar(opening_box, "COMMS_OPENING_PROGRESS", CommsSystem::channel_open_time, 0.0, 0.0); - opening_progress->setSize(500, 40)->setPosition(50, -10, sp::Alignment::BottomLeft); + opening_box + ->setSize(800.0f, 100.0f) + ->setPosition(0.0f, -250.0f, sp::Alignment::BottomCenter) + ->hide(); + + (new GuiLabel(opening_box, "COMMS_OPENING_LABEL", tr("Opening communications..."), 40.0f)) + ->setSize(GuiElement::GuiSizeMax, 50.0f) + ->setPosition(0.0f, 0.0f, sp::Alignment::TopCenter); + + opening_progress = new GuiProgressbar(opening_box, "COMMS_OPENING_PROGRESS", CommsSystem::channel_open_time, 0.0f, 0.0f); + opening_progress + ->setSize(500.0f, 40.0f) + ->setPosition(50.0f, -10.0f, sp::Alignment::BottomLeft); // Cancel button closes the communication. - opening_cancel = new GuiButton(opening_box, "COMMS_OPENING_CANCEL", tr("button", "Cancel"), []() - { - if (my_spaceship) - my_player_info->commandCloseTextComm(); - }); - opening_cancel->setSize(200, 40)->setPosition(-50, -10, sp::Alignment::BottomRight); + opening_cancel = new GuiButton(opening_box, "COMMS_OPENING_CANCEL", tr("button", "Cancel"), + []() + { + if (my_spaceship) my_player_info->commandCloseTextComm(); + } + ); + opening_cancel + ->setSize(200.0f, 40.0f) + ->setPosition(-50.0f, -10.0f, sp::Alignment::BottomRight); + + (new GuiButton(opening_box, "COMMS_OPENING_MINIMIZE", "", + [this]() + { + comms_minimized = true; + } + ))->setIcon("gui/widget/IndicatorArrow.png", sp::Alignment::Center, -90.0f) + ->setPosition(-5.0f, 5.0f, sp::Alignment::TopRight) + ->setSize(50.0f, 50.0f); // Panel for reporting incoming hails. hailed_box = new GuiPanel(this, "COMMS_BEING_HAILED_BOX"); - hailed_box->hide()->setSize(800, 140)->setPosition(0, -250, sp::Alignment::BottomCenter); + hailed_box + ->setSize(800.0f, 140.0f) + ->setPosition(0.0f, -250.0f, sp::Alignment::BottomCenter) + ->hide(); hailed_label = new GuiLabel(hailed_box, "COMMS_BEING_HAILED_LABEL", "..", 40); - hailed_label->setSize(GuiElement::GuiSizeMax, 50)->setPosition(0, 20, sp::Alignment::TopCenter); + hailed_label + ->setSize(GuiElement::GuiSizeMax, 50.0f) + ->setPosition(0.0f, 20.0f, sp::Alignment::TopCenter); // Buttons to answer or ignore hails. - hailed_answer = new GuiButton(hailed_box, "COMMS_BEING_HAILED_ANSWER", tr("Answer"), []() { - if (my_spaceship) - my_player_info->commandAnswerCommHail(true); - }); - hailed_answer->setSize(300, 50)->setPosition(20, -20, sp::Alignment::BottomLeft); - - hailed_ignore = new GuiButton(hailed_box, "COMMS_BEING_HAILED_IGNORE", tr("Ignore"), []() { - if (my_spaceship) - my_player_info->commandAnswerCommHail(false); - }); - hailed_ignore->setSize(300, 50)->setPosition(-20, -20, sp::Alignment::BottomRight); + hailed_answer = new GuiButton(hailed_box, "COMMS_BEING_HAILED_ANSWER", tr("Answer"), + []() + { + if (my_spaceship) my_player_info->commandAnswerCommHail(true); + } + ); + hailed_answer + ->setSize(300.0f, 50.0f) + ->setPosition(20.0f, -20.0f, sp::Alignment::BottomLeft); + + hailed_ignore = new GuiButton(hailed_box, "COMMS_BEING_HAILED_IGNORE", tr("Ignore"), + []() + { + if (my_spaceship) my_player_info->commandAnswerCommHail(false); + } + ); + hailed_ignore + ->setSize(300.0f, 50.0f) + ->setPosition(-20.0f, -20.0f, sp::Alignment::BottomRight); + + (new GuiButton(hailed_box, "COMMS_HAILED_MINIMIZE", "", + [this]() + { + comms_minimized = true; + } + ))->setIcon("gui/widget/IndicatorArrow.png", sp::Alignment::Center, -90.0f) + ->setPosition(-5.0f, 5.0f, sp::Alignment::TopRight) + ->setSize(50.0f, 50.0f); // Panel for unresponsive hails. no_response_box = new GuiPanel(this, "COMMS_OPENING_BOX"); - no_response_box->hide()->setSize(800, 70)->setPosition(0, -250, sp::Alignment::BottomCenter); - (new GuiLabel(no_response_box, "COMMS_NO_REPONSE_LABEL", tr("No reply..."), 40))->setSize(GuiElement::GuiSizeMax, GuiElement::GuiSizeMax)->setPosition(0, 0, sp::Alignment::TopLeft); + no_response_box + ->setSize(800.0f, 70.0f) + ->setPosition(0.0f, -250.0f, sp::Alignment::BottomCenter) + ->hide(); + (new GuiLabel(no_response_box, "COMMS_NO_REPONSE_LABEL", tr("No reply..."), 40.0f)) + ->setSize(GuiElement::GuiSizeMax, GuiElement::GuiSizeMax) + ->setPosition(0.0f, 0.0f, sp::Alignment::TopLeft); // Button to acknowledge unresponsive hails. - (new GuiButton(no_response_box, "COMMS_NO_REPLY_OK", "Ok", []() { - if (my_spaceship) - my_player_info->commandCloseTextComm(); - }))->setSize(100, 50)->setPosition(-20, -10, sp::Alignment::BottomRight); + (new GuiButton(no_response_box, "COMMS_NO_REPLY_OK", "Ok", + []() + { + if (my_spaceship) my_player_info->commandCloseTextComm(); + } + ))->setSize(100.0f, 50.0f) + ->setPosition(-20.0f, -10.0f, sp::Alignment::BottomRight); // Panel for broken communications. broken_box = new GuiPanel(this, "COMMS_BROKEN_BOX"); - broken_box->hide()->setSize(800, 70)->setPosition(0, -250, sp::Alignment::BottomCenter); - (new GuiLabel(broken_box, "COMMS_BROKEN_LABEL", tr("Communications were suddenly cut"), 40))->setSize(GuiElement::GuiSizeMax, GuiElement::GuiSizeMax)->setPosition(0, 0, sp::Alignment::TopLeft); + broken_box + ->setSize(800.0f, 70.0f) + ->setPosition(0.0f, -250.0f, sp::Alignment::BottomCenter) + ->hide(); + + (new GuiLabel(broken_box, "COMMS_BROKEN_LABEL", tr("Communications were suddenly cut"), 40.0f)) + ->setSize(GuiElement::GuiSizeMax, GuiElement::GuiSizeMax) + ->setPosition(0.0f, 0.0f, sp::Alignment::TopLeft); // Button to acknowledge broken communications. - (new GuiButton(broken_box, "COMMS_BROKEN_OK", "Ok", []() { - if (my_spaceship) - my_player_info->commandCloseTextComm(); - }))->setSize(100, 50)->setPosition(-20, -10, sp::Alignment::BottomRight); + (new GuiButton(broken_box, "COMMS_BROKEN_OK", "Ok", + []() + { + if (my_spaceship) my_player_info->commandCloseTextComm(); + } + ))->setSize(100.0f, 50.0f) + ->setPosition(-20.0f, -10.0f, sp::Alignment::BottomRight); // Panel for communications closed by the other object. closed_box = new GuiPanel(this, "COMMS_CLOSED_BOX"); - closed_box->hide()->setSize(800, 70)->setPosition(0, -250, sp::Alignment::BottomCenter); - (new GuiLabel(closed_box, "COMMS_BROKEN_LABEL", tr("Communications channel closed"), 40))->setSize(GuiElement::GuiSizeMax, GuiElement::GuiSizeMax)->setPosition(0, 0, sp::Alignment::TopLeft); + closed_box + ->setSize(800.0f, 70.0f) + ->setPosition(0.0f, -250.0f, sp::Alignment::BottomCenter) + ->hide(); + + (new GuiLabel(closed_box, "COMMS_BROKEN_LABEL", tr("Communications channel closed"), 40.0f)) + ->setSize(GuiElement::GuiSizeMax, GuiElement::GuiSizeMax) + ->setPosition(0.0f, 0.0f, sp::Alignment::TopLeft); // Button to acknowledge closed communications. - (new GuiButton(closed_box, "COMMS_CLOSED_OK", "Ok", []() { - if (my_spaceship) - my_player_info->commandCloseTextComm(); - }))->setSize(100, 50)->setPosition(-20, -10, sp::Alignment::BottomRight); - - // Panel for chat communications with GMs and other player ships. - chat_comms_box = new GuiPanel(this, "COMMS_CHAT_BOX"); - chat_comms_box->hide()->setSize(800, 600)->setPosition(0, -100, sp::Alignment::BottomCenter); - - // Message entry field for chat. - chat_comms_message_entry = new GuiTextEntry(chat_comms_box, "COMMS_CHAT_MESSAGE_ENTRY", ""); - chat_comms_message_entry->setPosition(20, -20, sp::Alignment::BottomLeft)->setSize(640, 50); - chat_comms_message_entry->enterCallback([this](string text){ - if (my_spaceship) - my_player_info->commandSendCommPlayer(chat_comms_message_entry->getText()); - chat_comms_message_entry->setText(""); - }); - - // Text of incoming chat messages. - chat_comms_text = new GuiScrollFormattedText(chat_comms_box, "COMMS_CHAT_TEXT", ""); - chat_comms_text->enableAutoScrollDown()->setPosition(20, 30, sp::Alignment::TopLeft)->setSize(760, 500); - - // Button to send a message. - chat_comms_send_button = new GuiButton(chat_comms_box, "SEND_BUTTON", tr("button", "Send"), [this]() { - if (my_spaceship) - my_player_info->commandSendCommPlayer(chat_comms_message_entry->getText()); - chat_comms_message_entry->setText(""); - }); - chat_comms_send_button->setPosition(-20, -20, sp::Alignment::BottomRight)->setSize(120, 50); - - // Button to close chat comms. - chat_comms_close_button = new GuiButton(chat_comms_box, "CLOSE_BUTTON", tr("button", "Close"), []() { - if (my_spaceship) - my_player_info->commandCloseTextComm(); - }); - chat_comms_close_button->setTextSize(20)->setPosition(-10, 0, sp::Alignment::TopRight)->setSize(70, 30); - - if (!engine->getObject("mouseRenderer")) //If we are a touch screen, add a on screen keyboard. + (new GuiButton(closed_box, "COMMS_CLOSED_OK", "Ok", + []() + { + if (my_spaceship) my_player_info->commandCloseTextComm(); + } + ))->setSize(100.0f, 50.0f) + ->setPosition(-20.0f, -10.0f, sp::Alignment::BottomRight); + + // Panel for chat with GMs/other players and scripted comms with objects. + comms_dialog_box = new GuiPanel(this, "COMMS_DIALOG_BOX"); + comms_dialog_box + ->setSize(800.0f, 600.0f) + ->setPosition(0.0f, -100.0f, sp::Alignment::BottomCenter) + ->hide() + ->setAttribute("layout", "vertical"); + + // Title bar for comms panels. + GuiElement* comms_dialog_title_bar = new GuiElement(comms_dialog_box, ""); + comms_dialog_title_bar + ->setMargins(20.0f, 0.0f, 0.0f, 0.0f) + ->setSize(GuiElement::GuiSizeMax, 50.0f) + ->setAttribute("layout", "horizontal"); + + // Title label showing the comms target's name. + comms_dialog_title_label = new GuiLabel(comms_dialog_title_bar, "COMMS_DIALOG_TITLE", "", 30.0f); + comms_dialog_title_label + ->addBackground() + ->setSize(GuiElement::GuiSizeMax, 50.0f); + + // Minimize button collapses the panel to a restore button without closing comms. + (new GuiButton(comms_dialog_title_bar, "COMMS_DIALOG_MINIMIZE", "", + [this]() + { + comms_minimized = true; + } + ))->setIcon("gui/widget/IndicatorArrow.png", sp::Alignment::Center, -90.0f) + ->setMargins(20.0f, 0.0f, 0.0f, 0.0f) + ->setSize(50.0f, GuiElement::GuiSizeMax); + + // Button to close comms. + (new GuiButton(comms_dialog_title_bar, "COMMS_DIALOG_CLOSE", "X", + [this]() + { + script_comms_options->setOptions({}); + if (my_spaceship) my_player_info->commandCloseTextComm(); + } + ))->setTextSize(30.0f) + ->setSize(50.0f, 50.0f); + + // Floating restore button shown when any comms panel is minimized. + comms_restore_button = new GuiToggleButton(this, "COMMS_RESTORE", "", + [this](bool) + { + comms_minimized = false; + comms_has_unread = false; + } + ); + comms_restore_button + ->setIcon("gui/widget/IndicatorArrow.png", sp::Alignment::CenterLeft, 90.0f) + ->setPosition(0.0f, -70.0f, sp::Alignment::BottomCenter) + ->setSize(400.0f, 50.0f) + ->hide(); + + // Text area shared by both chat and scripted comms. + comms_dialog_text = new GuiScrollFormattedText(comms_dialog_box, "COMMS_DIALOG_TEXT", ""); + comms_dialog_text + ->enableAutoScrollDown() + ->setSize(GuiElement::GuiSizeMax, GuiElement::GuiSizeMax) + ->setMargins(20.0f); + + // Chat comms free-text message entry. + GuiElement* chat_comms_message_row = new GuiElement(comms_dialog_box, "COMMS_CHAT_MESSAGE_ROW"); + chat_comms_message_row + ->setMargins(20.0f) + ->setSize(GuiElement::GuiSizeMax, 50.0f) + ->setAttribute("layout", "horizontal"); + + chat_comms_message_entry = new GuiTextEntry(chat_comms_message_row, "COMMS_CHAT_MESSAGE_ENTRY", ""); + chat_comms_message_entry + ->enterCallback([this](string text) + { + if (my_spaceship) + my_player_info->commandSendCommPlayer(chat_comms_message_entry->getText()); + chat_comms_message_entry->setText(""); + } + ) + ->setSize(GuiElement::GuiSizeMax, GuiElement::GuiSizeMax); + + // Chat comms send button. + chat_comms_send_button = new GuiButton(chat_comms_message_row, "COMMS_CHAT_SEND", tr("button", "Send"), + [this]() + { + if (my_spaceship) + my_player_info->commandSendCommPlayer(chat_comms_message_entry->getText()); + chat_comms_message_entry->setText(""); + } + ); + chat_comms_send_button + ->setSize(120.0f, GuiElement::GuiSizeMax); + + // Script comms response options listbox. + script_comms_options = new GuiListbox(comms_dialog_box, "COMMS_SCRIPT_OPTIONS", + [this](int index, string value) + { + script_comms_options->setOptions({}); + my_player_info->commandSendComm(index); + } + ); + script_comms_options + ->setSize(GuiElement::GuiSizeMax, 200.0f) + ->setMargins(20.0f) + ->hide(); + + // If using a touchscreen, add an on-screen keyboard. + if (!engine->getObject("mouseRenderer")) { - OnScreenKeyboardControl* keyboard = new OnScreenKeyboardControl(chat_comms_box, chat_comms_message_entry); - keyboard->setPosition(20, -20, sp::Alignment::BottomLeft)->setSize(760, 200); - chat_comms_message_entry->setPosition(20, -220, sp::Alignment::BottomLeft); - chat_comms_send_button->setPosition(-20, -220, sp::Alignment::BottomRight); - chat_comms_text->setSize(chat_comms_text->getSize().x, chat_comms_text->getSize().y - 200); + OnScreenKeyboardControl* keyboard = new OnScreenKeyboardControl(comms_dialog_box, chat_comms_message_entry); + keyboard + ->setSize(760.0f, 200.0f) + ->setPosition(20.0f, -20.0f, sp::Alignment::BottomLeft); + chat_comms_message_entry + ->setPosition(20.0f, -220.0f, sp::Alignment::BottomLeft); + chat_comms_send_button + ->setPosition(-20.0f, -220.0f, sp::Alignment::BottomRight); + comms_dialog_text + ->setSize(comms_dialog_text->getSize().x, comms_dialog_text->getSize().y - 200.0f); } - - // Panel for scripted comms with objects. - script_comms_box = new GuiPanel(this, "COMMS_SCRIPT_BOX"); - script_comms_box->hide()->setSize(800, 600)->setPosition(0, -100, sp::Alignment::BottomCenter); - - script_comms_text = new GuiScrollFormattedText(script_comms_box, "COMMS_SCRIPT_TEXT", ""); - script_comms_text->setPosition(20, 30, sp::Alignment::TopLeft)->setSize(760, 500); - - // List possible responses to a scripted communication. - script_comms_options = new GuiListbox(script_comms_box, "COMMS_SCRIPT_LIST", [this](int index, string value) { - script_comms_options->setOptions({}); - my_player_info->commandSendComm(index); - }); - script_comms_options->setPosition(20, -70, sp::Alignment::BottomLeft)->setSize(700, 400); - - // Button to close scripted comms. - script_comms_close = new GuiButton(script_comms_box, "CLOSE_BUTTON", tr("button", "Close"), [this]() { - script_comms_options->setOptions({}); - if (my_spaceship) - my_player_info->commandCloseTextComm(); - }); - script_comms_close->setTextSize(20)->setPosition(-20, -20, sp::Alignment::BottomRight)->setSize(150, 50); } void GuiCommsOverlay::onUpdate() @@ -155,45 +281,81 @@ void GuiCommsOverlay::onUpdate() // If we're on a ship, show comms activity on draw. if (auto transmitter = my_spaceship.getComponent()) { - opening_box->setVisible(transmitter->state == CommsTransmitter::State::OpeningChannel); opening_progress->setValue(transmitter->open_delay); - - hailed_box->setVisible(transmitter->state == CommsTransmitter::State::BeingHailed || transmitter->state == CommsTransmitter::State::BeingHailedByGM); hailed_label->setText(tr("Hailed by {name}").format({{"name", transmitter->target_name}})); no_response_box->setVisible(transmitter->state == CommsTransmitter::State::ChannelFailed); - broken_box->setVisible(transmitter->state == CommsTransmitter::State::ChannelBroken); closed_box->setVisible(transmitter->state == CommsTransmitter::State::ChannelClosed); + const bool is_opening = transmitter->state == CommsTransmitter::State::OpeningChannel; + const bool is_hailed = transmitter->state == CommsTransmitter::State::BeingHailed || transmitter->state == CommsTransmitter::State::BeingHailedByGM; const bool is_open = transmitter->state == CommsTransmitter::State::ChannelOpenGM || transmitter->state == CommsTransmitter::State::ChannelOpenPlayer; - chat_comms_box->setVisible(is_open); - chat_comms_text->setText(transmitter->incomming_message); + const bool is_script = transmitter->state == CommsTransmitter::State::ChannelOpen; + const bool any_minimizable = is_opening || is_hailed || is_open || is_script; + + if (!any_minimizable) + { + comms_minimized = false; + comms_has_unread = false; + } + + opening_box->setVisible(is_opening && !comms_minimized); + hailed_box->setVisible(is_hailed && !comms_minimized); + comms_dialog_box->setVisible((is_open || is_script) && !comms_minimized); + chat_comms_message_entry->setVisible(is_open); + chat_comms_send_button->setVisible(is_open); + + string restore_text; + if (is_opening) + restore_text = tr("Opening comms with {name}").format({{"name", transmitter->target_name}}); + else if (is_hailed) + restore_text = tr("Hailed by {name}").format({{"name", transmitter->target_name}}); + else + restore_text = tr("Comms open with {name}").format({{"name", transmitter->target_name}}); + + if (comms_minimized && transmitter->incomming_message != last_incoming_message) + comms_has_unread = true; + last_incoming_message = transmitter->incomming_message; + + comms_restore_button + ->setValue(comms_has_unread) + ->setText(restore_text) + ->setVisible(comms_minimized && any_minimizable); + + comms_dialog_title_label->setText(transmitter->target_name); + comms_dialog_text->setText(transmitter->incomming_message); + + // Chat window has just opened, let's auto-focus the text input. if (is_open && !chat_open_last_update) { - // Chat window has just opened, let's auto-focus the text input - if (auto canvas = dynamic_cast(getTopLevelContainer())) - canvas->focus(chat_comms_message_entry); + if (auto canvas = dynamic_cast(getTopLevelContainer())) + canvas->focus(chat_comms_message_entry); } chat_open_last_update = is_open; - script_comms_box->setVisible(transmitter->state == CommsTransmitter::State::ChannelOpen); - script_comms_text->setText(transmitter->incomming_message); - - // Show the scripted comms options. If they've changed, update the lsit - bool changed = script_comms_options->entryCount() != int(transmitter->script_replies.size()); - if (!changed && transmitter->script_replies.size() > 0) - for (auto i = 0u; !changed && i < transmitter->script_replies.size(); i++) + // Show scripted comms options, if any. If they've changed, update the + // list. + const int transmitter_replies_count = static_cast(transmitter->script_replies.size()); + script_comms_options->setVisible(transmitter_replies_count); + bool changed = script_comms_options->entryCount() != transmitter_replies_count; + if (!changed && transmitter_replies_count > 0) + { + for (auto i = 0u; !changed && i < static_cast(transmitter_replies_count); i++) changed = transmitter->script_replies[i].message != script_comms_options->getEntryName(i); + } + if (changed) { + // Repopulate the comms options with the transmitter's. script_comms_options->setOptions({}); - for(const auto& reply : transmitter->script_replies) + for (const auto& reply : transmitter->script_replies) script_comms_options->addEntry(reply.message, reply.message); script_comms_options->setSelectionIndex(-1); - int display_options_count = std::min(5, script_comms_options->entryCount()); - script_comms_options->setSize(760, display_options_count * 50); - script_comms_text->setSize(760, 500 - display_options_count * 50); + + // Resize displayed options list to show at most 5 entries. + const int display_options_count = std::min(5, script_comms_options->entryCount()); + script_comms_options->setSize(GuiElement::GuiSizeMax, display_options_count * 50.0f); } } } @@ -207,6 +369,8 @@ void GuiCommsOverlay::clearElements() no_response_box->hide(); broken_box->hide(); closed_box->hide(); - chat_comms_box->hide(); - script_comms_box->hide(); + comms_dialog_box->hide(); + comms_restore_button->hide(); + comms_minimized = false; + comms_has_unread = false; } diff --git a/src/screenComponents/commsOverlay.h b/src/screenComponents/commsOverlay.h index 5eb8706003..36c3e3acde 100644 --- a/src/screenComponents/commsOverlay.h +++ b/src/screenComponents/commsOverlay.h @@ -6,6 +6,7 @@ class GuiPanel; class GuiProgressbar; class GuiButton; +class GuiToggleButton; class GuiLabel; class GuiScrollText; class GuiListbox; @@ -27,18 +28,19 @@ class GuiCommsOverlay : public GuiElement GuiPanel* broken_box; GuiPanel* closed_box; - GuiPanel* chat_comms_box; + GuiToggleButton* comms_restore_button; + + GuiPanel* comms_dialog_box; + GuiLabel* comms_dialog_title_label; + GuiScrollText* comms_dialog_text; GuiTextEntry* chat_comms_message_entry; - GuiScrollText* chat_comms_text; GuiButton* chat_comms_send_button; - GuiButton* chat_comms_close_button; - - GuiPanel* script_comms_box; - GuiScrollText* script_comms_text; GuiListbox* script_comms_options; - GuiButton* script_comms_close; - bool chat_open_last_update; + bool chat_open_last_update = false; + bool comms_minimized = false; + bool comms_has_unread = false; + string last_incoming_message; public: GuiCommsOverlay(GuiContainer* owner); From 23f37ebd398fe580aae5fed86e473fd17790dcea Mon Sep 17 00:00:00 2001 From: oznogon Date: Sun, 31 May 2026 16:09:06 -0700 Subject: [PATCH 2/2] enableAutoScrollDown on CommsOverlay only when chatting --- src/screenComponents/commsOverlay.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/screenComponents/commsOverlay.cpp b/src/screenComponents/commsOverlay.cpp index 2c5c321008..26bc5d2752 100644 --- a/src/screenComponents/commsOverlay.cpp +++ b/src/screenComponents/commsOverlay.cpp @@ -213,7 +213,6 @@ GuiCommsOverlay::GuiCommsOverlay(GuiContainer* owner) // Text area shared by both chat and scripted comms. comms_dialog_text = new GuiScrollFormattedText(comms_dialog_box, "COMMS_DIALOG_TEXT", ""); comms_dialog_text - ->enableAutoScrollDown() ->setSize(GuiElement::GuiSizeMax, GuiElement::GuiSizeMax) ->setMargins(20.0f); @@ -306,6 +305,11 @@ void GuiCommsOverlay::onUpdate() chat_comms_message_entry->setVisible(is_open); chat_comms_send_button->setVisible(is_open); + if (is_open) + comms_dialog_text->enableAutoScrollDown(); + else + comms_dialog_text->disableAutoScrollDown(); + string restore_text; if (is_opening) restore_text = tr("Opening comms with {name}").format({{"name", transmitter->target_name}});