make all lobbies, mp ui screens, and chat handlers use the new code

This commit replaces all appearance of `game_config::sounds::...`
where ... is an mp ui specific sound, with an appropriate call to
the mp_ui_sounds code. This makes sure that the preferences are
checked appropriately and notifications are distributed in all cases
appropriate.

This also obsoletes the "lobby sounds" advanced preference, it
doesn't do anything anymore. Its removal is pending.
This commit is contained in:
Chris Beck 2014-10-11 21:48:04 -04:00
parent a2ed0df973
commit 3a5eec03a4
7 changed files with 30 additions and 35 deletions

View file

@ -22,7 +22,7 @@
#include "game_preferences.hpp"
#include "log.hpp"
#include "marked-up_text.hpp"
#include "sound.hpp"
#include "mp_ui_sounds.hpp"
#include "serialization/string_utils.hpp"
#include <boost/cstdint.hpp>
@ -74,13 +74,13 @@ void display_chat_manager::add_chat_message(const time_t& time, const std::strin
if (bell) {
if ((type == events::chat_handler::MESSAGE_PRIVATE && (!is_observer || whisper))
|| utils::word_match(message, preferences::login())) {
sound::play_UI_sound(game_config::sounds::receive_message_highlight);
mp_ui_sounds::private_message(false);
} else if (preferences::is_friend(sender)) {
sound::play_UI_sound(game_config::sounds::receive_message_friend);
mp_ui_sounds::friend_message(false);
} else if (sender == "server") {
sound::play_UI_sound(game_config::sounds::receive_message_server);
mp_ui_sounds::server_message(false);
} else {
sound::play_UI_sound(game_config::sounds::receive_message);
mp_ui_sounds::public_message(false);
}
}

View file

@ -45,7 +45,7 @@
#include "network.hpp"
#include "playmp_controller.hpp"
#include "preferences_display.hpp"
#include "sound.hpp"
#include "mp_ui_sounds.hpp"
#include <boost/bind.hpp>
#include <boost/foreach.hpp>
@ -323,24 +323,22 @@ void tlobby_main::do_notify(t_notify_mode mode)
case NOTIFY_WHISPER:
case NOTIFY_WHISPER_OTHER_WINDOW:
case NOTIFY_OWN_NICK:
sound::play_UI_sound(
game_config::sounds::receive_message_highlight);
mp_ui_sounds::private_message(true);
break;
case NOTIFY_FRIEND_MESSAGE:
sound::play_UI_sound(
game_config::sounds::receive_message_friend);
mp_ui_sounds::friend_message(true);
break;
case NOTIFY_SERVER_MESSAGE:
sound::play_UI_sound(
game_config::sounds::receive_message_server);
mp_ui_sounds::server_message(true);
break;
case NOTIFY_LOBBY_QUIT:
sound::play_UI_sound(game_config::sounds::user_leave);
mp_ui_sounds::player_leaves(true);
break;
case NOTIFY_LOBBY_JOIN:
sound::play_UI_sound(game_config::sounds::user_arrive);
mp_ui_sounds::player_joins(true);
break;
case NOTIFY_MESSAGE:
mp_ui_sounds::public_message(true);
break;
default:
break;

View file

@ -55,7 +55,7 @@ bool notif_pref(std::string id)
// Note: This list must agree with data/gui/.../lobby_sound_options.cfg
const std::vector<std::string> items = boost::assign::list_of("player_joins")("player_leaves")("private_message")("friend_message")("public_message")("server_message")("ready_to_start")("game_has_begun");
void player_enters(bool is_lobby)
void player_joins(bool is_lobby)
{
std::string id = "player_enters";
if (is_lobby && !lobby_pref(id)) {

View file

@ -26,7 +26,7 @@
namespace mp_ui_sounds {
// Functions called when such an event occurs
void player_enters(bool is_lobby);
void player_joins(bool is_lobby);
void player_leaves(bool is_lobby);
void public_message(bool is_lobby);
void friend_message(bool is_lobby);

View file

@ -19,7 +19,6 @@
#include "multiplayer_connect.hpp"
#include "ai/configuration.hpp"
#include "desktop/notifications.hpp"
#include "dialogs.hpp"
#include "display_chat_manager.hpp"
#include "game_display.hpp"
@ -28,7 +27,7 @@
#include "log.hpp"
#include "map.hpp"
#include "wml_separators.hpp"
#include "sound.hpp"
#include "mp_ui_sounds.hpp"
#include <boost/foreach.hpp>
@ -560,10 +559,7 @@ void connect::process_network_data(const config& data,
update_playerlist_state(result.second); //result.second is the silent flag
if (!was_able_to_start && engine_.can_start_game()) {
DBG_MP << "play party full sound" << std::endl;
if(preferences::UI_sound_on()) {
sound::play_bell(game_config::sounds::party_full_bell); //this is play_bell instead of play_UI_sound to economize on sound channels. UI only has two sounds, and turn bell has a dedicated channel.
}
desktop::notifications::send(_("Wesnoth"), _ ("Ready to start!"), desktop::notifications::OTHER);
mp_ui_sounds::ready_for_start();
}
}

View file

@ -26,7 +26,7 @@
#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 "mp_ui_sounds.hpp"
#include "wml_separators.hpp"
#include "formula_string_utils.hpp"
@ -413,15 +413,16 @@ void ui::process_message(const config& msg, const bool whisper) {
preferences::parse_admin_authentication(sender, message);
bool is_lobby = dynamic_cast<mp::lobby*>(this) != NULL;
if (whisper || utils::word_match(message, preferences::login())) {
sound::play_UI_sound(game_config::sounds::receive_message_highlight);
mp_ui_sounds::private_message(is_lobby);
} else if (preferences::is_friend(sender)) {
sound::play_UI_sound(game_config::sounds::receive_message_friend);
mp_ui_sounds::friend_message(is_lobby);
} else if (sender == "server") {
sound::play_UI_sound(game_config::sounds::receive_message_server);
mp_ui_sounds::server_message(is_lobby);
} else {
// too annoying and probably not any helpful
//sound::play_UI_sound(game_config::sounds::receive_message);
mp_ui_sounds::public_message(is_lobby);
}
std::string prefix;
@ -690,11 +691,13 @@ 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 && (!dynamic_cast<mp::lobby*>(this) || preferences::lobby_sounds())) {
if(!silent) {
bool is_lobby = dynamic_cast<mp::lobby*>(this) != NULL;
if(list.size() < user_list_.size()) {
sound::play_UI_sound(game_config::sounds::user_leave);
mp_ui_sounds::player_leaves(is_lobby);
} else if(list.size() > user_list_.size()) {
sound::play_UI_sound(game_config::sounds::user_arrive);
mp_ui_sounds::player_joins(is_lobby);
}
}

View file

@ -14,7 +14,6 @@
#include "global.hpp"
#include "desktop/notifications.hpp"
#include "dialogs.hpp"
#include "gettext.hpp"
#include "game_config_manager.hpp"
@ -28,7 +27,7 @@
#include "resources.hpp"
#include "statistics.hpp"
#include "saved_game.hpp"
#include "sound.hpp"
#include "mp_ui_sounds.hpp"
#include "unit_types.hpp"
#include "wml_exception.hpp"
#include "wml_separators.hpp"
@ -408,8 +407,7 @@ void wait::start_game()
level_to_gamestate(level_, state_);
LOG_NW << "starting game\n";
sound::play_UI_sound(game_config::sounds::mp_game_begins);
desktop::notifications::send(_("Wesnoth"), _ ("Game has begun!"), desktop::notifications::OTHER);
mp_ui_sounds::game_has_begun();
}
void wait::layout_children(const SDL_Rect& rect)