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
4243String 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+
7695void 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 }
0 commit comments