delete last town is just the inverse of create town
This commit is contained in:
@@ -23,13 +23,13 @@ cAction::~cAction() {}
|
||||
|
||||
void cAction::undo() {
|
||||
UNDO_LOG("Undoing " + actname);
|
||||
if(done && undo_me())
|
||||
if(done && reversed ? redo_me() : undo_me())
|
||||
done = false;
|
||||
}
|
||||
|
||||
void cAction::redo() {
|
||||
UNDO_LOG("Redoing " + actname);
|
||||
if(!done && redo_me())
|
||||
if(!done && reversed ? undo_me() : redo_me())
|
||||
done = true;
|
||||
}
|
||||
|
||||
|
@@ -23,7 +23,9 @@ class cAction {
|
||||
protected:
|
||||
/// Construct a named action
|
||||
/// @param name The name of the action to show in the Edit menu
|
||||
cAction(std::string name) : actname(name) {}
|
||||
cAction(std::string name, bool reversed = false) : actname(name), reversed(reversed) {}
|
||||
/// For actions that have an inverse, this flag inverts the action implementation (i.e. create/delete)
|
||||
bool reversed = true;
|
||||
public:
|
||||
/// Undoes this action if it has not already been undone.
|
||||
/// If it has already been undone, does nothing.
|
||||
|
Reference in New Issue
Block a user