You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-11 13:10:58 +00:00
Add remote history to EditorUndoRedoManager
This commit is contained in:
@@ -123,6 +123,9 @@
|
|||||||
<constant name="GLOBAL_HISTORY" value="0" enum="SpecialHistory">
|
<constant name="GLOBAL_HISTORY" value="0" enum="SpecialHistory">
|
||||||
Global history not associated with any scene, but with external resources etc.
|
Global history not associated with any scene, but with external resources etc.
|
||||||
</constant>
|
</constant>
|
||||||
|
<constant name="REMOTE_HISTORY" value="-9" enum="SpecialHistory">
|
||||||
|
History associated with remote inspector. Used when live editing a running project.
|
||||||
|
</constant>
|
||||||
<constant name="INVALID_HISTORY" value="-99" enum="SpecialHistory">
|
<constant name="INVALID_HISTORY" value="-99" enum="SpecialHistory">
|
||||||
Invalid "null" history. It's a special value, not associated with any object.
|
Invalid "null" history. It's a special value, not associated with any object.
|
||||||
</constant>
|
</constant>
|
||||||
|
|||||||
@@ -36,6 +36,7 @@
|
|||||||
#include "editor/editor_log.h"
|
#include "editor/editor_log.h"
|
||||||
#include "editor/editor_node.h"
|
#include "editor/editor_node.h"
|
||||||
#include "editor/editor_settings.h"
|
#include "editor/editor_settings.h"
|
||||||
|
#include "editor/editor_undo_redo_manager.h"
|
||||||
#include "editor/inspector_dock.h"
|
#include "editor/inspector_dock.h"
|
||||||
#include "editor/plugins/editor_debugger_plugin.h"
|
#include "editor/plugins/editor_debugger_plugin.h"
|
||||||
#include "editor/plugins/script_editor_plugin.h"
|
#include "editor/plugins/script_editor_plugin.h"
|
||||||
@@ -274,6 +275,7 @@ void EditorDebuggerNode::stop(bool p_force) {
|
|||||||
});
|
});
|
||||||
_break_state_changed();
|
_break_state_changed();
|
||||||
breakpoints.clear();
|
breakpoints.clear();
|
||||||
|
EditorNode::get_undo_redo()->clear_history(false, EditorUndoRedoManager::REMOTE_HISTORY);
|
||||||
set_process(false);
|
set_process(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -33,6 +33,7 @@
|
|||||||
#include "core/io/resource.h"
|
#include "core/io/resource.h"
|
||||||
#include "core/os/os.h"
|
#include "core/os/os.h"
|
||||||
#include "core/templates/local_vector.h"
|
#include "core/templates/local_vector.h"
|
||||||
|
#include "editor/debugger/editor_debugger_inspector.h"
|
||||||
#include "editor/debugger/editor_debugger_node.h"
|
#include "editor/debugger/editor_debugger_node.h"
|
||||||
#include "editor/editor_log.h"
|
#include "editor/editor_log.h"
|
||||||
#include "editor/editor_node.h"
|
#include "editor/editor_node.h"
|
||||||
@@ -59,6 +60,10 @@ UndoRedo *EditorUndoRedoManager::get_history_undo_redo(int p_idx) const {
|
|||||||
int EditorUndoRedoManager::get_history_id_for_object(Object *p_object) const {
|
int EditorUndoRedoManager::get_history_id_for_object(Object *p_object) const {
|
||||||
int history_id = INVALID_HISTORY;
|
int history_id = INVALID_HISTORY;
|
||||||
|
|
||||||
|
if (Object::cast_to<EditorDebuggerRemoteObject>(p_object)) {
|
||||||
|
return REMOTE_HISTORY;
|
||||||
|
}
|
||||||
|
|
||||||
if (Node *node = Object::cast_to<Node>(p_object)) {
|
if (Node *node = Object::cast_to<Node>(p_object)) {
|
||||||
Node *edited_scene = EditorNode::get_singleton()->get_edited_scene();
|
Node *edited_scene = EditorNode::get_singleton()->get_edited_scene();
|
||||||
|
|
||||||
@@ -277,6 +282,14 @@ bool EditorUndoRedoManager::undo() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
History &history = get_or_create_history(REMOTE_HISTORY);
|
||||||
|
if (!history.undo_stack.is_empty() && history.undo_stack.back()->get().timestamp > global_timestamp) {
|
||||||
|
selected_history = history.id;
|
||||||
|
global_timestamp = history.undo_stack.back()->get().timestamp;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
History &history = get_or_create_history(EditorNode::get_editor_data().get_current_edited_scene_history_id());
|
History &history = get_or_create_history(EditorNode::get_editor_data().get_current_edited_scene_history_id());
|
||||||
if (!history.undo_stack.is_empty() && history.undo_stack.back()->get().timestamp > global_timestamp) {
|
if (!history.undo_stack.is_empty() && history.undo_stack.back()->get().timestamp > global_timestamp) {
|
||||||
@@ -322,6 +335,14 @@ bool EditorUndoRedoManager::redo() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
History &history = get_or_create_history(REMOTE_HISTORY);
|
||||||
|
if (!history.redo_stack.is_empty() && history.redo_stack.back()->get().timestamp < global_timestamp) {
|
||||||
|
selected_history = history.id;
|
||||||
|
global_timestamp = history.redo_stack.back()->get().timestamp;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
History &history = get_or_create_history(EditorNode::get_editor_data().get_current_edited_scene_history_id());
|
History &history = get_or_create_history(EditorNode::get_editor_data().get_current_edited_scene_history_id());
|
||||||
if (!history.redo_stack.is_empty() && history.redo_stack.back()->get().timestamp < global_timestamp) {
|
if (!history.redo_stack.is_empty() && history.redo_stack.back()->get().timestamp < global_timestamp) {
|
||||||
@@ -367,7 +388,7 @@ bool EditorUndoRedoManager::is_history_unsaved(int p_id) {
|
|||||||
|
|
||||||
bool EditorUndoRedoManager::has_undo() {
|
bool EditorUndoRedoManager::has_undo() {
|
||||||
for (const KeyValue<int, History> &E : history_map) {
|
for (const KeyValue<int, History> &E : history_map) {
|
||||||
if ((E.key == GLOBAL_HISTORY || E.key == EditorNode::get_editor_data().get_current_edited_scene_history_id()) && !E.value.undo_stack.is_empty()) {
|
if ((E.key == GLOBAL_HISTORY || E.key == REMOTE_HISTORY || E.key == EditorNode::get_editor_data().get_current_edited_scene_history_id()) && !E.value.undo_stack.is_empty()) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -376,7 +397,7 @@ bool EditorUndoRedoManager::has_undo() {
|
|||||||
|
|
||||||
bool EditorUndoRedoManager::has_redo() {
|
bool EditorUndoRedoManager::has_redo() {
|
||||||
for (const KeyValue<int, History> &E : history_map) {
|
for (const KeyValue<int, History> &E : history_map) {
|
||||||
if ((E.key == GLOBAL_HISTORY || E.key == EditorNode::get_editor_data().get_current_edited_scene_history_id()) && !E.value.redo_stack.is_empty()) {
|
if ((E.key == GLOBAL_HISTORY || E.key == REMOTE_HISTORY || E.key == EditorNode::get_editor_data().get_current_edited_scene_history_id()) && !E.value.redo_stack.is_empty()) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -385,7 +406,11 @@ bool EditorUndoRedoManager::has_redo() {
|
|||||||
|
|
||||||
void EditorUndoRedoManager::clear_history(bool p_increase_version, int p_idx) {
|
void EditorUndoRedoManager::clear_history(bool p_increase_version, int p_idx) {
|
||||||
if (p_idx != INVALID_HISTORY) {
|
if (p_idx != INVALID_HISTORY) {
|
||||||
get_or_create_history(p_idx).undo_redo->clear_history(p_increase_version);
|
History &history = get_or_create_history(p_idx);
|
||||||
|
history.undo_redo->clear_history(p_increase_version);
|
||||||
|
history.undo_stack.clear();
|
||||||
|
history.redo_stack.clear();
|
||||||
|
|
||||||
if (!p_increase_version) {
|
if (!p_increase_version) {
|
||||||
set_history_as_saved(p_idx);
|
set_history_as_saved(p_idx);
|
||||||
}
|
}
|
||||||
@@ -414,6 +439,14 @@ String EditorUndoRedoManager::get_current_action_name() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
History &history = get_or_create_history(REMOTE_HISTORY);
|
||||||
|
if (!history.undo_stack.is_empty() && history.undo_stack.back()->get().timestamp > global_timestamp) {
|
||||||
|
selected_history = &history;
|
||||||
|
global_timestamp = history.undo_stack.back()->get().timestamp;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
History &history = get_or_create_history(EditorNode::get_editor_data().get_current_edited_scene_history_id());
|
History &history = get_or_create_history(EditorNode::get_editor_data().get_current_edited_scene_history_id());
|
||||||
if (!history.undo_stack.is_empty() && history.undo_stack.back()->get().timestamp > global_timestamp) {
|
if (!history.undo_stack.is_empty() && history.undo_stack.back()->get().timestamp > global_timestamp) {
|
||||||
@@ -477,6 +510,7 @@ void EditorUndoRedoManager::_bind_methods() {
|
|||||||
ADD_SIGNAL(MethodInfo("version_changed"));
|
ADD_SIGNAL(MethodInfo("version_changed"));
|
||||||
|
|
||||||
BIND_ENUM_CONSTANT(GLOBAL_HISTORY);
|
BIND_ENUM_CONSTANT(GLOBAL_HISTORY);
|
||||||
|
BIND_ENUM_CONSTANT(REMOTE_HISTORY);
|
||||||
BIND_ENUM_CONSTANT(INVALID_HISTORY);
|
BIND_ENUM_CONSTANT(INVALID_HISTORY);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -41,6 +41,7 @@ class EditorUndoRedoManager : public RefCounted {
|
|||||||
public:
|
public:
|
||||||
enum SpecialHistory {
|
enum SpecialHistory {
|
||||||
GLOBAL_HISTORY = 0,
|
GLOBAL_HISTORY = 0,
|
||||||
|
REMOTE_HISTORY = -9,
|
||||||
INVALID_HISTORY = -99,
|
INVALID_HISTORY = -99,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user