The Battle for Wesnoth  1.13.4+dev
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
Classes | Public Types | Public Member Functions | Protected Member Functions | Protected Attributes | Static Protected Attributes | Private Attributes | List of all members
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

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_contextget_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::stringid () 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
 
CVideovideo ()
 
const configgame_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)
 
configgamelist ()
 Returns the current gamelist. More...
 
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 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 ()
 
CVideovideo () 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

CVideovideo_
 
twesnothd_connectionwesnothd_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 configgame_config_
 The main game configuration, as defined by loading the preprocessed WML files. More...
 
chatchat_
 
configgamelist_
 
gui::label title_
 
gui::textbox entry_textbox_
 
gui::textbox chat_textbox_
 
gui::menu users_menu_
 
std::vector< std::stringuser_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 ()
 

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

Enumerator
LOBBY 
GAME 
SEL_GAME 

Definition at line 233 of file multiplayer_ui.hpp.

Constructor & Destructor Documentation

mp::ui::ui ( CVideo v,
twesnothd_connection wesnothd_connection,
const std::string title,
const config cfg,
chat c,
config gamelist 
)

Member Function Documentation

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

void mp::ui::append_to_title ( const std::string name)
protected
SDL_Rect mp::ui::client_area ( ) const
protected
void mp::ui::draw_contents ( )
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().

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

config& mp::ui::gamelist ( )
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().

void mp::ui::gamelist_updated ( bool  silent = true)
protectedvirtual
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 ( )
std::string mp::ui::get_selected_user_game ( )
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().

void mp::ui::handle_event ( const SDL_Event &  event)
protectedvirtual
void mp::ui::handle_key_event ( const SDL_KeyboardEvent &  event)
protectedvirtual
void mp::ui::hide_children ( bool  hide = true)
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().

void mp::ui::layout_children ( const SDL_Rect &  rect)
protectedvirtual
void mp::ui::process_event ( )
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.

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

void mp::ui::process_network_data ( const config data)
protectedvirtual
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().

bool mp::ui::selected_user_changed ( ) const
inlineprotected

Definition at line 189 of file multiplayer_ui.hpp.

References selected_user_changed_.

Referenced by mp::lobby::process_event_impl().

void mp::ui::send_chat_message ( const std::string message,
bool  allies_only = false 
)
protectedvirtual
void mp::ui::send_to_server ( const config cfg)
overridevirtual
void mp::ui::set_location ( const SDL_Rect &  rect)
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().

ui::result mp::ui::set_result ( ui::result  res)
protected
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 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().

void mp::ui::set_selected_user_changed ( const bool &  changed)
inlineprotected

Definition at line 190 of file multiplayer_ui.hpp.

References selected_user_changed_.

Referenced by mp::lobby::process_event_impl().

void mp::ui::set_user_list ( const std::vector< std::string > &  list,
bool  silent 
)
protected
void mp::ui::set_user_menu_items ( const std::vector< std::string > &  list)
protected
const gui::label & mp::ui::title ( ) const
protected
const std::vector<std::string>& mp::ui::user_list ( ) const
inline

Definition at line 106 of file multiplayer_ui.hpp.

References user_list_.

Referenced by enter_wait_mode().

CVideo& mp::ui::video ( )
inlineprotected
int mp::ui::xscale ( int  x) const
protected

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

int mp::ui::yscale ( int  y) const
protected

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

Member Data Documentation

chat& mp::ui::chat_
private
gui::textbox mp::ui::chat_textbox_
private
gui::textbox mp::ui::entry_textbox_
private

Definition at line 211 of file multiplayer_ui.hpp.

Referenced by handle_key_event(), hide_children(), layout_children(), and set_location().

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 204 of file multiplayer_ui.hpp.

Referenced by game_config().

config& mp::ui::gamelist_
private
bool mp::ui::gamelist_initialized_
private

Definition at line 198 of file multiplayer_ui.hpp.

Referenced by process_network_data().

bool mp::ui::gamelist_refresh_
private

Definition at line 225 of file multiplayer_ui.hpp.

Referenced by process_network(), and process_network_data().

bool mp::ui::initialized_
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().

Uint32 mp::ui::lobby_clock_
private

Definition at line 227 of file multiplayer_ui.hpp.

Referenced by process_network(), and process_network_data().

boost::scoped_ptr<plugins_context> mp::ui::plugins_context_
protected
result mp::ui::result_
private

Definition at line 223 of file multiplayer_ui.hpp.

Referenced by get_result(), and set_result().

std::string mp::ui::selected_game_
private

Definition at line 218 of file multiplayer_ui.hpp.

Referenced by gamelist_updated(), and set_selected_game().

std::string mp::ui::selected_user_
private

Definition at line 220 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
gui::label mp::ui::title_
private

Definition at line 210 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
gui::menu mp::ui::users_menu_
private
CVideo& mp::ui::video_
protected

Definition at line 117 of file multiplayer_ui.hpp.

Referenced by video().

twesnothd_connection* mp::ui::wesnothd_connection_
protected
std::map<std::string, time_t> mp::ui::whisper_warnings_
private

Definition at line 229 of file multiplayer_ui.hpp.

Referenced by process_message().

const int mp::ui::xscale_base = 1024
staticprotected

Definition at line 112 of file multiplayer_ui.hpp.

Referenced by mp::lobby::layout_children(), and xscale().

const int mp::ui::yscale_base = 768
staticprotected

Definition at line 113 of file multiplayer_ui.hpp.

Referenced by yscale().


The documentation for this class was generated from the following files: