summaryrefslogtreecommitdiff
path: root/editor/scene_tree_dock.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'editor/scene_tree_dock.cpp')
-rw-r--r--editor/scene_tree_dock.cpp54
1 files changed, 30 insertions, 24 deletions
diff --git a/editor/scene_tree_dock.cpp b/editor/scene_tree_dock.cpp
index 4a59eb4fb3..def97345aa 100644
--- a/editor/scene_tree_dock.cpp
+++ b/editor/scene_tree_dock.cpp
@@ -47,10 +47,13 @@
#include "editor/plugins/script_editor_plugin.h"
#include "editor/shader_create_dialog.h"
#include "scene/main/window.h"
+#include "scene/property_utils.h"
#include "scene/resources/packed_scene.h"
#include "servers/display_server.h"
#include "servers/rendering_server.h"
+#include "modules/modules_enabled.gen.h" // For regex.
+
void SceneTreeDock::_nodes_drag_begin() {
if (restore_script_editor_on_drag) {
EditorNode::get_singleton()->set_visible_editor(EditorNode::EDITOR_SCRIPT);
@@ -213,7 +216,7 @@ void SceneTreeDock::_perform_instantiate_scenes(const Vector<String> &p_files, N
for (int i = 0; i < instances.size(); i++) {
Node *instantiated_scene = instances[i];
- editor_data->get_undo_redo().add_do_method(parent, "add_child", instantiated_scene);
+ editor_data->get_undo_redo().add_do_method(parent, "add_child", instantiated_scene, true);
if (p_pos >= 0) {
editor_data->get_undo_redo().add_do_method(parent, "move_child", instantiated_scene, p_pos + i);
}
@@ -258,8 +261,8 @@ void SceneTreeDock::_replace_with_branch_scene(const String &p_file, Node *base)
int pos = base->get_index();
undo_redo->add_do_method(parent, "remove_child", base);
undo_redo->add_undo_method(parent, "remove_child", instantiated_scene);
- undo_redo->add_do_method(parent, "add_child", instantiated_scene);
- undo_redo->add_undo_method(parent, "add_child", base);
+ undo_redo->add_do_method(parent, "add_child", instantiated_scene, true);
+ undo_redo->add_undo_method(parent, "add_child", base, true);
undo_redo->add_do_method(parent, "move_child", instantiated_scene, pos);
undo_redo->add_undo_method(parent, "move_child", base, pos);
@@ -511,7 +514,7 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) {
ERR_CONTINUE(!dup);
- editor_data->get_undo_redo().add_do_method(paste_parent, "add_child", dup);
+ editor_data->get_undo_redo().add_do_method(paste_parent, "add_child", dup, true);
for (KeyValue<const Node *, Node *> &E2 : duplimap) {
Node *d = E2.value;
@@ -813,7 +816,7 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) {
editor_data->get_undo_redo().create_action(TTR("Make node as Root"));
editor_data->get_undo_redo().add_do_method(node->get_parent(), "remove_child", node);
editor_data->get_undo_redo().add_do_method(editor, "set_edited_scene", node);
- editor_data->get_undo_redo().add_do_method(node, "add_child", root);
+ editor_data->get_undo_redo().add_do_method(node, "add_child", root, true);
editor_data->get_undo_redo().add_do_method(node, "set_scene_file_path", root->get_scene_file_path());
editor_data->get_undo_redo().add_do_method(root, "set_scene_file_path", String());
editor_data->get_undo_redo().add_do_method(node, "set_owner", (Object *)nullptr);
@@ -824,7 +827,7 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) {
editor_data->get_undo_redo().add_undo_method(node, "set_scene_file_path", String());
editor_data->get_undo_redo().add_undo_method(node, "remove_child", root);
editor_data->get_undo_redo().add_undo_method(editor, "set_edited_scene", root);
- editor_data->get_undo_redo().add_undo_method(node->get_parent(), "add_child", node);
+ editor_data->get_undo_redo().add_undo_method(node->get_parent(), "add_child", node, true);
editor_data->get_undo_redo().add_undo_method(node->get_parent(), "move_child", node, node->get_index());
editor_data->get_undo_redo().add_undo_method(root, "set_owner", (Object *)nullptr);
editor_data->get_undo_redo().add_undo_method(node, "set_owner", root);
@@ -1785,7 +1788,7 @@ void SceneTreeDock::_do_reparent(Node *p_new_parent, int p_position_in_parent, V
}
editor_data->get_undo_redo().add_do_method(node->get_parent(), "remove_child", node);
- editor_data->get_undo_redo().add_do_method(new_parent, "add_child", node);
+ editor_data->get_undo_redo().add_do_method(new_parent, "add_child", node, true);
if (p_position_in_parent >= 0) {
editor_data->get_undo_redo().add_do_method(new_parent, "move_child", node, p_position_in_parent + inc);
@@ -1858,7 +1861,7 @@ void SceneTreeDock::_do_reparent(Node *p_new_parent, int p_position_in_parent, V
int child_pos = node->get_index();
- editor_data->get_undo_redo().add_undo_method(node->get_parent(), "add_child", node);
+ editor_data->get_undo_redo().add_undo_method(node->get_parent(), "add_child", node, true);
editor_data->get_undo_redo().add_undo_method(node->get_parent(), "move_child", node, child_pos);
editor_data->get_undo_redo().add_undo_method(this, "_set_owners", edited_scene, owners);
if (AnimationPlayerEditor::get_singleton()->get_track_editor()->get_root() == node) {
@@ -2071,7 +2074,7 @@ void SceneTreeDock::_delete_confirm(bool p_cut) {
}
editor_data->get_undo_redo().add_do_method(n->get_parent(), "remove_child", n);
- editor_data->get_undo_redo().add_undo_method(n->get_parent(), "add_child", n);
+ editor_data->get_undo_redo().add_undo_method(n->get_parent(), "add_child", n, true);
editor_data->get_undo_redo().add_undo_method(n->get_parent(), "move_child", n, n->get_index());
if (AnimationPlayerEditor::get_singleton()->get_track_editor()->get_root() == n) {
editor_data->get_undo_redo().add_undo_method(AnimationPlayerEditor::get_singleton()->get_track_editor(), "set_root", n);
@@ -2153,7 +2156,7 @@ void SceneTreeDock::_do_create(Node *p_parent) {
editor_data->get_undo_redo().create_action(TTR("Create Node"));
if (edited_scene) {
- editor_data->get_undo_redo().add_do_method(p_parent, "add_child", child);
+ editor_data->get_undo_redo().add_do_method(p_parent, "add_child", child, true);
editor_data->get_undo_redo().add_do_method(child, "set_owner", edited_scene);
editor_data->get_undo_redo().add_do_method(editor_selection, "clear");
editor_data->get_undo_redo().add_do_method(editor_selection, "add_node", child);
@@ -2943,7 +2946,7 @@ void SceneTreeDock::open_script_dialog(Node *p_for_node, bool p_extend) {
}
}
-void SceneTreeDock::attach_shader_to_selected() {
+void SceneTreeDock::attach_shader_to_selected(int p_preferred_mode) {
if (selected_shader_material.is_null()) {
return;
}
@@ -2970,13 +2973,13 @@ void SceneTreeDock::attach_shader_to_selected() {
shader_create_dialog->connect("shader_created", callable_mp(this, &SceneTreeDock::_shader_created));
shader_create_dialog->connect("confirmed", callable_mp(this, &SceneTreeDock::_shader_creation_closed));
shader_create_dialog->connect("cancelled", callable_mp(this, &SceneTreeDock::_shader_creation_closed));
- shader_create_dialog->config(path);
+ shader_create_dialog->config(path, true, true, p_preferred_mode);
shader_create_dialog->popup_centered();
}
-void SceneTreeDock::open_shader_dialog(Ref<ShaderMaterial> &p_for_material) {
+void SceneTreeDock::open_shader_dialog(Ref<ShaderMaterial> &p_for_material, int p_preferred_mode) {
selected_shader_material = p_for_material;
- attach_shader_to_selected();
+ attach_shader_to_selected(p_preferred_mode);
}
void SceneTreeDock::open_add_child_dialog() {
@@ -3132,7 +3135,9 @@ void SceneTreeDock::_clear_clipboard() {
void SceneTreeDock::_create_remap_for_node(Node *p_node, Map<RES, RES> &r_remap) {
List<PropertyInfo> props;
p_node->get_property_list(&props);
- bool is_instantiated = EditorPropertyRevert::may_node_be_in_instance(p_node);
+
+ Vector<SceneState::PackState> states_stack;
+ bool states_stack_ready = false;
for (const PropertyInfo &E : props) {
if (!(E.usage & PROPERTY_USAGE_STORAGE)) {
@@ -3143,16 +3148,17 @@ void SceneTreeDock::_create_remap_for_node(Node *p_node, Map<RES, RES> &r_remap)
if (v.is_ref()) {
RES res = v;
if (res.is_valid()) {
- if (is_instantiated) {
- Variant orig;
- if (EditorPropertyRevert::get_instantiated_node_original_property(p_node, E.name, orig)) {
- if (!EditorPropertyRevert::is_node_property_different(p_node, v, orig)) {
- continue;
- }
- }
+ if (!states_stack_ready) {
+ states_stack = PropertyUtils::get_node_states_stack(p_node);
+ states_stack_ready = true;
+ }
+
+ Variant orig = PropertyUtils::get_property_default_value(p_node, E.name, &states_stack);
+ if (!PropertyUtils::is_property_value_different(v, orig)) {
+ continue;
}
- if ((res->get_path() == "" || res->get_path().find("::") > -1) && !r_remap.has(res)) {
+ if (res->is_built_in() && !r_remap.has(res)) {
_create_remap_for_resource(res, r_remap);
}
}
@@ -3179,7 +3185,7 @@ void SceneTreeDock::_create_remap_for_resource(RES p_resource, Map<RES, RES> &r_
if (v.is_ref()) {
RES res = v;
if (res.is_valid()) {
- if ((res->get_path() == "" || res->get_path().find("::") > -1) && !r_remap.has(res)) {
+ if (res->is_built_in() && !r_remap.has(res)) {
_create_remap_for_resource(res, r_remap);
}
}