diff options
Diffstat (limited to 'editor/scene_tree_dock.cpp')
-rw-r--r-- | editor/scene_tree_dock.cpp | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/editor/scene_tree_dock.cpp b/editor/scene_tree_dock.cpp index a6a014f3bd..45c20121da 100644 --- a/editor/scene_tree_dock.cpp +++ b/editor/scene_tree_dock.cpp @@ -574,6 +574,8 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) { editor_data->get_undo_redo().add_do_method(editor, "set_edited_scene", node); editor_data->get_undo_redo().add_do_method(node, "set_filename", root->get_filename()); editor_data->get_undo_redo().add_do_method(root, "set_filename", String()); + editor_data->get_undo_redo().add_do_method(node, "set_owner", (Object *)NULL); + editor_data->get_undo_redo().add_do_method(root, "set_owner", node); _node_replace_owner(root, root, node, MODE_DO); editor_data->get_undo_redo().add_undo_method(root, "set_filename", root->get_filename()); @@ -581,6 +583,9 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) { 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(root, "set_owner", (Object *)NULL); + editor_data->get_undo_redo().add_undo_method(node, "set_owner", root); + _node_replace_owner(root, root, root, MODE_UNDO); editor_data->get_undo_redo().add_do_method(scene_tree, "update_tree"); @@ -982,7 +987,7 @@ void SceneTreeDock::_notification(int p_what) { void SceneTreeDock::_node_replace_owner(Node *p_base, Node *p_node, Node *p_root, ReplaceOwnerMode p_mode) { - if (p_node->get_owner() == p_base || !p_node->get_owner()) { + if (p_node->get_owner() == p_base && p_node != p_root) { UndoRedo *undo_redo = &editor_data->get_undo_redo(); switch (p_mode) { case MODE_BIDI: { @@ -1608,6 +1613,14 @@ void SceneTreeDock::_delete_confirm() { void SceneTreeDock::_update_script_button() { if (EditorNode::get_singleton()->get_editor_selection()->get_selection().size() == 1) { button_create_script->show(); + Node *n = EditorNode::get_singleton()->get_editor_selection()->get_selected_node_list()[0]; + if (n->get_script().is_null()) { + button_create_script->set_icon(get_icon("ScriptCreate", "EditorIcons")); + button_create_script->set_tooltip(TTR("Attach a new or existing script for the selected node.")); + } else { + button_create_script->set_icon(get_icon("ScriptExtend", "EditorIcons")); + button_create_script->set_tooltip(TTR("Extend the selected node's script with a new or existing script.")); + } } else { button_create_script->hide(); } @@ -2354,7 +2367,6 @@ SceneTreeDock::SceneTreeDock(EditorNode *p_editor, Node *p_scene_root, EditorSel tb = memnew(ToolButton); tb->connect("pressed", this, "_tool_selected", make_binds(TOOL_ATTACH_SCRIPT, false)); - tb->set_tooltip(TTR("Attach a new or existing script for the selected node.")); tb->set_shortcut(ED_GET_SHORTCUT("scene_tree/attach_script")); filter_hbc->add_child(tb); tb->hide(); |