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
1=== added file 'sound/message_chat_00.ogg'
2Binary 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
3=== added file 'sound/message_freshmen_00.ogg'
4Binary 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
5=== modified file 'src/sound/sound_handler.cc'
6--- src/sound/sound_handler.cc 2014-02-22 18:04:02 +0000
7+++ src/sound/sound_handler.cc 2014-02-25 19:46:58 +0000
8@@ -213,6 +213,8 @@
9 load_fx_if_needed("sound", "message", "sound/message");
10 load_fx_if_needed("sound/military", "under_attack", "sound/military/under_attack");
11 load_fx_if_needed("sound/military", "site_occupied", "sound/military/site_occupied");
12+ load_fx_if_needed("sound", "message_chat", "sound/message_chat");
13+ load_fx_if_needed("sound", "message_freshmen", "sound/message_freshmen");
14 }
15
16 /** Load a sound effect. One sound effect can consist of several audio files
17
18=== modified file 'src/ui_basic/panel.cc'
19--- src/ui_basic/panel.cc 2014-02-22 18:04:02 +0000
20+++ src/ui_basic/panel.cc 2014-02-25 19:46:58 +0000
21@@ -815,6 +815,15 @@
22 {
23 g_sound_handler.play_fx("sound/click", 128, PRIO_ALWAYS_PLAY);
24 }
25+void Panel::play_new_chat_message()
26+{
27+ g_sound_handler.play_fx("sound/message_chat", 128, PRIO_ALWAYS_PLAY);
28+}
29+void Panel::play_new_chat_member()
30+{
31+ g_sound_handler.play_fx("sound/message_freshmen", 128, PRIO_ALWAYS_PLAY);
32+}
33+
34
35 /**
36 * Recursively walk the panel tree, killing panels that are marked for death
37
38=== modified file 'src/ui_basic/panel.h'
39--- src/ui_basic/panel.h 2013-10-14 07:20:46 +0000
40+++ src/ui_basic/panel.h 2014-02-25 19:46:58 +0000
41@@ -241,6 +241,8 @@
42 virtual void update_desired_size();
43
44 static void play_click();
45+ static void play_new_chat_member();
46+ static void play_new_chat_message();
47
48 static bool draw_tooltip(RenderTarget &, const std::string & text);
49
50
51=== modified file 'src/ui_fsmenu/internet_lobby.cc'
52--- src/ui_fsmenu/internet_lobby.cc 2014-02-22 18:04:02 +0000
53+++ src/ui_fsmenu/internet_lobby.cc 2014-02-25 19:46:58 +0000
54@@ -43,6 +43,7 @@
55 m_buth (get_h() * 19 / 400),
56 m_lisw (get_w() * 623 / 1000),
57 m_fs (fs_small()),
58+ m_prev_clientlist_len(1000),
59 m_fn (ui_fn()),
60
61 // Text labels
62@@ -295,6 +296,14 @@
63 continue;
64 }
65 }
66+
67+ // If a new player joins the lobby, play a sound.
68+ if (clients.size() != m_prev_clientlist_len)
69+ {
70+ if (clients.size() > m_prev_clientlist_len)
71+ play_new_chat_member();
72+ m_prev_clientlist_len = clients.size();
73+ }
74 }
75
76
77
78=== modified file 'src/ui_fsmenu/internet_lobby.h'
79--- src/ui_fsmenu/internet_lobby.h 2014-02-22 18:04:02 +0000
80+++ src/ui_fsmenu/internet_lobby.h 2014-02-25 19:46:58 +0000
81@@ -52,6 +52,7 @@
82 uint32_t m_buth;
83 uint32_t m_lisw;
84 uint32_t m_fs;
85+ uint32_t m_prev_clientlist_len;
86 std::string m_fn;
87 UI::Textarea title, m_clients, m_opengames;
88 UI::Textarea m_servername;
89
90=== modified file 'src/wui/gamechatpanel.cc'
91--- src/wui/gamechatpanel.cc 2013-09-21 15:24:24 +0000
92+++ src/wui/gamechatpanel.cc 2014-02-25 19:46:58 +0000
93@@ -31,7 +31,8 @@
94 UI::Panel(parent, x, y, w, h),
95 m_chat (chat),
96 chatbox (this, 0, 0, w, h - 25, "", UI::Align_Left, 1),
97- editbox (this, 0, h - 20, w, 20)
98+ editbox (this, 0, h - 20, w, 20),
99+ chat_message_counter(0)
100 {
101 chatbox.set_scrollmode(UI::Multiline_Textarea::ScrollLog);
102 editbox.ok.connect(boost::bind(&GameChatPanel::keyEnter, this));
103@@ -62,6 +63,20 @@
104 str += "</rt>";
105
106 chatbox.set_text(str);
107+
108+ // If there are new messages, play a sound
109+ if (msgs.size() > chat_message_counter)
110+ {
111+ // computer generated ones are ignored
112+ // Note: if many messages arrive simultaneously,
113+ // the latest is a system message and some others
114+ // are not, then this act wrong!
115+ if (!msgs.back().sender.empty())
116+ // The latest message is not a system message
117+ play_new_chat_message();
118+ chat_message_counter = msgs . size();
119+
120+ }
121 }
122
123 /**
124
125=== modified file 'src/wui/gamechatpanel.h'
126--- src/wui/gamechatpanel.h 2014-02-22 18:04:02 +0000
127+++ src/wui/gamechatpanel.h 2014-02-25 19:46:58 +0000
128@@ -63,6 +63,7 @@
129 ChatProvider & m_chat;
130 UI::Multiline_Textarea chatbox;
131 UI::EditBox editbox;
132+ uint32_t chat_message_counter;
133 };
134
135 #endif

Subscribers

People subscribed via source and target branches

to status/vote changes: