1
0
mirror of https://github.com/godotengine/godot.git synced 2025-11-04 12:00:25 +00:00

Add EditorUndoRedoManager singleton

This commit is contained in:
kobewi
2022-12-23 23:53:16 +01:00
parent 91fedb60de
commit b58111588a
89 changed files with 551 additions and 546 deletions

View File

@@ -39,6 +39,8 @@
#include "editor/editor_node.h"
#include "scene/main/node.h"
EditorUndoRedoManager *EditorUndoRedoManager::singleton = nullptr;
EditorUndoRedoManager::History &EditorUndoRedoManager::get_or_create_history(int p_idx) {
if (!history_map.has(p_idx)) {
History history;
@@ -503,6 +505,16 @@ void EditorUndoRedoManager::_bind_methods() {
BIND_ENUM_CONSTANT(INVALID_HISTORY);
}
EditorUndoRedoManager *EditorUndoRedoManager::get_singleton() {
return singleton;
}
EditorUndoRedoManager::EditorUndoRedoManager() {
if (!singleton) {
singleton = this;
}
}
EditorUndoRedoManager::~EditorUndoRedoManager() {
for (const KeyValue<int, History> &E : history_map) {
discard_history(E.key, false);