Selaa lähdekoodia

Texture format error on export: Show project setting

Changing the project setting manually will prompt for a restart, which
will trigger the required re-import of textures.
Previously the project setting would be changed automatically but
textures would not be re-imported, which could be unexpected.
Ricardo Buring 1 kuukausi sitten
vanhempi
commit
e521d69d39

+ 10 - 9
editor/export/project_export.cpp

@@ -40,6 +40,7 @@
 #include "editor/export/editor_export.h"
 #include "editor/gui/editor_file_dialog.h"
 #include "editor/import/resource_importer_texture_settings.h"
+#include "editor/project_settings_editor.h"
 #include "editor/themes/editor_scale.h"
 #include "scene/gui/check_button.h"
 #include "scene/gui/item_list.h"
@@ -55,14 +56,14 @@
 #include "scene/gui/tree.h"
 
 void ProjectExportTextureFormatError::_on_fix_texture_format_pressed() {
-	ProjectSettings::get_singleton()->set_setting(setting_identifier, true);
-	ProjectSettings::get_singleton()->save();
-	EditorFileSystem::get_singleton()->scan_changes();
-	emit_signal("texture_format_enabled");
+	export_dialog->hide();
+	ProjectSettingsEditor *project_settings = EditorNode::get_singleton()->get_project_settings();
+	project_settings->set_general_page("rendering/textures");
+	project_settings->set_filter(setting_identifier);
+	project_settings->popup_project_settings(false);
 }
 
 void ProjectExportTextureFormatError::_bind_methods() {
-	ADD_SIGNAL(MethodInfo("texture_format_enabled"));
 }
 
 void ProjectExportTextureFormatError::_notification(int p_what) {
@@ -79,7 +80,8 @@ void ProjectExportTextureFormatError::show_for_texture_format(const String &p_fr
 	show();
 }
 
-ProjectExportTextureFormatError::ProjectExportTextureFormatError() {
+ProjectExportTextureFormatError::ProjectExportTextureFormatError(ProjectExportDialog *p_export_dialog) {
+	export_dialog = p_export_dialog;
 	// Set up the label.
 	texture_format_error_label = memnew(Label);
 	texture_format_error_label->set_focus_mode(Control::FOCUS_ACCESSIBILITY);
@@ -87,7 +89,7 @@ ProjectExportTextureFormatError::ProjectExportTextureFormatError() {
 	// Set up the fix button.
 	fix_texture_format_button = memnew(LinkButton);
 	fix_texture_format_button->set_v_size_flags(Control::SIZE_SHRINK_CENTER);
-	fix_texture_format_button->set_text(TTR("Fix Import"));
+	fix_texture_format_button->set_text(TTR("Show Project Setting"));
 	add_child(fix_texture_format_button);
 	fix_texture_format_button->connect(SceneStringName(pressed), callable_mp(this, &ProjectExportTextureFormatError::_on_fix_texture_format_pressed));
 }
@@ -1791,10 +1793,9 @@ ProjectExportDialog::ProjectExportDialog() {
 
 	// Export warnings and errors bottom section.
 
-	export_texture_format_error = memnew(ProjectExportTextureFormatError);
+	export_texture_format_error = memnew(ProjectExportTextureFormatError(this));
 	main_vb->add_child(export_texture_format_error);
 	export_texture_format_error->hide();
-	export_texture_format_error->connect("texture_format_enabled", callable_mp(this, &ProjectExportDialog::_update_current_preset));
 
 	export_error = memnew(Label);
 	export_error->set_focus_mode(Control::FOCUS_ACCESSIBILITY);

+ 3 - 1
editor/export/project_export.h

@@ -44,6 +44,7 @@ class LinkButton;
 class MenuButton;
 class OptionButton;
 class PopupMenu;
+class ProjectExportDialog;
 class RichTextLabel;
 class TabContainer;
 class Tree;
@@ -52,6 +53,7 @@ class TreeItem;
 class ProjectExportTextureFormatError : public HBoxContainer {
 	GDCLASS(ProjectExportTextureFormatError, HBoxContainer);
 
+	ProjectExportDialog *export_dialog = nullptr;
 	Label *texture_format_error_label = nullptr;
 	LinkButton *fix_texture_format_button = nullptr;
 	String setting_identifier;
@@ -63,7 +65,7 @@ protected:
 
 public:
 	void show_for_texture_format(const String &p_friendly_name, const String &p_setting_identifier);
-	ProjectExportTextureFormatError();
+	ProjectExportTextureFormatError(ProjectExportDialog *p_export_dialog);
 };
 
 class ProjectExportDialog : public ConfirmationDialog {

+ 4 - 0
editor/project_settings_editor.cpp

@@ -80,6 +80,10 @@ void ProjectSettingsEditor::popup_for_override(const String &p_override) {
 	general_settings_inspector->set_current_section(ProjectSettings::EDITOR_SETTING_OVERRIDE_PREFIX + p_override.get_slicec('/', 0));
 }
 
+void ProjectSettingsEditor::set_filter(const String &p_filter) {
+	search_box->set_text(p_filter);
+}
+
 void ProjectSettingsEditor::queue_save() {
 	settings_changed = true;
 	timer->start();

+ 2 - 0
editor/project_settings_editor.h

@@ -144,6 +144,8 @@ public:
 	void update_plugins();
 	void init_autoloads();
 
+	void set_filter(const String &p_filter);
+
 	EditorAutoloadSettings *get_autoload_settings() { return autoload_settings; }
 	GroupSettingsEditor *get_group_settings() { return group_settings; }
 	TabContainer *get_tabs() { return tab_container; }