fix [on_undo] in menu items and custom_command

also fixes menu items beeing marked as undoabel even if they used the
synced rng.
This commit is contained in:
gfgtdf 2018-04-29 20:25:11 +02:00
parent fd370f5b95
commit 55065e10d4
3 changed files with 12 additions and 2 deletions

View file

@ -107,6 +107,8 @@ undo_action_base * undo_list::create_action(const config & cfg)
else if ( str == "update_shroud" )
res = new undo::update_shroud_action();
else if ( str == "dummy" )
res = new undo_dummy_action(cfg);
else
{
// Unrecognized type.

View file

@ -101,6 +101,7 @@ namespace actions {
/// Undoes this action.
virtual bool undo(int)
{
execute_undo_umc_wml();
return true;
}
};

View file

@ -336,7 +336,7 @@ SYNCED_COMMAND_HANDLER_FUNCTION(fire_event, child, use_undo, /*show*/, /*error_
// Not clearing the undo stack here causes OOS because we added an entry to the replay but no entry to the undo stack.
if(use_undo) {
if(!undoable) {
if(!undoable || !synced_context::can_undo()) {
resources::undo_stack->clear();
} else {
resources::undo_stack->add_dummy();
@ -345,10 +345,17 @@ SYNCED_COMMAND_HANDLER_FUNCTION(fire_event, child, use_undo, /*show*/, /*error_
return true;
}
SYNCED_COMMAND_HANDLER_FUNCTION(custom_command, child, /*use_undo*/, /*show*/, /*error_handler*/)
SYNCED_COMMAND_HANDLER_FUNCTION(custom_command, child, use_undo, /*show*/, /*error_handler*/)
{
assert(resources::lua_kernel);
resources::lua_kernel->custom_command(child["name"], child.child_or_empty("data"));
if(use_undo) {
if(!synced_context::can_undo()) {
resources::undo_stack->clear();
} else {
resources::undo_stack->add_dummy();
}
}
return true;
}