a base class for the different multiplayer base dialogs: game list, create game, wait game, game setup. More...
#include <multiplayer_ui.hpp>
Classes | |
struct | user_info |
Public Types | |
enum | result { CONTINUE, JOIN, OBSERVE, CREATE, LOAD_GAME, PREFERENCES, PLAY, QUIT } |
enum | user_relation { ME, FRIEND, NEUTRAL, IGNORED } |
enum | user_state { LOBBY, GAME, SEL_GAME } |
Public Member Functions | |
ui (CVideo &v, twesnothd_connection *wesnothd_connection, const std::string &title, const config &cfg, chat &c, config &gamelist) | |
void | process_network () |
Asks the multiplayer_ui to pump some data from the network, and then to process it. More... | |
result | get_result () |
Returns the result of the current widget. More... | |
void | set_location (const SDL_Rect &rect) |
Hides children, moves them (using layout_children), then shows them. More... | |
const std::vector< std::string > & | user_list () const |
void | send_to_server (const config &cfg) override |
bool | receive_from_server (config &dst) |
plugins_context * | get_plugins_context () |
Public Member Functions inherited from gui::widget | |
SDL_Rect const & | location () const |
void | set_location (int x, int y) |
void | set_width (int w) |
void | set_height (int h) |
void | set_measurements (int w, int h) |
int | width () const |
int | height () const |
bool | focus (const SDL_Event *event) |
void | set_focus (bool focus) |
virtual void | hide (bool value=true) |
bool | hidden () const |
virtual void | enable (bool new_val=true) |
bool | enabled () const |
void | set_clip_rect (const SDL_Rect &rect) |
void | set_volatile (bool val=true) |
void | set_dirty (bool dirty=true) |
bool | dirty () const |
const std::string & | id () const |
void | set_id (const std::string &id) |
void | set_help_string (const std::string &str) |
void | set_tooltip_string (const std::string &str) |
virtual void | process_help_string (int mousex, int mousey) |
virtual void | process_tooltip_string (int mousex, int mousey) |
Public Member Functions inherited from events::sdl_handler | |
virtual bool | requires_event_focus (const SDL_Event *=nullptr) const |
virtual void | join () |
virtual void | join (context &c) |
virtual void | join_same (sdl_handler *parent) |
virtual void | leave () |
virtual void | join_global () |
virtual void | leave_global () |
Protected Member Functions | |
int | xscale (int x) const |
int | yscale (int y) const |
SDL_Rect | client_area () const |
CVideo & | video () |
const config & | game_config () const |
Returns the main game config, as defined by loading the preprocessed WML files. More... | |
virtual void | draw_contents () |
virtual void | process_event () |
virtual void | handle_event (const SDL_Event &event) |
virtual void | handle_key_event (const SDL_KeyboardEvent &event) |
void | add_chat_message (const time_t &time, const std::string &speaker, int side, const std::string &message, events::chat_handler::MESSAGE_TYPE type=events::chat_handler::MESSAGE_PRIVATE) |
Override chat_handler. More... | |
void | send_chat_message (const std::string &message, bool allies_only=false) |
void | process_message (const config &msg, const bool whisper=false) |
Process chat messages. More... | |
virtual void | process_network_data (const config &data) |
Processes any pending network data. More... | |
virtual void | hide_children (bool hide=true) |
Hides or shows all gui::widget children of this widget. More... | |
virtual void | layout_children (const SDL_Rect &rect) |
Lays the children out. More... | |
result | set_result (result res) |
Sets the result of this dialog, to be checked by get_result(). More... | |
void | set_selected_game (const std::string &game_name) |
Sets the name of the selected game which is used to highlight the names of the players which have joined this game. More... | |
virtual void | gamelist_updated (bool silent=true) |
Called each time the gamelist_ variable is updated. More... | |
void | set_user_list (const std::vector< std::string > &, bool silent) |
Sets the user list. More... | |
void | set_user_menu_items (const std::vector< std::string > &list) |
config & | gamelist () |
Returns the current gamelist. More... | |
void | append_to_title (const std::string &name) |
const gui::label & | title () const |
std::string | get_selected_user_game () |
bool | selected_user_changed () const |
void | set_selected_user_changed (const bool &changed) |
Protected Member Functions inherited from gui::widget | |
widget (widget const &o) | |
widget (CVideo &video, const bool auto_join=true) | |
virtual | ~widget () |
void | bg_register (SDL_Rect const &rect) |
void | bg_restore () const |
void | bg_restore (SDL_Rect const &rect) const |
void | bg_update () |
void | bg_cancel () |
CVideo & | video () const |
virtual void | draw () |
virtual void | update_location (SDL_Rect const &rect) |
const SDL_Rect * | clip_rect () const |
virtual sdl_handler_vector | member_handlers () |
virtual void | handle_window_event (SDL_Event const &event) |
bool | mouse_locked () const |
void | aquire_mouse_lock () |
void | free_mouse_lock () |
Protected Member Functions inherited from events::sdl_handler | |
sdl_handler (const bool auto_join=true) | |
virtual | ~sdl_handler () |
virtual std::vector < sdl_handler * > | handler_members () |
Protected Attributes | |
CVideo & | video_ |
twesnothd_connection * | wesnothd_connection_ |
boost::scoped_ptr < plugins_context > | plugins_context_ |
Protected Attributes inherited from gui::widget | |
bool | focus_ |
Static Protected Attributes | |
static const int | xscale_base = 1024 |
static const int | yscale_base = 768 |
Private Attributes | |
bool | initialized_ |
Set to true when the widgets are initialized. More... | |
bool | gamelist_initialized_ |
const config & | game_config_ |
The main game configuration, as defined by loading the preprocessed WML files. More... | |
chat & | chat_ |
config & | gamelist_ |
gui::label | title_ |
gui::textbox | entry_textbox_ |
gui::textbox | chat_textbox_ |
gui::menu | users_menu_ |
std::vector< std::string > | user_list_ |
std::string | selected_game_ |
std::string | selected_user_ |
bool | selected_user_changed_ |
result | result_ |
bool | gamelist_refresh_ |
Uint32 | lobby_clock_ |
std::map< std::string, time_t > | whisper_warnings_ |
Additional Inherited Members | |
Private Types inherited from events::chat_handler | |
enum | MESSAGE_TYPE { MESSAGE_PUBLIC, MESSAGE_PRIVATE } |
Private Member Functions inherited from events::chat_handler | |
chat_handler () | |
virtual | ~chat_handler () |
void | send_command (const std::string &cmd, const std::string &args="") |
void | do_speak (const std::string &message, bool allies_only=false) |
virtual void | send_whisper (const std::string &receiver, const std::string &message) |
virtual void | add_whisper_sent (const std::string &receiver, const std::string &message) |
virtual void | add_whisper_received (const std::string &sender, const std::string &message) |
virtual void | send_chat_room_message (const std::string &room, const std::string &message) |
virtual void | add_chat_room_message_sent (const std::string &room, const std::string &message) |
virtual void | add_chat_room_message_received (const std::string &room, const std::string &speaker, const std::string &message) |
virtual void | user_relation_changed (const std::string &name) |
Called when a processed command results in a relation (friend/ignore) change for a user whose name is passed as the 'name' arg. More... | |
void | change_logging (const std::string &data) |
Change the log level of a log domain. More... | |
Private Member Functions inherited from font::floating_label_context | |
floating_label_context () | |
~floating_label_context () | |
a base class for the different multiplayer base dialogs: game list, create game, wait game, game setup.
Definition at line 76 of file multiplayer_ui.hpp.
enum mp::ui::result |
Enumerator | |
---|---|
CONTINUE | |
JOIN | |
OBSERVE | |
CREATE | |
LOAD_GAME | |
PREFERENCES | |
PLAY | |
QUIT |
Definition at line 79 of file multiplayer_ui.hpp.
Enumerator | |
---|---|
ME | |
FRIEND | |
NEUTRAL | |
IGNORED |
Definition at line 232 of file multiplayer_ui.hpp.
enum mp::ui::user_state |
Enumerator | |
---|---|
LOBBY | |
GAME | |
SEL_GAME |
Definition at line 233 of file multiplayer_ui.hpp.
mp::ui::ui | ( | CVideo & | v, |
twesnothd_connection * | wesnothd_connection, | ||
const std::string & | title, | ||
const config & | cfg, | ||
chat & | c, | ||
config & | gamelist | ||
) |
Definition at line 182 of file multiplayer_ui.cpp.
References sdl::create_rect(), CVideo::getx(), CVideo::gety(), set_location(), gui::menu::set_numeric_keypress_selection(), and users_menu_.
|
protectedvirtual |
Override chat_handler.
Implements events::chat_handler.
Definition at line 378 of file multiplayer_ui.cpp.
References mp::chat::add_message(), chat_, chat_textbox_, and mp::chat::update_textbox().
Referenced by send_chat_message().
|
protected |
Definition at line 771 of file multiplayer_ui.cpp.
References gui::label::get_text(), gui::label::set_text(), and title_.
Referenced by mp::connect::connect(), and mp::wait::join_game().
|
protected |
Definition at line 258 of file multiplayer_ui.cpp.
References xscale(), and yscale().
Referenced by mp::wait::layout_children(), mp::create::layout_children(), mp::configure::layout_children(), mp::connect::layout_children(), and mp::lobby::layout_children().
|
protectedvirtual |
Reimplemented from gui::widget.
Definition at line 275 of file multiplayer_ui.cpp.
References image::get_image(), hide_children(), scale_surface(), sdl_blit(), and video().
|
protected |
Returns the main game config, as defined by loading the preprocessed WML files.
Children of this class may need this to obtain, for example, the list of available eras.
Definition at line 270 of file multiplayer_ui.cpp.
References game_config_.
Referenced by mp::create::create(), mp::lobby::gamelist_updated(), mp::lobby::lobby(), and mp::create::process_event_impl().
|
inlineprotected |
Returns the current gamelist.
Definition at line 183 of file multiplayer_ui.hpp.
References gamelist_.
Referenced by mp::lobby::gamelist_updated(), mp::wait::generate_menu(), mp::lobby::lobby(), and mp::connect::update_playerlist_state().
|
protectedvirtual |
Called each time the gamelist_ variable is updated.
May be overridden by child classes to add custom gamelist behavior.
Reimplemented in mp::lobby.
Definition at line 653 of file multiplayer_ui.cpp.
References config::child_range(), FRIEND, GAME, mp::ui::user_info::game_id, gamelist_, HELP_STRING_SEPARATOR, preferences::iconize_list(), IGNORED, IMAGE_PREFIX, IMG_TEXT_SEPARATOR, preferences::is_friend(), preferences::is_ignored(), LOBBY, mp::ui::user_info::location, preferences::login(), ME, mp::ui::user_info::name, NEUTRAL, mp::ui::user_info::registered, mp::ui::user_info::relation, SEL_GAME, selected_game_, set_user_list(), set_user_menu_items(), preferences::sort_list(), and mp::ui::user_info::state.
Referenced by mp::configure::configure(), mp::create::create(), mp::lobby::gamelist_updated(), mp::lobby::process_event_impl(), process_network(), process_network_data(), mp::connect::update_playerlist_state(), and mp::wait::wait().
plugins_context * mp::ui::get_plugins_context | ( | ) |
Definition at line 780 of file multiplayer_ui.cpp.
References plugins_context_.
Referenced by mp::run_lobby_loop().
ui::result mp::ui::get_result | ( | ) |
Returns the result of the current widget.
While the result is equal to continue, the widget should not be destroyed.
Definition at line 234 of file multiplayer_ui.cpp.
References result_.
Referenced by mp::connect::connect(), sp::enter_configure_mode(), enter_configure_mode(), enter_create_mode(), enter_lobby_mode(), enter_wait_mode(), mp::goto_mp_connect(), mp::goto_mp_wait(), mp::create::plugin_event_helper(), mp::configure::plugin_event_helper(), mp::connect::plugin_event_helper(), mp::lobby::plugin_event_helper(), mp::run_lobby_loop(), mp::configure::~configure(), mp::create::~create(), and mp::wait::~wait().
|
protected |
Definition at line 764 of file multiplayer_ui.cpp.
References config::find_child(), gamelist_, and selected_user_.
Referenced by mp::lobby::process_event_impl().
|
protectedvirtual |
Reimplemented from gui::widget.
Definition at line 305 of file multiplayer_ui.cpp.
References _(), config::add_child(), CVideo::clear_all_help_strings(), gui2::tloadscreen::displaying(), gui::menu::double_clicked(), gui2::tdialog::get_retval(), gui::widget::handle_event(), handle_key_event(), gui2::tmp_cmd_wrapper::message(), game_logic::msg(), gui2::tmp_cmd_wrapper::reason(), selected_user_, selected_user_changed_, gui::menu::selection(), send_to_server(), set_location(), gui2::tdialog::show(), gui2::tmp_cmd_wrapper::time(), user_list_, users_menu_, and video().
|
protectedvirtual |
Definition at line 395 of file multiplayer_ui.cpp.
References mp::chat::add_message(), chat_, chat_textbox_, gui::textbox::clear(), entry_textbox_, utils::join(), preferences::login(), schema_validation::remove, gui::textbox::set_text(), gui::textbox::text(), mp::chat::update_textbox(), user_list_, and utils::word_completion().
Referenced by handle_event().
|
protectedvirtual |
Hides or shows all gui::widget children of this widget.
Should be overridden by subclasses which add their own children.
Reimplemented in mp::lobby, mp::connect, mp::configure, mp::create, and mp::wait.
Definition at line 579 of file multiplayer_ui.cpp.
References chat_textbox_, entry_textbox_, gui::scrollarea::hide(), gui::widget::hide(), title_, and users_menu_.
Referenced by draw_contents(), mp::wait::hide_children(), mp::create::hide_children(), mp::configure::hide_children(), mp::connect::hide_children(), mp::lobby::hide_children(), and set_location().
|
protectedvirtual |
Lays the children out.
This method is to be overridden by the subclasses of the mp_ui class; it will be called.
Reimplemented in mp::lobby, mp::connect, mp::configure, mp::create, and mp::wait.
Definition at line 587 of file multiplayer_ui.cpp.
References chat_textbox_, entry_textbox_, gui::widget::set_height(), gui::widget::set_location(), gui::menu::set_max_height(), gui::menu::set_max_width(), gui::widget::set_measurements(), gui::widget::set_width(), title_, users_menu_, xscale(), and yscale().
Referenced by mp::wait::layout_children(), mp::create::layout_children(), mp::configure::layout_children(), mp::connect::layout_children(), mp::lobby::layout_children(), and set_location().
|
protectedvirtual |
Reimplemented from events::sdl_handler.
Reimplemented in mp::lobby, mp::connect, mp::configure, mp::create, and mp::wait.
Definition at line 301 of file multiplayer_ui.cpp.
Process chat messages.
Definition at line 424 of file multiplayer_ui.cpp.
References mp::chat::add_message(), chat_, chat_textbox_, mp_ui_alerts::friend_message(), plugins_manager::get(), i, preferences::is_friend(), preferences::is_ignored(), LOG_NW, preferences::login(), game_logic::msg(), plugins_manager::notify_event(), preferences::parse_admin_authentication(), preferences::parse_should_show_lobby_join(), mp_ui_alerts::private_message(), mp_ui_alerts::public_message(), mp_ui_alerts::server_message(), mp::chat::update_textbox(), VGETTEXT, preferences::whisper_friends_only(), whisper_warnings_, and utils::word_match().
Referenced by process_network_data().
void mp::ui::process_network | ( | ) |
Asks the multiplayer_ui to pump some data from the network, and then to process it.
The actual processing will be left to the child classes, through process_network_data and process_network_error.
Definition at line 217 of file multiplayer_ui.cpp.
References gamelist_refresh_, gamelist_updated(), lobby_clock_, game_config::lobby_refresh, process_network_data(), receive_from_server(), and cursor::WAIT.
Referenced by mp::run_lobby_loop().
Processes any pending network data.
Called by the public process_network() method. Overridden by subclasses who add more behavior for network.
Reimplemented in mp::lobby, mp::connect, and mp::wait.
Definition at line 513 of file multiplayer_ui.cpp.
References mp::chat::add_message(), config::apply_diff(), chat_, chat_textbox_, config::child(), config::child_range(), e, ERR_CF, gamelist_, gamelist_initialized_, gamelist_refresh_, gamelist_updated(), lobby_clock_, preferences::login(), game::error::message, process_message(), send_to_server(), mp::chat::update_textbox(), and cursor::WAIT.
Referenced by process_network(), mp::wait::process_network_data(), mp::connect::process_network_data(), and mp::lobby::process_network_data().
bool mp::ui::receive_from_server | ( | config & | dst | ) |
Definition at line 792 of file multiplayer_ui.cpp.
References twesnothd_connection::receive_data(), and wesnothd_connection_.
Referenced by process_network().
|
inlineprotected |
Definition at line 189 of file multiplayer_ui.hpp.
References selected_user_changed_.
Referenced by mp::lobby::process_event_impl().
|
protectedvirtual |
Implements events::chat_handler.
Definition at line 384 of file multiplayer_ui.cpp.
References add_chat_message(), config::add_child(), preferences::login(), game_logic::msg(), and send_to_server().
Referenced by mp::connect::connect(), mp::create::create(), mp::lobby::lobby(), and mp::wait::wait().
Implements events::chat_handler.
Definition at line 785 of file multiplayer_ui.cpp.
References twesnothd_connection::send_data(), and wesnothd_connection_.
Referenced by mp::wait::download_level_data(), handle_event(), mp::wait::join_game(), mp::connect::process_event_impl(), mp::lobby::process_event_impl(), process_network_data(), and send_chat_message().
|
virtual |
Hides children, moves them (using layout_children), then shows them.
The methodes hide_children and layout_children are supposed to be overridden by subclasses of this class which add new sub-widgets.
Reimplemented from gui::widget.
Definition at line 287 of file multiplayer_ui.cpp.
References chat_, chat_textbox_, entry_textbox_, hide_children(), mp::chat::init_textbox(), initialized_, layout_children(), gui::textbox::set_edit_target(), and gui::textbox::set_wrap().
Referenced by handle_event(), mp::run_lobby_loop(), and ui().
|
protected |
Sets the result of this dialog, to be checked by get_result().
Definition at line 239 of file multiplayer_ui.cpp.
References result_.
Referenced by mp::configure::configure(), mp::connect::connect(), mp::wait::join_game(), mp::wait::process_event_impl(), mp::create::process_event_impl(), mp::configure::process_event_impl(), mp::connect::process_event_impl(), mp::lobby::process_event_impl(), mp::wait::process_network_data(), and mp::connect::process_network_data().
|
protected |
Sets the name of the selected game which is used to highlight the names of the players which have joined this game.
Definition at line 728 of file multiplayer_ui.cpp.
References gui::menu::move_selection(), selected_game_, preferences::sort_list(), and users_menu_.
Referenced by mp::lobby::process_event_impl().
|
inlineprotected |
Definition at line 190 of file multiplayer_ui.hpp.
References selected_user_changed_.
Referenced by mp::lobby::process_event_impl().
|
protected |
Sets the user list.
Definition at line 749 of file multiplayer_ui.cpp.
References mp_ui_alerts::player_joins(), mp_ui_alerts::player_leaves(), and user_list_.
Referenced by gamelist_updated(), mp::wait::generate_menu(), and mp::connect::update_playerlist_state().
|
protected |
Definition at line 737 of file multiplayer_ui.cpp.
References gui2::event::find(), i, gui::menu::move_selection_keeping_viewport(), selected_user_, gui::menu::set_items(), user_list_, and users_menu_.
Referenced by gamelist_updated(), and mp::connect::update_playerlist_state().
|
protected |
Definition at line 775 of file multiplayer_ui.cpp.
References title_.
Referenced by mp::wait::layout_children(), mp::create::layout_children(), mp::configure::layout_children(), and mp::lobby::layout_children().
|
inline |
Definition at line 106 of file multiplayer_ui.hpp.
References user_list_.
Referenced by enter_wait_mode().
|
inlineprotected |
Definition at line 119 of file multiplayer_ui.hpp.
References video_.
Referenced by mp::wait::download_level_data(), mp::wait::leader_preview_pane::draw_contents(), draw_contents(), mp::create::draw_level_image(), handle_event(), mp::create::hide_children(), mp::wait::join_game(), mp::create::process_event_impl(), mp::configure::process_event_impl(), mp::lobby::process_event_impl(), and mp::wait::process_network_data().
Definition at line 248 of file multiplayer_ui.cpp.
References gui::widget::width(), and xscale_base.
Referenced by client_area(), layout_children(), and mp::lobby::layout_children().
Definition at line 253 of file multiplayer_ui.cpp.
References gui::widget::height(), and yscale_base.
Referenced by client_area(), layout_children(), and mp::lobby::layout_children().
|
private |
Definition at line 206 of file multiplayer_ui.hpp.
Referenced by add_chat_message(), handle_key_event(), process_message(), process_network_data(), and set_location().
|
private |
Definition at line 212 of file multiplayer_ui.hpp.
Referenced by add_chat_message(), handle_key_event(), hide_children(), layout_children(), process_message(), process_network_data(), and set_location().
|
private |
Definition at line 211 of file multiplayer_ui.hpp.
Referenced by handle_key_event(), hide_children(), layout_children(), and set_location().
|
private |
The main game configuration, as defined by loading the preprocessed WML files.
Access using the game_config() method if necessary.
Definition at line 204 of file multiplayer_ui.hpp.
Referenced by game_config().
|
private |
Definition at line 208 of file multiplayer_ui.hpp.
Referenced by gamelist(), gamelist_updated(), get_selected_user_game(), and process_network_data().
|
private |
Definition at line 198 of file multiplayer_ui.hpp.
Referenced by process_network_data().
|
private |
Definition at line 225 of file multiplayer_ui.hpp.
Referenced by process_network(), and process_network_data().
|
private |
Set to true when the widgets are initialized.
Allows delayed initialization on first positioning.
Definition at line 197 of file multiplayer_ui.hpp.
Referenced by set_location().
|
private |
Definition at line 227 of file multiplayer_ui.hpp.
Referenced by process_network(), and process_network_data().
|
protected |
Definition at line 259 of file multiplayer_ui.hpp.
Referenced by mp::configure::configure(), mp::connect::connect(), mp::create::create(), get_plugins_context(), mp::lobby::lobby(), and mp::wait::wait().
|
private |
Definition at line 223 of file multiplayer_ui.hpp.
Referenced by get_result(), and set_result().
|
private |
Definition at line 218 of file multiplayer_ui.hpp.
Referenced by gamelist_updated(), and set_selected_game().
|
private |
Definition at line 220 of file multiplayer_ui.hpp.
Referenced by get_selected_user_game(), handle_event(), and set_user_menu_items().
|
private |
Definition at line 221 of file multiplayer_ui.hpp.
Referenced by handle_event(), selected_user_changed(), and set_selected_user_changed().
|
private |
Definition at line 210 of file multiplayer_ui.hpp.
Referenced by append_to_title(), hide_children(), layout_children(), and title().
|
private |
Definition at line 216 of file multiplayer_ui.hpp.
Referenced by handle_event(), handle_key_event(), set_user_list(), set_user_menu_items(), and user_list().
|
private |
Definition at line 214 of file multiplayer_ui.hpp.
Referenced by handle_event(), hide_children(), layout_children(), set_selected_game(), set_user_menu_items(), and ui().
|
protected |
Definition at line 117 of file multiplayer_ui.hpp.
Referenced by video().
|
protected |
Definition at line 118 of file multiplayer_ui.hpp.
Referenced by mp::wait::download_level_data(), mp::connect::process_event_impl(), receive_from_server(), and send_to_server().
|
private |
Definition at line 229 of file multiplayer_ui.hpp.
Referenced by process_message().
|
staticprotected |
Definition at line 112 of file multiplayer_ui.hpp.
Referenced by mp::lobby::layout_children(), and xscale().
|
staticprotected |
Definition at line 113 of file multiplayer_ui.hpp.
Referenced by yscale().