You've already forked godot
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:
@@ -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).
|
[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).
|
||||||
</description>
|
</description>
|
||||||
</method>
|
</method>
|
||||||
<method name="add_side_menu">
|
<method name="add_side_menu" deprecated="This feature is no longer supported.">
|
||||||
<return type="void" />
|
<return type="void" />
|
||||||
<param index="0" name="menu" type="Control" />
|
<param index="0" name="menu" type="Control" />
|
||||||
<param index="1" name="title" type="String" default="""" />
|
<param index="1" name="title" type="String" default="""" />
|
||||||
<description>
|
<description>
|
||||||
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.
|
||||||
</description>
|
</description>
|
||||||
</method>
|
</method>
|
||||||
<method name="clear_filename_filter">
|
<method name="clear_filename_filter">
|
||||||
|
|||||||
@@ -75,11 +75,10 @@ void EditorFileDialog::popup(const Rect2i &p_rect) {
|
|||||||
_update_option_controls();
|
_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());
|
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();
|
_native_popup();
|
||||||
} else {
|
} else {
|
||||||
// Show custom file dialog (full dialog or side menu only).
|
// Show custom file dialog.
|
||||||
_update_side_menu_visibility(use_native);
|
|
||||||
ConfirmationDialog::popup(p_rect);
|
ConfirmationDialog::popup(p_rect);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -88,11 +87,10 @@ void EditorFileDialog::set_visible(bool p_visible) {
|
|||||||
if (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());
|
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();
|
_update_option_controls();
|
||||||
if (!side_vbox && use_native) {
|
if (use_native) {
|
||||||
_native_popup();
|
_native_popup();
|
||||||
} else {
|
} else {
|
||||||
// Show custom file dialog (full dialog or side menu only).
|
// Show custom file dialog.
|
||||||
_update_side_menu_visibility(use_native);
|
|
||||||
ConfirmationDialog::set_visible(p_visible);
|
ConfirmationDialog::set_visible(p_visible);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@@ -556,14 +554,6 @@ void EditorFileDialog::_request_single_thumbnail(const String &p_path) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void EditorFileDialog::_action_pressed() {
|
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.
|
// Accept selection in the custom dialog.
|
||||||
if (mode == FILE_MODE_OPEN_FILES) {
|
if (mode == FILE_MODE_OPEN_FILES) {
|
||||||
String fbase = dir_access->get_current_dir();
|
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("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("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("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);
|
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);
|
ClassDB::bind_method(D_METHOD("invalidate"), &EditorFileDialog::invalidate);
|
||||||
|
|
||||||
@@ -2300,39 +2292,6 @@ bool EditorFileDialog::are_previews_enabled() {
|
|||||||
return 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() {
|
EditorFileDialog::EditorFileDialog() {
|
||||||
show_hidden_files = default_show_hidden_files;
|
show_hidden_files = default_show_hidden_files;
|
||||||
display_mode = default_display_mode;
|
display_mode = default_display_mode;
|
||||||
|
|||||||
@@ -122,7 +122,6 @@ private:
|
|||||||
ConfirmationDialog *confirm_save = nullptr;
|
ConfirmationDialog *confirm_save = nullptr;
|
||||||
DependencyRemoveDialog *dep_remove_dialog = nullptr;
|
DependencyRemoveDialog *dep_remove_dialog = nullptr;
|
||||||
ConfirmationDialog *global_remove_dialog = nullptr;
|
ConfirmationDialog *global_remove_dialog = nullptr;
|
||||||
VBoxContainer *side_vbox = nullptr;
|
|
||||||
VBoxContainer *vbc = nullptr;
|
VBoxContainer *vbc = nullptr;
|
||||||
HBoxContainer *pathhb = nullptr;
|
HBoxContainer *pathhb = nullptr;
|
||||||
|
|
||||||
@@ -280,8 +279,6 @@ private:
|
|||||||
|
|
||||||
bool _is_open_should_be_disabled();
|
bool _is_open_should_be_disabled();
|
||||||
|
|
||||||
void _update_side_menu_visibility(bool p_native_dlg);
|
|
||||||
|
|
||||||
void _native_popup();
|
void _native_popup();
|
||||||
void _native_dialog_cb(bool p_ok, const Vector<String> &p_files, int p_filter, const Dictionary &p_selected_options);
|
void _native_dialog_cb(bool p_ok, const Vector<String> &p_files, int p_filter, const Dictionary &p_selected_options);
|
||||||
|
|
||||||
@@ -367,7 +364,9 @@ public:
|
|||||||
void set_previews_enabled(bool p_enabled);
|
void set_previews_enabled(bool p_enabled);
|
||||||
bool are_previews_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();
|
||||||
~EditorFileDialog();
|
~EditorFileDialog();
|
||||||
|
|||||||
@@ -38,6 +38,7 @@
|
|||||||
#include "editor/import/3d/scene_import_settings.h"
|
#include "editor/import/3d/scene_import_settings.h"
|
||||||
#include "editor/inspector/editor_inspector.h"
|
#include "editor/inspector/editor_inspector.h"
|
||||||
#include "editor/themes/editor_scale.h"
|
#include "editor/themes/editor_scale.h"
|
||||||
|
#include "scene/gui/dialogs.h"
|
||||||
|
|
||||||
String SceneExporterGLTFPlugin::get_plugin_name() const {
|
String SceneExporterGLTFPlugin::get_plugin_name() const {
|
||||||
return "ConvertGLTF2";
|
return "ConvertGLTF2";
|
||||||
@@ -51,7 +52,7 @@ SceneExporterGLTFPlugin::SceneExporterGLTFPlugin() {
|
|||||||
_gltf_document.instantiate();
|
_gltf_document.instantiate();
|
||||||
// Set up the file dialog.
|
// Set up the file dialog.
|
||||||
_file_dialog = memnew(EditorFileDialog);
|
_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_title(TTR("Export Library"));
|
||||||
_file_dialog->set_file_mode(EditorFileDialog::FILE_MODE_SAVE_FILE);
|
_file_dialog->set_file_mode(EditorFileDialog::FILE_MODE_SAVE_FILE);
|
||||||
_file_dialog->set_access(EditorFileDialog::ACCESS_FILESYSTEM);
|
_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"));
|
_file_dialog->set_title(TTR("Export Scene to glTF 2.0 File"));
|
||||||
EditorNode::get_singleton()->get_gui_base()->add_child(_file_dialog);
|
EditorNode::get_singleton()->get_gui_base()->add_child(_file_dialog);
|
||||||
// Set up the export settings menu.
|
// 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.instantiate();
|
||||||
_export_settings->generate_property_list(_gltf_document);
|
_export_settings->generate_property_list(_gltf_document);
|
||||||
_settings_inspector = memnew(EditorInspector);
|
_settings_inspector = memnew(EditorInspector);
|
||||||
_settings_inspector->set_custom_minimum_size(Size2(350, 300) * EDSCALE);
|
_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.
|
// Add a button to the Scene -> Export menu to pop up the settings dialog.
|
||||||
PopupMenu *menu = get_export_as_menu();
|
PopupMenu *menu = get_export_as_menu();
|
||||||
int idx = menu->get_item_count();
|
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));
|
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() {
|
void SceneExporterGLTFPlugin::_popup_gltf_export_dialog() {
|
||||||
Node *root = EditorNode::get_singleton()->get_tree()->get_edited_scene_root();
|
Node *root = EditorNode::get_singleton()->get_tree()->get_edited_scene_root();
|
||||||
if (!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;
|
return;
|
||||||
}
|
}
|
||||||
// Set the file dialog's file name to the scene name.
|
// 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();
|
filename = root->get_name();
|
||||||
}
|
}
|
||||||
_file_dialog->set_current_file(filename + String(".gltf"));
|
_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.
|
// 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();
|
Node *root = EditorNode::get_singleton()->get_tree()->get_edited_scene_root();
|
||||||
if (!root) {
|
ERR_FAIL_NULL(root);
|
||||||
EditorNode::get_singleton()->show_accept(TTR("This operation can't be done without a scene."), TTR("OK"));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
List<String> deps;
|
List<String> deps;
|
||||||
Ref<GLTFState> state;
|
Ref<GLTFState> state;
|
||||||
state.instantiate();
|
state.instantiate();
|
||||||
@@ -110,7 +122,7 @@ void SceneExporterGLTFPlugin::_export_scene_as_gltf(const String &p_file_path) {
|
|||||||
if (err != OK) {
|
if (err != OK) {
|
||||||
ERR_PRINT(vformat("glTF2 save scene error %s.", itos(err)));
|
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) {
|
if (err != OK) {
|
||||||
ERR_PRINT(vformat("glTF2 save scene error %s.", itos(err)));
|
ERR_PRINT(vformat("glTF2 save scene error %s.", itos(err)));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -35,6 +35,7 @@
|
|||||||
|
|
||||||
#include "editor/plugins/editor_plugin.h"
|
#include "editor/plugins/editor_plugin.h"
|
||||||
|
|
||||||
|
class ConfirmationDialog;
|
||||||
class EditorFileDialog;
|
class EditorFileDialog;
|
||||||
class EditorInspector;
|
class EditorInspector;
|
||||||
|
|
||||||
@@ -43,10 +44,15 @@ class SceneExporterGLTFPlugin : public EditorPlugin {
|
|||||||
|
|
||||||
Ref<GLTFDocument> _gltf_document;
|
Ref<GLTFDocument> _gltf_document;
|
||||||
Ref<EditorSceneExporterGLTFSettings> _export_settings;
|
Ref<EditorSceneExporterGLTFSettings> _export_settings;
|
||||||
|
String export_path;
|
||||||
|
|
||||||
EditorInspector *_settings_inspector = nullptr;
|
EditorInspector *_settings_inspector = nullptr;
|
||||||
|
ConfirmationDialog *_config_dialog = nullptr;
|
||||||
EditorFileDialog *_file_dialog = nullptr;
|
EditorFileDialog *_file_dialog = nullptr;
|
||||||
|
|
||||||
|
void _popup_gltf_settings_dialog(const String &p_selected_path);
|
||||||
void _popup_gltf_export_dialog();
|
void _popup_gltf_export_dialog();
|
||||||
void _export_scene_as_gltf(const String &p_file_path);
|
void _export_scene_as_gltf();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
virtual String get_plugin_name() const override;
|
virtual String get_plugin_name() const override;
|
||||||
|
|||||||
Reference in New Issue
Block a user