The Battle for Wesnoth  1.13.4+dev
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
Public Types | Public Member Functions | Static Public Member Functions | Public Attributes | List of all members
actions::undo_action Struct Referenceabstract

actions that are undoable (this does not include update_shroud and auto_shroud) More...

#include <undo_action.hpp>

Inheritance diagram for actions::undo_action:
Inheritance graph

Public Types

typedef std::vector< undo_eventevent_vector
 actions wml (specified by wml) that should be executed when undoing this command. More...
 

Public Member Functions

 undo_action ()
 Default constructor. More...
 
 undo_action (const config &cfg)
 
virtual ~undo_action ()
 
virtual void write (config &cfg) const
 Writes this into the provided config. More...
 
virtual bool undo (int side)=0
 Undoes this action. More...
 
virtual bool redo (int side)=0
 Redoes this action. More...
 
void execute_undo_umc_wml ()
 
void execute_redo_umc_wml ()
 
- Public Member Functions inherited from actions::undo_action_base
 undo_action_base ()
 Default constructor. More...
 
virtual ~undo_action_base ()
 
virtual const char * get_type () const =0
 

Static Public Member Functions

static void read_event_vector (event_vector &vec, const config &cfg, const std::string &tag)
 
static void write_event_vector (const event_vector &vec, config &cfg, const std::string &tag)
 

Public Attributes

config replay_data
 the replay data to do this action, this is only !empty() when this action is on the redo stack we need this because we don't recalculate the redos like they would be in real game, but even undoable commands can have "dependent" (= user_input) commands, which we save here. More...
 
int unit_id_diff
 the difference in the unit ids TODO: does it really make sense to allow undoing if the unit id counter has changed? More...
 
event_vector umc_commands_undo
 
event_vector umc_commands_redo
 

Detailed Description

actions that are undoable (this does not include update_shroud and auto_shroud)

Definition at line 47 of file undo_action.hpp.

Member Typedef Documentation

actions wml (specified by wml) that should be executed when undoing this command.

Definition at line 74 of file undo_action.hpp.

Constructor & Destructor Documentation

actions::undo_action::undo_action ( )

Default constructor.

It is assumed that undo actions are contructed after the action is performed so that the unit id diff does not change after this contructor.

Definition at line 49 of file undo_action.cpp.

References synced_context::get_redo_commands(), synced_context::get_undo_commands(), redo(), umc_commands_redo, umc_commands_undo, and undo().

actions::undo_action::undo_action ( const config cfg)

Definition at line 65 of file undo_action.cpp.

References read_event_vector(), umc_commands_redo, and umc_commands_undo.

virtual actions::undo_action::~undo_action ( )
inlinevirtual

Definition at line 55 of file undo_action.hpp.

Member Function Documentation

void actions::undo_action::execute_redo_umc_wml ( )
void actions::undo_action::execute_undo_umc_wml ( )
void actions::undo_action::read_event_vector ( event_vector vec,
const config cfg,
const std::string tag 
)
static

Definition at line 157 of file undo_action.cpp.

References config::child_range().

Referenced by undo_action().

virtual bool actions::undo_action::redo ( int  side)
pure virtual

Redoes this action.

Returns
true on success; false on an error.

Implemented in actions::undo_dummy_action, actions::undo::move_action, actions::undo::recall_action, actions::undo::recruit_action, and actions::undo::dismiss_action.

Referenced by undo_action().

virtual bool actions::undo_action::undo ( int  side)
pure virtual

Undoes this action.

Returns
true on success; false on an error.

Implemented in actions::undo_dummy_action, actions::undo::move_action, actions::undo::recall_action, actions::undo::recruit_action, and actions::undo::dismiss_action.

Referenced by undo_action().

void actions::undo_action::write ( config cfg) const
virtual
void actions::undo_action::write_event_vector ( const event_vector vec,
config cfg,
const std::string tag 
)
static

Definition at line 164 of file undo_action.cpp.

References config::add_child().

Referenced by write().

Member Data Documentation

config actions::undo_action::replay_data

the replay data to do this action, this is only !empty() when this action is on the redo stack we need this because we don't recalculate the redos like they would be in real game, but even undoable commands can have "dependent" (= user_input) commands, which we save here.

Definition at line 69 of file undo_action.hpp.

Referenced by actions::undo::dismiss_action::redo(), actions::undo::recruit_action::redo(), actions::undo::recall_action::redo(), actions::undo::move_action::redo(), and write().

event_vector actions::undo_action::umc_commands_redo

Definition at line 76 of file undo_action.hpp.

Referenced by execute_redo_umc_wml(), undo_action(), and write().

event_vector actions::undo_action::umc_commands_undo

Definition at line 75 of file undo_action.hpp.

Referenced by execute_undo_umc_wml(), undo_action(), and write().

int actions::undo_action::unit_id_diff

the difference in the unit ids TODO: does it really make sense to allow undoing if the unit id counter has changed?

Definition at line 72 of file undo_action.hpp.

Referenced by write().


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