check lobby_sounds preference for the GUI 1 lobby also

This fixes a bug reported on forums here:
http://forums.wesnoth.org/viewtopic.php?f=4&t=40660#p572131

The lobby sounds pref now affects the GUI 1 and 2 mp lobbies,
but it only affects the lobby screen, not mp::wait or mp::connect
etc.

This check is implemented by trying to dynamic cast 'this' mp::ui
object to a mp::lobby, at the time when we would play the arrive
or leave sounds.

The lobby sounds pref does *not* block the sounds due to server
messages, messages from a friend, or whispers.
This commit is contained in:
Chris Beck 2014-07-13 13:31:30 -04:00
parent fe31cc0ff0
commit f47de95341

View file

@ -26,6 +26,7 @@
#include "menu_events.hpp"
#include "multiplayer.hpp"
#include "multiplayer_ui.hpp"
#include "multiplayer_lobby.hpp" //needed for dynamic cast when implementing the lobby_sounds preference
#include "sound.hpp"
#include "wml_separators.hpp"
#include "formula_string_utils.hpp"
@ -690,7 +691,7 @@ void ui::set_user_menu_items(const std::vector<std::string>& list)
void ui::set_user_list(const std::vector<std::string>& list, bool silent)
{
if(!silent) {
if(!silent && (!dynamic_cast<mp::lobby*>(this) || preferences::lobby_sounds())) {
if(list.size() < user_list_.size()) {
sound::play_UI_sound(game_config::sounds::user_leave);
} else if(list.size() > user_list_.size()) {