Classes | Public Types | Public Member Functions | Protected Member Functions | Protected Attributes | Static Protected Attributes | Private Attributes

mp::ui Class Reference

a base class for the different multiplayer base dialogs: game list, create game, wait game, game setup. More...

#include <multiplayer_ui.hpp>

Inheritance diagram for mp::ui:
Inheritance graph
[legend]
Collaboration diagram for mp::ui:
Collaboration graph
[legend]

List of all members.

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_displaydisp ()
const configgame_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)
configgamelist ()
 Returns the current gamelist.
void append_to_title (const std::string &name)
const gui::labeltitle () const
std::string get_selected_user_game ()
bool selected_user_changed () const
void set_selected_user_changed (const bool &changed)

Protected Attributes

game_displaydisp_

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 configgame_config_
 The main game configuration, as defined by loading the preprocessed WML files.
chatchat_
configgamelist_
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_

Detailed Description

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.


Member Enumeration Documentation

Enumerator:
CONTINUE 
JOIN 
OBSERVE 
CREATE 
PREFERENCES 
PLAY 
QUIT 

Definition at line 79 of file multiplayer_ui.hpp.

Enumerator:
ME 
FRIEND 
NEUTRAL 
IGNORED 

Definition at line 246 of file multiplayer_ui.hpp.

Enumerator:
LOBBY 
GAME 
SEL_GAME 

Definition at line 247 of file multiplayer_ui.hpp.


Constructor & Destructor Documentation

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().

Here is the call graph for this function:


Member Function Documentation

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().

Here is the caller graph for this function:

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().

Here is the call graph for this function:

Here is the caller graph for this function:

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().

Here is the call graph for this function:

Here is the caller graph for this function:

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().

Here is the call graph for this function:

Here is the caller graph for this function:

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().

Here is the caller graph for this function:

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().

Here is the call graph for this function:

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().

Here is the caller graph for this function:

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().

Here is the caller graph for this function:

void mp::ui::gamelist_updated ( bool  silent = true  )  [protected, virtual]
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().

Here is the caller graph for this function:

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().

Here is the call graph for this function:

Here is the caller graph for this function:

void mp::ui::handle_event ( const SDL_Event &  event  )  [protected, virtual]
void mp::ui::handle_key_event ( const SDL_KeyboardEvent &  event  )  [protected, virtual]
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().

Here is the call graph for this function:

Here is the caller graph for this function:

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().

Here is the call graph for this function:

Here is the caller graph for this function:

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]
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().

Here is the call graph for this function:

Here is the caller graph for this function:

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().

Here is the caller graph for this function:

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().

Here is the call graph for this function:

Here is the caller graph for this function:

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().

Here is the caller graph for this function:

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().

Here is the caller graph for this function:

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().

Here is the call graph for this function:

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().

Here is the call graph for this function:

Here is the caller graph for this function:

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().

Here is the caller graph for this function:

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().

Here is the call graph for this function:

Here is the caller graph for this function:

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().

Here is the caller graph for this function:

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().

Here is the call graph for this function:

Here is the caller graph for this function:

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().

Here is the call graph for this function:

Here is the caller graph for this function:

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().

Here is the caller graph for this function:

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().

Here is the call graph for this function:

Here is the caller graph for this function:

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().

Here is the call graph for this function:

Here is the caller graph for this function:


Member Data Documentation

chat& mp::ui::chat_ [private]

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().

Definition at line 214 of file multiplayer_ui.hpp.

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().

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().

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().

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().

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]
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().


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

Generated by doxygen 1.7.1 on Thu May 24 2012 01:24:56 for The Battle for Wesnoth
Gna! | Forum | Wiki | CIA | devdocs