Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't paste nodes as sibling of scene root #81673

Merged
merged 1 commit into from
Sep 15, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions editor/scene_tree_dock.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2981,7 +2981,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();
}
Expand Down Expand Up @@ -3380,12 +3383,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.
YuriSizov marked this conversation as resolved.
Show resolved Hide resolved
}

paste_sibling = paste_parent;
paste_parent = paste_parent->get_parent();
}

Expand All @@ -3399,7 +3409,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);
}
Expand Down