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

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.
This commit is contained in:
Ricardo Buring
2025-06-01 13:23:04 +02:00
parent e45cc68092
commit e521d69d39
4 changed files with 19 additions and 10 deletions

View File

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

View File

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

View File

@@ -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)); 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() { void ProjectSettingsEditor::queue_save() {
settings_changed = true; settings_changed = true;
timer->start(); timer->start();

View File

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