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, PREFERENCES, PLAY, QUIT } |
| enum | user_relation { ME, FRIEND, NEUTRAL, IGNORED } |
| enum | user_state { LOBBY, GAME, SEL_GAME } |
Public Member Functions | |
| ui (game_display &d, 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. | |
| result | get_result () |
| Returns the result of the current widget. | |
| void | set_location (const SDL_Rect &rect) |
| Hides children, moves them (using layout_children), then shows them. | |
Protected Member Functions | |
| int | xscale (int x) const |
| int | yscale (int y) const |
| SDL_Rect | client_area () const |
| game_display & | disp () |
| const config & | game_config () const |
| Returns the main game config, as defined by loading the preprocessed WML files. | |
| 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. | |
| 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. | |
| virtual void | process_network_data (const config &data, const network::connection sock) |
| Processes any pending network data. | |
| virtual void | process_network_error (network::error &error) |
| Processes any pending network error. | |
| virtual bool | accept_connections () |
| Return true if we must accept incoming connections, false if not. | |
| virtual void | process_network_connection (const network::connection sock) |
| Processes a pending network connection. | |
| virtual void | hide_children (bool hide=true) |
| Hides or shows all gui::widget children of this widget. | |
| virtual void | layout_children (const SDL_Rect &rect) |
| Lays the children out. | |
| result | set_result (result res) |
| Sets the result of this dialog, to be checked by get_result(). | |
| 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. | |
| virtual void | gamelist_updated (bool silent=true) |
| Called each time the gamelist_ variable is updated. | |
| void | set_user_list (const std::vector< std::string > &, bool silent) |
| Sets the user list. | |
| void | set_user_menu_items (const std::vector< std::string > &list) |
| config & | gamelist () |
| Returns the current gamelist. | |
| 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 Attributes | |
| game_display & | disp_ |
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 intialized. | |
| bool | gamelist_initialized_ |
| const hotkey::basic_handler | hotkey_handler_ |
| Ensures standard hotkeys are coorectly handled. | |
| const preferences::display_manager | disp_manager_ |
| const config & | game_config_ |
| The main game configuration, as defined by loading the preprocessed WML files. | |
| 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_ |
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 |
Definition at line 79 of file multiplayer_ui.hpp.
Definition at line 246 of file multiplayer_ui.hpp.
| enum mp::ui::user_state |
Definition at line 247 of file multiplayer_ui.hpp.
| mp::ui::ui | ( | game_display & | d, | |
| const std::string & | title, | |||
| const config & | cfg, | |||
| chat & | c, | |||
| config & | gamelist | |||
| ) |
Definition at line 273 of file multiplayer_ui.cpp.
References gui2::create_rect(), CVideo::getx(), CVideo::gety(), set_location(), gui::menu::set_numeric_keypress_selection(), users_menu_, and display::video().

| virtual bool mp::ui::accept_connections | ( | ) | [inline, protected, virtual] |
Return true if we must accept incoming connections, false if not.
Defaults to not.
Reimplemented in mp::connect.
Definition at line 157 of file multiplayer_ui.hpp.
Referenced by process_network().

| void mp::ui::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 | |||
| ) | [protected] |
Override chat_handler.
Definition at line 471 of file multiplayer_ui.cpp.
References mp::chat::add_message(), chat_, chat_textbox_, and mp::chat::update_textbox().
Referenced by send_chat_message().


| void mp::ui::append_to_title | ( | const std::string & | name | ) | [protected] |
Definition at line 821 of file multiplayer_ui.cpp.
References gui::label::get_text(), gui::label::set_text(), and title_.
Referenced by mp::wait::join_game(), and mp::connect::load_game().


| SDL_Rect mp::ui::client_area | ( | ) | const [protected] |
Definition at line 364 of file multiplayer_ui.cpp.
References xscale(), and yscale().
Referenced by mp::wait::layout_children(), mp::lobby::layout_children(), mp::create::layout_children(), and mp::connect::layout_children().


| game_display& mp::ui::disp | ( | ) | [inline, protected] |
Definition at line 115 of file multiplayer_ui.hpp.
References disp_.
Referenced by handle_event(), mp::wait::join_game(), mp::connect::load_game(), mp::create::process_event(), and mp::wait::process_network_data().

| void mp::ui::draw_contents | ( | ) | [protected, virtual] |
Definition at line 381 of file multiplayer_ui.cpp.
References image::get_image(), hide_children(), scale_surface(), sdl_blit(), update_whole_screen(), and gui::widget::video().

| const config & mp::ui::game_config | ( | ) | const [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 376 of file multiplayer_ui.cpp.
References game_config_.
Referenced by mp::lobby::gamelist_updated(), mp::create::get_parameters(), mp::create::hide_children(), mp::connect::load_game(), and mp::create::process_event().

| config& mp::ui::gamelist | ( | ) | [inline, protected] |
Returns the current gamelist.
Definition at line 194 of file multiplayer_ui.hpp.
References gamelist_.
Referenced by mp::lobby::gamelist_updated(), mp::wait::generate_menu(), and mp::connect::update_playerlist_state().

| void mp::ui::gamelist_updated | ( | bool | silent = true |
) | [protected, virtual] |
Called each time the gamelist_ variable is updated.
May be overridden by child classes to add custom gamelist behaviour.
Reimplemented in mp::lobby.
Definition at line 705 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::create::create(), process_network(), process_network_data(), mp::connect::update_playerlist_state(), and mp::wait::wait().


| 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 340 of file multiplayer_ui.cpp.
References result_.
Referenced by mp::connect::connect(), enter_connect_mode(), enter_create_mode(), enter_lobby_mode(), enter_wait_mode(), run_lobby_loop(), and mp::create::~create().

| std::string mp::ui::get_selected_user_game | ( | ) | [protected] |
Definition at line 814 of file multiplayer_ui.cpp.
References config::find_child(), gamelist_, and selected_user_.
Referenced by mp::lobby::process_event().


| void mp::ui::handle_event | ( | const SDL_Event & | event | ) | [protected, virtual] |
Definition at line 412 of file multiplayer_ui.cpp.
References _, config::add_child(), CVideo::clear_all_help_strings(), disp(), events::chat_handler::do_speak(), gui::menu::double_clicked(), gui2::tdialog::get_retval(), handle_key_event(), gui2::tmp_cmd_wrapper::message(), gui2::tmp_cmd_wrapper::reason(), selected_user_, selected_user_changed_, gui::menu::selection(), network::send_data(), gui2::tdialog::show(), gui2::tmp_cmd_wrapper::time(), user_list_, users_menu_, gui::widget::video(), and display::video().

| void mp::ui::handle_key_event | ( | const SDL_KeyboardEvent & | event | ) | [protected, virtual] |
Definition at line 488 of file multiplayer_ui.cpp.
References mp::chat::add_message(), chat_, chat_textbox_, gui::textbox::clear(), events::chat_handler::do_speak(), entry_textbox_, events::handler::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().


| void mp::ui::hide_children | ( | bool | hide = true |
) | [protected, virtual] |
Hides or shows all gui::widget children of this widget.
Should be overridden by subclasses which add their own children.
Reimplemented in mp::connect, mp::create, mp::lobby, and mp::wait.
Definition at line 633 of file multiplayer_ui.cpp.
References chat_textbox_, entry_textbox_, gui::scrollarea::hide(), gui::widget::hide(), title_, and users_menu_.
Referenced by draw_contents(), and set_location().


| void mp::ui::layout_children | ( | const SDL_Rect & | rect | ) | [protected, virtual] |
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::connect, mp::create, mp::lobby, and mp::wait.
Definition at line 641 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 set_location().


| void mp::ui::process_event | ( | ) | [protected, virtual] |
Reimplemented in mp::connect, mp::create, mp::lobby, and mp::wait.
Definition at line 408 of file multiplayer_ui.cpp.
| void mp::ui::process_message | ( | const config & | msg, | |
| const bool | whisper = false | |||
| ) | [protected] |
Process chat messages.
Definition at line 517 of file multiplayer_ui.cpp.
References mp::chat::add_message(), chat_, chat_textbox_, preferences::is_friend(), preferences::is_ignored(), preferences::login(), preferences::parse_admin_authentication(), preferences::parse_should_show_lobby_join(), sound::play_UI_sound(), game_config::sounds::receive_message_friend, game_config::sounds::receive_message_highlight, game_config::sounds::receive_message_server, mp::chat::update_textbox(), VGETTEXT, 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 308 of file multiplayer_ui.cpp.
References network::accept_connection(), accept_connections(), gamelist_refresh_, gamelist_updated(), lobby_clock_, game_config::lobby_refresh, LOG_NW, process_network_connection(), process_network_data(), process_network_error(), network::receive_data(), and cursor::WAIT.
Referenced by run_lobby_loop().


| void mp::ui::process_network_connection | ( | const network::connection | sock | ) | [protected, virtual] |
Processes a pending network connection.
Reimplemented in mp::connect.
Definition at line 628 of file multiplayer_ui.cpp.
References LOG_NW.
Referenced by process_network().

| void mp::ui::process_network_data | ( | const config & | data, | |
| const network::connection | sock | |||
| ) | [protected, virtual] |
Processes any pending network data.
Called by the public process_network() method. Overridden by subclasses who add more behaviour for network.
Reimplemented in mp::connect, mp::lobby, and mp::wait.
Definition at line 554 of file multiplayer_ui.cpp.
References mp::chat::add_message(), config::apply_diff(), chat_, chat_textbox_, config::child(), ERR_CF, error(), gamelist_, gamelist_initialized_, gamelist_refresh_, gamelist_updated(), lobby_clock_, preferences::login(), game::error::message, process_message(), network::send_data(), mp::chat::update_textbox(), and cursor::WAIT.
Referenced by process_network().


| void mp::ui::process_network_error | ( | network::error & | error | ) | [protected, virtual] |
Processes any pending network error.
Called by the public process_network() method. Overridden by subclasses.
Reimplemented in mp::connect.
Definition at line 620 of file multiplayer_ui.cpp.
References ERR_NW, and game::error::message.
Referenced by process_network().

| bool mp::ui::selected_user_changed | ( | ) | const [inline, protected] |
Definition at line 200 of file multiplayer_ui.hpp.
References selected_user_changed_.
Referenced by mp::lobby::process_event().

| void mp::ui::send_chat_message | ( | const std::string & | message, | |
| bool | allies_only = false | |||
| ) | [protected] |
Definition at line 477 of file multiplayer_ui.cpp.
References add_chat_message(), config::add_child(), preferences::login(), and network::send_data().

| void mp::ui::set_location | ( | const SDL_Rect & | rect | ) |
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.
Definition at line 395 of file multiplayer_ui.cpp.
References chat_, chat_textbox_, hide_children(), mp::chat::init_textbox(), initialized_, layout_children(), and gui::textbox::set_wrap().
Referenced by run_lobby_loop(), and ui().


| ui::result mp::ui::set_result | ( | ui::result | res | ) | [protected] |
Sets the result of this dialog, to be checked by get_result().
Definition at line 345 of file multiplayer_ui.cpp.
References result_.
Referenced by mp::wait::join_game(), mp::connect::load_game(), mp::wait::process_event(), mp::lobby::process_event(), mp::create::process_event(), mp::connect::process_event(), mp::wait::process_network_data(), and mp::connect::process_network_data().

| void mp::ui::set_selected_game | ( | const std::string & | game_name | ) | [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 780 of file multiplayer_ui.cpp.
References gui::menu::move_selection(), selected_game_, preferences::sort_list(), and users_menu_.
Referenced by mp::lobby::process_event().


| void mp::ui::set_selected_user_changed | ( | const bool & | changed | ) | [inline, protected] |
Definition at line 201 of file multiplayer_ui.hpp.
References selected_user_changed_.
Referenced by mp::lobby::process_event().

| void mp::ui::set_user_list | ( | const std::vector< std::string > & | list, | |
| bool | silent | |||
| ) | [protected] |
Sets the user list.
Definition at line 801 of file multiplayer_ui.cpp.
References sound::play_UI_sound(), game_config::sounds::user_arrive, game_config::sounds::user_leave, and user_list_.
Referenced by gamelist_updated(), mp::wait::generate_menu(), and mp::connect::update_playerlist_state().


| void mp::ui::set_user_menu_items | ( | const std::vector< std::string > & | list | ) | [protected] |
Definition at line 789 of file multiplayer_ui.cpp.
References gui2::event::find(), 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().


| const gui::label & mp::ui::title | ( | ) | const [protected] |
Definition at line 825 of file multiplayer_ui.cpp.
References title_.
Referenced by mp::wait::layout_children(), mp::lobby::layout_children(), and mp::create::layout_children().

| int mp::ui::xscale | ( | int | x | ) | const [protected] |
Definition at line 354 of file multiplayer_ui.cpp.
References gui::widget::width(), and xscale_base.
Referenced by client_area(), layout_children(), and mp::lobby::layout_children().


| int mp::ui::yscale | ( | int | y | ) | const [protected] |
Definition at line 359 of file multiplayer_ui.cpp.
References gui::widget::height(), and yscale_base.
Referenced by client_area(), layout_children(), and mp::lobby::layout_children().


chat& mp::ui::chat_ [private] |
Definition at line 222 of file multiplayer_ui.hpp.
Referenced by add_chat_message(), handle_key_event(), process_message(), process_network_data(), and set_location().
gui::textbox mp::ui::chat_textbox_ [private] |
Definition at line 228 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().
game_display& mp::ui::disp_ [protected] |
Reimplemented in mp::connect.
Definition at line 114 of file multiplayer_ui.hpp.
Referenced by disp(), mp::lobby::process_event(), and mp::create::process_event().
const preferences::display_manager mp::ui::disp_manager_ [private] |
Definition at line 214 of file multiplayer_ui.hpp.
gui::textbox mp::ui::entry_textbox_ [private] |
Definition at line 227 of file multiplayer_ui.hpp.
Referenced by handle_key_event(), hide_children(), and layout_children().
const config& mp::ui::game_config_ [private] |
The main game configuration, as defined by loading the preprocessed WML files.
Access using the game_config() method if necessary.
Definition at line 220 of file multiplayer_ui.hpp.
Referenced by game_config().
config& mp::ui::gamelist_ [private] |
Definition at line 224 of file multiplayer_ui.hpp.
Referenced by gamelist(), gamelist_updated(), get_selected_user_game(), and process_network_data().
bool mp::ui::gamelist_initialized_ [private] |
Definition at line 209 of file multiplayer_ui.hpp.
Referenced by process_network_data().
bool mp::ui::gamelist_refresh_ [private] |
Definition at line 241 of file multiplayer_ui.hpp.
Referenced by process_network(), and process_network_data().
const hotkey::basic_handler mp::ui::hotkey_handler_ [private] |
Ensures standard hotkeys are coorectly handled.
Definition at line 212 of file multiplayer_ui.hpp.
bool mp::ui::initialized_ [private] |
Set to true when the widgets are intialized.
Allows delayed initialization on first positioning.
Definition at line 208 of file multiplayer_ui.hpp.
Referenced by set_location().
Uint32 mp::ui::lobby_clock_ [private] |
Definition at line 243 of file multiplayer_ui.hpp.
Referenced by process_network(), and process_network_data().
result mp::ui::result_ [private] |
Definition at line 239 of file multiplayer_ui.hpp.
Referenced by get_result(), and set_result().
std::string mp::ui::selected_game_ [private] |
Definition at line 234 of file multiplayer_ui.hpp.
Referenced by gamelist_updated(), and set_selected_game().
std::string mp::ui::selected_user_ [private] |
Definition at line 236 of file multiplayer_ui.hpp.
Referenced by get_selected_user_game(), handle_event(), and set_user_menu_items().
bool mp::ui::selected_user_changed_ [private] |
Definition at line 237 of file multiplayer_ui.hpp.
Referenced by handle_event(), selected_user_changed(), and set_selected_user_changed().
gui::label mp::ui::title_ [private] |
Definition at line 226 of file multiplayer_ui.hpp.
Referenced by append_to_title(), hide_children(), layout_children(), and title().
std::vector<std::string> mp::ui::user_list_ [private] |
Definition at line 232 of file multiplayer_ui.hpp.
Referenced by handle_event(), handle_key_event(), set_user_list(), and set_user_menu_items().
gui::menu mp::ui::users_menu_ [private] |
Definition at line 230 of file multiplayer_ui.hpp.
Referenced by handle_event(), hide_children(), layout_children(), set_selected_game(), set_user_menu_items(), and ui().
const int mp::ui::xscale_base = 1024 [static, protected] |
Definition at line 109 of file multiplayer_ui.hpp.
Referenced by mp::lobby::layout_children(), and xscale().
const int mp::ui::yscale_base = 768 [static, protected] |
Definition at line 110 of file multiplayer_ui.hpp.
Referenced by yscale().
| Generated by doxygen 1.7.1 on Thu May 24 2012 01:24:56 for The Battle for Wesnoth | Gna! | Forum | Wiki | CIA | devdocs |