37 bool lobby_pref(
const std::string&
id)
42 bool sound_pref(
const std::string&
id)
47 bool notif_pref(
const std::string&
id)
52 const std::string _player_joins =
"player_joins";
53 const std::string _player_leaves =
"player_leaves";
54 const std::string _private_message =
"private_message";
55 const std::string _friend_message =
"friend_message";
56 const std::string _public_message =
"public_message";
57 const std::string _server_message =
"server_message";
58 const std::string _ready_for_start =
"ready_for_start";
59 const std::string _game_has_begun =
"game_has_begun";
60 const std::string _turn_changed =
"turn_changed";
61 const std::string _game_created =
"game_created";
64 const std::vector<std::string>
items{
77 void game_created(
const std::string& scenario,
const std::string& name)
79 if(!lobby_pref(_game_created)) {
83 if(sound_pref(_game_created)) {
87 if(notif_pref(_game_created)) {
88 const std::string
message =
VGETTEXT(
"A game ($name|, $scenario|) has been created", {{
"name", name}, {
"scenario", scenario}});
95 if(is_lobby && !lobby_pref(_player_joins)) {
99 if(sound_pref(_player_joins)) {
103 if(notif_pref(_player_joins)) {
110 if(is_lobby && !lobby_pref(_player_leaves)) {
114 if(sound_pref(_player_leaves)) {
118 if(notif_pref(_player_leaves)) {
123 void public_message(
bool is_lobby,
const std::string& sender,
const std::string& message)
125 if(is_lobby && !lobby_pref(_public_message)) {
129 if(sound_pref(_public_message)) {
133 if(notif_pref(_public_message)) {
138 void friend_message(
bool is_lobby,
const std::string& sender,
const std::string& message)
140 if(is_lobby && !lobby_pref(_friend_message)) {
144 if(sound_pref(_friend_message)) {
148 if(notif_pref(_friend_message)) {
153 void private_message(
bool is_lobby,
const std::string& sender,
const std::string& message)
155 if(is_lobby && !lobby_pref(_private_message)) {
159 if(sound_pref(_private_message)) {
163 if(notif_pref(_private_message)) {
168 void server_message(
bool is_lobby,
const std::string& sender,
const std::string& message)
170 if(is_lobby && !lobby_pref(_server_message)) {
174 if(sound_pref(_server_message)) {
178 if(notif_pref(_server_message)) {
185 if(sound_pref(_ready_for_start)) {
193 if(notif_pref(_ready_for_start)) {
200 if(sound_pref(_game_has_begun)) {
204 if(notif_pref(_game_has_begun)) {
211 if(notif_pref(_turn_changed)) {
213 player[
"name"] = player_name;
220 return (
id != _public_message &&
id != _friend_message);
226 id == _private_message ||
227 id == _ready_for_start ||
228 id == _game_has_begun ||
229 id == _turn_changed ||
236 return (
id == _private_message ||
id == _server_message ||
id == _game_created);
static std::string _(const char *str)
bool available()
Returns whether we were compiled with support for desktop notifications.
void send(const std::string &, const std::string &, type)
Displays a desktop notification message, from owner, of type t.
std::string public_message
std::string private_message
std::string player_leaves
std::string server_message
std::string friend_message
std::string ready_for_start
std::string game_has_begun
This namespace provides handlers which play the sounds / notifications for various mp server events,...
void turn_changed(const std::string &player_name)
void public_message(bool is_lobby, const std::string &sender, const std::string &message)
const std::vector< std::string > items
bool get_def_pref_lobby(const std::string &id)
void game_created(const std::string &scenario, const std::string &name)
void private_message(bool is_lobby, const std::string &sender, const std::string &message)
void player_joins(bool is_lobby)
void friend_message(bool is_lobby, const std::string &sender, const std::string &message)
bool get_def_pref_sound(const std::string &id)
bool get_def_pref_notif(const std::string &id)
void server_message(bool is_lobby, const std::string &sender, const std::string &message)
void player_leaves(bool is_lobby)
std::string get(const std::string &key)
void play_UI_sound(const std::string &files)
void play_bell(const std::string &files)
std::map< std::string, t_string > string_map