#include <lobby.hpp>
Public Types | |
enum | lobby_result { QUIT, JOIN, OBSERVE, CREATE, RELOAD_CONFIG } |
Public Member Functions | |
mp_lobby (mp::lobby_info &info, wesnothd_connection &connection, int &joined_game) | |
~mp_lobby () | |
void | update_gamelist () |
void | update_playerlist () |
![]() | |
modal_dialog () | |
virtual | ~modal_dialog () |
bool | show (const unsigned auto_close_time=0) |
Shows the window. More... | |
window * | get_window () const |
Returns a pointer to the dialog's window. More... | |
int | get_retval () const |
Returns the cached window exit code. More... | |
void | set_retval (int retval) |
Convenience wrapper to set the window's exit code. More... | |
void | set_always_save_fields (const bool always_save_fields) |
void | set_restore (const bool restore) |
void | set_allow_plugin_skip (const bool allow_plugin_skip) |
void | set_show_even_without_video (const bool show_even_without_video) |
![]() | |
quit_confirmation (const std::function< bool()> &prompt=&quit_confirmation::default_prompt) | |
~quit_confirmation () | |
Protected Member Functions | |
void | update_visible_games () |
void | update_gamelist_diff () |
void | update_gamelist_filter () |
std::map< std::string, string_map > | make_game_row_data (const mp::game_info &game) |
void | adjust_game_row_contents (const mp::game_info &game, grid *grid, bool add_callbacks=true) |
![]() | |
template<typename T , typename... Args> | |
T * | register_field (Args &&... args) |
Creates a new field of given type with given arguments. More... | |
field_bool * | register_bool (const std::string &id, const bool mandatory, const std::function< bool()> callback_load_value=nullptr, const std::function< void(bool)> callback_save_value=nullptr, const std::function< void(widget &)> callback_change=nullptr, const bool initial_fire=false) |
Creates a new boolean field. More... | |
field_bool * | register_bool (const std::string &id, const bool mandatory, bool &linked_variable, const std::function< void(widget &)> callback_change=nullptr, const bool initial_fire=false) |
Creates a new boolean field. More... | |
field_integer * | register_integer (const std::string &id, const bool mandatory, const std::function< int()> callback_load_value=nullptr, const std::function< void(int)> callback_save_value=nullptr) |
Creates a new integer field. More... | |
field_integer * | register_integer (const std::string &id, const bool mandatory, int &linked_variable) |
Creates a new integer field. More... | |
field_text * | register_text (const std::string &id, const bool mandatory, const std::function< std::string()> callback_load_value=nullptr, const std::function< void(const std::string &)> callback_save_value=nullptr, const bool capture_focus=false) |
Creates a new text field. More... | |
field_text * | register_text (const std::string &id, const bool mandatory, std::string &linked_variable, const bool capture_focus=false) |
Creates a new text field. More... | |
field_label * | register_label (const std::string &id, const bool mandatory, const std::string &text, const bool use_markup=false) |
Registers a new styled_widget as a label. More... | |
field_label * | register_image (const std::string &id, const bool mandatory, const std::string &filename) |
Registers a new styled_widget as image. More... | |
Private Types | |
enum | JOIN_MODE { DO_JOIN, DO_OBSERVE, DO_EITHER } |
Private Member Functions | |
void | update_selected_game () |
void | network_handler () |
Network polling callback. More... | |
void | process_network_data (const config &data) |
void | process_gamelist (const config &data) |
void | process_gamelist_diff (const config &data) |
void | enter_game (const mp::game_info &game, JOIN_MODE mode) |
Exits the lobby and enters the given game. More... | |
void | enter_game_by_index (const int index, JOIN_MODE mode) |
Entry wrapper for enter_game, where game is located by index. More... | |
void | enter_game_by_id (const int game_id, JOIN_MODE mode) |
Entry wrapper for enter_game, where game is located by game id. More... | |
void | enter_selected_game (JOIN_MODE mode) |
Enter game by index, where index is the selected game listbox row. More... | |
void | show_help_callback () |
void | show_preferences_button_callback () |
void | show_server_info () |
void | refresh_lobby () |
void | game_filter_init () |
void | game_filter_keypress_callback (const SDL_Keycode key) |
void | user_dialog_callback (const mp::user_info *info) |
void | skip_replay_changed_callback () |
bool | exit_hook (window &window) |
virtual const std::string & | window_id () const override |
The id of the window to build. More... | |
virtual void | post_build (window &window) override |
Actions to be taken directly after the window is build. More... | |
virtual void | pre_show (window &window) override |
Actions to be taken before showing the window. More... | |
virtual void | post_show (window &window) override |
Actions to be taken after the window has been shown. More... | |
![]() | |
plugin_executor () | |
~plugin_executor () | |
Static Private Member Functions | |
static bool | logout_prompt () |
Private Attributes | |
listbox * | gamelistbox_ |
mp::lobby_info & | lobby_info_ |
chatbox * | chatbox_ |
field_bool * | filter_friends_ |
field_bool * | filter_ignored_ |
field_bool * | filter_slots_ |
field_bool * | filter_invert_ |
text_box * | filter_text_ |
int | selected_game_id_ |
lobby_player_list_helper | player_list_ |
bool | player_list_dirty_ |
bool | gamelist_dirty_ |
unsigned | last_lobby_update_ |
bool | gamelist_diff_update_ |
wesnothd_connection & | network_connection_ |
std::size_t | lobby_update_timer_ |
Timer for updating the lobby. More... | |
std::vector< int > | gamelist_id_at_row_ |
bool | delay_playerlist_update_ |
bool | delay_gamelist_update_ |
int & | joined_game_id_ |
![]() | |
std::unique_ptr< plugins_context > | plugins_context_ |
Static Private Attributes | |
static std::string | server_information_ = "" |
static std::string | announcements_ = "" |
Friends | |
struct | lobby_delay_gamelist_update_guard |
Additional Inherited Members | |
![]() | |
static bool | quit () |
Shows the quit confirmation if needed. More... | |
static void | quit_to_title () |
static void | quit_to_desktop () |
static bool | show_prompt (const std::string &message) |
static bool | default_prompt () |
![]() | |
std::unique_ptr< window > | window_ |
The window object build for this dialog. More... | |
|
private |
gui2::dialogs::mp_lobby::mp_lobby | ( | mp::lobby_info & | info, |
wesnothd_connection & | connection, | ||
int & | joined_game | ||
) |
Definition at line 72 of file lobby.cpp.
References gui2::dialogs::modal_dialog::set_allow_plugin_skip(), gui2::dialogs::modal_dialog::set_always_save_fields(), and gui2::dialogs::modal_dialog::set_show_even_without_video().
gui2::dialogs::mp_lobby::~mp_lobby | ( | ) |
Definition at line 130 of file lobby.cpp.
References lobby_update_timer_, and gui2::remove_timer().
|
protected |
Definition at line 411 of file lobby.cpp.
References _(), font::BAD_COLOR, gui2::event::connect_signal_mouse_left_double_click(), DO_EITHER, enter_game_by_id(), mp::game_info::era, mp::game_info::gold, preferences::grid(), mp::game_info::have_all_mods, mp::game_info::have_era, gui2::widget::hidden, mp::game_info::id, mp::game_info::map_data, mp::game_info::map_size_info, mp::game_info::mod_info, mp::game_info::observers, mp::game_info::password_required, mp::game_info::reloaded, mp::game_info::required_addons, gui2::styled_widget::set_label(), gui2::minimap::set_map_data(), gui2::styled_widget::set_tooltip(), gui2::widget::set_visible(), mp::game_info::shuffle_sides, font::span_color(), mp::game_info::time_limit, font::TITLE_COLOR, mp::game_info::use_map_settings, gui2::widget::visible, mp::game_info::vision, and mp::game_info::xp.
Referenced by update_gamelist(), and update_gamelist_diff().
|
private |
Exits the lobby and enters the given game.
This assembles the game request for the server and handles any applicable pre-join actions, such as prompting the player for the game's password or informing them additional content needs installing.
The lobby window will be closed on completion, assuming an error wasn't encountered.
game | Info on the game we're attempting to join. |
mode | Whether joining as player, observer or whichever works. |
Definition at line 787 of file lobby.cpp.
References _(), config::add_child(), mp::game_info::addons_outcome, mp::game_info::can_join(), mp::game_info::can_observe(), DBG_LB, DO_EITHER, DO_JOIN, DO_OBSERVE, config::empty(), ERR_LB, gui2::dialogs::modal_dialog::get_window(), mp::game_info::id, JOIN, joined_game_id_, mp::logged_in_as_moderator(), OBSERVE, mp::game_info::observers, gui2::OK, preferences::password(), mp::game_info::password_required, RELOAD_CONFIG, mp::game_info::required_addons, mp::game_info::SATISFIED, mp::send_to_server(), gui2::window::set_retval(), gui2::show_error_message(), gui2::show_message(), and gui2::dialogs::message::yes_no_buttons.
Referenced by enter_game_by_id(), and enter_game_by_index().
|
private |
Entry wrapper for enter_game, where game is located by game id.
Definition at line 884 of file lobby.cpp.
References enter_game(), ERR_LB, mp::lobby_info::get_game_by_id(), and lobby_info_.
Referenced by adjust_game_row_contents(), and pre_show().
|
private |
Entry wrapper for enter_game, where game is located by index.
Definition at line 873 of file lobby.cpp.
References enter_game(), ERR_LB, mp::lobby_info::games(), and lobby_info_.
Referenced by enter_selected_game().
|
private |
Enter game by index, where index is the selected game listbox row.
Definition at line 896 of file lobby.cpp.
References enter_game_by_index(), gamelistbox_, and gui2::listbox::get_selected_row().
Referenced by pre_show().
|
private |
Definition at line 561 of file lobby.cpp.
References gui2::CANCEL, gui2::window::get_retval(), and quit_confirmation::quit().
Referenced by pre_show().
|
private |
Definition at line 942 of file lobby.cpp.
References mp::lobby_info::add_game_filter(), mp::lobby_info::clear_game_filters(), filter_friends_, filter_ignored_, filter_invert_, filter_slots_, filter_text_, gui2::text_box_base::get_value(), gui2::field< T, W, CT >::get_widget_value(), mp::game_info::has_friends, mp::game_info::has_ignored, lg::info(), lobby_info_, mp::game_info::match_string_filter(), s, mp::lobby_info::set_game_filter_invert(), utils::split(), and mp::game_info::vacant_slots.
Referenced by pre_show().
|
private |
Definition at line 975 of file lobby.cpp.
References update_gamelist_filter().
Referenced by pre_show().
|
staticprivate |
|
protected |
Definition at line 382 of file lobby.cpp.
References mp::game_info::era, font::GOOD_COLOR, font::GRAY_COLOR, mp::game_info::name, mp::game_info::reloaded, mp::game_info::scenario, font::span_color(), mp::game_info::started, mp::game_info::status, mp::game_info::type_marker, mp::game_info::vacant_slots, VGETTEXT, and font::YELLOW_COLOR.
Referenced by update_gamelist(), and update_gamelist_diff().
|
private |
Network polling callback.
Definition at line 698 of file lobby.cpp.
References delay_gamelist_update_, delay_playerlist_update_, e, gamelist_diff_update_, gamelist_dirty_, mp::lobby_info::gamelist_initialized(), last_lobby_update_, lobby_info_, game_config::lobby_refresh, LOG_LB, game::error::message, network_connection_, player_list_dirty_, process_network_data(), wesnothd_connection::receive_data(), update_gamelist(), update_gamelist_diff(), update_gamelist_filter(), and update_playerlist().
Referenced by pre_show().
|
overrideprivatevirtual |
Actions to be taken directly after the window is build.
At this point the registered fields are not yet registered.
window | The window just created. |
Reimplemented from gui2::dialogs::modal_dialog.
Definition at line 137 of file lobby.cpp.
References _(), a, ad_hoc_addon_fetch_session(), gui2::dialogs::message::auto_close, c, mp::game_info::CANNOT_SATISFY, gui2::grid::find(), hotkey::HOTKEY_HELP, hotkey::HOTKEY_PREFERENCES, mp::game_info::NEED_DOWNLOAD, gui2::OK, gui2::event::dispatcher::register_hotkey(), gui2::styled_widget::set_label(), gui2::styled_widget::set_tooltip(), show_help_callback(), gui2::show_message(), show_preferences_button_callback(), font::unicode_bullet, w, and gui2::dialogs::message::yes_no_buttons.
|
overrideprivatevirtual |
Actions to be taken after the window has been shown.
At this point the registered fields already stored their values (if the OK has been pressed).
window | The window which has been shown. |
Reimplemented from gui2::dialogs::modal_dialog.
Definition at line 691 of file lobby.cpp.
References lobby_update_timer_, gui2::dialogs::plugin_executor::plugins_context_, and gui2::remove_timer().
|
overrideprivatevirtual |
Actions to be taken before showing the window.
At this point the registered fields are registered and initialized with their initial values.
window | The window to be shown. |
Reimplemented from gui2::dialogs::modal_dialog.
Definition at line 566 of file lobby.cpp.
References gui2::chatbox::active_window_changed(), gui2::add_timer(), preferences::blindfold_replay(), gui2::CANCEL, chatbox_, gui2::event::connect_signal_mouse_left_click(), gui2::event::connect_signal_notify_modified(), gui2::event::connect_signal_pre_key_press(), CREATE, default_chat_log, DO_JOIN, DO_OBSERVE, enter_game_by_id(), enter_selected_game(), exit_hook(), filter_text_, game_filter_init(), game_filter_keypress_callback(), mp::lobby_info::gamelist(), gamelistbox_, mp::lobby_info::games(), mp::get_profile_link(), config::has_attribute(), gui2::lobby_player_list_helper::init(), gui2::chatbox::load_log(), lobby_info_, game_config::lobby_network_timer, lobby_update_timer_, mp::user_info::ME, N_, network_handler(), desktop::open_object(), player_list_, player_list_dirty_, gui2::dialogs::plugin_executor::plugins_context_, gui2::chatbox::room_window_open(), SCOPE_LB, selected_game_id_, gui2::chatbox::send_chat_message(), gui2::chatbox::set_active_window_changed_callback(), gui2::dialogs::modal_dialog::set_retval(), gui2::menu_button::set_selected(), show_preferences_button_callback(), show_server_info(), preferences::skip_mp_replay(), skip_replay_changed_callback(), update_gamelist(), update_playerlist(), update_selected_game(), and mp::lobby_info::users().
|
private |
Definition at line 755 of file lobby.cpp.
References DBG_LB, delay_gamelist_update_, delay_playerlist_update_, gamelist_diff_update_, gamelist_dirty_, lobby_info_, and mp::lobby_info::process_gamelist().
Referenced by process_network_data().
|
private |
Definition at line 765 of file lobby.cpp.
References config::child_count(), DBG_LB, delay_gamelist_update_, delay_playerlist_update_, mp::do_notify(), ERR_LB, gamelist_dirty_, lobby_info_, mp::lobby_join, mp::lobby_quit, mp::lobby_info::process_gamelist_diff(), and refresh_lobby().
Referenced by process_network_data().
|
private |
Definition at line 734 of file lobby.cpp.
References announcements_, chatbox_, config::child(), lg::info(), process_gamelist(), process_gamelist_diff(), gui2::chatbox::process_network_data(), and server_information_.
Referenced by network_handler().
|
private |
Definition at line 901 of file lobby.cpp.
References mp::send_to_server().
Referenced by process_gamelist_diff(), show_preferences_button_callback(), update_gamelist_diff(), and user_dialog_callback().
|
private |
|
private |
The screen size might have changed force an update of the size.
The screen size might have changed force an update of the size.
Definition at line 911 of file lobby.cpp.
References CVideo::draw_area(), gui2::settings::gamemap_height, gui2::settings::gamemap_width, CVideo::get_singleton(), gui2::dialogs::modal_dialog::get_window(), gui2::window::invalidate_layout(), refresh_lobby(), gui2::settings::screen_height, and gui2::settings::screen_width.
Referenced by post_build(), and pre_show().
|
private |
Definition at line 937 of file lobby.cpp.
References announcements_, gui2::dialogs::server_info::display(), and server_information_.
Referenced by pre_show().
|
private |
Definition at line 1005 of file lobby.cpp.
References gui2::dialogs::modal_dialog::get_window(), preferences::set_blindfold_replay(), and preferences::set_skip_mp_replay().
Referenced by pre_show().
void gui2::dialogs::mp_lobby::update_gamelist | ( | ) |
Definition at line 227 of file lobby.cpp.
References gui2::listbox::add_row(), adjust_game_row_contents(), mp::lobby_info::begin_state_sync(), gui2::listbox::clear(), delay_gamelist_update_, gamelist_dirty_, gamelist_id_at_row_, gamelistbox_, mp::lobby_info::games(), gui2::listbox::get_selected_row(), i, mp::game_info::id, last_lobby_update_, lobby_info_, LOG_LB, make_game_row_data(), SCOPE_LB, gui2::listbox::select_row(), selected_game_id_, update_selected_game(), and update_visible_games().
Referenced by network_handler(), and pre_show().
|
protected |
Definition at line 263 of file lobby.cpp.
References gui2::listbox::add_row(), adjust_game_row_contents(), mp::lobby_info::begin_state_sync(), DBG_LB, delay_gamelist_update_, mp::game_info::DELETED, mp::game_info::display_status, mp::do_notify(), ERR_LB, mp::game_created, gamelist_dirty_, gamelist_id_at_row_, gamelistbox_, mp::lobby_info::games(), gui2::listbox::get_item_count(), gui2::listbox::get_row_grid(), gui2::listbox::get_selected_row(), i, mp::game_info::id, mp::lobby_info::is_game_visible(), last_lobby_update_, lobby_info_, LOG_LB, make_game_row_data(), mp::game_info::name, mp::game_info::NEW, refresh_lobby(), gui2::listbox::remove_row(), mp::game_info::scenario, SCOPE_LB, gui2::listbox::select_row(), selected_game_id_, update_selected_game(), update_visible_games(), and mp::game_info::UPDATED.
Referenced by network_handler().
|
protected |
Definition at line 517 of file lobby.cpp.
References mp::lobby_info::apply_game_filter(), DBG_LB, gamelistbox_, mp::lobby_info::games(), gui2::listbox::get_item_count(), lobby_info_, and update_visible_games().
Referenced by game_filter_keypress_callback(), and network_handler().
void gui2::dialogs::mp_lobby::update_playerlist | ( | ) |
Definition at line 528 of file lobby.cpp.
References DBG_LB, delay_playerlist_update_, last_lobby_update_, lobby_info_, player_list_, player_list_dirty_, SCOPE_LB, selected_game_id_, gui2::lobby_player_list_helper::update(), and mp::lobby_info::users().
Referenced by network_handler(), and pre_show().
|
private |
Definition at line 541 of file lobby.cpp.
References mp::game_info::can_join(), mp::game_info::can_observe(), gamelistbox_, mp::lobby_info::games(), gui2::listbox::get_selected_row(), gui2::dialogs::modal_dialog::get_window(), mp::game_info::id, lobby_info_, player_list_dirty_, and selected_game_id_.
Referenced by pre_show(), update_gamelist(), and update_gamelist_diff().
|
protected |
Definition at line 370 of file lobby.cpp.
References gamelistbox_, mp::lobby_info::games(), mp::lobby_info::games_visibility(), lobby_info_, and VGETTEXT.
Referenced by update_gamelist(), update_gamelist_diff(), and update_gamelist_filter().
|
private |
Definition at line 982 of file lobby.cpp.
References chatbox_, delay_playerlist_update_, g, mp::user_info::game_id, lobby_info_, mp::user_info::name, player_list_dirty_, refresh_lobby(), gui2::dialogs::lobby_player_info::result_open_whisper(), selected_game_id_, gui2::dialogs::modal_dialog::show(), gui2::chatbox::switch_to_window(), t, and gui2::chatbox::whisper_window_open().
|
overrideprivatevirtual |
The id of the window to build.
Implements gui2::dialogs::modal_dialog.
|
friend |
|
inlinestaticprivate |
Definition at line 179 of file lobby.hpp.
Referenced by process_network_data(), and show_server_info().
|
private |
Definition at line 142 of file lobby.hpp.
Referenced by pre_show(), process_network_data(), and user_dialog_callback().
|
private |
Definition at line 172 of file lobby.hpp.
Referenced by gui2::dialogs::lobby_delay_gamelist_update_guard::lobby_delay_gamelist_update_guard(), network_handler(), process_gamelist(), process_gamelist_diff(), update_gamelist(), and update_gamelist_diff().
|
private |
Definition at line 170 of file lobby.hpp.
Referenced by network_handler(), process_gamelist(), process_gamelist_diff(), update_playerlist(), and user_dialog_callback().
|
private |
Definition at line 144 of file lobby.hpp.
Referenced by game_filter_init().
|
private |
Definition at line 145 of file lobby.hpp.
Referenced by game_filter_init().
|
private |
Definition at line 147 of file lobby.hpp.
Referenced by game_filter_init().
|
private |
Definition at line 146 of file lobby.hpp.
Referenced by game_filter_init().
|
private |
Definition at line 149 of file lobby.hpp.
Referenced by game_filter_init(), and pre_show().
|
private |
Definition at line 161 of file lobby.hpp.
Referenced by network_handler(), and process_gamelist().
|
private |
Definition at line 157 of file lobby.hpp.
Referenced by network_handler(), process_gamelist(), process_gamelist_diff(), update_gamelist(), and update_gamelist_diff().
|
private |
Definition at line 168 of file lobby.hpp.
Referenced by update_gamelist(), and update_gamelist_diff().
|
private |
Definition at line 138 of file lobby.hpp.
Referenced by enter_selected_game(), pre_show(), update_gamelist(), update_gamelist_diff(), update_gamelist_filter(), update_selected_game(), and update_visible_games().
|
private |
Definition at line 174 of file lobby.hpp.
Referenced by enter_game().
|
private |
Definition at line 159 of file lobby.hpp.
Referenced by network_handler(), update_gamelist(), update_gamelist_diff(), and update_playerlist().
|
private |
Definition at line 140 of file lobby.hpp.
Referenced by enter_game_by_id(), enter_game_by_index(), game_filter_init(), network_handler(), pre_show(), process_gamelist(), process_gamelist_diff(), update_gamelist(), update_gamelist_diff(), update_gamelist_filter(), update_playerlist(), update_selected_game(), update_visible_games(), and user_dialog_callback().
|
private |
Timer for updating the lobby.
Definition at line 166 of file lobby.hpp.
Referenced by post_show(), pre_show(), and ~mp_lobby().
|
private |
Definition at line 163 of file lobby.hpp.
Referenced by network_handler().
|
private |
Definition at line 153 of file lobby.hpp.
Referenced by pre_show(), and update_playerlist().
|
private |
Definition at line 155 of file lobby.hpp.
Referenced by network_handler(), pre_show(), update_playerlist(), update_selected_game(), and user_dialog_callback().
|
private |
Definition at line 151 of file lobby.hpp.
Referenced by pre_show(), update_gamelist(), update_gamelist_diff(), update_playerlist(), update_selected_game(), and user_dialog_callback().
|
inlinestaticprivate |
Definition at line 178 of file lobby.hpp.
Referenced by process_network_data(), and show_server_info().