diff options
author | RĂ©mi Verschelde <rverschelde@gmail.com> | 2018-11-20 08:49:17 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-11-20 08:49:17 +0100 |
commit | 16a2c31e53502a076f538acb32031e582912af4b (patch) | |
tree | bbd72406ac577e5c44a9d4725ca9dd1ab33647d7 /core | |
parent | 9c55d6842b0b9ebb51e40822539997528122a700 (diff) | |
parent | 6ba94d5ca03e51a4c10f6d47e12b347a84ecb722 (diff) |
Merge pull request #23812 from YeldhamDev/clear_history_version_optional
Add argument to UndoRedo's "clear_history()" to not increase the version
Diffstat (limited to 'core')
-rw-r--r-- | core/undo_redo.cpp | 7 | ||||
-rw-r--r-- | core/undo_redo.h | 2 |
2 files changed, 5 insertions, 4 deletions
diff --git a/core/undo_redo.cpp b/core/undo_redo.cpp index 6f7c8ea08a..3d41c374ea 100644 --- a/core/undo_redo.cpp +++ b/core/undo_redo.cpp @@ -325,7 +325,7 @@ bool UndoRedo::undo() { return true; } -void UndoRedo::clear_history() { +void UndoRedo::clear_history(bool p_increase_version) { ERR_FAIL_COND(action_level > 0); _discard_redo(); @@ -333,7 +333,8 @@ void UndoRedo::clear_history() { while (actions.size()) _pop_history_tail(); - version++; + if (p_increase_version) + version++; } String UndoRedo::get_current_action_name() const { @@ -493,7 +494,7 @@ void UndoRedo::_bind_methods() { ClassDB::bind_method(D_METHOD("add_undo_property", "object", "property", "value"), &UndoRedo::add_undo_property); ClassDB::bind_method(D_METHOD("add_do_reference", "object"), &UndoRedo::add_do_reference); ClassDB::bind_method(D_METHOD("add_undo_reference", "object"), &UndoRedo::add_undo_reference); - ClassDB::bind_method(D_METHOD("clear_history"), &UndoRedo::clear_history); + ClassDB::bind_method(D_METHOD("clear_history", "increase_version"), &UndoRedo::clear_history, DEFVAL(true)); ClassDB::bind_method(D_METHOD("get_current_action_name"), &UndoRedo::get_current_action_name); ClassDB::bind_method(D_METHOD("get_version"), &UndoRedo::get_version); ClassDB::bind_method(D_METHOD("redo"), &UndoRedo::redo); diff --git a/core/undo_redo.h b/core/undo_redo.h index 22dcd60472..f09fca9a78 100644 --- a/core/undo_redo.h +++ b/core/undo_redo.h @@ -112,7 +112,7 @@ public: bool redo(); bool undo(); String get_current_action_name() const; - void clear_history(); + void clear_history(bool p_increase_version = true); uint64_t get_version() const; |