← Back to team overview

widelands-dev team mailing list archive

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

 

Teppo Mäenpää has proposed merging lp:~widelands-dev/widelands/feature-loudylobby into lp:widelands.

Requested reviews:
  Widelands Developers (widelands-dev)
Related bugs:
  Bug #1278026 in widelands: "Waiting for participants in the metaserver lobby is not fun."
  https://bugs.launchpad.net/widelands/+bug/1278026

For more details, see:
https://code.launchpad.net/~widelands-dev/widelands/feature-loudylobby/+merge/207819

This adds two sounds to the internet lobby: One when a new person enters the lobby, another one when somebody posts a message there.
-- 
https://code.launchpad.net/~widelands-dev/widelands/feature-loudylobby/+merge/207819
Your team Widelands Developers is requested to review the proposed merge of lp:~widelands-dev/widelands/feature-loudylobby into lp:widelands.
=== added file 'sound/message_chat_00.ogg'
Binary files sound/message_chat_00.ogg	1970-01-01 00:00:00 +0000 and sound/message_chat_00.ogg	2014-02-23 07:26:47 +0000 differ
=== added file 'sound/message_freshmen_00.ogg'
Binary files sound/message_freshmen_00.ogg	1970-01-01 00:00:00 +0000 and sound/message_freshmen_00.ogg	2014-02-23 07:26:47 +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-23 07:26:47 +0000
@@ -213,6 +213,8 @@
 	load_fx_if_needed("sound", "message", "sound/message");
 	load_fx_if_needed("sound/military", "under_attack", "sound/military/under_attack");
 	load_fx_if_needed("sound/military", "site_occupied", "sound/military/site_occupied");
+	load_fx_if_needed("sound", "message_chat", "sound/message_chat");
+	load_fx_if_needed("sound", "message_freshmen", "sound/message_freshmen");
 }
 
 /** Load a sound effect. One sound effect can consist of several audio files

=== 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-23 07:26:47 +0000
@@ -815,6 +815,15 @@
 {
 	g_sound_handler.play_fx("sound/click", 128, PRIO_ALWAYS_PLAY);
 }
+void Panel::play_new_chat_message()
+{
+	g_sound_handler.play_fx("sound/message_chat", 128, PRIO_ALWAYS_PLAY);
+}
+void Panel::play_new_chat_member()
+{
+	g_sound_handler.play_fx("sound/message_freshmen", 128, PRIO_ALWAYS_PLAY);
+}
+
 
 /**
  * Recursively walk the panel tree, killing panels that are marked for death

=== 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-23 07:26:47 +0000
@@ -241,6 +241,8 @@
 	virtual void update_desired_size();
 
 	static void play_click();
+	static void play_new_chat_member();
+	static void play_new_chat_message();
 
 	static bool draw_tooltip(RenderTarget &, const std::string & text);
 

=== 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-23 07:26:47 +0000
@@ -43,6 +43,7 @@
 	m_buth (get_h() * 19 / 400),
 	m_lisw (get_w() * 623 / 1000),
 	m_fs   (fs_small()),
+	m_prev_clientlist_len(1000),
 	m_fn   (ui_fn()),
 
 // Text labels
@@ -295,6 +296,14 @@
 				continue;
 		}
 	}
+
+	// If a new player joins the lobby, play a sound.
+	if (clients.size() != m_prev_clientlist_len)
+	{
+		if (clients.size() > m_prev_clientlist_len)
+			play_new_chat_member();
+		m_prev_clientlist_len = clients.size();
+	}
 }
 
 

=== 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-23 07:26:47 +0000
@@ -52,6 +52,7 @@
 	uint32_t m_buth;
 	uint32_t m_lisw;
 	uint32_t m_fs;
+	uint32_t m_prev_clientlist_len;
 	std::string m_fn;
 	UI::Textarea title, m_clients, m_opengames;
 	UI::Textarea m_servername;

=== modified file 'src/wui/gamechatpanel.cc'
--- src/wui/gamechatpanel.cc	2013-09-21 15:24:24 +0000
+++ src/wui/gamechatpanel.cc	2014-02-23 07:26:47 +0000
@@ -31,7 +31,8 @@
 	UI::Panel(parent, x, y, w, h),
 	m_chat   (chat),
 	chatbox  (this, 0, 0, w, h - 25, "", UI::Align_Left, 1),
-	editbox  (this, 0, h - 20, w,  20)
+	editbox  (this, 0, h - 20, w,  20),
+	chat_message_counter(0)
 {
 	chatbox.set_scrollmode(UI::Multiline_Textarea::ScrollLog);
 	editbox.ok.connect(boost::bind(&GameChatPanel::keyEnter, this));
@@ -62,6 +63,20 @@
 	str += "</rt>";
 
 	chatbox.set_text(str);
+
+	// If there are new messages, play a sound
+	if (msgs.size() > chat_message_counter)
+	{
+		// computer generated ones are ignored
+		// Note: if many messages arrive simultaneously,
+		// the latest is a system message and some others
+		// are not, then this act wrong!
+		if (not msgs . back() . sender . empty())
+			// Alert me!
+			play_new_chat_message();
+		chat_message_counter = msgs . size();
+
+	}
 }
 
 /**

=== modified file 'src/wui/gamechatpanel.h'
--- src/wui/gamechatpanel.h	2014-02-22 18:04:02 +0000
+++ src/wui/gamechatpanel.h	2014-02-23 07:26:47 +0000
@@ -63,6 +63,7 @@
 	ChatProvider & m_chat;
 	UI::Multiline_Textarea chatbox;
 	UI::EditBox editbox;
+	uint32_t chat_message_counter;
 };
 
 #endif


Follow ups