widelands-dev team mailing list archive
-
widelands-dev team
-
Mailing list archive
-
Message #14885
[Merge] lp:~widelands-dev/widelands/bug-1794063-extra-chat-message-sound into lp:widelands
GunChleoc has proposed merging lp:~widelands-dev/widelands/bug-1794063-extra-chat-message-sound into lp:widelands.
Commit message:
Never play message sound when a new chat window is opened
Requested reviews:
Widelands Developers (widelands-dev)
Related bugs:
Bug #1794063 in widelands: "Extra message arrival sound"
https://bugs.launchpad.net/widelands/+bug/1794063
For more details, see:
https://code.launchpad.net/~widelands-dev/widelands/bug-1794063-extra-chat-message-sound/+merge/355974
--
Your team Widelands Developers is requested to review the proposed merge of lp:~widelands-dev/widelands/bug-1794063-extra-chat-message-sound into lp:widelands.
=== modified file 'src/wui/game_chat_panel.cc'
--- src/wui/game_chat_panel.cc 2018-07-08 09:18:33 +0000
+++ src/wui/game_chat_panel.cc 2018-10-02 08:32:02 +0000
@@ -55,14 +55,14 @@
set_can_focus(true);
chat_message_subscriber_ =
- Notifications::subscribe<ChatMessage>([this](const ChatMessage&) { recalculate(); });
+ Notifications::subscribe<ChatMessage>([this](const ChatMessage&) { recalculate(true); });
recalculate();
}
/**
* Updates the chat message area.
*/
-void GameChatPanel::recalculate() {
+void GameChatPanel::recalculate(bool has_new_message) {
const std::vector<ChatMessage> msgs = chat_.get_messages();
size_t msgs_size = msgs.size();
@@ -74,19 +74,17 @@
chatbox.set_text(str);
- if (chat_message_counter < msgs_size) { // are there new messages?
- if (!chat_.sound_off()) { // play a sound, if needed
- for (size_t i = chat_message_counter; i < msgs_size; ++i) {
- if (msgs[i].sender.empty()) {
- continue; // System message. Don't play a sound
- }
+ // Play a sound if there is a new non-system message
+ if (!chat_.sound_off() && has_new_message) {
+ for (size_t i = chat_message_counter; i < msgs_size; ++i) {
+ if (!msgs[i].sender.empty()) {
// Got a message that is no system message. Beep
play_new_chat_message();
break;
}
}
- chat_message_counter = msgs_size;
}
+ chat_message_counter = msgs_size;
}
/**
=== modified file 'src/wui/game_chat_panel.h'
--- src/wui/game_chat_panel.h 2018-05-16 05:30:22 +0000
+++ src/wui/game_chat_panel.h 2018-10-02 08:32:02 +0000
@@ -58,7 +58,7 @@
void unfocus_edit();
private:
- void recalculate();
+ void recalculate(bool has_new_message = false);
void key_enter();
void key_escape();
Follow ups