The Battle for Wesnoth  1.15.1+dev
Classes | Public Member Functions | Protected Member Functions | Protected Attributes | Private Member Functions | Private Attributes | List of all members
playmp_controller Class Reference

#include <playmp_controller.hpp>

Inheritance diagram for playmp_controller:
Inheritance graph

Classes

class  hotkey_handler
 

Public Member Functions

 playmp_controller (const config &level, saved_game &state_of_game, const ter_data_cache &tdata, mp_campaign_info *mp_info)
 
virtual ~playmp_controller ()
 
void maybe_linger () override
 
void process_oos (const std::string &err_msg) const override
 Asks the user whether to continue on an OOS error. More...
 
void pull_remote_choice () override
 
void send_user_choice () override
 
void surrender (int side_number)
 
bool is_networked_mp () const override
 
void send_to_wesnothd (const config &cfg, const std::string &packet_type="unknown") const override
 
bool receive_from_wesnothd (config &cfg) const override
 
void play_slice (bool is_delay_enabled=true) override
 
- Public Member Functions inherited from playsingle_controller
 playsingle_controller (const config &level, saved_game &state_of_game, const ter_data_cache &tdata, bool skip_replay)
 
LEVEL_RESULT play_scenario (const config &level)
 
void play_scenario_init ()
 
void play_scenario_main_loop ()
 
virtual void check_objectives () override
 
void end_turn ()
 
void force_end_turn () override
 
std::string describe_result () const
 
bool get_player_type_changed () const
 
void set_player_type_changed ()
 
virtual bool should_return_to_play_side () const override
 
replay_controllerget_replay_controller () const override
 
void enable_replay (bool is_unit_test=false)
 
void on_replay_end (bool is_unit_test)
 
- Public Member Functions inherited from play_controller
 play_controller (const config &level, saved_game &state_of_game, const ter_data_cache &tdata, bool skip_replay)
 
virtual ~play_controller ()
 
bool can_undo () const
 
bool can_redo () const
 
void undo ()
 
void redo ()
 
void load_game ()
 
void save_game ()
 
void save_game_auto (const std::string &filename)
 
void save_replay ()
 
void save_replay_auto (const std::string &filename)
 
void save_map ()
 
replayget_replay ()
 
void init_side_begin ()
 
void maybe_do_init_side ()
 Called by turn_info::process_network_data() or init_side() to call do_init_side() if necessary. More...
 
void do_init_side ()
 Called by replay handler or init_side() to do actual work for turn change. More...
 
void init_side_end ()
 
void set_end_level_data (const end_level_data &data)
 
void reset_end_level_data ()
 
bool is_regular_game_end () const
 
const end_level_dataget_end_level_data_const () const
 
const std::vector< team > & get_teams_const () const
 
const unit_mapget_units_const () const
 
const gamemapget_map_const () const
 
const tod_managerget_tod_manager_const () const
 
bool is_observer () const
 
bool do_healing () const
 
void set_do_healing (bool do_healing)
 
game_stategamestate ()
 
const game_stategamestate () const
 
void check_victory ()
 Checks to see if a side has won. More...
 
std::size_t turn () const
 
int current_side () const
 Returns the number of the side whose turn it is. More...
 
config to_config () const
 Builds the snapshot config from members and their respective configs. More...
 
bool is_skipping_replay () const
 
void toggle_skipping_replay ()
 
bool is_linger_mode () const
 
void do_autosave ()
 
bool is_skipping_story () const
 
void do_consolesave (const std::string &filename)
 
events::mouse_handlerget_mouse_handler_base () override
 Get a reference to a mouse handler member a derived class uses. More...
 
events::menu_handlerget_menu_handler ()
 
std::shared_ptr< wb::managerget_whiteboard () const
 
const mp_game_settingsget_mp_settings ()
 
game_classificationget_classification ()
 
int get_server_request_number () const
 
void increase_server_request_number ()
 
game_events::wml_event_pumppump ()
 
int get_ticks () const
 
virtual soundsource::managerget_soundsource_man () override
 Get (optionally) a soundsources manager a derived class uses. More...
 
virtual plugins_contextget_plugins_context () override
 Get (optionally) a plugins context a derived class uses. More...
 
hotkey::command_executorget_hotkey_command_executor () override
 Optionally get a command executor to handle context menu events. More...
 
actions::undo_listget_undo_stack ()
 
bool is_browsing () const override
 
bool is_lingering () const
 
bool is_replay () const
 
t_string get_scenario_name () const
 
bool get_disallow_recall () const
 
std::string theme () const
 
void maybe_throw_return_to_play_side () const
 
void play_side ()
 
teamcurrent_team ()
 
const teamcurrent_team () const
 
bool can_use_synced_wml_menu () const
 
std::set< std::string > all_players () const
 
int ticks () const
 
game_displayget_display () override
 Get a reference to a display member a derived class uses. More...
 
void update_savegame_snapshot () const
 
void update_gui_to_player (const int team_index, const bool observe=false)
 Changes the UI for this client to the passed side index. More...
 
void refresh_objectives () const
 Reevaluate [show_if] conditions and build a new objectives string. More...
 
void show_objectives () const
 
saved_gameget_saved_game ()
 
- Public Member Functions inherited from controller_base
 controller_base ()
 
virtual ~controller_base ()
 
void apply_keyboard_scroll (int x, int y)
 
void set_scroll_up (bool on)
 
void set_scroll_down (bool on)
 
void set_scroll_left (bool on)
 
void set_scroll_right (bool on)
 
- Public Member Functions inherited from events::sdl_handler
virtual void process_event ()
 
virtual void draw ()
 
virtual void volatile_draw ()
 
virtual void volatile_undraw ()
 
virtual bool requires_event_focus (const SDL_Event *=nullptr) const
 
virtual void process_help_string (int, int)
 
virtual void process_tooltip_string (int, int)
 
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 ()
 
virtual bool has_joined ()
 
virtual bool has_joined_global ()
 
sdl_handleroperator= (sdl_handler &&)=delete
 Moving would require two instances' context membership to be handled, it's simpler to delete these and require the two instances to be separately constructed / destructed. More...
 
 sdl_handler (sdl_handler &&)=delete
 
- Public Member Functions inherited from events::pump_monitor
 pump_monitor ()
 
virtual ~pump_monitor ()
 
- Public Member Functions inherited from events::observer
virtual ~observer ()
 
- Public Member Functions inherited from quit_confirmation
 quit_confirmation (const std::function< bool()> &prompt=&quit_confirmation::default_prompt)
 
 ~quit_confirmation ()
 
- Public Member Functions inherited from syncmp_handler
 syncmp_handler ()
 
virtual ~syncmp_handler ()
 

Protected Member Functions

virtual void handle_generic_event (const std::string &name) override
 
void start_network ()
 
void stop_network ()
 
virtual void play_human_turn () override
 
virtual void play_linger_turn ()
 
virtual void after_human_turn () override
 
virtual void play_network_turn () override
 Will handle networked turns in descendent classes. More...
 
virtual void do_idle_notification () override
 Will handle sending a networked notification in descendent classes. More...
 
virtual void play_idle_loop () override
 
void linger ()
 
void wait_for_upload ()
 Wait for the host to upload the next scenario. More...
 
virtual void on_not_observer () override
 
bool is_host () const
 
void remove_blindfold ()
 
- Protected Member Functions inherited from playsingle_controller
virtual void play_side_impl () override
 
void before_human_turn ()
 
void show_turn_dialog ()
 
void execute_gotos ()
 
void end_turn_enable (bool enable)
 
void play_ai_turn ()
 
virtual void init_gui () override
 
void linger ()
 
void sync_end_turn () override
 
void update_viewing_player () override
 
void reset_replay ()
 
- Protected Member Functions inherited from play_controller
void play_slice_catch ()
 
bool have_keyboard_focus () override
 Derived classes should override this to return false when arrow keys should not scroll the map, hotkeys not processed etc, for example when a textbox is active. More...
 
void process_focus_keydown_event (const SDL_Event &event) override
 Process keydown (only when the general map display does not have focus). More...
 
void process_keydown_event (const SDL_Event &event) override
 Process keydown (always). More...
 
void process_keyup_event (const SDL_Event &event) override
 Process keyup (always). More...
 
void init_managers ()
 
void fire_preload ()
 preload events cannot be synced More...
 
void fire_prestart ()
 
void fire_start ()
 
void start_game ()
 
void finish_side_turn ()
 
void finish_turn ()
 
bool enemies_visible () const
 
void enter_textbox ()
 
void tab ()
 
bool is_team_visible (int team_num, bool observer) const
 
int find_last_visible_team () const
 returns 0 if no such team was found. More...
 
actions::undo_listundo_stack ()
 
const actions::undo_listundo_stack () const
 
const std::string & select_music (bool victory) const
 
void reset_gamestate (const config &level, int replay_pos)
 
virtual void check_time_over ()
 
void play_turn ()
 
- Protected Member Functions inherited from controller_base
virtual std::vector< std::string > additional_actions_pressed ()
 
bool handle_scroll (int mousex, int mousey, int mouse_flags, double joystickx, double joysticky)
 Handle scrolling by keyboard, joystick and moving mouse near map edges. More...
 
void handle_event (const SDL_Event &event) override
 Process mouse- and keypress-events from SDL. More...
 
void handle_window_event (const SDL_Event &) override
 
virtual void process (events::pump_info &) override
 
virtual void show_menu (const std::vector< config > &items_arg, int xloc, int yloc, bool context_menu, display &disp)
 
virtual void execute_action (const std::vector< std::string > &items_arg, int xloc, int yloc, bool context_menu)
 
virtual bool in_context_menu (hotkey::HOTKEY_COMMAND command) const
 
void long_touch_callback (int x, int y)
 
- Protected Member Functions inherited from video2::draw_layering
 draw_layering (const bool auto_join=true)
 
virtual ~draw_layering ()
 
- Protected Member Functions inherited from events::sdl_handler
 sdl_handler (const bool auto_join=true)
 
 sdl_handler (const sdl_handler &)
 
sdl_handleroperator= (const sdl_handler &)
 
virtual ~sdl_handler ()
 
virtual std::vector< sdl_handler * > handler_members ()
 

Protected Attributes

bool network_processing_stopped_
 
blindfold blindfold_
 
- Protected Attributes inherited from playsingle_controller
const cursor::setter cursor_setter_
 
gui::floating_textbox textbox_info_
 
replay_network_sender replay_sender_
 
playturn_network_adapter network_reader_
 
turn_info turn_data_
 
END_TURN_STATE end_turn_
 
bool skip_next_turn_
 
bool ai_fallback_
 
std::unique_ptr< replay_controllerreplay_controller_
 
- Protected Attributes inherited from play_controller
const ter_data_cachetdata_
 
std::unique_ptr< game_stategamestate_
 
config level_
 
saved_gamesaved_game_
 
std::unique_ptr< tooltips::managertooltips_manager_
 
std::shared_ptr< wb::managerwhiteboard_manager_
 
std::unique_ptr< plugins_contextplugins_context_
 
font::floating_label_context labels_manager_
 
help::help_manager help_manager_
 
events::mouse_handler mouse_handler_
 
events::menu_handler menu_handler_
 
std::unique_ptr< hotkey_handlerhotkey_handler_
 
std::unique_ptr< soundsource::managersoundsources_manager_
 
persist_manager persist_
 
std::unique_ptr< game_displaygui_
 
const std::unique_ptr< unit_experience_acceleratorxp_mod_
 
const std::unique_ptr< const statistics::scenario_contextstatistics_context_
 
std::unique_ptr< replayreplay_
 
bool skip_replay_
 
bool skip_story_
 
bool linger_
 
bool init_side_done_now_
 Whether we did init sides in this session (false = we did init sides before we reloaded the game). More...
 
map_location map_start_
 
bool ignore_replay_errors_
 
bool player_type_changed_
 
- Protected Attributes inherited from controller_base
const configgame_config_
 
CKey key_
 
bool scrolling_
 
bool scroll_up_
 
bool scroll_down_
 
bool scroll_left_
 
bool scroll_right_
 
joystick_manager joystick_manager_
 

Private Member Functions

void set_end_scenario_button ()
 
void reset_end_scenario_button ()
 
void process_network_data (bool chat_only=false)
 

Private Attributes

mp_campaign_infomp_info_
 

Additional Inherited Members

- Static Public Member Functions inherited from controller_base
static const configget_theme (const config &game_config, std::string theme_name)
 
- Static Public Member Functions inherited from quit_confirmation
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 ()
 
- Protected Types inherited from playsingle_controller
enum  END_TURN_STATE { END_TURN_NONE, END_TURN_REQUIRED, END_TURN_SYNCED }
 

Detailed Description

Definition at line 23 of file playmp_controller.hpp.

Constructor & Destructor Documentation

◆ playmp_controller()

playmp_controller::playmp_controller ( const config level,
saved_game state_of_game,
const ter_data_cache tdata,
mp_campaign_info mp_info 
)

◆ ~playmp_controller()

playmp_controller::~playmp_controller ( )
virtual

Member Function Documentation

◆ after_human_turn()

void playmp_controller::after_human_turn ( )
overrideprotectedvirtual

◆ do_idle_notification()

void playmp_controller::do_idle_notification ( )
overrideprotectedvirtual

Will handle sending a networked notification in descendent classes.

Reimplemented from playsingle_controller.

Definition at line 398 of file playmp_controller.cpp.

References _(), play_controller::gui_, and events::chat_handler::MESSAGE_PUBLIC.

◆ handle_generic_event()

void playmp_controller::handle_generic_event ( const std::string &  name)
overrideprotectedvirtual

◆ is_host()

bool playmp_controller::is_host ( ) const
protected

◆ is_networked_mp()

bool playmp_controller::is_networked_mp ( ) const
overridevirtual

Reimplemented from play_controller.

Definition at line 489 of file playmp_controller.cpp.

References mp_info_.

Referenced by playmp_controller::hotkey_handler::can_execute_command().

◆ linger()

void playmp_controller::linger ( )
protected

◆ maybe_linger()

void playmp_controller::maybe_linger ( )
overridevirtual

◆ on_not_observer()

void playmp_controller::on_not_observer ( )
overrideprotectedvirtual

Reimplemented from playsingle_controller.

Definition at line 80 of file playmp_controller.cpp.

References remove_blindfold().

◆ play_human_turn()

void playmp_controller::play_human_turn ( )
overrideprotectedvirtual

◆ play_idle_loop()

void playmp_controller::play_idle_loop ( )
overrideprotectedvirtual

◆ play_linger_turn()

void playmp_controller::play_linger_turn ( )
protectedvirtual

◆ play_network_turn()

void playmp_controller::play_network_turn ( )
overrideprotectedvirtual

◆ play_slice()

void playmp_controller::play_slice ( bool  is_delay_enabled = true)
overridevirtual

◆ process_network_data()

void playmp_controller::process_network_data ( bool  chat_only = false)
private

◆ process_oos()

void playmp_controller::process_oos ( const std::string &  msg) const
overridevirtual

Asks the user whether to continue on an OOS error.

Exceptions
quit_game_exceptionIf the user wants to abort.

Reimplemented from play_controller.

Definition at line 348 of file playmp_controller.cpp.

References _(), config::add_child(), i, play_controller::ignore_replay_errors_, lg::info(), save(), savegame::savegame::save_game_interactive(), play_controller::saved_game_, send_to_wesnothd(), utils::split(), and savegame::savegame::YES_NO.

◆ pull_remote_choice()

void playmp_controller::pull_remote_choice ( )
overridevirtual

◆ receive_from_wesnothd()

bool playmp_controller::receive_from_wesnothd ( config cfg) const
overridevirtual

Reimplemented from play_controller.

Definition at line 500 of file playmp_controller.cpp.

References mp_campaign_info::connection, mp_info_, and wesnothd_connection::receive_data().

Referenced by wait_for_upload().

◆ remove_blindfold()

void playmp_controller::remove_blindfold ( )
protected

◆ reset_end_scenario_button()

void playmp_controller::reset_end_scenario_button ( )
private

Definition at line 218 of file playmp_controller.cpp.

References play_controller::gui_, and game_display::RUNNING.

Referenced by linger().

◆ send_to_wesnothd()

void playmp_controller::send_to_wesnothd ( const config cfg,
const std::string &  packet_type = "unknown" 
) const
overridevirtual

Reimplemented from play_controller.

Definition at line 494 of file playmp_controller.cpp.

References mp_campaign_info::connection, mp_info_, and wesnothd_connection::send_data().

Referenced by process_oos().

◆ send_user_choice()

void playmp_controller::send_user_choice ( )
overridevirtual

Implements syncmp_handler.

Definition at line 444 of file playmp_controller.cpp.

References turn_info::send_data(), and playsingle_controller::turn_data_.

◆ set_end_scenario_button()

void playmp_controller::set_end_scenario_button ( )
private

Definition at line 206 of file playmp_controller.cpp.

References play_controller::gui_, and is_host().

Referenced by linger().

◆ start_network()

void playmp_controller::start_network ( )
protected

◆ stop_network()

void playmp_controller::stop_network ( )
protected

◆ surrender()

void playmp_controller::surrender ( int  side_number)

◆ wait_for_upload()

void playmp_controller::wait_for_upload ( )
protected

Member Data Documentation

◆ blindfold_

blindfold playmp_controller::blindfold_
protected

Definition at line 68 of file playmp_controller.hpp.

Referenced by playmp_controller(), and remove_blindfold().

◆ mp_info_

mp_campaign_info* playmp_controller::mp_info_
private

◆ network_processing_stopped_

bool playmp_controller::network_processing_stopped_
mutableprotected

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