summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAaron Franke <arnfranke@yahoo.com>2023-06-19 21:50:09 -0500
committerAaron Franke <arnfranke@yahoo.com>2023-08-17 02:56:42 -0500
commitada360affefa5476e9b23effe58ecac15db5052e (patch)
tree4cf64308ccc54b1179cf51ae2e17a844714d53bd
parenta278c1b98a81738a35b96a933a6e6cf771f9ab2d (diff)
downloadredot-engine-ada360affefa5476e9b23effe58ecac15db5052e.tar.gz
Add a button in the export dialog to fix missing texture formats
-rw-r--r--editor/export/editor_export.cpp17
-rw-r--r--editor/export/editor_export_platform.h2
-rw-r--r--editor/export/project_export.cpp72
-rw-r--r--editor/export/project_export.h20
-rw-r--r--platform/android/export/export_plugin.cpp5
-rw-r--r--platform/ios/export/export_plugin.cpp5
-rw-r--r--platform/macos/export/export_plugin.cpp9
-rw-r--r--platform/web/export/export_plugin.cpp5
8 files changed, 93 insertions, 42 deletions
diff --git a/editor/export/editor_export.cpp b/editor/export/editor_export.cpp
index 6c4fb480d7..670fd0a06d 100644
--- a/editor/export/editor_export.cpp
+++ b/editor/export/editor_export.cpp
@@ -32,7 +32,6 @@
#include "core/config/project_settings.h"
#include "core/io/config_file.h"
-#include "editor/import/resource_importer_texture_settings.h"
EditorExport *EditorExport::singleton = nullptr;
@@ -138,22 +137,6 @@ void EditorExport::add_export_preset(const Ref<EditorExportPreset> &p_preset, in
}
}
-String EditorExportPlatform::test_etc2() const {
- if (!ResourceImporterTextureSettings::should_import_etc2_astc()) {
- return TTR("Target platform requires 'ETC2/ASTC' texture compression. Enable 'Import ETC2 ASTC' in Project Settings.") + "\n";
- }
-
- return String();
-}
-
-String EditorExportPlatform::test_bc() const {
- if (!ResourceImporterTextureSettings::should_import_s3tc_bptc()) {
- return TTR("Target platform requires 'S3TC/BPTC' texture compression. Enable 'Import S3TC BPTC' in Project Settings.") + "\n";
- }
-
- return String();
-}
-
int EditorExport::get_export_preset_count() const {
return export_presets.size();
}
diff --git a/editor/export/editor_export_platform.h b/editor/export/editor_export_platform.h
index 763836e3ec..5f5702026c 100644
--- a/editor/export/editor_export_platform.h
+++ b/editor/export/editor_export_platform.h
@@ -237,8 +237,6 @@ public:
virtual Error run(const Ref<EditorExportPreset> &p_preset, int p_device, int p_debug_flags) { return OK; }
virtual Ref<Texture2D> get_run_icon() const { return get_logo(); }
- String test_etc2() const;
- String test_bc() const;
bool can_export(const Ref<EditorExportPreset> &p_preset, String &r_error, bool &r_missing_templates, bool p_debug = false) const;
virtual bool has_valid_export_configuration(const Ref<EditorExportPreset> &p_preset, String &r_error, bool &r_missing_templates, bool p_debug = false) const = 0;
virtual bool has_valid_project_configuration(const Ref<EditorExportPreset> &p_preset, String &r_error) const = 0;
diff --git a/editor/export/project_export.cpp b/editor/export/project_export.cpp
index 7c7762e0fd..61f875713f 100644
--- a/editor/export/project_export.cpp
+++ b/editor/export/project_export.cpp
@@ -39,6 +39,7 @@
#include "editor/editor_settings.h"
#include "editor/export/editor_export.h"
#include "editor/gui/editor_file_dialog.h"
+#include "editor/import/resource_importer_texture_settings.h"
#include "scene/gui/check_box.h"
#include "scene/gui/check_button.h"
#include "scene/gui/item_list.h"
@@ -51,6 +52,44 @@
#include "scene/gui/texture_rect.h"
#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");
+}
+
+void ProjectExportTextureFormatError::_bind_methods() {
+ ADD_SIGNAL(MethodInfo("texture_format_enabled"));
+}
+
+void ProjectExportTextureFormatError::_notification(int p_what) {
+ switch (p_what) {
+ case NOTIFICATION_ENTER_TREE:
+ case NOTIFICATION_THEME_CHANGED: {
+ texture_format_error_label->add_theme_color_override("font_color", get_theme_color(SNAME("error_color"), SNAME("Editor")));
+ } break;
+ }
+}
+
+void ProjectExportTextureFormatError::show_for_texture_format(const String &p_friendly_name, const String &p_setting_identifier) {
+ texture_format_error_label->set_text(vformat(TTR("Target platform requires '%s' texture compression. Enable 'Import %s' to fix."), p_friendly_name, p_friendly_name.replace("/", " ")));
+ setting_identifier = p_setting_identifier;
+ show();
+}
+
+ProjectExportTextureFormatError::ProjectExportTextureFormatError() {
+ // Set up the label.
+ texture_format_error_label = memnew(Label);
+ add_child(texture_format_error_label);
+ // 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"));
+ add_child(fix_texture_format_button);
+ fix_texture_format_button->connect("pressed", callable_mp(this, &ProjectExportTextureFormatError::_on_fix_texture_format_pressed));
+}
+
void ProjectExportDialog::_theme_changed() {
duplicate_preset->set_icon(presets->get_theme_icon(SNAME("Duplicate"), SNAME("EditorIcons")));
delete_preset->set_icon(presets->get_theme_icon(SNAME("Remove"), SNAME("EditorIcons")));
@@ -300,6 +339,14 @@ void ProjectExportDialog::_edit_preset(int p_index) {
_update_export_all();
child_controls_changed();
+ if ((feature_set.has("s3tc") || feature_set.has("bptc")) && !ResourceImporterTextureSettings::should_import_s3tc_bptc()) {
+ export_texture_format_error->show_for_texture_format("S3TC/BPTC", "rendering/textures/vram_compression/import_s3tc_bptc");
+ } else if ((feature_set.has("etc2") || feature_set.has("astc")) && !ResourceImporterTextureSettings::should_import_etc2_astc()) {
+ export_texture_format_error->show_for_texture_format("ETC2/ASTC", "rendering/textures/vram_compression/import_etc2_astc");
+ } else {
+ export_texture_format_error->hide();
+ }
+
String enc_in_filters_str = current->get_enc_in_filter();
String enc_ex_filters_str = current->get_enc_ex_filter();
if (!updating_enc_filters) {
@@ -343,29 +390,29 @@ void ProjectExportDialog::_update_feature_list() {
Ref<EditorExportPreset> current = get_current_preset();
ERR_FAIL_COND(current.is_null());
- RBSet<String> fset;
- List<String> features;
+ List<String> features_list;
- current->get_platform()->get_platform_features(&features);
- current->get_platform()->get_preset_features(current, &features);
+ current->get_platform()->get_platform_features(&features_list);
+ current->get_platform()->get_preset_features(current, &features_list);
String custom = current->get_custom_features();
Vector<String> custom_list = custom.split(",");
for (int i = 0; i < custom_list.size(); i++) {
String f = custom_list[i].strip_edges();
if (!f.is_empty()) {
- features.push_back(f);
+ features_list.push_back(f);
}
}
- for (const String &E : features) {
- fset.insert(E);
+ feature_set.clear();
+ for (const String &E : features_list) {
+ feature_set.insert(E);
}
custom_feature_display->clear();
String text;
bool first = true;
- for (const String &E : fset) {
+ for (const String &E : feature_set) {
if (!first) {
text += ", ";
} else {
@@ -1356,6 +1403,13 @@ ProjectExportDialog::ProjectExportDialog() {
add_child(export_pck_zip);
export_pck_zip->connect("file_selected", callable_mp(this, &ProjectExportDialog::_export_pck_zip_selected));
+ // Export warnings and errors bottom section.
+
+ export_texture_format_error = memnew(ProjectExportTextureFormatError);
+ 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);
main_vb->add_child(export_error);
export_error->hide();
@@ -1390,6 +1444,8 @@ ProjectExportDialog::ProjectExportDialog() {
export_templates_error->add_child(download_templates);
download_templates->connect("pressed", callable_mp(this, &ProjectExportDialog::_open_export_template_manager));
+ // Export project file dialog.
+
export_project = memnew(EditorFileDialog);
export_project->set_access(EditorFileDialog::ACCESS_FILESYSTEM);
add_child(export_project);
diff --git a/editor/export/project_export.h b/editor/export/project_export.h
index e53e393432..4f76167e22 100644
--- a/editor/export/project_export.h
+++ b/editor/export/project_export.h
@@ -41,6 +41,7 @@ class EditorFileSystemDirectory;
class EditorInspector;
class EditorPropertyPath;
class ItemList;
+class LinkButton;
class MenuButton;
class OptionButton;
class PopupMenu;
@@ -49,6 +50,23 @@ class TabContainer;
class Tree;
class TreeItem;
+class ProjectExportTextureFormatError : public HBoxContainer {
+ GDCLASS(ProjectExportTextureFormatError, HBoxContainer);
+
+ Label *texture_format_error_label = nullptr;
+ LinkButton *fix_texture_format_button = nullptr;
+ String setting_identifier;
+ void _on_fix_texture_format_pressed();
+
+protected:
+ static void _bind_methods();
+ void _notification(int p_what);
+
+public:
+ void show_for_texture_format(const String &p_friendly_name, const String &p_setting_identifier);
+ ProjectExportTextureFormatError();
+};
+
class ProjectExportDialog : public ConfirmationDialog {
GDCLASS(ProjectExportDialog, ConfirmationDialog);
@@ -86,12 +104,14 @@ private:
Button *export_all_button = nullptr;
AcceptDialog *export_all_dialog = nullptr;
+ RBSet<String> feature_set;
LineEdit *custom_features = nullptr;
RichTextLabel *custom_feature_display = nullptr;
LineEdit *script_key = nullptr;
Label *script_key_error = nullptr;
+ ProjectExportTextureFormatError *export_texture_format_error = nullptr;
Label *export_error = nullptr;
Label *export_warning = nullptr;
HBoxContainer *export_templates_error = nullptr;
diff --git a/platform/android/export/export_plugin.cpp b/platform/android/export/export_plugin.cpp
index 20aaed1e3e..21de46f4fc 100644
--- a/platform/android/export/export_plugin.cpp
+++ b/platform/android/export/export_plugin.cpp
@@ -47,6 +47,7 @@
#include "editor/editor_paths.h"
#include "editor/editor_scale.h"
#include "editor/editor_settings.h"
+#include "editor/import/resource_importer_texture_settings.h"
#include "main/splash.gen.h"
#include "scene/resources/image_texture.h"
@@ -2384,10 +2385,8 @@ bool EditorExportPlatformAndroid::has_valid_project_configuration(const Ref<Edit
}
}
- String etc_error = test_etc2();
- if (!etc_error.is_empty()) {
+ if (!ResourceImporterTextureSettings::should_import_etc2_astc()) {
valid = false;
- err += etc_error;
}
String min_sdk_str = p_preset->get("gradle_build/min_sdk");
diff --git a/platform/ios/export/export_plugin.cpp b/platform/ios/export/export_plugin.cpp
index 3d63b7bb55..b6320fb22b 100644
--- a/platform/ios/export/export_plugin.cpp
+++ b/platform/ios/export/export_plugin.cpp
@@ -39,6 +39,7 @@
#include "editor/editor_paths.h"
#include "editor/editor_scale.h"
#include "editor/export/editor_export.h"
+#include "editor/import/resource_importer_texture_settings.h"
#include "editor/plugins/script_editor_plugin.h"
#include "modules/modules_enabled.gen.h" // For mono and svg.
@@ -1984,10 +1985,8 @@ bool EditorExportPlatformIOS::has_valid_project_configuration(const Ref<EditorEx
}
}
- const String etc_error = test_etc2();
- if (!etc_error.is_empty()) {
+ if (!ResourceImporterTextureSettings::should_import_etc2_astc()) {
valid = false;
- err += etc_error;
}
if (!err.is_empty()) {
diff --git a/platform/macos/export/export_plugin.cpp b/platform/macos/export/export_plugin.cpp
index e788ff1eec..6586fe7f82 100644
--- a/platform/macos/export/export_plugin.cpp
+++ b/platform/macos/export/export_plugin.cpp
@@ -41,6 +41,7 @@
#include "editor/editor_node.h"
#include "editor/editor_paths.h"
#include "editor/editor_scale.h"
+#include "editor/import/resource_importer_texture_settings.h"
#include "scene/resources/image_texture.h"
#include "modules/modules_enabled.gen.h" // For svg and regex.
@@ -2124,16 +2125,12 @@ bool EditorExportPlatformMacOS::has_valid_export_configuration(const Ref<EditorE
// Check the texture formats, which vary depending on the target architecture.
String architecture = p_preset->get("binary_format/architecture");
if (architecture == "universal" || architecture == "x86_64") {
- const String bc_error = test_bc();
- if (!bc_error.is_empty()) {
+ if (!ResourceImporterTextureSettings::should_import_s3tc_bptc()) {
valid = false;
- err += bc_error;
}
} else if (architecture == "arm64") {
- const String etc_error = test_etc2();
- if (!etc_error.is_empty()) {
+ if (!ResourceImporterTextureSettings::should_import_etc2_astc()) {
valid = false;
- err += etc_error;
}
} else {
ERR_PRINT("Invalid architecture");
diff --git a/platform/web/export/export_plugin.cpp b/platform/web/export/export_plugin.cpp
index 38e2714d9f..993abd2cee 100644
--- a/platform/web/export/export_plugin.cpp
+++ b/platform/web/export/export_plugin.cpp
@@ -37,6 +37,7 @@
#include "editor/editor_scale.h"
#include "editor/editor_settings.h"
#include "editor/export/editor_export.h"
+#include "editor/import/resource_importer_texture_settings.h"
#include "scene/resources/image_texture.h"
#include "modules/modules_enabled.gen.h" // For mono and svg.
@@ -406,10 +407,8 @@ bool EditorExportPlatformWeb::has_valid_project_configuration(const Ref<EditorEx
// Validate the project configuration.
if (p_preset->get("vram_texture_compression/for_mobile")) {
- String etc_error = test_etc2();
- if (!etc_error.is_empty()) {
+ if (!ResourceImporterTextureSettings::should_import_etc2_astc()) {
valid = false;
- err += etc_error;
}
}