diff options
author | Yuri Sizov <yuris@humnom.net> | 2023-09-15 19:48:44 +0200 |
---|---|---|
committer | Yuri Sizov <yuris@humnom.net> | 2023-09-15 19:48:44 +0200 |
commit | fa31a9fe2a27e4a571a815c99816ff8965b95be9 (patch) | |
tree | 16e567806163a4deaad67359eb691a4c6dbbd4de | |
parent | 51a196ef5bc3f15b1acb9be9aa6ac8b81bcf796b (diff) | |
parent | 4778b53da9e26db966073a0a3123a3aa4acb9337 (diff) | |
download | redot-engine-fa31a9fe2a27e4a571a815c99816ff8965b95be9.tar.gz |
Merge pull request #81673 from KoBeWi/only_child
Don't paste nodes as sibling of scene root
-rw-r--r-- | editor/scene_tree_dock.cpp | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/editor/scene_tree_dock.cpp b/editor/scene_tree_dock.cpp index a83f7c5ceb..118d512905 100644 --- a/editor/scene_tree_dock.cpp +++ b/editor/scene_tree_dock.cpp @@ -2977,7 +2977,10 @@ void SceneTreeDock::_tree_rmb(const Vector2 &p_menu_pos) { menu->add_icon_shortcut(get_editor_theme_icon(SNAME("ActionCopy")), ED_GET_SHORTCUT("scene_tree/copy_node"), TOOL_COPY); if (selection.size() == 1 && !node_clipboard.is_empty()) { menu->add_icon_shortcut(get_editor_theme_icon(SNAME("ActionPaste")), ED_GET_SHORTCUT("scene_tree/paste_node"), TOOL_PASTE); - menu->add_icon_shortcut(get_editor_theme_icon(SNAME("ActionPaste")), ED_GET_SHORTCUT("scene_tree/paste_node_as_sibling"), TOOL_PASTE); + menu->add_icon_shortcut(get_editor_theme_icon(SNAME("ActionPaste")), ED_GET_SHORTCUT("scene_tree/paste_node_as_sibling"), TOOL_PASTE_AS_SIBLING); + if (selection.front()->get() == edited_scene) { + menu->set_item_disabled(-1, true); + } } menu->add_separator(); } @@ -3376,12 +3379,19 @@ List<Node *> SceneTreeDock::paste_nodes(bool p_paste_as_sibling) { } Node *paste_parent = edited_scene; + Node *paste_sibling = nullptr; + List<Node *> selection = editor_selection->get_selected_node_list(); if (selection.size() > 0) { paste_parent = selection.back()->get(); } if (p_paste_as_sibling) { + if (paste_parent == edited_scene) { + return pasted_nodes; // Don't paste as sibling of scene root. + } + + paste_sibling = paste_parent; paste_parent = paste_parent->get_parent(); } @@ -3395,7 +3405,7 @@ List<Node *> SceneTreeDock::paste_nodes(bool p_paste_as_sibling) { EditorUndoRedoManager *ur = EditorUndoRedoManager::get_singleton(); if (paste_parent) { - ur->create_action(vformat(p_paste_as_sibling ? TTR("Paste Node(s) as Sibling of %s") : TTR("Paste Node(s) as Child of %s"), paste_parent->get_name()), UndoRedo::MERGE_DISABLE, edited_scene); + ur->create_action(vformat(p_paste_as_sibling ? TTR("Paste Node(s) as Sibling of %s") : TTR("Paste Node(s) as Child of %s"), paste_sibling ? paste_sibling->get_name() : paste_parent->get_name()), UndoRedo::MERGE_DISABLE, edited_scene); } else { ur->create_action(TTR("Paste Node(s) as Root"), UndoRedo::MERGE_DISABLE, edited_scene); } |