Skip to content

Commit 33ccc51

Browse files
committed
Remove side menu functionality in EditorFileDialog
1 parent 9cd297b commit 33ccc51

File tree

5 files changed

+45
-69
lines changed

5 files changed

+45
-69
lines changed

doc/classes/EditorFileDialog.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,12 @@
3030
[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).
3131
</description>
3232
</method>
33-
<method name="add_side_menu">
33+
<method name="add_side_menu" deprecated="This feature is no longer supported.">
3434
<return type="void" />
3535
<param index="0" name="menu" type="Control" />
3636
<param index="1" name="title" type="String" default="&quot;&quot;" />
3737
<description>
38-
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.
38+
This method is kept for compatibility and does nothing. As an alternative, you can display another dialog after showing the file dialog.
3939
</description>
4040
</method>
4141
<method name="clear_filename_filter">

editor/gui/editor_file_dialog.cpp

Lines changed: 7 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -75,11 +75,10 @@ void EditorFileDialog::popup(const Rect2i &p_rect) {
7575
_update_option_controls();
7676

7777
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());
78-
if (!side_vbox && use_native) {
78+
if (use_native) {
7979
_native_popup();
8080
} else {
81-
// Show custom file dialog (full dialog or side menu only).
82-
_update_side_menu_visibility(use_native);
81+
// Show custom file dialog.
8382
ConfirmationDialog::popup(p_rect);
8483
}
8584
}
@@ -88,11 +87,10 @@ void EditorFileDialog::set_visible(bool p_visible) {
8887
if (p_visible) {
8988
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());
9089
_update_option_controls();
91-
if (!side_vbox && use_native) {
90+
if (use_native) {
9291
_native_popup();
9392
} else {
94-
// Show custom file dialog (full dialog or side menu only).
95-
_update_side_menu_visibility(use_native);
93+
// Show custom file dialog.
9694
ConfirmationDialog::set_visible(p_visible);
9795
}
9896
} else {
@@ -556,14 +554,6 @@ void EditorFileDialog::_request_single_thumbnail(const String &p_path) {
556554
}
557555

558556
void EditorFileDialog::_action_pressed() {
559-
// Accept side menu properties and show native dialog.
560-
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())) {
561-
hide();
562-
_native_popup();
563-
564-
return;
565-
}
566-
567557
// Accept selection in the custom dialog.
568558
if (mode == FILE_MODE_OPEN_FILES) {
569559
String fbase = dir_access->get_current_dir();
@@ -2176,8 +2166,10 @@ void EditorFileDialog::_bind_methods() {
21762166
ClassDB::bind_method(D_METHOD("get_display_mode"), &EditorFileDialog::get_display_mode);
21772167
ClassDB::bind_method(D_METHOD("set_disable_overwrite_warning", "disable"), &EditorFileDialog::set_disable_overwrite_warning);
21782168
ClassDB::bind_method(D_METHOD("is_overwrite_warning_disabled"), &EditorFileDialog::is_overwrite_warning_disabled);
2179-
ClassDB::bind_method(D_METHOD("add_side_menu", "menu", "title"), &EditorFileDialog::add_side_menu, DEFVAL(""));
21802169
ClassDB::bind_method(D_METHOD("popup_file_dialog"), &EditorFileDialog::popup_file_dialog);
2170+
#ifndef DISABLE_DEPRECATED
2171+
ClassDB::bind_method(D_METHOD("add_side_menu", "menu", "title"), &EditorFileDialog::add_side_menu, DEFVAL(""));
2172+
#endif
21812173

21822174
ClassDB::bind_method(D_METHOD("invalidate"), &EditorFileDialog::invalidate);
21832175

@@ -2300,39 +2292,6 @@ bool EditorFileDialog::are_previews_enabled() {
23002292
return previews_enabled;
23012293
}
23022294

2303-
void EditorFileDialog::add_side_menu(Control *p_menu, const String &p_title) {
2304-
// HSplitContainer has 3 children at maximum capacity, 1 of them is the SplitContainerDragger.
2305-
ERR_FAIL_COND_MSG(body_hsplit->get_child_count() > 2, "EditorFileDialog: Only one side menu can be added.");
2306-
// Everything for the side menu goes inside of a VBoxContainer.
2307-
side_vbox = memnew(VBoxContainer);
2308-
side_vbox->set_h_size_flags(Control::SIZE_EXPAND_FILL);
2309-
side_vbox->set_stretch_ratio(0.5);
2310-
body_hsplit->add_child(side_vbox);
2311-
// Add a Label to the VBoxContainer.
2312-
if (!p_title.is_empty()) {
2313-
Label *title_label = memnew(Label(p_title));
2314-
title_label->set_theme_type_variation("HeaderSmall");
2315-
side_vbox->add_child(title_label);
2316-
}
2317-
// Add the given menu to the VBoxContainer.
2318-
p_menu->set_v_size_flags(Control::SIZE_EXPAND_FILL);
2319-
side_vbox->add_child(p_menu);
2320-
}
2321-
2322-
void EditorFileDialog::_update_side_menu_visibility(bool p_native_dlg) {
2323-
if (p_native_dlg) {
2324-
pathhb->set_visible(false);
2325-
flow_checkbox_options->set_visible(false);
2326-
grid_select_options->set_visible(false);
2327-
list_hb->set_visible(false);
2328-
} else {
2329-
pathhb->set_visible(true);
2330-
flow_checkbox_options->set_visible(true);
2331-
grid_select_options->set_visible(true);
2332-
list_hb->set_visible(true);
2333-
}
2334-
}
2335-
23362295
EditorFileDialog::EditorFileDialog() {
23372296
show_hidden_files = default_show_hidden_files;
23382297
display_mode = default_display_mode;

editor/gui/editor_file_dialog.h

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,6 @@ class EditorFileDialog : public ConfirmationDialog {
122122
ConfirmationDialog *confirm_save = nullptr;
123123
DependencyRemoveDialog *dep_remove_dialog = nullptr;
124124
ConfirmationDialog *global_remove_dialog = nullptr;
125-
VBoxContainer *side_vbox = nullptr;
126125
VBoxContainer *vbc = nullptr;
127126
HBoxContainer *pathhb = nullptr;
128127

@@ -280,8 +279,6 @@ class EditorFileDialog : public ConfirmationDialog {
280279

281280
bool _is_open_should_be_disabled();
282281

283-
void _update_side_menu_visibility(bool p_native_dlg);
284-
285282
void _native_popup();
286283
void _native_dialog_cb(bool p_ok, const Vector<String> &p_files, int p_filter, const Dictionary &p_selected_options);
287284

@@ -367,7 +364,9 @@ class EditorFileDialog : public ConfirmationDialog {
367364
void set_previews_enabled(bool p_enabled);
368365
bool are_previews_enabled();
369366

370-
void add_side_menu(Control *p_menu, const String &p_title = "");
367+
#ifndef DISABLE_DEPRECATED
368+
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."); }
369+
#endif
371370

372371
EditorFileDialog();
373372
~EditorFileDialog();

modules/gltf/editor/editor_scene_exporter_gltf_plugin.cpp

Lines changed: 26 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
#include "editor/import/3d/scene_import_settings.h"
3939
#include "editor/inspector/editor_inspector.h"
4040
#include "editor/themes/editor_scale.h"
41+
#include "scene/gui/dialogs.h"
4142

4243
String SceneExporterGLTFPlugin::get_plugin_name() const {
4344
return "ConvertGLTF2";
@@ -51,7 +52,7 @@ SceneExporterGLTFPlugin::SceneExporterGLTFPlugin() {
5152
_gltf_document.instantiate();
5253
// Set up the file dialog.
5354
_file_dialog = memnew(EditorFileDialog);
54-
_file_dialog->connect("file_selected", callable_mp(this, &SceneExporterGLTFPlugin::_export_scene_as_gltf));
55+
_file_dialog->connect("file_selected", callable_mp(this, &SceneExporterGLTFPlugin::_popup_gltf_settings_dialog));
5556
_file_dialog->set_title(TTR("Export Library"));
5657
_file_dialog->set_file_mode(EditorFileDialog::FILE_MODE_SAVE_FILE);
5758
_file_dialog->set_access(EditorFileDialog::ACCESS_FILESYSTEM);
@@ -61,22 +62,40 @@ SceneExporterGLTFPlugin::SceneExporterGLTFPlugin() {
6162
_file_dialog->set_title(TTR("Export Scene to glTF 2.0 File"));
6263
EditorNode::get_singleton()->get_gui_base()->add_child(_file_dialog);
6364
// Set up the export settings menu.
65+
_config_dialog = memnew(ConfirmationDialog);
66+
_config_dialog->set_title(TTRC("Export Settings"));
67+
EditorNode::get_singleton()->get_gui_base()->add_child(_config_dialog);
68+
_config_dialog->connect(SceneStringName(confirmed), callable_mp(this, &SceneExporterGLTFPlugin::_export_scene_as_gltf));
69+
6470
_export_settings.instantiate();
6571
_export_settings->generate_property_list(_gltf_document);
6672
_settings_inspector = memnew(EditorInspector);
6773
_settings_inspector->set_custom_minimum_size(Size2(350, 300) * EDSCALE);
68-
_file_dialog->add_side_menu(_settings_inspector, TTR("Export Settings:"));
74+
_config_dialog->add_child(_settings_inspector);
6975
// Add a button to the Scene -> Export menu to pop up the settings dialog.
7076
PopupMenu *menu = get_export_as_menu();
7177
int idx = menu->get_item_count();
7278
menu->add_item(TTRC("glTF 2.0 Scene..."));
7379
menu->set_item_metadata(idx, callable_mp(this, &SceneExporterGLTFPlugin::_popup_gltf_export_dialog));
7480
}
7581

82+
void SceneExporterGLTFPlugin::_popup_gltf_settings_dialog(const String &p_selected_path) {
83+
export_path = p_selected_path;
84+
85+
Node *root = EditorNode::get_singleton()->get_tree()->get_edited_scene_root();
86+
ERR_FAIL_NULL(root);
87+
// Generate and refresh the export settings.
88+
_export_settings->generate_property_list(_gltf_document, root);
89+
_settings_inspector->edit(nullptr);
90+
_settings_inspector->edit(_export_settings.ptr());
91+
// Show the config dialog.
92+
_config_dialog->popup_centered();
93+
}
94+
7695
void SceneExporterGLTFPlugin::_popup_gltf_export_dialog() {
7796
Node *root = EditorNode::get_singleton()->get_tree()->get_edited_scene_root();
7897
if (!root) {
79-
EditorNode::get_singleton()->show_accept(TTR("This operation can't be done without a scene."), TTR("OK"));
98+
EditorNode::get_singleton()->show_warning(TTR("This operation can't be done without a scene."));
8099
return;
81100
}
82101
// Set the file dialog's file name to the scene name.
@@ -85,20 +104,13 @@ void SceneExporterGLTFPlugin::_popup_gltf_export_dialog() {
85104
filename = root->get_name();
86105
}
87106
_file_dialog->set_current_file(filename + String(".gltf"));
88-
// Generate and refresh the export settings.
89-
_export_settings->generate_property_list(_gltf_document, root);
90-
_settings_inspector->edit(nullptr);
91-
_settings_inspector->edit(_export_settings.ptr());
92107
// Show the file dialog.
93-
_file_dialog->popup_centered_ratio();
108+
_file_dialog->popup_file_dialog();
94109
}
95110

96-
void SceneExporterGLTFPlugin::_export_scene_as_gltf(const String &p_file_path) {
111+
void SceneExporterGLTFPlugin::_export_scene_as_gltf() {
97112
Node *root = EditorNode::get_singleton()->get_tree()->get_edited_scene_root();
98-
if (!root) {
99-
EditorNode::get_singleton()->show_accept(TTR("This operation can't be done without a scene."), TTR("OK"));
100-
return;
101-
}
113+
ERR_FAIL_NULL(root);
102114
List<String> deps;
103115
Ref<GLTFState> state;
104116
state.instantiate();
@@ -110,7 +122,7 @@ void SceneExporterGLTFPlugin::_export_scene_as_gltf(const String &p_file_path) {
110122
if (err != OK) {
111123
ERR_PRINT(vformat("glTF2 save scene error %s.", itos(err)));
112124
}
113-
err = _gltf_document->write_to_filesystem(state, p_file_path);
125+
err = _gltf_document->write_to_filesystem(state, export_path);
114126
if (err != OK) {
115127
ERR_PRINT(vformat("glTF2 save scene error %s.", itos(err)));
116128
}

modules/gltf/editor/editor_scene_exporter_gltf_plugin.h

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535

3636
#include "editor/plugins/editor_plugin.h"
3737

38+
class ConfirmationDialog;
3839
class EditorFileDialog;
3940
class EditorInspector;
4041

@@ -43,10 +44,15 @@ class SceneExporterGLTFPlugin : public EditorPlugin {
4344

4445
Ref<GLTFDocument> _gltf_document;
4546
Ref<EditorSceneExporterGLTFSettings> _export_settings;
47+
String export_path;
48+
4649
EditorInspector *_settings_inspector = nullptr;
50+
ConfirmationDialog *_config_dialog = nullptr;
4751
EditorFileDialog *_file_dialog = nullptr;
52+
53+
void _popup_gltf_settings_dialog(const String &p_selected_path);
4854
void _popup_gltf_export_dialog();
49-
void _export_scene_as_gltf(const String &p_file_path);
55+
void _export_scene_as_gltf();
5056

5157
public:
5258
virtual String get_plugin_name() const override;

0 commit comments

Comments
 (0)