mirror of
https://github.com/wesnoth/wesnoth
synced 2025-05-07 13:20:15 +00:00
fix [allow_undo] in menu event commands
This was disabled in a previous commit
This commit is contained in:
parent
6b28e1ae89
commit
f42ea8097c
@ -162,6 +162,14 @@ void undo_list::add_auto_shroud(bool turned_on)
|
||||
add(new undo::auto_shroud_action(turned_on));
|
||||
}
|
||||
|
||||
void undo_list::add_dummy()
|
||||
{
|
||||
/// @todo: Consecutive shroud actions can be collapsed into one.
|
||||
|
||||
// Do not call add(), as this should not clear the redo stack.
|
||||
add(new undo_dummy_action());
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a dismissal to the undo stack.
|
||||
*/
|
||||
|
@ -51,6 +51,8 @@ public:
|
||||
|
||||
/// Adds an auto-shroud toggle to the undo stack.
|
||||
void add_auto_shroud(bool turned_on);
|
||||
/// Adds an auto-shroud toggle to the undo stack.
|
||||
void add_dummy();
|
||||
/// Adds a dismissal to the undo stack.
|
||||
void add_dismissal(const unit_const_ptr u);
|
||||
/// Adds a move to the undo stack.
|
||||
|
@ -74,4 +74,30 @@ namespace actions {
|
||||
|
||||
int unit_id_diff;
|
||||
};
|
||||
|
||||
/// entry for player actions that do not need any special code to be performed when undoing such as right-click menu items.
|
||||
struct undo_dummy_action : undo_action
|
||||
{
|
||||
undo_dummy_action ()
|
||||
: undo_action()
|
||||
{
|
||||
}
|
||||
explicit undo_dummy_action (const config & cfg)
|
||||
: undo_action(cfg)
|
||||
{
|
||||
}
|
||||
virtual const char* get_type() const { return "dummy"; }
|
||||
virtual ~undo_dummy_action () {};
|
||||
/// Undoes this action.
|
||||
virtual bool undo(int side)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
/// Redoes this action.
|
||||
virtual bool redo(int side)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
}
|
@ -318,7 +318,7 @@ SYNCED_COMMAND_HANDLER_FUNCTION(move, child, use_undo, show, error_handler)
|
||||
return true;
|
||||
}
|
||||
|
||||
SYNCED_COMMAND_HANDLER_FUNCTION(fire_event, child, /*use_undo*/, /*show*/, /*error_handler*/)
|
||||
SYNCED_COMMAND_HANDLER_FUNCTION(fire_event, child, use_undo, /*show*/, /*error_handler*/)
|
||||
{
|
||||
bool undoable = true;
|
||||
|
||||
@ -333,9 +333,15 @@ SYNCED_COMMAND_HANDLER_FUNCTION(fire_event, child, /*use_undo*/, /*show*/, /*er
|
||||
} else {
|
||||
undoable = undoable & !resources::game_events->pump().fire(event_name);
|
||||
}
|
||||
|
||||
// Not clearing the undo stack here casues OOS because we added an entry to the replay but no entry to the undo stack.
|
||||
// if ( !undoable)
|
||||
resources::undo_stack->clear();
|
||||
if(use_undo) {
|
||||
if(!undoable) {
|
||||
resources::undo_stack->clear();
|
||||
} else {
|
||||
resources::undo_stack->add_dummy();
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user