read sounds from the game_config.cfg, rename sounds to match ui ids

I'm renaming the sounds to match the ui ids, because currently the
lobby sounds options dialog gives for each event, the name of the
corresponding sound entry in game_config.cfg, and I want the code
to look up those ids to be as simple as possible.
This commit is contained in:
Chris Beck 2014-10-11 23:44:26 -04:00
parent ac6e648fc1
commit 17d6b5e574
3 changed files with 38 additions and 22 deletions

View file

@ -146,18 +146,18 @@ namespace game_config
const size_t max_loop = 65536;
namespace sounds {
const std::string turn_bell = "bell.wav",
std::string turn_bell = "bell.wav",
timer_bell = "timer.wav",
receive_message = "chat-[1~3].ogg",
receive_message_highlight = "chat-highlight.ogg",
receive_message_friend = "chat-friend.ogg",
receive_message_server = "receive.wav",
user_arrive = "arrive.wav",
user_leave = "leave.wav",
public_message = "chat-[1~3].ogg",
private_message = "chat-highlight.ogg",
friend_message = "chat-friend.ogg",
server_message = "receive.wav",
player_joins = "arrive.wav",
player_leaves = "leave.wav",
game_user_arrive = "join.wav",
game_user_leave = "leave.wav",
party_full_bell = "bell.wav",
mp_game_begins = "join.wav";
ready_for_start = "bell.wav",
game_has_begun = "join.wav";
const std::string button_press = "button.wav",
checkbox_release = "checkbox.wav",
@ -300,6 +300,22 @@ namespace game_config
server_list.push_back(sinf);
}
if(const config & s = v.child("sounds")) {
using namespace game_config::sounds;
if (s.has_attribute("turn_bell")) turn_bell = s["turn_bell"].str();
if (s.has_attribute("timer_bell")) timer_bell = s["timer_bell"].str();
if (s.has_attribute("public_message")) public_message = s["public_message"].str();
if (s.has_attribute("private_message")) private_message = s["private_message"].str();
if (s.has_attribute("friend_message")) friend_message = s["friend_message"].str();
if (s.has_attribute("server_message")) server_message = s["server_message"].str();
if (s.has_attribute("player_joins")) player_joins = s["player_joins"].str();
if (s.has_attribute("player_leaves")) player_leaves = s["player_leaves"].str();
if (s.has_attribute("game_user_arrive")) game_user_arrive = s["game_user_arrive"].str();
if (s.has_attribute("game_user_leave")) game_user_leave = s["game_user_leave"].str();
if (s.has_attribute("ready_for_start")) ready_for_start = s["ready_for_start"].str();
if (s.has_attribute("game_has_begun")) game_has_begun = s["game_has_begun"].str();
}
assert(wesnoth_version.good());
assert(min_savegame_version.good());
assert(test_version.good());

View file

@ -145,11 +145,11 @@ namespace game_config
extern const size_t max_loop;
namespace sounds {
extern const std::string turn_bell, timer_bell, receive_message,
receive_message_highlight, receive_message_friend,
receive_message_server, user_arrive, user_leave,
game_user_arrive, game_user_leave, party_full_bell,
mp_game_begins;
extern std::string turn_bell, timer_bell, public_message,
private_message, friend_message,
server_message, player_joins, player_leaves,
game_user_arrive, game_user_leave, ready_for_start,
game_has_begun;
extern const std::string button_press, checkbox_release, slider_adjust,
menu_expand, menu_contract, menu_select;
}

View file

@ -62,7 +62,7 @@ void player_joins(bool is_lobby)
return ;
}
if (sound_pref(id)) {
sound::play_UI_sound(game_config::sounds::user_arrive);
sound::play_UI_sound(game_config::sounds::player_joins);
}
if (notif_pref(id)) {
desktop::notifications::send(_("Wesnoth"), _("A player has joined"), desktop::notifications::OTHER);
@ -76,7 +76,7 @@ void player_leaves(bool is_lobby)
return ;
}
if (sound_pref(id)) {
sound::play_UI_sound(game_config::sounds::user_leave);
sound::play_UI_sound(game_config::sounds::player_leaves);
}
if (notif_pref(id)) {
desktop::notifications::send(_("Wesnoth"), _("A player has left"), desktop::notifications::OTHER);
@ -90,7 +90,7 @@ void public_message(bool is_lobby)
return ;
}
if (sound_pref(id)) {
sound::play_UI_sound(game_config::sounds::receive_message);
sound::play_UI_sound(game_config::sounds::public_message);
}
if (notif_pref(id)) {
desktop::notifications::send(_("Wesnoth"), _("Received a message"), desktop::notifications::OTHER);
@ -104,7 +104,7 @@ void friend_message(bool is_lobby)
return ;
}
if (sound_pref(id)) {
sound::play_UI_sound(game_config::sounds::receive_message_friend);
sound::play_UI_sound(game_config::sounds::friend_message);
}
if (notif_pref(id)) {
desktop::notifications::send(_("Wesnoth"), _("Received a message from a friend"), desktop::notifications::OTHER);
@ -118,7 +118,7 @@ void private_message(bool is_lobby)
return ;
}
if (sound_pref(id)) {
sound::play_UI_sound(game_config::sounds::receive_message_highlight);
sound::play_UI_sound(game_config::sounds::private_message);
}
if (notif_pref(id)) {
desktop::notifications::send(_("Wesnoth"), _("Someone is talking to you"), desktop::notifications::OTHER);
@ -132,7 +132,7 @@ void server_message(bool is_lobby)
return ;
}
if (sound_pref(id)) {
sound::play_UI_sound(game_config::sounds::receive_message_server);
sound::play_UI_sound(game_config::sounds::server_message);
}
if (notif_pref(id)) {
desktop::notifications::send(_("Wesnoth"), _("The server has sent a message"), desktop::notifications::OTHER);
@ -144,7 +144,7 @@ void ready_for_start()
std::string id = "ready_for_start";
if (sound_pref(id)) {
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.
sound::play_bell(game_config::sounds::ready_for_start); //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.
}
}
if (notif_pref(id)) {
@ -156,7 +156,7 @@ void game_has_begun()
{
std::string id = "game_has_begun";
if (sound_pref(id)) {
sound::play_UI_sound(game_config::sounds::mp_game_begins);
sound::play_UI_sound(game_config::sounds::game_has_begun);
}
if (notif_pref(id)) {
desktop::notifications::send(_("Wesnoth"), _ ("Game has begun!"), desktop::notifications::OTHER);