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.cpp59
1 files changed, 44 insertions, 15 deletions
diff --git a/editor/scene_tree_dock.cpp b/editor/scene_tree_dock.cpp
index fe438236c9..be1c4a36bd 100644
--- a/editor/scene_tree_dock.cpp
+++ b/editor/scene_tree_dock.cpp
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2018 Godot Engine contributors (cf. AUTHORS.md) */
+/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2019 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 */
@@ -563,6 +563,20 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) {
if (node == root)
return;
+ //check that from node to root, all owners are right
+
+ if (node->get_owner() != root) {
+ accept->set_text(TTR("Node must belong to the edited scene to become root."));
+ accept->popup_centered_minsize();
+ return;
+ }
+
+ if (node->get_filename() != String()) {
+ accept->set_text(TTR("Instantiated scenes can't become root"));
+ accept->popup_centered_minsize();
+ return;
+ }
+
editor_data->get_undo_redo().create_action("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(root->get_parent(), "remove_child", root);
@@ -1615,7 +1629,10 @@ void SceneTreeDock::_delete_confirm() {
}
void SceneTreeDock::_update_script_button() {
- if (EditorNode::get_singleton()->get_editor_selection()->get_selection().size() == 1) {
+ if (EditorNode::get_singleton()->get_editor_selection()->get_selection().size() == 0) {
+ button_create_script->hide();
+ button_clear_script->hide();
+ } else if (EditorNode::get_singleton()->get_editor_selection()->get_selection().size() == 1) {
Node *n = EditorNode::get_singleton()->get_editor_selection()->get_selected_node_list()[0];
if (n->get_script().is_null()) {
button_create_script->show();
@@ -1626,6 +1643,14 @@ void SceneTreeDock::_update_script_button() {
}
} else {
button_create_script->show();
+ List<Node *> selection = EditorNode::get_singleton()->get_editor_selection()->get_selected_node_list();
+ for (List<Node *>::Element *E = selection.front(); E; E = E->next()) {
+ Node *n = E->get();
+ if (!n->get_script().is_null()) {
+ button_clear_script->show();
+ return;
+ }
+ }
button_clear_script->hide();
}
}
@@ -1726,24 +1751,28 @@ void SceneTreeDock::_create() {
}
}
-void SceneTreeDock::replace_node(Node *p_node, Node *p_by_node) {
+void SceneTreeDock::replace_node(Node *p_node, Node *p_by_node, bool p_keep_properties) {
Node *n = p_node;
Node *newnode = p_by_node;
- Node *default_oldnode = Object::cast_to<Node>(ClassDB::instance(n->get_class()));
- List<PropertyInfo> pinfo;
- n->get_property_list(&pinfo);
- for (List<PropertyInfo>::Element *E = pinfo.front(); E; E = E->next()) {
- if (!(E->get().usage & PROPERTY_USAGE_STORAGE))
- continue;
- if (E->get().name == "__meta__")
- continue;
- if (default_oldnode->get(E->get().name) != n->get(E->get().name)) {
- newnode->set(E->get().name, n->get(E->get().name));
+ if (p_keep_properties) {
+ Node *default_oldnode = Object::cast_to<Node>(ClassDB::instance(n->get_class()));
+ List<PropertyInfo> pinfo;
+ n->get_property_list(&pinfo);
+
+ for (List<PropertyInfo>::Element *E = pinfo.front(); E; E = E->next()) {
+ if (!(E->get().usage & PROPERTY_USAGE_STORAGE))
+ continue;
+ if (E->get().name == "__meta__")
+ continue;
+ if (default_oldnode->get(E->get().name) != n->get(E->get().name)) {
+ newnode->set(E->get().name, n->get(E->get().name));
+ }
}
+
+ memdelete(default_oldnode);
}
- memdelete(default_oldnode);
editor->push_item(NULL);