diff --git a/doc/classes/EditorFileDialog.xml b/doc/classes/EditorFileDialog.xml index bd15baa071b..5992a52f539 100644 --- a/doc/classes/EditorFileDialog.xml +++ b/doc/classes/EditorFileDialog.xml @@ -30,12 +30,12 @@ [param default_value_index] should be an index of the value in the [param values]. If [param values] is empty it should be either [code]1[/code] (checked), or [code]0[/code] (unchecked). - + - Adds the given [param menu] to the side of the file dialog with the given [param title] text on top. Only one side menu is allowed. + This method is kept for compatibility and does nothing. As an alternative, you can display another dialog after showing the file dialog. diff --git a/editor/gui/editor_file_dialog.cpp b/editor/gui/editor_file_dialog.cpp index bc2e91d09b6..15f32e68628 100644 --- a/editor/gui/editor_file_dialog.cpp +++ b/editor/gui/editor_file_dialog.cpp @@ -75,11 +75,10 @@ void EditorFileDialog::popup(const Rect2i &p_rect) { _update_option_controls(); bool use_native = DisplayServer::get_singleton()->has_feature(DisplayServer::FEATURE_NATIVE_DIALOG_FILE) && (bool(EDITOR_GET("interface/editor/use_native_file_dialogs")) || OS::get_singleton()->is_sandboxed()); - if (!side_vbox && use_native) { + if (use_native) { _native_popup(); } else { - // Show custom file dialog (full dialog or side menu only). - _update_side_menu_visibility(use_native); + // Show custom file dialog. ConfirmationDialog::popup(p_rect); } } @@ -88,11 +87,10 @@ void EditorFileDialog::set_visible(bool p_visible) { if (p_visible) { bool use_native = DisplayServer::get_singleton()->has_feature(DisplayServer::FEATURE_NATIVE_DIALOG_FILE) && (bool(EDITOR_GET("interface/editor/use_native_file_dialogs")) || OS::get_singleton()->is_sandboxed()); _update_option_controls(); - if (!side_vbox && use_native) { + if (use_native) { _native_popup(); } else { - // Show custom file dialog (full dialog or side menu only). - _update_side_menu_visibility(use_native); + // Show custom file dialog. ConfirmationDialog::set_visible(p_visible); } } else { @@ -556,14 +554,6 @@ void EditorFileDialog::_request_single_thumbnail(const String &p_path) { } void EditorFileDialog::_action_pressed() { - // Accept side menu properties and show native dialog. - if (side_vbox && DisplayServer::get_singleton()->has_feature(DisplayServer::FEATURE_NATIVE_DIALOG_FILE) && (bool(EDITOR_GET("interface/editor/use_native_file_dialogs")) || OS::get_singleton()->is_sandboxed())) { - hide(); - _native_popup(); - - return; - } - // Accept selection in the custom dialog. if (mode == FILE_MODE_OPEN_FILES) { String fbase = dir_access->get_current_dir(); @@ -2176,8 +2166,10 @@ void EditorFileDialog::_bind_methods() { ClassDB::bind_method(D_METHOD("get_display_mode"), &EditorFileDialog::get_display_mode); ClassDB::bind_method(D_METHOD("set_disable_overwrite_warning", "disable"), &EditorFileDialog::set_disable_overwrite_warning); ClassDB::bind_method(D_METHOD("is_overwrite_warning_disabled"), &EditorFileDialog::is_overwrite_warning_disabled); - ClassDB::bind_method(D_METHOD("add_side_menu", "menu", "title"), &EditorFileDialog::add_side_menu, DEFVAL("")); ClassDB::bind_method(D_METHOD("popup_file_dialog"), &EditorFileDialog::popup_file_dialog); +#ifndef DISABLE_DEPRECATED + ClassDB::bind_method(D_METHOD("add_side_menu", "menu", "title"), &EditorFileDialog::add_side_menu, DEFVAL("")); +#endif ClassDB::bind_method(D_METHOD("invalidate"), &EditorFileDialog::invalidate); @@ -2300,39 +2292,6 @@ bool EditorFileDialog::are_previews_enabled() { return previews_enabled; } -void EditorFileDialog::add_side_menu(Control *p_menu, const String &p_title) { - // HSplitContainer has 3 children at maximum capacity, 1 of them is the SplitContainerDragger. - ERR_FAIL_COND_MSG(body_hsplit->get_child_count() > 2, "EditorFileDialog: Only one side menu can be added."); - // Everything for the side menu goes inside of a VBoxContainer. - side_vbox = memnew(VBoxContainer); - side_vbox->set_h_size_flags(Control::SIZE_EXPAND_FILL); - side_vbox->set_stretch_ratio(0.5); - body_hsplit->add_child(side_vbox); - // Add a Label to the VBoxContainer. - if (!p_title.is_empty()) { - Label *title_label = memnew(Label(p_title)); - title_label->set_theme_type_variation("HeaderSmall"); - side_vbox->add_child(title_label); - } - // Add the given menu to the VBoxContainer. - p_menu->set_v_size_flags(Control::SIZE_EXPAND_FILL); - side_vbox->add_child(p_menu); -} - -void EditorFileDialog::_update_side_menu_visibility(bool p_native_dlg) { - if (p_native_dlg) { - pathhb->set_visible(false); - flow_checkbox_options->set_visible(false); - grid_select_options->set_visible(false); - list_hb->set_visible(false); - } else { - pathhb->set_visible(true); - flow_checkbox_options->set_visible(true); - grid_select_options->set_visible(true); - list_hb->set_visible(true); - } -} - EditorFileDialog::EditorFileDialog() { show_hidden_files = default_show_hidden_files; display_mode = default_display_mode; diff --git a/editor/gui/editor_file_dialog.h b/editor/gui/editor_file_dialog.h index 78405db687f..4b6cdeda304 100644 --- a/editor/gui/editor_file_dialog.h +++ b/editor/gui/editor_file_dialog.h @@ -122,7 +122,6 @@ private: ConfirmationDialog *confirm_save = nullptr; DependencyRemoveDialog *dep_remove_dialog = nullptr; ConfirmationDialog *global_remove_dialog = nullptr; - VBoxContainer *side_vbox = nullptr; VBoxContainer *vbc = nullptr; HBoxContainer *pathhb = nullptr; @@ -280,8 +279,6 @@ private: bool _is_open_should_be_disabled(); - void _update_side_menu_visibility(bool p_native_dlg); - void _native_popup(); void _native_dialog_cb(bool p_ok, const Vector &p_files, int p_filter, const Dictionary &p_selected_options); @@ -367,7 +364,9 @@ public: void set_previews_enabled(bool p_enabled); bool are_previews_enabled(); - void add_side_menu(Control *p_menu, const String &p_title = ""); +#ifndef DISABLE_DEPRECATED + void add_side_menu(Control *p_menu, const String &p_title = "") { ERR_FAIL_MSG("add_side_menu() is kept for compatibility and does nothing. For similar functionality, you can show another dialog after file dialog."); } +#endif EditorFileDialog(); ~EditorFileDialog(); diff --git a/modules/gltf/editor/editor_scene_exporter_gltf_plugin.cpp b/modules/gltf/editor/editor_scene_exporter_gltf_plugin.cpp index 96b7485a4fd..579c8a03a87 100644 --- a/modules/gltf/editor/editor_scene_exporter_gltf_plugin.cpp +++ b/modules/gltf/editor/editor_scene_exporter_gltf_plugin.cpp @@ -38,6 +38,7 @@ #include "editor/import/3d/scene_import_settings.h" #include "editor/inspector/editor_inspector.h" #include "editor/themes/editor_scale.h" +#include "scene/gui/dialogs.h" String SceneExporterGLTFPlugin::get_plugin_name() const { return "ConvertGLTF2"; @@ -51,7 +52,7 @@ SceneExporterGLTFPlugin::SceneExporterGLTFPlugin() { _gltf_document.instantiate(); // Set up the file dialog. _file_dialog = memnew(EditorFileDialog); - _file_dialog->connect("file_selected", callable_mp(this, &SceneExporterGLTFPlugin::_export_scene_as_gltf)); + _file_dialog->connect("file_selected", callable_mp(this, &SceneExporterGLTFPlugin::_popup_gltf_settings_dialog)); _file_dialog->set_title(TTR("Export Library")); _file_dialog->set_file_mode(EditorFileDialog::FILE_MODE_SAVE_FILE); _file_dialog->set_access(EditorFileDialog::ACCESS_FILESYSTEM); @@ -61,11 +62,16 @@ SceneExporterGLTFPlugin::SceneExporterGLTFPlugin() { _file_dialog->set_title(TTR("Export Scene to glTF 2.0 File")); EditorNode::get_singleton()->get_gui_base()->add_child(_file_dialog); // Set up the export settings menu. + _config_dialog = memnew(ConfirmationDialog); + _config_dialog->set_title(TTRC("Export Settings")); + EditorNode::get_singleton()->get_gui_base()->add_child(_config_dialog); + _config_dialog->connect(SceneStringName(confirmed), callable_mp(this, &SceneExporterGLTFPlugin::_export_scene_as_gltf)); + _export_settings.instantiate(); _export_settings->generate_property_list(_gltf_document); _settings_inspector = memnew(EditorInspector); _settings_inspector->set_custom_minimum_size(Size2(350, 300) * EDSCALE); - _file_dialog->add_side_menu(_settings_inspector, TTR("Export Settings:")); + _config_dialog->add_child(_settings_inspector); // Add a button to the Scene -> Export menu to pop up the settings dialog. PopupMenu *menu = get_export_as_menu(); int idx = menu->get_item_count(); @@ -73,10 +79,23 @@ SceneExporterGLTFPlugin::SceneExporterGLTFPlugin() { menu->set_item_metadata(idx, callable_mp(this, &SceneExporterGLTFPlugin::_popup_gltf_export_dialog)); } +void SceneExporterGLTFPlugin::_popup_gltf_settings_dialog(const String &p_selected_path) { + export_path = p_selected_path; + + Node *root = EditorNode::get_singleton()->get_tree()->get_edited_scene_root(); + ERR_FAIL_NULL(root); + // Generate and refresh the export settings. + _export_settings->generate_property_list(_gltf_document, root); + _settings_inspector->edit(nullptr); + _settings_inspector->edit(_export_settings.ptr()); + // Show the config dialog. + _config_dialog->popup_centered(); +} + void SceneExporterGLTFPlugin::_popup_gltf_export_dialog() { Node *root = EditorNode::get_singleton()->get_tree()->get_edited_scene_root(); if (!root) { - EditorNode::get_singleton()->show_accept(TTR("This operation can't be done without a scene."), TTR("OK")); + EditorNode::get_singleton()->show_warning(TTR("This operation can't be done without a scene.")); return; } // Set the file dialog's file name to the scene name. @@ -85,20 +104,13 @@ void SceneExporterGLTFPlugin::_popup_gltf_export_dialog() { filename = root->get_name(); } _file_dialog->set_current_file(filename + String(".gltf")); - // Generate and refresh the export settings. - _export_settings->generate_property_list(_gltf_document, root); - _settings_inspector->edit(nullptr); - _settings_inspector->edit(_export_settings.ptr()); // Show the file dialog. - _file_dialog->popup_centered_ratio(); + _file_dialog->popup_file_dialog(); } -void SceneExporterGLTFPlugin::_export_scene_as_gltf(const String &p_file_path) { +void SceneExporterGLTFPlugin::_export_scene_as_gltf() { Node *root = EditorNode::get_singleton()->get_tree()->get_edited_scene_root(); - if (!root) { - EditorNode::get_singleton()->show_accept(TTR("This operation can't be done without a scene."), TTR("OK")); - return; - } + ERR_FAIL_NULL(root); List deps; Ref state; state.instantiate(); @@ -110,7 +122,7 @@ void SceneExporterGLTFPlugin::_export_scene_as_gltf(const String &p_file_path) { if (err != OK) { ERR_PRINT(vformat("glTF2 save scene error %s.", itos(err))); } - err = _gltf_document->write_to_filesystem(state, p_file_path); + err = _gltf_document->write_to_filesystem(state, export_path); if (err != OK) { ERR_PRINT(vformat("glTF2 save scene error %s.", itos(err))); } diff --git a/modules/gltf/editor/editor_scene_exporter_gltf_plugin.h b/modules/gltf/editor/editor_scene_exporter_gltf_plugin.h index 65b3d19e999..2ba895959e1 100644 --- a/modules/gltf/editor/editor_scene_exporter_gltf_plugin.h +++ b/modules/gltf/editor/editor_scene_exporter_gltf_plugin.h @@ -35,6 +35,7 @@ #include "editor/plugins/editor_plugin.h" +class ConfirmationDialog; class EditorFileDialog; class EditorInspector; @@ -43,10 +44,15 @@ class SceneExporterGLTFPlugin : public EditorPlugin { Ref _gltf_document; Ref _export_settings; + String export_path; + EditorInspector *_settings_inspector = nullptr; + ConfirmationDialog *_config_dialog = nullptr; EditorFileDialog *_file_dialog = nullptr; + + void _popup_gltf_settings_dialog(const String &p_selected_path); void _popup_gltf_export_dialog(); - void _export_scene_as_gltf(const String &p_file_path); + void _export_scene_as_gltf(); public: virtual String get_plugin_name() const override;