diff options
author | Andrew McDonald <andy@vcmobile.net> | 2018-10-16 22:03:22 -0700 |
---|---|---|
committer | Andrew McDonald <andy@vcmobile.net> | 2018-10-16 22:19:51 -0700 |
commit | 66503465dbf599be4392b71c9f4e146c95b501c0 (patch) | |
tree | 1b9a28d50731e9e2d14f10c1fe78d901d0ade57a | |
parent | 43c28681add010b5daccbcfde3e3065d7be7b52c (diff) |
Use EditorQuickOpen dialog instead of EditorFileDialog when instancing a child scene.
Addresses the bulk of #5180
-rw-r--r-- | editor/scene_tree_dock.cpp | 26 | ||||
-rw-r--r-- | editor/scene_tree_dock.h | 4 |
2 files changed, 16 insertions, 14 deletions
diff --git a/editor/scene_tree_dock.cpp b/editor/scene_tree_dock.cpp index a6a014f3bd..ffe75c38f3 100644 --- a/editor/scene_tree_dock.cpp +++ b/editor/scene_tree_dock.cpp @@ -53,6 +53,13 @@ void SceneTreeDock::_nodes_drag_begin() { } } +void SceneTreeDock::_quick_open() { + Vector<String> files = quick_open->get_selected_files(); + for (int i = 0; i < files.size(); i++) { + instance(files[i]); + } +} + void SceneTreeDock::_input(Ref<InputEvent> p_event) { Ref<InputEventMouseButton> mb = p_event; @@ -319,16 +326,8 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) { break; } - file->set_mode(EditorFileDialog::MODE_OPEN_FILE); - List<String> extensions; - ResourceLoader::get_recognized_extensions_for_type("PackedScene", &extensions); - file->clear_filters(); - for (int i = 0; i < extensions.size(); i++) { - - file->add_filter("*." + extensions[i] + " ; " + extensions[i].to_upper()); - } - - file->popup_centered_ratio(); + quick_open->popup_dialog("PackedScene", true); + quick_open->set_title(TTR("Instance Child Scene")); } break; case TOOL_REPLACE: { @@ -2283,6 +2282,7 @@ void SceneTreeDock::_bind_methods() { ClassDB::bind_method(D_METHOD("_new_scene_from"), &SceneTreeDock::_new_scene_from); ClassDB::bind_method(D_METHOD("_nodes_dragged"), &SceneTreeDock::_nodes_dragged); ClassDB::bind_method(D_METHOD("_files_dropped"), &SceneTreeDock::_files_dropped); + ClassDB::bind_method(D_METHOD("_quick_open"), &SceneTreeDock::_quick_open); ClassDB::bind_method(D_METHOD("_script_dropped"), &SceneTreeDock::_script_dropped); ClassDB::bind_method(D_METHOD("_tree_rmb"), &SceneTreeDock::_tree_rmb); ClassDB::bind_method(D_METHOD("_filter_changed"), &SceneTreeDock::_filter_changed); @@ -2433,9 +2433,9 @@ SceneTreeDock::SceneTreeDock(EditorNode *p_editor, Node *p_scene_root, EditorSel accept = memnew(AcceptDialog); add_child(accept); - file = memnew(EditorFileDialog); - add_child(file); - file->connect("file_selected", this, "instance"); + quick_open = memnew(EditorQuickOpen); + add_child(quick_open); + quick_open->connect("quick_open", this, "_quick_open"); set_process_unhandled_key_input(true); delete_dialog = memnew(ConfirmationDialog); diff --git a/editor/scene_tree_dock.h b/editor/scene_tree_dock.h index eea34a3ec5..3939f4f361 100644 --- a/editor/scene_tree_dock.h +++ b/editor/scene_tree_dock.h @@ -36,6 +36,7 @@ #include "editor/editor_data.h" #include "editor/editor_sub_scene.h" #include "editor/groups_editor.h" +#include "editor/quick_open.h" #include "editor/rename_dialog.h" #include "editor/reparent_dialog.h" #include "editor/script_create_dialog.h" @@ -125,7 +126,7 @@ class SceneTreeDock : public VBoxContainer { ConfirmationDialog *editable_instance_remove_dialog; ReparentDialog *reparent_dialog; - EditorFileDialog *file; + EditorQuickOpen *quick_open; EditorSubScene *import_subscene_dialog; EditorFileDialog *new_scene_from_dialog; @@ -194,6 +195,7 @@ class SceneTreeDock : public VBoxContainer { void _nodes_dragged(Array p_nodes, NodePath p_to, int p_type); void _files_dropped(Vector<String> p_files, NodePath p_to, int p_type); void _script_dropped(String p_file, NodePath p_to); + void _quick_open(); void _tree_rmb(const Vector2 &p_menu_pos); |