Skip to content

Commit

Permalink
MP Lobby: minor cleanup
Browse files Browse the repository at this point in the history
* Removed some dead code.
* Removed some unnecessary bound window references.
* Removed some unnecessary code duplication.
  • Loading branch information
Vultraz authored and GregoryLundberg committed Nov 30, 2017
1 parent d31be79 commit 976c830
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 15 deletions.
23 changes: 10 additions & 13 deletions src/gui/dialogs/lobby/lobby.cpp
Expand Up @@ -318,7 +318,7 @@ void mp_lobby::update_gamelist_diff()
} else {
if(list_i >= gamelistbox_->get_item_count()) {
ERR_LB << "Ran out of listbox items -- triggering a full refresh\n";
network_connection_.send_data(config("refresh_lobby"));
refresh_lobby();
return;
}

Expand All @@ -327,15 +327,15 @@ void mp_lobby::update_gamelist_diff()
<< list_rows_deleted
<< " >= " << gamelist_id_at_row_.size()
<< " -- triggering a full refresh\n";
network_connection_.send_data(config("refresh_lobby"));
refresh_lobby();
return;
}

int listbox_game_id = gamelist_id_at_row_[list_i + list_rows_deleted];
if(game.id != listbox_game_id) {
ERR_LB << "Listbox game id does not match expected id "
<< listbox_game_id << " " << game.id << " (row " << list_i << ")\n";
network_connection_.send_data(config("refresh_lobby"));
refresh_lobby();
return;
}

Expand Down Expand Up @@ -547,7 +547,6 @@ void mp_lobby::update_playerlist()
for(auto userptr : lobby_info_.users_sorted()) {
mp::user_info& user = *userptr;
sub_player_list* target_list(nullptr);
std::map<std::string, string_map> data;

std::string name = user.name;

Expand Down Expand Up @@ -604,8 +603,6 @@ void mp_lobby::update_playerlist()
}

icon_ss << ".png";
add_label_data(data, "player", name);
add_label_data(data, "main_icon", icon_ss.str());

if(!preferences::playerlist_group_players()) {
target_list = &player_list_.other_rooms;
Expand Down Expand Up @@ -674,7 +671,7 @@ void mp_lobby::pre_show(window& window)
gamelistbox_ = find_widget<listbox>(&window, "game_list", false, true);

connect_signal_notify_modified(*gamelistbox_,
std::bind(&mp_lobby::gamelist_change_callback, this, std::ref(window)));
std::bind(&mp_lobby::gamelist_change_callback, this));

window.keyboard_capture(gamelistbox_);

Expand Down Expand Up @@ -704,7 +701,7 @@ void mp_lobby::pre_show(window& window)

connect_signal_mouse_left_click(
find_widget<button>(&window, "refresh", false),
std::bind(&mp_lobby::refresh_button_callback, this, std::ref(window)));
std::bind(&mp_lobby::refresh_lobby, this));

connect_signal_mouse_left_click(
find_widget<button>(&window, "show_preferences", false),
Expand Down Expand Up @@ -855,7 +852,7 @@ void mp_lobby::process_gamelist_diff(const config& data)
gamelist_dirty_ = true;
} else {
ERR_LB << "process_gamelist_diff failed!" << std::endl;
network_connection_.send_data(config("refresh_lobby"));
refresh_lobby();
}
const int joined = data.child_count("insert_child");
const int left = data.child_count("remove_child");
Expand Down Expand Up @@ -993,7 +990,7 @@ bool mp_lobby::do_game_join(int idx, bool observe)
return true;
}

void mp_lobby::refresh_button_callback(window& /*window*/)
void mp_lobby::refresh_lobby()
{
network_connection_.send_data(config("refresh_lobby"));
}
Expand Down Expand Up @@ -1021,7 +1018,7 @@ void mp_lobby::show_preferences_button_callback(window& window)
*/
window.invalidate_layout();

network_connection_.send_data(config("refresh_lobby"));
refresh_lobby();
}

void mp_lobby::game_filter_reload()
Expand Down Expand Up @@ -1070,7 +1067,7 @@ void mp_lobby::game_filter_change_callback()
update_gamelist_filter();
}

void mp_lobby::gamelist_change_callback(window& /*window*/)
void mp_lobby::gamelist_change_callback()
{
update_selected_game();
}
Expand Down Expand Up @@ -1122,7 +1119,7 @@ void mp_lobby::user_dialog_callback(mp::user_info* info)
// update_gamelist();
delay_playerlist_update_ = false;
player_list_dirty_ = true;
network_connection_.send_data(config("refresh_lobby"));
refresh_lobby();
}

void mp_lobby::skip_replay_changed_callback(window& window)
Expand Down
4 changes: 2 additions & 2 deletions src/gui/dialogs/lobby/lobby.hpp
Expand Up @@ -134,15 +134,15 @@ class mp_lobby : public modal_dialog, public quit_confirmation, private plugin_e

void show_preferences_button_callback(window& window);

void refresh_button_callback(window& window);
void refresh_lobby();

void game_filter_reload();

void game_filter_change_callback();

void game_filter_keypress_callback(const SDL_Keycode key);

void gamelist_change_callback(window& window);
void gamelist_change_callback();

void player_filter_callback();

Expand Down

0 comments on commit 976c830

Please sign in to comment.