Merge lp:~widelands-dev/widelands/feature-loudylobby into lp:widelands

Proposed by Teppo Mäenpää
Status: Merged
Merged at revision: 6843
Proposed branch: lp:~widelands-dev/widelands/feature-loudylobby
Merge into: lp:widelands
Diff against target: 135 lines (+40/-1)
7 files modified
src/sound/sound_handler.cc (+2/-0)
src/ui_basic/panel.cc (+9/-0)
src/ui_basic/panel.h (+2/-0)
src/ui_fsmenu/internet_lobby.cc (+9/-0)
src/ui_fsmenu/internet_lobby.h (+1/-0)
src/wui/gamechatpanel.cc (+16/-1)
src/wui/gamechatpanel.h (+1/-0)
To merge this branch: bzr merge lp:~widelands-dev/widelands/feature-loudylobby
Reviewer Review Type Date Requested Status
SirVer Needs Fixing
Nasenbaer Approve
Review via email: mp+207819@code.launchpad.net

Description of the change

This adds two sounds to the internet lobby: One when a new person enters the lobby, another one when somebody posts a message there.

To post a comment you must log in.
Revision history for this message
Nasenbaer (nasenbaer) wrote :

Approved not just because the code looks good, but as well because it simply works and because I was wishing for such a feature for some time already :)

review: Approve
Revision history for this message
SirVer (sirver) wrote :

Just a nit: Please change:

if (not msgs . back() . sender . empty())
116 + // Alert me!
117 + play_new_chat_message();

to

if (!msgs.back().sender.empty()) {
    // Alert me!
    play_new_chat_message();
}

and I do not understand the comment that is directly above this if statement - can you rephrase it somehow?

Otherwise lgtm. Feel free to merge yourself.

review: Needs Fixing

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== added file 'sound/message_chat_00.ogg'
0Binary files sound/message_chat_00.ogg 1970-01-01 00:00:00 +0000 and sound/message_chat_00.ogg 2014-02-25 19:46:58 +0000 differ0Binary files sound/message_chat_00.ogg 1970-01-01 00:00:00 +0000 and sound/message_chat_00.ogg 2014-02-25 19:46:58 +0000 differ
=== added file 'sound/message_freshmen_00.ogg'
1Binary files sound/message_freshmen_00.ogg 1970-01-01 00:00:00 +0000 and sound/message_freshmen_00.ogg 2014-02-25 19:46:58 +0000 differ1Binary files sound/message_freshmen_00.ogg 1970-01-01 00:00:00 +0000 and sound/message_freshmen_00.ogg 2014-02-25 19:46:58 +0000 differ
=== modified file 'src/sound/sound_handler.cc'
--- src/sound/sound_handler.cc 2014-02-22 18:04:02 +0000
+++ src/sound/sound_handler.cc 2014-02-25 19:46:58 +0000
@@ -213,6 +213,8 @@
213 load_fx_if_needed("sound", "message", "sound/message");213 load_fx_if_needed("sound", "message", "sound/message");
214 load_fx_if_needed("sound/military", "under_attack", "sound/military/under_attack");214 load_fx_if_needed("sound/military", "under_attack", "sound/military/under_attack");
215 load_fx_if_needed("sound/military", "site_occupied", "sound/military/site_occupied");215 load_fx_if_needed("sound/military", "site_occupied", "sound/military/site_occupied");
216 load_fx_if_needed("sound", "message_chat", "sound/message_chat");
217 load_fx_if_needed("sound", "message_freshmen", "sound/message_freshmen");
216}218}
217219
218/** Load a sound effect. One sound effect can consist of several audio files220/** Load a sound effect. One sound effect can consist of several audio files
219221
=== modified file 'src/ui_basic/panel.cc'
--- src/ui_basic/panel.cc 2014-02-22 18:04:02 +0000
+++ src/ui_basic/panel.cc 2014-02-25 19:46:58 +0000
@@ -815,6 +815,15 @@
815{815{
816 g_sound_handler.play_fx("sound/click", 128, PRIO_ALWAYS_PLAY);816 g_sound_handler.play_fx("sound/click", 128, PRIO_ALWAYS_PLAY);
817}817}
818void Panel::play_new_chat_message()
819{
820 g_sound_handler.play_fx("sound/message_chat", 128, PRIO_ALWAYS_PLAY);
821}
822void Panel::play_new_chat_member()
823{
824 g_sound_handler.play_fx("sound/message_freshmen", 128, PRIO_ALWAYS_PLAY);
825}
826
818827
819/**828/**
820 * Recursively walk the panel tree, killing panels that are marked for death829 * Recursively walk the panel tree, killing panels that are marked for death
821830
=== modified file 'src/ui_basic/panel.h'
--- src/ui_basic/panel.h 2013-10-14 07:20:46 +0000
+++ src/ui_basic/panel.h 2014-02-25 19:46:58 +0000
@@ -241,6 +241,8 @@
241 virtual void update_desired_size();241 virtual void update_desired_size();
242242
243 static void play_click();243 static void play_click();
244 static void play_new_chat_member();
245 static void play_new_chat_message();
244246
245 static bool draw_tooltip(RenderTarget &, const std::string & text);247 static bool draw_tooltip(RenderTarget &, const std::string & text);
246248
247249
=== modified file 'src/ui_fsmenu/internet_lobby.cc'
--- src/ui_fsmenu/internet_lobby.cc 2014-02-22 18:04:02 +0000
+++ src/ui_fsmenu/internet_lobby.cc 2014-02-25 19:46:58 +0000
@@ -43,6 +43,7 @@
43 m_buth (get_h() * 19 / 400),43 m_buth (get_h() * 19 / 400),
44 m_lisw (get_w() * 623 / 1000),44 m_lisw (get_w() * 623 / 1000),
45 m_fs (fs_small()),45 m_fs (fs_small()),
46 m_prev_clientlist_len(1000),
46 m_fn (ui_fn()),47 m_fn (ui_fn()),
4748
48// Text labels49// Text labels
@@ -295,6 +296,14 @@
295 continue;296 continue;
296 }297 }
297 }298 }
299
300 // If a new player joins the lobby, play a sound.
301 if (clients.size() != m_prev_clientlist_len)
302 {
303 if (clients.size() > m_prev_clientlist_len)
304 play_new_chat_member();
305 m_prev_clientlist_len = clients.size();
306 }
298}307}
299308
300309
301310
=== modified file 'src/ui_fsmenu/internet_lobby.h'
--- src/ui_fsmenu/internet_lobby.h 2014-02-22 18:04:02 +0000
+++ src/ui_fsmenu/internet_lobby.h 2014-02-25 19:46:58 +0000
@@ -52,6 +52,7 @@
52 uint32_t m_buth;52 uint32_t m_buth;
53 uint32_t m_lisw;53 uint32_t m_lisw;
54 uint32_t m_fs;54 uint32_t m_fs;
55 uint32_t m_prev_clientlist_len;
55 std::string m_fn;56 std::string m_fn;
56 UI::Textarea title, m_clients, m_opengames;57 UI::Textarea title, m_clients, m_opengames;
57 UI::Textarea m_servername;58 UI::Textarea m_servername;
5859
=== modified file 'src/wui/gamechatpanel.cc'
--- src/wui/gamechatpanel.cc 2013-09-21 15:24:24 +0000
+++ src/wui/gamechatpanel.cc 2014-02-25 19:46:58 +0000
@@ -31,7 +31,8 @@
31 UI::Panel(parent, x, y, w, h),31 UI::Panel(parent, x, y, w, h),
32 m_chat (chat),32 m_chat (chat),
33 chatbox (this, 0, 0, w, h - 25, "", UI::Align_Left, 1),33 chatbox (this, 0, 0, w, h - 25, "", UI::Align_Left, 1),
34 editbox (this, 0, h - 20, w, 20)34 editbox (this, 0, h - 20, w, 20),
35 chat_message_counter(0)
35{36{
36 chatbox.set_scrollmode(UI::Multiline_Textarea::ScrollLog);37 chatbox.set_scrollmode(UI::Multiline_Textarea::ScrollLog);
37 editbox.ok.connect(boost::bind(&GameChatPanel::keyEnter, this));38 editbox.ok.connect(boost::bind(&GameChatPanel::keyEnter, this));
@@ -62,6 +63,20 @@
62 str += "</rt>";63 str += "</rt>";
6364
64 chatbox.set_text(str);65 chatbox.set_text(str);
66
67 // If there are new messages, play a sound
68 if (msgs.size() > chat_message_counter)
69 {
70 // computer generated ones are ignored
71 // Note: if many messages arrive simultaneously,
72 // the latest is a system message and some others
73 // are not, then this act wrong!
74 if (!msgs.back().sender.empty())
75 // The latest message is not a system message
76 play_new_chat_message();
77 chat_message_counter = msgs . size();
78
79 }
65}80}
6681
67/**82/**
6883
=== modified file 'src/wui/gamechatpanel.h'
--- src/wui/gamechatpanel.h 2014-02-22 18:04:02 +0000
+++ src/wui/gamechatpanel.h 2014-02-25 19:46:58 +0000
@@ -63,6 +63,7 @@
63 ChatProvider & m_chat;63 ChatProvider & m_chat;
64 UI::Multiline_Textarea chatbox;64 UI::Multiline_Textarea chatbox;
65 UI::EditBox editbox;65 UI::EditBox editbox;
66 uint32_t chat_message_counter;
66};67};
6768
68#endif69#endif

Subscribers

People subscribed via source and target branches

to status/vote changes: