#include <replay_controller.hpp>
Classes | |
class | replay_stop_condition |
Public Member Functions | |
replay_controller (play_controller &controller, bool control_view, const std::shared_ptr< config > &reset_state, const std::function< void()> &on_end_replay=nop) | |
~replay_controller () | |
void | play_replay () |
void | stop_replay () |
void | replay_next_turn () |
void | replay_next_side () |
void | replay_next_move () |
void | play_side_impl () |
bool | recorder_at_end () const |
bool | should_stop () const |
bool | can_execute_command (const hotkey::ui_command &cmd) const |
bool | is_controlling_view () const |
bool | allow_reset_replay () const |
const std::shared_ptr< config > & | get_reset_state () const |
void | return_to_play_side (bool r=true) |
void | replay_show_everything () |
void | replay_show_each () |
void | replay_show_team1 () |
void | update_teams () |
void | update_viewing_player () |
bool | see_all () |
Public Member Functions inherited from events::observer | |
virtual | ~observer () |
Static Public Member Functions | |
static void | nop () |
Private Types | |
enum | REPLAY_VISION { HUMAN_TEAM , CURRENT_TEAM , SHOW_ALL } |
Private Member Functions | |
void | add_replay_theme () |
void | init () |
void | update_gui () |
void | handle_generic_event (const std::string &name) override |
void | update_enabled_buttons () |
Refresh the states of the replay-control buttons, this will cause the hotkey framework to query can_execute_command() for each button and then set the enabled/disabled state based on that query. More... | |
Private Attributes | |
play_controller & | controller_ |
std::unique_ptr< replay_stop_condition > | stop_condition_ |
events::command_disabler | disabler_ |
utils::optional< REPLAY_VISION > | vision_ |
std::shared_ptr< config > | reset_state_ |
When the "Reset" button is pressed reset the gamestate to this serialized gamestaten, the initial gamestate. More... | |
std::function< void()> | on_end_replay_ |
Called when there are no more moves in the [replay] to process. More... | |
bool | return_to_play_side_ |
Used by unit tests. More... | |
Definition at line 21 of file replay_controller.hpp.
|
private |
Enumerator | |
---|---|
HUMAN_TEAM | |
CURRENT_TEAM | |
SHOW_ALL |
Definition at line 80 of file replay_controller.hpp.
replay_controller::replay_controller | ( | play_controller & | controller, |
bool | control_view, | ||
const std::shared_ptr< config > & | reset_state, | ||
const std::function< void()> & | on_end_replay = nop |
||
) |
Definition at line 64 of file replay_controller.cpp.
References events::generic_event::attach_handler(), controller_, play_controller::get_display(), display::get_theme(), HUMAN_TEAM, display::queue_rerender(), theme::theme_reset_event(), and vision_.
replay_controller::~replay_controller | ( | ) |
Definition at line 79 of file replay_controller.cpp.
References controller_, events::generic_event::detach_handler(), play_controller::get_display(), display::get_theme(), play_controller::is_skipping_replay(), display::queue_rerender(), theme::theme_reset_event(), and play_controller::toggle_skipping_replay().
|
private |
Definition at line 87 of file replay_controller.cpp.
References controller_, play_controller::get_display(), display::get_theme(), theme::get_theme_config(), theme::modify(), config::optional_child(), and play_controller::theme().
Referenced by handle_generic_event().
|
inline |
Definition at line 50 of file replay_controller.hpp.
References reset_state_.
Referenced by can_execute_command().
bool replay_controller::can_execute_command | ( | const hotkey::ui_command & | cmd | ) | const |
Definition at line 197 of file replay_controller.cpp.
References allow_reset_replay(), events::commands_disabled, hotkey::ui_command::hotkey_command, hotkey::HOTKEY_REPLAY_NEXT_MOVE, hotkey::HOTKEY_REPLAY_NEXT_SIDE, hotkey::HOTKEY_REPLAY_NEXT_TURN, hotkey::HOTKEY_REPLAY_PLAY, hotkey::HOTKEY_REPLAY_RESET, hotkey::HOTKEY_REPLAY_SHOW_EACH, hotkey::HOTKEY_REPLAY_SHOW_EVERYTHING, hotkey::HOTKEY_REPLAY_SHOW_TEAM1, hotkey::HOTKEY_REPLAY_SKIP_ANIMATION, hotkey::HOTKEY_REPLAY_STOP, is_controlling_view(), recorder_at_end(), and should_stop().
|
inline |
Definition at line 51 of file replay_controller.hpp.
References reset_state_.
|
overrideprivatevirtual |
Implements events::observer.
Definition at line 139 of file replay_controller.cpp.
References add_replay_theme(), controller_, display::find_action_button(), play_controller::get_display(), and play_controller::is_skipping_replay().
|
private |
|
inline |
Definition at line 47 of file replay_controller.hpp.
References vision_.
Referenced by can_execute_command().
|
inlinestatic |
Definition at line 32 of file replay_controller.hpp.
void replay_controller::play_replay | ( | ) |
Definition at line 123 of file replay_controller.cpp.
References stop_condition_, and update_enabled_buttons().
Referenced by playsingle_controller::hotkey_handler::play_replay().
void replay_controller::play_side_impl | ( | ) |
Definition at line 155 of file replay_controller.cpp.
References controller_, play_controller::current_side(), do_replay(), play_controller::gamestate(), play_controller::is_regular_game_end(), on_end_replay_, controller_base::play_slice(), resources::recorder, REPLAY_FOUND_END_TURN, REPLAY_FOUND_INIT_TURN, return_to_play_side_, stop_condition_, game_state::tod_manager_, tod_manager::turn(), and update_enabled_buttons().
bool replay_controller::recorder_at_end | ( | ) | const |
Definition at line 150 of file replay_controller.cpp.
References replay::at_end(), and resources::recorder.
Referenced by can_execute_command().
void replay_controller::replay_next_move | ( | ) |
Definition at line 116 of file replay_controller.cpp.
References stop_condition_, and update_enabled_buttons().
Referenced by playsingle_controller::hotkey_handler::replay_next_move().
void replay_controller::replay_next_side | ( | ) |
Definition at line 110 of file replay_controller.cpp.
References stop_condition_, and update_enabled_buttons().
Referenced by playsingle_controller::hotkey_handler::replay_next_side().
void replay_controller::replay_next_turn | ( | ) |
Definition at line 104 of file replay_controller.cpp.
References controller_, play_controller::gamestate(), stop_condition_, game_state::tod_manager_, tod_manager::turn(), and update_enabled_buttons().
Referenced by playsingle_controller::hotkey_handler::replay_next_turn().
void replay_controller::replay_show_each | ( | ) |
Definition at line 229 of file replay_controller.cpp.
References CURRENT_TEAM, update_teams(), and vision_.
Referenced by playsingle_controller::hotkey_handler::replay_show_each().
void replay_controller::replay_show_everything | ( | ) |
Definition at line 223 of file replay_controller.cpp.
References SHOW_ALL, update_teams(), and vision_.
Referenced by playsingle_controller::hotkey_handler::replay_show_everything().
void replay_controller::replay_show_team1 | ( | ) |
Definition at line 235 of file replay_controller.cpp.
References HUMAN_TEAM, update_teams(), and vision_.
Referenced by playsingle_controller::hotkey_handler::replay_show_team1().
|
inline |
Definition at line 52 of file replay_controller.hpp.
References return_to_play_side_.
bool replay_controller::see_all | ( | ) |
Definition at line 257 of file replay_controller.cpp.
|
inline |
Definition at line 45 of file replay_controller.hpp.
References stop_condition_.
Referenced by can_execute_command().
void replay_controller::stop_replay | ( | ) |
Definition at line 98 of file replay_controller.cpp.
References stop_condition_, and update_enabled_buttons().
Referenced by playsingle_controller::hotkey_handler::stop_replay().
|
private |
Refresh the states of the replay-control buttons, this will cause the hotkey framework to query can_execute_command() for each button and then set the enabled/disabled state based on that query.
The ids for the associated buttons are: "button-playreplay", "button-stopreplay", "button-resetreplay", "button-nextturn", "button-nextside", and "button-nextmove".
Definition at line 134 of file replay_controller.cpp.
References controller_, play_controller::get_display(), and display::queue_rerender().
Referenced by play_replay(), play_side_impl(), replay_next_move(), replay_next_side(), replay_next_turn(), and stop_replay().
|
private |
Definition at line 129 of file replay_controller.cpp.
References controller_, play_controller::get_display(), and display::queue_rerender().
Referenced by update_teams().
void replay_controller::update_teams | ( | ) |
Definition at line 241 of file replay_controller.cpp.
References controller_, play_controller::get_display(), display::invalidate_all(), update_gui(), and update_viewing_player().
Referenced by replay_show_each(), replay_show_everything(), and replay_show_team1().
void replay_controller::update_viewing_player | ( | ) |
Definition at line 248 of file replay_controller.cpp.
References controller_, play_controller::current_side(), play_controller::find_viewing_side(), HUMAN_TEAM, SHOW_ALL, play_controller::update_gui_to_player(), and vision_.
Referenced by update_teams().
|
private |
Definition at line 76 of file replay_controller.hpp.
Referenced by add_replay_theme(), handle_generic_event(), play_side_impl(), replay_controller(), replay_next_turn(), update_enabled_buttons(), update_gui(), update_teams(), update_viewing_player(), and ~replay_controller().
|
private |
Definition at line 78 of file replay_controller.hpp.
|
private |
Called when there are no more moves in the [replay] to process.
Definition at line 91 of file replay_controller.hpp.
Referenced by play_side_impl().
|
private |
When the "Reset" button is pressed reset the gamestate to this serialized gamestaten, the initial gamestate.
Definition at line 89 of file replay_controller.hpp.
Referenced by allow_reset_replay(), and get_reset_state().
|
private |
Used by unit tests.
Definition at line 93 of file replay_controller.hpp.
Referenced by play_side_impl(), and return_to_play_side().
|
private |
Definition at line 77 of file replay_controller.hpp.
Referenced by play_replay(), play_side_impl(), replay_next_move(), replay_next_side(), replay_next_turn(), should_stop(), and stop_replay().
|
private |
Definition at line 86 of file replay_controller.hpp.
Referenced by is_controlling_view(), replay_controller(), replay_show_each(), replay_show_everything(), replay_show_team1(), see_all(), and update_viewing_player().