better filtering of lobby join, using the new friend list

This commit is contained in:
Jérémy Rosen 2007-01-06 16:34:24 +00:00
parent 94b1aee7ac
commit ce317d7580
6 changed files with 75 additions and 40 deletions

View file

@ -94,6 +94,8 @@ Version 1.3-svn:
* add a friend list in MP lobby, they will display a special icon in lobby,
and you can be warned when they join the lobby even when not receiving
lobby joins
* add an option to specify what you want to see as joins: all, friends,
none
* added option to have random time of day in begin of multiplayer game
* WML engine
* added prerecruit event that takes place after the unit is created but

View file

@ -47,3 +47,6 @@ Version 1.3-svn:
* Updated translations: British English, French, German, Italian, Russian,
Swedish.
* Fixed spelling mistakes in the default en_US language.
* User interface
* Users in the MP lobby can be marked as friends. It is possible to only be warned about friends joining

View file

@ -321,18 +321,24 @@ void _set_grid(bool ison)
prefs["grid"] = (ison ? "true" : "false");
}
bool lobby_joins()
int lobby_joins()
{
return prefs["lobby_joins"] != "no";
if (prefs["lobby_joins"] == "friends") {return SHOW_FRIENDS;}
else if (prefs["lobby_joins"] == "all") {return SHOW_ALL;}
else {return SHOW_NON;}
//return prefs["lobby_joins"] != "no";
}
void _set_lobby_joins(bool show)
void _set_lobby_joins(int show)
{
if(show)
if (show == SHOW_FRIENDS) {prefs["lobby_joins"] = "friends";}
else if (show == SHOW_ALL) {prefs["lobby_joins"] = "all";}
else {prefs["lobby_joins"] = "non";}
/*if(show)
prefs["lobby_joins"] = "yes";
else
prefs["lobby_joins"] = "no";
prefs["lobby_joins"] = "no";*/
}
bool sort_list()

View file

@ -97,8 +97,9 @@ namespace preferences {
bool grid();
void _set_grid(bool ison);
bool lobby_joins();
void _set_lobby_joins(bool show);
int lobby_joins();
void _set_lobby_joins(int show);
enum { SHOW_NON, SHOW_FRIENDS, SHOW_ALL };
bool sort_list();
void _set_sort_list(bool show);

View file

@ -164,7 +164,7 @@ void set_grid(bool ison)
}
}
void set_lobby_joins(bool ison)
void set_lobby_joins(int ison)
{
_set_lobby_joins(ison);
}
@ -217,7 +217,7 @@ private:
gui::slider music_slider_, sound_slider_, bell_slider_, scroll_slider_, gamma_slider_,
chat_lines_slider_, turbo_slider_, buffer_size_slider_;
gui::button fullscreen_button_, turbo_button_, show_ai_moves_button_, show_grid_button_,
lobby_minimaps_button_, show_lobby_joins_button_, sort_list_by_group_button_,
lobby_minimaps_button_, show_lobby_joins_button1_, show_lobby_joins_button2_, show_lobby_joins_button3_, sort_list_by_group_button_,
iconize_list_button_, show_floating_labels_button_, turn_dialog_button_,
turn_bell_button_, show_team_colours_button_, show_colour_cursors_button_,
show_haloing_button_, video_mode_button_, theme_button_, hotkeys_button_, gamma_button_,
@ -254,7 +254,9 @@ preferences_dialog::preferences_dialog(display& disp, const config& game_cfg)
show_ai_moves_button_(disp.video(), _("Skip AI Moves"), gui::button::TYPE_CHECK),
show_grid_button_(disp.video(), _("Show Grid"), gui::button::TYPE_CHECK),
lobby_minimaps_button_(disp.video(), _("Show Lobby Minimaps"), gui::button::TYPE_CHECK),
show_lobby_joins_button_(disp.video(), _("Show Lobby Joins Of Friends"), gui::button::TYPE_CHECK),
show_lobby_joins_button1_(disp.video(), _("Do Not Show Lobby Joins"), gui::button::TYPE_CHECK),
show_lobby_joins_button2_(disp.video(), _("Show Lobby Joins Of Friends Only"), gui::button::TYPE_CHECK),
show_lobby_joins_button3_(disp.video(), _("Show All Lobby Joins"), gui::button::TYPE_CHECK),
sort_list_by_group_button_(disp.video(), _("Sort Lobby List"), gui::button::TYPE_CHECK),
iconize_list_button_(disp.video(), _("Iconize Lobby List"), gui::button::TYPE_CHECK),
show_floating_labels_button_(disp.video(), _("Show Floating Labels"), gui::button::TYPE_CHECK),
@ -394,8 +396,12 @@ preferences_dialog::preferences_dialog(display& disp, const config& game_cfg)
iconize_list_button_.set_check(iconize_list());
iconize_list_button_.set_help_string(_("Show icons in front of the player names in the lobby."));
show_lobby_joins_button_.set_check(lobby_joins());
show_lobby_joins_button_.set_help_string(_("Show messages about your friends joining the multiplayer lobby"));
show_lobby_joins_button1_.set_check(lobby_joins() == SHOW_NON);
show_lobby_joins_button1_.set_help_string(_("Do not show messages about players joining the multiplayer lobby"));
show_lobby_joins_button2_.set_check(lobby_joins() == SHOW_FRIENDS);
show_lobby_joins_button2_.set_help_string(_("Show messages about your friends joining the multiplayer lobby"));
show_lobby_joins_button3_.set_check(lobby_joins() == SHOW_ALL);
show_lobby_joins_button3_.set_help_string(_("Show messages about all players joining the multiplayer lobby"));
show_floating_labels_button_.set_check(show_floating_labels());
show_floating_labels_button_.set_help_string(_("Show text above a unit when it is hit to display damage inflicted"));
@ -444,7 +450,9 @@ handler_vector preferences_dialog::handler_members()
h.push_back(&lobby_minimaps_button_);
h.push_back(&sort_list_by_group_button_);
h.push_back(&iconize_list_button_);
h.push_back(&show_lobby_joins_button_);
h.push_back(&show_lobby_joins_button1_);
h.push_back(&show_lobby_joins_button2_);
h.push_back(&show_lobby_joins_button3_);
h.push_back(&show_floating_labels_button_);
h.push_back(&turn_dialog_button_);
h.push_back(&turn_bell_button_);
@ -598,9 +606,12 @@ void preferences_dialog::update_location(SDL_Rect const &rect)
chat_lines_slider_.set_location(chat_lines_rect);
ypos += item_interline; chat_timestamp_button_.set_location(rect.x, ypos);
ypos += item_interline; lobby_minimaps_button_.set_location(rect.x, ypos);
ypos += item_interline; show_lobby_joins_button_.set_location(rect.x, ypos);
ypos += item_interline; sort_list_by_group_button_.set_location(rect.x, ypos);
ypos += item_interline; iconize_list_button_.set_location(rect.x, ypos);
ypos += item_interline; show_lobby_joins_button1_.set_location(rect.x, ypos);
ypos += short_interline; show_lobby_joins_button2_.set_location(rect.x, ypos);
ypos += short_interline; show_lobby_joins_button3_.set_location(rect.x, ypos);
//Advanced tab
ypos = rect.y + top_border;
@ -752,8 +763,25 @@ void preferences_dialog::process_event()
if (tab_ == MULTIPLAYER_TAB) {
if (lobby_minimaps_button_.pressed())
save_show_lobby_minimaps(lobby_minimaps_button_.checked());
if (show_lobby_joins_button_.pressed())
set_lobby_joins(show_lobby_joins_button_.checked());
if (show_lobby_joins_button1_.pressed()) {
set_lobby_joins(SHOW_NON);
show_lobby_joins_button1_.set_check(true);
show_lobby_joins_button2_.set_check(false);
show_lobby_joins_button3_.set_check(false);
}
if (show_lobby_joins_button2_.pressed()) {
set_lobby_joins(SHOW_FRIENDS);
show_lobby_joins_button1_.set_check(false);
show_lobby_joins_button2_.set_check(true);
show_lobby_joins_button3_.set_check(false);
}
if (show_lobby_joins_button3_.pressed()) {
set_lobby_joins(SHOW_ALL);
show_lobby_joins_button1_.set_check(false);
show_lobby_joins_button2_.set_check(false);
show_lobby_joins_button3_.set_check(true);
}
if (sort_list_by_group_button_.pressed())
set_sort_list(sort_list_by_group_button_.checked());
if (iconize_list_button_.pressed())
@ -898,7 +926,9 @@ void preferences_dialog::set_selection(int index)
lobby_minimaps_button_.hide(hide_multiplayer);
sort_list_by_group_button_.hide(hide_multiplayer);
iconize_list_button_.hide(hide_multiplayer);
show_lobby_joins_button_.hide(hide_multiplayer);
show_lobby_joins_button1_.hide(hide_multiplayer);
show_lobby_joins_button2_.hide(hide_multiplayer);
show_lobby_joins_button3_.hide(hide_multiplayer);
const bool hide_advanced = tab_ != ADVANCED_TAB;
advanced_.hide(hide_advanced);

View file

@ -713,33 +713,26 @@ bool do_replay(display& disp, const gamemap& map, const game_data& gameinfo,
if(team_name == "" || teams[disp.viewing_team()].team_name() == team_name) {
bool is_lobby_join = (speaker_name == "server"
&& (*child)["message"].value().find("has logged into the lobby") != std::string::npos);
std::string str = (*child)["message"];
std::string buf;
std::stringstream ss(str);
ss >> buf;
if (!preferences::get_prefs()->child("relationship")){
preferences::get_prefs()->add_child("relationship");
}
config* cignore;
cignore = preferences::get_prefs()->child("relationship");
bool is_lobby_join_of_friend = ((*cignore)[buf] == "friend");
bool is_whisper = (speaker_name.find("whisper: ") == 0);
if((!replayer.is_skipping() || is_whisper) && (!is_lobby_join || preferences::lobby_joins())) {
if((!replayer.is_skipping() || is_whisper) &&
(!is_lobby_join || ((is_lobby_join && preferences::lobby_joins() == preferences::SHOW_ALL) || (is_lobby_join_of_friend && preferences::lobby_joins() == preferences::SHOW_FRIENDS)))) {
if(preferences::message_bell()) {
sound::play_sound(game_config::sounds::receive_message);
}
if (is_lobby_join) {
std::string str = (*child)["message"];
std::string buf;
std::stringstream ss(str);
ss >> buf;
if (!preferences::get_prefs()->child("relationship")){
preferences::get_prefs()->add_child("relationship");
}
config* cignore;
cignore = preferences::get_prefs()->child("relationship");
if ((*cignore)[buf] == "friend") {
const int side = lexical_cast_default<int>((*child)["side"].c_str(),0);
disp.add_chat_message(speaker_name,side,(*child)["message"],
team_name == "" ? display::MESSAGE_PUBLIC : display::MESSAGE_PRIVATE);
}
} else {
const int side = lexical_cast_default<int>((*child)["side"].c_str(),0);
disp.add_chat_message(speaker_name,side,(*child)["message"],
team_name == "" ? display::MESSAGE_PUBLIC : display::MESSAGE_PRIVATE);
}
const int side = lexical_cast_default<int>((*child)["side"].c_str(),0);
disp.add_chat_message(speaker_name,side,(*child)["message"],
team_name == "" ? display::MESSAGE_PUBLIC : display::MESSAGE_PRIVATE);
}
}
} else if((child = cfg->child("label")) != NULL) {