diff options
Diffstat (limited to 'editor')
-rw-r--r-- | editor/debugger/editor_debugger_node.cpp | 2 | ||||
-rw-r--r-- | editor/editor_node.cpp | 2 | ||||
-rw-r--r-- | editor/editor_undo_redo_manager.cpp | 40 | ||||
-rw-r--r-- | editor/editor_undo_redo_manager.h | 1 | ||||
-rw-r--r-- | editor/plugins/packed_scene_editor_plugin.cpp | 81 | ||||
-rw-r--r-- | editor/plugins/packed_scene_editor_plugin.h | 68 | ||||
-rw-r--r-- | editor/register_editor_types.cpp | 2 |
7 files changed, 191 insertions, 5 deletions
diff --git a/editor/debugger/editor_debugger_node.cpp b/editor/debugger/editor_debugger_node.cpp index 610f467faa..0a0f0cf90a 100644 --- a/editor/debugger/editor_debugger_node.cpp +++ b/editor/debugger/editor_debugger_node.cpp @@ -36,6 +36,7 @@ #include "editor/editor_log.h" #include "editor/editor_node.h" #include "editor/editor_settings.h" +#include "editor/editor_undo_redo_manager.h" #include "editor/inspector_dock.h" #include "editor/plugins/editor_debugger_plugin.h" #include "editor/plugins/script_editor_plugin.h" @@ -274,6 +275,7 @@ void EditorDebuggerNode::stop(bool p_force) { }); _break_state_changed(); breakpoints.clear(); + EditorNode::get_undo_redo()->clear_history(false, EditorUndoRedoManager::REMOTE_HISTORY); set_process(false); } diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp index 463e8f6bdc..4c3c9973cb 100644 --- a/editor/editor_node.cpp +++ b/editor/editor_node.cpp @@ -437,8 +437,6 @@ void EditorNode::_update_from_settings() { bool glow_bicubic = int(GLOBAL_GET("rendering/environment/glow/upscale_mode")) > 0; RS::get_singleton()->environment_set_ssil_quality(RS::EnvironmentSSILQuality(int(GLOBAL_GET("rendering/environment/ssil/quality"))), GLOBAL_GET("rendering/environment/ssil/half_size"), GLOBAL_GET("rendering/environment/ssil/adaptive_target"), GLOBAL_GET("rendering/environment/ssil/blur_passes"), GLOBAL_GET("rendering/environment/ssil/fadeout_from"), GLOBAL_GET("rendering/environment/ssil/fadeout_to")); RS::get_singleton()->environment_glow_set_use_bicubic_upscale(glow_bicubic); - bool glow_high_quality = GLOBAL_GET("rendering/environment/glow/use_high_quality"); - RS::get_singleton()->environment_glow_set_use_high_quality(glow_high_quality); RS::EnvironmentSSRRoughnessQuality ssr_roughness_quality = RS::EnvironmentSSRRoughnessQuality(int(GLOBAL_GET("rendering/environment/screen_space_reflection/roughness_quality"))); RS::get_singleton()->environment_set_ssr_roughness_quality(ssr_roughness_quality); RS::SubSurfaceScatteringQuality sss_quality = RS::SubSurfaceScatteringQuality(int(GLOBAL_GET("rendering/environment/subsurface_scattering/subsurface_scattering_quality"))); diff --git a/editor/editor_undo_redo_manager.cpp b/editor/editor_undo_redo_manager.cpp index 4bfa9b686c..ab33b2d051 100644 --- a/editor/editor_undo_redo_manager.cpp +++ b/editor/editor_undo_redo_manager.cpp @@ -33,6 +33,7 @@ #include "core/io/resource.h" #include "core/os/os.h" #include "core/templates/local_vector.h" +#include "editor/debugger/editor_debugger_inspector.h" #include "editor/debugger/editor_debugger_node.h" #include "editor/editor_log.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 history_id = INVALID_HISTORY; + if (Object::cast_to<EditorDebuggerRemoteObject>(p_object)) { + return REMOTE_HISTORY; + } + if (Node *node = Object::cast_to<Node>(p_object)) { Node *edited_scene = EditorNode::get_singleton()->get_edited_scene(); @@ -278,6 +283,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()); if (!history.undo_stack.is_empty() && history.undo_stack.back()->get().timestamp > global_timestamp) { selected_history = history.id; @@ -323,6 +336,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()); if (!history.redo_stack.is_empty() && history.redo_stack.back()->get().timestamp < global_timestamp) { selected_history = history.id; @@ -367,7 +388,7 @@ bool EditorUndoRedoManager::is_history_unsaved(int p_id) { bool EditorUndoRedoManager::has_undo() { 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; } } @@ -376,7 +397,7 @@ bool EditorUndoRedoManager::has_undo() { bool EditorUndoRedoManager::has_redo() { 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; } } @@ -385,7 +406,11 @@ bool EditorUndoRedoManager::has_redo() { void EditorUndoRedoManager::clear_history(bool p_increase_version, int p_idx) { 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) { set_history_as_saved(p_idx); } @@ -415,6 +440,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()); if (!history.undo_stack.is_empty() && history.undo_stack.back()->get().timestamp > global_timestamp) { selected_history = &history; @@ -477,6 +510,7 @@ void EditorUndoRedoManager::_bind_methods() { ADD_SIGNAL(MethodInfo("version_changed")); BIND_ENUM_CONSTANT(GLOBAL_HISTORY); + BIND_ENUM_CONSTANT(REMOTE_HISTORY); BIND_ENUM_CONSTANT(INVALID_HISTORY); } diff --git a/editor/editor_undo_redo_manager.h b/editor/editor_undo_redo_manager.h index 60bcd059df..08482b6e2d 100644 --- a/editor/editor_undo_redo_manager.h +++ b/editor/editor_undo_redo_manager.h @@ -41,6 +41,7 @@ class EditorUndoRedoManager : public RefCounted { public: enum SpecialHistory { GLOBAL_HISTORY = 0, + REMOTE_HISTORY = -9, INVALID_HISTORY = -99, }; diff --git a/editor/plugins/packed_scene_editor_plugin.cpp b/editor/plugins/packed_scene_editor_plugin.cpp new file mode 100644 index 0000000000..0a1b96dccb --- /dev/null +++ b/editor/plugins/packed_scene_editor_plugin.cpp @@ -0,0 +1,81 @@ +/*************************************************************************/ +/* packed_scene_editor_plugin.cpp */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* https://godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */ +/* */ +/* Permission is hereby granted, free of charge, to any person obtaining */ +/* a copy of this software and associated documentation files (the */ +/* "Software"), to deal in the Software without restriction, including */ +/* without limitation the rights to use, copy, modify, merge, publish, */ +/* distribute, sublicense, and/or sell copies of the Software, and to */ +/* permit persons to whom the Software is furnished to do so, subject to */ +/* the following conditions: */ +/* */ +/* The above copyright notice and this permission notice shall be */ +/* included in all copies or substantial portions of the Software. */ +/* */ +/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ +/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ +/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ +/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ +/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ +/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ +/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +/*************************************************************************/ + +#include "packed_scene_editor_plugin.h" + +#include "editor/editor_node.h" +#include "scene/gui/button.h" +#include "scene/resources/packed_scene.h" +#include "scene/scene_string_names.h" + +void PackedSceneEditor::_on_open_scene_pressed() { + // Using deferred call because changing scene updates the Inspector and thus destroys this plugin. + callable_mp(EditorNode::get_singleton(), &EditorNode::open_request).call_deferred(packed_scene->get_path()); +} + +void PackedSceneEditor::_notification(int p_what) { + switch (p_what) { + case NOTIFICATION_ENTER_TREE: + case NOTIFICATION_THEME_CHANGED: { + open_scene_button->set_icon(get_theme_icon(SNAME("PackedScene"), SNAME("EditorIcons"))); + } break; + } +} + +PackedSceneEditor::PackedSceneEditor(Ref<PackedScene> &p_packed_scene) { + packed_scene = p_packed_scene; + + open_scene_button = EditorInspector::create_inspector_action_button(TTR("Open Scene")); + open_scene_button->connect(SNAME("pressed"), callable_mp(this, &PackedSceneEditor::_on_open_scene_pressed)); + open_scene_button->set_disabled(!packed_scene->get_path().get_file().is_valid_filename()); + add_child(open_scene_button); + + add_child(memnew(Control)); // Add padding before the regular properties. +} + +/////////////////////// + +bool EditorInspectorPluginPackedScene::can_handle(Object *p_object) { + return Object::cast_to<PackedScene>(p_object) != nullptr; +} + +void EditorInspectorPluginPackedScene::parse_begin(Object *p_object) { + Ref<PackedScene> packed_scene(p_object); + PackedSceneEditor *editor = memnew(PackedSceneEditor(packed_scene)); + add_custom_control(editor); +} + +/////////////////////// + +PackedSceneEditorPlugin::PackedSceneEditorPlugin() { + Ref<EditorInspectorPluginPackedScene> plugin; + plugin.instantiate(); + add_inspector_plugin(plugin); +} diff --git a/editor/plugins/packed_scene_editor_plugin.h b/editor/plugins/packed_scene_editor_plugin.h new file mode 100644 index 0000000000..0912030180 --- /dev/null +++ b/editor/plugins/packed_scene_editor_plugin.h @@ -0,0 +1,68 @@ +/*************************************************************************/ +/* packed_scene_editor_plugin.h */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* https://godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */ +/* */ +/* Permission is hereby granted, free of charge, to any person obtaining */ +/* a copy of this software and associated documentation files (the */ +/* "Software"), to deal in the Software without restriction, including */ +/* without limitation the rights to use, copy, modify, merge, publish, */ +/* distribute, sublicense, and/or sell copies of the Software, and to */ +/* permit persons to whom the Software is furnished to do so, subject to */ +/* the following conditions: */ +/* */ +/* The above copyright notice and this permission notice shall be */ +/* included in all copies or substantial portions of the Software. */ +/* */ +/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ +/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ +/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ +/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ +/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ +/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ +/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +/*************************************************************************/ + +#ifndef PACKED_SCENE_EDITOR_PLUGIN_H +#define PACKED_SCENE_EDITOR_PLUGIN_H + +#include "editor/editor_inspector.h" +#include "editor/editor_plugin.h" +#include "scene/gui/box_container.h" + +class PackedSceneEditor : public VBoxContainer { + GDCLASS(PackedSceneEditor, VBoxContainer); + + Ref<PackedScene> packed_scene; + Button *open_scene_button; + + void _on_open_scene_pressed(); + +protected: + void _notification(int p_what); + +public: + PackedSceneEditor(Ref<PackedScene> &p_packed_scene); +}; + +class EditorInspectorPluginPackedScene : public EditorInspectorPlugin { + GDCLASS(EditorInspectorPluginPackedScene, EditorInspectorPlugin); + +public: + virtual bool can_handle(Object *p_object) override; + virtual void parse_begin(Object *p_object) override; +}; + +class PackedSceneEditorPlugin : public EditorPlugin { + GDCLASS(PackedSceneEditorPlugin, EditorPlugin); + +public: + PackedSceneEditorPlugin(); +}; + +#endif // PACKED_SCENE_EDITOR_PLUGIN_H diff --git a/editor/register_editor_types.cpp b/editor/register_editor_types.cpp index f301ff5c6b..247d5e1717 100644 --- a/editor/register_editor_types.cpp +++ b/editor/register_editor_types.cpp @@ -79,6 +79,7 @@ #include "editor/plugins/navigation_polygon_editor_plugin.h" #include "editor/plugins/node_3d_editor_gizmos.h" #include "editor/plugins/occluder_instance_3d_editor_plugin.h" +#include "editor/plugins/packed_scene_editor_plugin.h" #include "editor/plugins/path_2d_editor_plugin.h" #include "editor/plugins/path_3d_editor_plugin.h" #include "editor/plugins/physical_bone_3d_editor_plugin.h" @@ -175,6 +176,7 @@ void register_editor_types() { EditorPlugins::add_by_type<MeshLibraryEditorPlugin>(); EditorPlugins::add_by_type<MultiMeshEditorPlugin>(); EditorPlugins::add_by_type<OccluderInstance3DEditorPlugin>(); + EditorPlugins::add_by_type<PackedSceneEditorPlugin>(); EditorPlugins::add_by_type<Path3DEditorPlugin>(); EditorPlugins::add_by_type<PhysicalBone3DEditorPlugin>(); EditorPlugins::add_by_type<Polygon3DEditorPlugin>(); |