The Battle for Wesnoth  1.19.5+dev
Classes | Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
playsingle_controller Class Reference

#include <playsingle_controller.hpp>

Inheritance diagram for playsingle_controller:

Classes

class  hotkey_handler
 
struct  ses_result
 

Public Member Functions

 playsingle_controller (const config &level, saved_game &state_of_game)
 
 ~playsingle_controller ()
 Defined here to reduce file includes. More...
 
level_result::type play_scenario (const config &level)
 
void play_scenario_init (const config &level)
 
ses_result skip_empty_sides (int side_num)
 Calculates the current side, starting at side_num that is non-empty. More...
 
void play_some ()
 
void play_side ()
 
void finish_side_turn ()
 
void do_end_level ()
 
void play_scenario_main_loop ()
 
virtual void handle_generic_event (const std::string &name) override
 
virtual void check_objectives () override
 
virtual void on_not_observer () override
 
virtual bool is_host () const
 
virtual void maybe_linger ()
 
void end_turn ()
 
void force_end_turn () override
 
void require_end_turn ()
 
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)
 
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 ()
 
virtual void process_oos (const std::string &msg) const
 Asks the user whether to continue on an OOS error. More...
 
bool reveal_map_default () const
 
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
 
std::vector< team > & get_teams ()
 
const std::vector< team > & get_teams () const
 
const unit_mapget_units () const
 
unit_mapget_units ()
 
const gamemapget_map () const
 
const tod_managerget_tod_manager () 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 ()
 
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 ()
 
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_replay () const
 
replayrecorder () const
 
t_string get_scenario_name () const
 
bool get_disallow_recall () const
 
std::string get_loaded_resources () const
 
std::string theme () const
 
void maybe_throw_return_to_play_side () const
 
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...
 
virtual void send_actions ()
 Sends replay [command]s to the server. More...
 
virtual void receive_actions ()
 Reads and executes replay [command]s from the server. More...
 
virtual bool is_networked_mp () const
 
virtual void send_to_wesnothd (const config &, const std::string &="unknown") const
 
virtual bool receive_from_wesnothd (config &) const
 
void refresh_objectives () const
 Reevaluate [show_if] conditions and build a new objectives string. More...
 
void show_objectives () const
 
saved_gameget_saved_game ()
 
statistics_tstatistics ()
 
bool is_during_turn () const
 
bool is_linger_mode () const
 
- Public Member Functions inherited from controller_base
 controller_base ()
 
virtual ~controller_base ()
 
virtual void play_slice (bool is_delay_enabled=true)
 
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 handle_window_event (const SDL_Event &)
 
virtual void process_event ()
 
virtual bool requires_event_focus (const SDL_Event *=nullptr) const
 
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 ()
 

Protected Member Functions

void play_side_impl ()
 
void before_human_turn ()
 
void show_turn_dialog ()
 
void execute_gotos ()
 
virtual void play_human_turn ()
 
virtual void after_human_turn ()
 
void end_turn_enable (bool enable)
 
void play_ai_turn ()
 
virtual void play_idle_loop ()
 
virtual void do_idle_notification ()
 Will handle sending a networked notification in descendent classes. More...
 
virtual void play_network_turn ()
 Will handle networked turns in descendent classes. More...
 
virtual void init_gui () override
 
void linger ()
 
void update_gui_linger ()
 
void sync_end_turn () override
 
bool is_team_visible (int team_num, bool observer) const
 
int find_viewing_side () const override
 returns 0 if no such team was found. More...
 
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_events ()
 
void finish_turn ()
 
bool enemies_visible () const
 
void enter_textbox ()
 
void textbox_move_vertically (bool up)
 
void tab ()
 
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 ()
 
- 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)
 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...
 
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 (const hotkey::ui_command &cmd) const
 
void long_touch_callback (int x, int y)
 
- 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

const cursor::setter cursor_setter_
 
bool end_turn_requested_
 true iff the user has pressed the end turn button this turn. More...
 
bool ai_fallback_
 true when the current side is actually an ai side but was taken over by a human (usually for debugging purposes), we need this variable to remember to give the ai control back next turn. More...
 
std::unique_ptr< replay_controllerreplay_controller_
 non-null when replay mode in active, is used in singleplayer and for the "back to turn" feature in multiplayer. More...
 
- Protected Attributes inherited from play_controller
std::unique_ptr< game_stategamestate_
 
config level_
 
saved_gamesaved_game_
 
tooltips::manager tooltips_manager_
 
std::shared_ptr< wb::managerwhiteboard_manager_
 
std::unique_ptr< plugins_contextplugins_context_
 
std::unique_ptr< font::floating_label_contextlabels_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< statistics_tstatistics_context_
 
std::unique_ptr< replayreplay_
 
bool skip_replay_
 
bool skip_story_
 
bool did_autosave_this_turn_
 Whether we did init sides in this session (false = we did init sides before we reloaded the game). More...
 
bool did_tod_sound_this_turn_
 
map_location map_start_
 
bool start_faded_
 
bool ignore_replay_errors_
 
bool player_type_changed_
 true when the controller of the currently playing side has changed. More...
 
- Protected Attributes inherited from controller_base
const game_config_viewgame_config_
 
CKey key_
 
bool scrolling_
 
bool scroll_up_
 
bool scroll_down_
 
bool scroll_left_
 
bool scroll_right_
 
uint32_t last_scroll_tick_
 
double scroll_carry_x_
 
double scroll_carry_y_
 

Additional Inherited Members

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

Detailed Description

Definition at line 46 of file playsingle_controller.hpp.

Constructor & Destructor Documentation

◆ playsingle_controller()

playsingle_controller::playsingle_controller ( const config level,
saved_game state_of_game 
)

◆ ~playsingle_controller()

playsingle_controller::~playsingle_controller ( )
default

Defined here to reduce file includes.

Member Function Documentation

◆ after_human_turn()

void playsingle_controller::after_human_turn ( )
protectedvirtual

Reimplemented in playmp_controller.

Definition at line 653 of file playsingle_controller.cpp.

References play_controller::gui_.

Referenced by playmp_controller::after_human_turn(), and play_side_impl().

◆ before_human_turn()

void playsingle_controller::before_human_turn ( )
protected

◆ check_objectives()

void playsingle_controller::check_objectives ( )
overridevirtual

◆ describe_result()

std::string playsingle_controller::describe_result ( ) const

◆ do_end_level()

void playsingle_controller::do_end_level ( )

◆ do_idle_notification()

void playsingle_controller::do_idle_notification ( )
protectedvirtual

Will handle sending a networked notification in descendent classes.

Reimplemented in playmp_controller.

Definition at line 704 of file playsingle_controller.cpp.

References play_controller::gui_, and events::chat_handler::MESSAGE_PUBLIC.

Referenced by play_side_impl().

◆ enable_replay()

void playsingle_controller::enable_replay ( bool  is_unit_test = false)

◆ end_turn()

void playsingle_controller::end_turn ( )

◆ end_turn_enable()

void playsingle_controller::end_turn_enable ( bool  enable)
protected

◆ execute_gotos()

void playsingle_controller::execute_gotos ( )
protected

◆ find_viewing_side()

int playsingle_controller::find_viewing_side ( ) const
overrideprotectedvirtual

◆ finish_side_turn()

void playsingle_controller::finish_side_turn ( )

◆ force_end_turn()

void playsingle_controller::force_end_turn ( )
overridevirtual

◆ get_player_type_changed()

bool playsingle_controller::get_player_type_changed ( ) const
inline

Definition at line 82 of file playsingle_controller.hpp.

References play_controller::player_type_changed_.

◆ get_replay_controller()

replay_controller* playsingle_controller::get_replay_controller ( ) const
inlineoverridevirtual

◆ handle_generic_event()

void playsingle_controller::handle_generic_event ( const std::string &  name)
overridevirtual

Reimplemented from play_controller.

Reimplemented in playmp_controller.

Definition at line 720 of file playsingle_controller.cpp.

References controller_base::play_slice().

Referenced by playmp_controller::handle_generic_event().

◆ init_gui()

void playsingle_controller::init_gui ( )
overrideprotectedvirtual

◆ is_host()

virtual bool playsingle_controller::is_host ( ) const
inlinevirtual

Reimplemented in playmp_controller.

Definition at line 72 of file playsingle_controller.hpp.

◆ is_team_visible()

bool playsingle_controller::is_team_visible ( int  team_num,
bool  observer 
) const
protected

◆ linger()

void playsingle_controller::linger ( )
protected

◆ maybe_linger()

void playsingle_controller::maybe_linger ( )
virtual

Reimplemented in playmp_controller.

Definition at line 758 of file playsingle_controller.cpp.

References end_turn_requested_, play_controller::is_regular_game_end(), and linger().

Referenced by play_some().

◆ on_not_observer()

virtual void playsingle_controller::on_not_observer ( )
inlineoverridevirtual

Implements play_controller.

Reimplemented in playmp_controller.

Definition at line 71 of file playsingle_controller.hpp.

◆ on_replay_end()

void playsingle_controller::on_replay_end ( bool  is_unit_test)

◆ play_ai_turn()

void playsingle_controller::play_ai_turn ( )
protected

◆ play_human_turn()

void playsingle_controller::play_human_turn ( )
protectedvirtual

◆ play_idle_loop()

void playsingle_controller::play_idle_loop ( )
protectedvirtual

Reimplemented in playmp_controller.

Definition at line 479 of file playsingle_controller.cpp.

References play_controller::play_slice_catch(), and should_return_to_play_side().

Referenced by play_side_impl().

◆ play_network_turn()

void playsingle_controller::play_network_turn ( )
protectedvirtual

Will handle networked turns in descendent classes.

Reimplemented in playmp_controller.

Definition at line 714 of file playsingle_controller.cpp.

References ERR_NG.

Referenced by play_side_impl().

◆ play_scenario()

level_result::type playsingle_controller::play_scenario ( const config level)

◆ play_scenario_init()

void playsingle_controller::play_scenario_init ( const config level)

◆ play_scenario_main_loop()

void playsingle_controller::play_scenario_main_loop ( )

◆ play_side()

void playsingle_controller::play_side ( )

◆ play_side_impl()

void playsingle_controller::play_side_impl ( )
protected

◆ play_some()

void playsingle_controller::play_some ( )

◆ require_end_turn()

void playsingle_controller::require_end_turn ( )

Definition at line 742 of file playsingle_controller.cpp.

References end_turn_requested_.

Referenced by end_turn(), play_ai_turn(), and play_side_impl().

◆ reset_replay()

void playsingle_controller::reset_replay ( )
protected

◆ set_player_type_changed()

void playsingle_controller::set_player_type_changed ( )
inline

Definition at line 83 of file playsingle_controller.hpp.

References play_controller::player_type_changed_.

Referenced by on_replay_end().

◆ should_return_to_play_side()

bool playsingle_controller::should_return_to_play_side ( ) const
overridevirtual

◆ show_turn_dialog()

void playsingle_controller::show_turn_dialog ( )
protected

◆ skip_empty_sides()

playsingle_controller::ses_result playsingle_controller::skip_empty_sides ( int  side_num)

Calculates the current side, starting at side_num that is non-empty.

Returns
side_num: the new side that is non-empty, side_num, if no such side was found. wrapped: whether we wrapped around (usually indicates a new tod turn.) also true if no non-empty side was found.

Definition at line 188 of file playsingle_controller.cpp.

References play_controller::gamestate(), play_controller::get_teams(), and modulo().

Referenced by finish_side_turn(), and play_scenario_init().

◆ sync_end_turn()

void playsingle_controller::sync_end_turn ( )
overrideprotectedvirtual

◆ update_gui_linger()

void playsingle_controller::update_gui_linger ( )
protected

◆ update_viewing_player()

void playsingle_controller::update_viewing_player ( )
overrideprotectedvirtual

Member Data Documentation

◆ ai_fallback_

bool playsingle_controller::ai_fallback_
protected

true when the current side is actually an ai side but was taken over by a human (usually for debugging purposes), we need this variable to remember to give the ai control back next turn.

Definition at line 109 of file playsingle_controller.hpp.

Referenced by play_ai_turn(), and sync_end_turn().

◆ cursor_setter_

const cursor::setter playsingle_controller::cursor_setter_
protected

Definition at line 102 of file playsingle_controller.hpp.

◆ end_turn_requested_

bool playsingle_controller::end_turn_requested_
protected

true iff the user has pressed the end turn button this turn.

(or wants to end linger mode, which is implemented via the same button)

Definition at line 106 of file playsingle_controller.hpp.

Referenced by end_turn(), finish_side_turn(), force_end_turn(), linger(), maybe_linger(), playmp_controller::maybe_linger(), play_human_turn(), playmp_controller::play_human_turn(), play_scenario_main_loop(), play_side_impl(), play_some(), require_end_turn(), should_return_to_play_side(), and sync_end_turn().

◆ replay_controller_

std::unique_ptr<replay_controller> playsingle_controller::replay_controller_
protected

non-null when replay mode in active, is used in singleplayer and for the "back to turn" feature in multiplayer.

Definition at line 111 of file playsingle_controller.hpp.

Referenced by enable_replay(), get_replay_controller(), linger(), playmp_controller::maybe_linger(), on_replay_end(), play_scenario_main_loop(), play_side_impl(), reset_replay(), should_return_to_play_side(), and update_viewing_player().


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