Skip to content

Commit

Permalink
create "turn_changed" preference under mp alerts
Browse files Browse the repository at this point in the history
  • Loading branch information
cbeck88 committed Oct 18, 2014
1 parent 304033e commit 835da04
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 5 deletions.
1 change: 1 addition & 0 deletions data/gui/default/window/mp_alerts_options.cfg
Expand Up @@ -179,6 +179,7 @@
{__GUI_LOBBY_SOUNDS_ENTRY "server_message" _"Server message:" _"When a server message is recieved"}
{__GUI_LOBBY_SOUNDS_ENTRY "ready_for_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"}
{__GUI_LOBBY_SOUNDS_ENTRY "turn_changed" _"Turn changed:" _"When a new turn has begun"}

[/grid]

Expand Down
6 changes: 6 additions & 0 deletions src/gui/dialogs/mp_alerts_options.cpp
Expand Up @@ -142,6 +142,12 @@ void tmp_alerts_options::pre_show(CVideo& /*video*/, twindow& window)
in_lobby = &find_widget<ttoggle_button>(&window,"game_has_begun_lobby", false);
in_lobby->set_visible(twidget::tvisible::invisible);

in_lobby = &find_widget<ttoggle_button>(&window,"turn_changed_sound", false); // If we get a sound for this then don't remove this button
in_lobby->set_visible(twidget::tvisible::invisible);

in_lobby = &find_widget<ttoggle_button>(&window,"turn_changed_lobby", false);
in_lobby->set_visible(twidget::tvisible::invisible);

tbutton * defaults;
defaults = &find_widget<tbutton>(&window,"revert_to_defaults", false);
connect_signal_mouse_left_click(*defaults, boost::bind(&revert_to_default_pref_values, boost::ref(window)));
Expand Down
13 changes: 8 additions & 5 deletions src/mp_ui_alerts.cpp
Expand Up @@ -54,7 +54,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")("friend_message")("public_message")("server_message")("ready_for_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_for_start")("game_has_begun")("turn_changed");

void player_joins(bool is_lobby)
{
Expand Down Expand Up @@ -166,17 +166,20 @@ void game_has_begun()

void turn_changed(const std::string & player_name)
{
utils::string_map player;
player["name"] = player_name;
desktop::notifications::send(_("Turn changed"), vgettext("$name has taken control", player), desktop::notifications::TURN_CHANGED);
std::string id = "turn_changed";
if (notif_pref(id)) {
utils::string_map player;
player["name"] = player_name;
desktop::notifications::send(_("Turn changed"), vgettext("$name has taken control", player), desktop::notifications::TURN_CHANGED);
}
}

bool get_def_pref_sound(const std::string & id) {
return (id != "public_message" && id != "friend_message");
}

bool get_def_pref_notif(const std::string & id) {
return (desktop::notifications::available() && (id == "private_message" || id == "ready_for_start" || id == "game_has_begun"));
return (desktop::notifications::available() && (id == "private_message" || id == "ready_for_start" || id == "game_has_begun" || id == "turn_changed"));
}

bool get_def_pref_lobby(const std::string & id) {
Expand Down

0 comments on commit 835da04

Please sign in to comment.