add friend_message preferences and handler

This commit is contained in:
Chris Beck 2014-10-11 20:49:55 -04:00
parent bb08fae9f6
commit a2ed0df973
3 changed files with 19 additions and 3 deletions

View file

@ -173,7 +173,8 @@
{__GUI_LOBBY_SOUNDS_ENTRY "player_joins" _"Player joins:" _"When a player joins the lobby or game."}
{__GUI_LOBBY_SOUNDS_ENTRY "player_leaves" _"Player leaves:" _"When a player leaves the lobby or game."}
{__GUI_LOBBY_SOUNDS_ENTRY "private_message" _"Private message:" _"When a private message is recieved."}
{__GUI_LOBBY_SOUNDS_ENTRY "public_message" _"Public message:" _"When a public message is recieved."}
{__GUI_LOBBY_SOUNDS_ENTRY "friend_message" _"Friend message:" _"When a message from a friend is recieved."}
{__GUI_LOBBY_SOUNDS_ENTRY "public_message" _"Public message:" _"When a public message is recieved."}
{__GUI_LOBBY_SOUNDS_ENTRY "server_message" _"Server message:" _"When a server message is recieved."}
{__GUI_LOBBY_SOUNDS_ENTRY "ready_to_start" _"Ready to start game:" _"When the game you are hosting is ready to start."}
{__GUI_LOBBY_SOUNDS_ENTRY "game_has_begun" _"Game has begun:" _"When the host (not you) has started the game."}

View file

@ -53,7 +53,7 @@ bool notif_pref(std::string id)
} // end anonymous namespace
// 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")("public_message")("server_message")("ready_to_start")("game_has_begun");
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)
{
@ -97,6 +97,20 @@ void public_message(bool is_lobby)
}
}
void friend_message(bool is_lobby)
{
std::string id = "friend_message";
if (is_lobby && !lobby_pref(id)) {
return ;
}
if (sound_pref(id)) {
sound::play_UI_sound(game_config::sounds::receive_message_friend);
}
if (notif_pref(id)) {
desktop::notifications::send(_("Wesnoth"), _("Received a message from a friend"), desktop::notifications::OTHER);
}
}
void private_message(bool is_lobby)
{
std::string id = "private_message";
@ -150,7 +164,7 @@ void game_has_begun()
}
bool get_def_pref_sound(const std::string & id) {
return (id != "public_message");
return (id != "public_message" && id != "friend_message");
}
bool get_def_pref_notif(const std::string & id) {

View file

@ -29,6 +29,7 @@ namespace mp_ui_sounds {
void player_enters(bool is_lobby);
void player_leaves(bool is_lobby);
void public_message(bool is_lobby);
void friend_message(bool is_lobby);
void private_message(bool is_lobby);
void server_message(bool is_lobby);
void ready_for_start();