1
0
mirror of https://github.com/godotengine/godot.git synced 2025-11-04 12:00:25 +00:00

Merge pull request #111162 from KoBeWi/tfw_your_side_projects_goes_to_trash

Remove side menu functionality in `EditorFileDialog`
This commit is contained in:
Thaddeus Crews
2025-10-22 13:48:43 -05:00
5 changed files with 45 additions and 69 deletions

View File

@@ -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<String> deps;
Ref<GLTFState> 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)));
}

View File

@@ -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<GLTFDocument> _gltf_document;
Ref<EditorSceneExporterGLTFSettings> _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;