diff options
Diffstat (limited to 'editor/editor_resource_picker.cpp')
-rw-r--r-- | editor/editor_resource_picker.cpp | 24 |
1 files changed, 21 insertions, 3 deletions
diff --git a/editor/editor_resource_picker.cpp b/editor/editor_resource_picker.cpp index a4ab749db4..9dbf69a779 100644 --- a/editor/editor_resource_picker.cpp +++ b/editor/editor_resource_picker.cpp @@ -135,13 +135,17 @@ void EditorResourcePicker::_file_selected(const String &p_path) { _update_resource(); } +void EditorResourcePicker::_file_quick_selected() { + _file_selected(quick_open->get_selected()); +} + void EditorResourcePicker::_update_menu() { _update_menu_items(); Rect2 gt = edit_button->get_screen_rect(); edit_menu->set_as_minsize(); int ms = edit_menu->get_contents_minimum_size().width; - Vector2 popup_pos = gt.position + gt.size - Vector2(ms, 0); + Vector2 popup_pos = gt.get_end() - Vector2(ms, 0); edit_menu->set_position(popup_pos); edit_menu->popup(); } @@ -153,7 +157,10 @@ void EditorResourcePicker::_update_menu_items() { // Add options for creating specific subtypes of the base resource type. set_create_options(edit_menu); - // Add an option to load a resource from a file. + // Add an option to load a resource from a file using the QuickOpen dialog. + edit_menu->add_icon_item(get_theme_icon(SNAME("Load"), SNAME("EditorIcons")), TTR("Quick Load"), OBJ_MENU_QUICKLOAD); + + // Add an option to load a resource from a file using the regular file dialog. edit_menu->add_icon_item(get_theme_icon(SNAME("Load"), SNAME("EditorIcons")), TTR("Load"), OBJ_MENU_LOAD); // Add options for changing existing value of the resource. @@ -246,6 +253,17 @@ void EditorResourcePicker::_edit_menu_cbk(int p_which) { file_dialog->popup_file_dialog(); } break; + case OBJ_MENU_QUICKLOAD: { + if (!quick_open) { + quick_open = memnew(EditorQuickOpen); + add_child(quick_open); + quick_open->connect("quick_open", callable_mp(this, &EditorResourcePicker::_file_quick_selected)); + } + + quick_open->popup_dialog(base_type); + quick_open->set_title(TTR("Resource")); + } break; + case OBJ_MENU_EDIT: { if (edited_resource.is_valid()) { emit_signal(SNAME("resource_selected"), edited_resource); @@ -906,7 +924,7 @@ void EditorShaderPicker::set_create_options(Object *p_menu_node) { return; } - menu_node->add_icon_item(get_theme_icon("Shader", "EditorIcons"), TTR("New Shader"), OBJ_MENU_NEW_SHADER); + menu_node->add_icon_item(get_theme_icon(SNAME("Shader"), SNAME("EditorIcons")), TTR("New Shader"), OBJ_MENU_NEW_SHADER); menu_node->add_separator(); } |