From 881c8da0a09426f736f65f83dd7098099d33e30b Mon Sep 17 00:00:00 2001 From: kobewi Date: Fri, 15 Jan 2021 20:13:09 +0100 Subject: Unify single and multiscene instancing --- editor/scene_tree_dock.cpp | 28 +++++++--------------------- 1 file changed, 7 insertions(+), 21 deletions(-) diff --git a/editor/scene_tree_dock.cpp b/editor/scene_tree_dock.cpp index bbedb4f033..afacc4ba1f 100644 --- a/editor/scene_tree_dock.cpp +++ b/editor/scene_tree_dock.cpp @@ -57,10 +57,7 @@ void SceneTreeDock::_nodes_drag_begin() { } void SceneTreeDock::_quick_open() { - Vector files = quick_open->get_selected_files(); - for (int i = 0; i < files.size(); i++) { - instance(files[i]); - } + instance_scenes(quick_open->get_selected_files(), scene_tree->get_selected()); } void SceneTreeDock::_input(Ref p_event) { @@ -123,24 +120,9 @@ void SceneTreeDock::_unhandled_key_input(Ref p_event) { } void SceneTreeDock::instance(const String &p_file) { - Node *parent = scene_tree->get_selected(); - - if (!parent) { - parent = edited_scene; - }; - - if (!edited_scene) { - current_option = -1; - accept->set_text(TTR("No parent to instance a child at.")); - accept->popup_centered(); - return; - }; - - ERR_FAIL_COND(!parent); - Vector scenes; scenes.push_back(p_file); - _perform_instance_scenes(scenes, parent, -1); + instance_scenes(scenes, scene_tree->get_selected()); } void SceneTreeDock::instance_scenes(const Vector &p_files, Node *p_parent) { @@ -151,7 +133,11 @@ void SceneTreeDock::instance_scenes(const Vector &p_files, Node *p_paren } if (!parent || !edited_scene) { - accept->set_text(TTR("No parent to instance the scenes at.")); + if (p_files.size() == 1) { + accept->set_text(TTR("No parent to instance a child at.")); + } else { + accept->set_text(TTR("No parent to instance the scenes at.")); + } accept->popup_centered(); return; }; -- cgit v1.2.3