From 1c1c3200e4b39c6184eaa3a69e8104d76d7a26be Mon Sep 17 00:00:00 2001 From: kobewi Date: Thu, 4 Sep 2025 13:19:22 +0200 Subject: [PATCH] Misc cleanup in EditorExportPlatform --- editor/export/editor_export.h | 2 + editor/export/editor_export_platform.cpp | 40 +++++++++---------- editor/export/editor_export_platform.h | 21 +++++----- .../editor_export_platform_apple_embedded.h | 1 + .../editor_export_platform_extension.cpp | 2 + .../export/editor_export_platform_extension.h | 8 +++- editor/export/editor_export_platform_pc.cpp | 2 + editor/export/editor_export_platform_pc.h | 2 + editor/export/editor_export_preset.cpp | 1 + editor/export/project_export.cpp | 1 + editor/export/shader_baker_export_plugin.cpp | 1 + platform/android/export/export_plugin.cpp | 6 +-- platform/android/export/export_plugin.h | 2 + .../android/export/gradle_export_util.cpp | 6 +-- platform/android/export/gradle_export_util.h | 1 + platform/linuxbsd/export/export_plugin.cpp | 1 + platform/macos/export/export_plugin.h | 1 + platform/web/export/export_plugin.cpp | 1 + platform/web/export/export_plugin.h | 2 + platform/windows/export/export_plugin.cpp | 2 + platform/windows/export/template_modifier.cpp | 2 + 21 files changed, 63 insertions(+), 42 deletions(-) diff --git a/editor/export/editor_export.h b/editor/export/editor_export.h index ec99e92ce7f..396f57a75e7 100644 --- a/editor/export/editor_export.h +++ b/editor/export/editor_export.h @@ -33,6 +33,8 @@ #include "editor_export_platform.h" #include "editor_export_plugin.h" +class Timer; + class EditorExport : public Node { GDCLASS(EditorExport, Node); diff --git a/editor/export/editor_export_platform.cpp b/editor/export/editor_export_platform.cpp index 541af413183..25ae10da041 100644 --- a/editor/export/editor_export_platform.cpp +++ b/editor/export/editor_export_platform.cpp @@ -35,12 +35,14 @@ #include "core/config/project_settings.h" #include "core/crypto/crypto_core.h" #include "core/extension/gdextension.h" +#include "core/io/dir_access.h" #include "core/io/file_access_encrypted.h" #include "core/io/file_access_pack.h" // PACK_HEADER_MAGIC, PACK_FORMAT_VERSION +#include "core/io/image.h" #include "core/io/image_loader.h" #include "core/io/resource_uid.h" -#include "core/io/zip_io.h" #include "core/math/random_pcg.h" +#include "core/os/shared_object.h" #include "core/version.h" #include "editor/editor_node.h" #include "editor/editor_string_names.h" @@ -51,8 +53,10 @@ #include "editor/settings/editor_settings.h" #include "editor/themes/editor_scale.h" #include "editor_export_plugin.h" -#include "scene/resources/image_texture.h" +#include "scene/gui/rich_text_label.h" +#include "scene/main/node.h" #include "scene/resources/packed_scene.h" +#include "scene/resources/texture.h" class EditorExportSaveProxy { HashSet saved_paths; @@ -84,7 +88,7 @@ static int _get_pad(int p_alignment, int p_n) { return pad; } -#define PCK_PADDING 16 +static constexpr int PCK_PADDING = 16; Ref EditorExportPlatform::_load_icon_or_splash_image(const String &p_path, Error *r_error) const { Ref image; @@ -311,11 +315,7 @@ Error EditorExportPlatform::_save_pack_file(void *p_userdata, const String &p_pa PackData *pd = (PackData *)p_userdata; - String simplified_path = p_path.simplify_path(); - if (simplified_path.begins_with("uid://")) { - simplified_path = ResourceUID::uid_to_path(simplified_path).simplify_path(); - print_verbose(vformat(R"(UID referenced exported file name "%s" was replaced with "%s".)", p_path, simplified_path)); - } + const String simplified_path = simplify_path(p_path); Ref ftmp; if (pd->use_sparse_pck) { @@ -374,13 +374,7 @@ Error EditorExportPlatform::_save_pack_patch_file(void *p_userdata, const String Error EditorExportPlatform::_save_zip_file(void *p_userdata, const String &p_path, const Vector &p_data, int p_file, int p_total, const Vector &p_enc_in_filters, const Vector &p_enc_ex_filters, const Vector &p_key, uint64_t p_seed) { ERR_FAIL_COND_V_MSG(p_total < 1, ERR_PARAMETER_RANGE_ERROR, "Must select at least one file to export."); - String path = p_path.simplify_path(); - if (path.begins_with("uid://")) { - path = ResourceUID::uid_to_path(path).simplify_path(); - print_verbose(vformat(R"(UID referenced exported file name "%s" was replaced with "%s".)", p_path, path)); - } - - path = path.replace_first("res://", ""); + const String path = simplify_path(p_path).replace_first("res://", ""); ZipData *zd = (ZipData *)p_userdata; @@ -1046,11 +1040,7 @@ Error EditorExportPlatform::_script_save_file(void *p_userdata, const String &p_ Callable cb = ((ScriptCallbackData *)p_userdata)->file_cb; ERR_FAIL_COND_V(!cb.is_valid(), FAILED); - String simplified_path = p_path.simplify_path(); - if (simplified_path.begins_with("uid://")) { - simplified_path = ResourceUID::uid_to_path(simplified_path).simplify_path(); - print_verbose(vformat(R"(UID referenced exported file name "%s" was replaced with "%s".)", p_path, simplified_path)); - } + const String simplified_path = simplify_path(p_path); Variant path = simplified_path; Variant data = p_data; @@ -2494,6 +2484,16 @@ Array EditorExportPlatform::get_current_presets() const { return ret; } +String EditorExportPlatform::simplify_path(const String &p_path) { + if (p_path.begins_with("uid://")) { + const String path = ResourceUID::uid_to_path(p_path); + print_verbose(vformat(R"(UID-referenced exported file name "%s" was replaced with "%s".)", p_path, path)); + return path.simplify_path(); + } else { + return p_path.simplify_path(); + } +} + Variant EditorExportPlatform::get_project_setting(const Ref &p_preset, const StringName &p_name) { if (p_preset.is_valid()) { return p_preset->get_project_setting(p_name); diff --git a/editor/export/editor_export_platform.h b/editor/export/editor_export_platform.h index 4f6ddaa480a..650dbdb7f18 100644 --- a/editor/export/editor_export_platform.h +++ b/editor/export/editor_export_platform.h @@ -30,19 +30,19 @@ #pragma once -class EditorFileSystemDirectory; -struct EditorProgress; - -#include "core/config/project_settings.h" -#include "core/io/dir_access.h" #include "core/io/zip_io.h" -#include "core/os/shared_object.h" -#include "editor_export_preset.h" -#include "scene/gui/rich_text_label.h" -#include "scene/main/node.h" -#include "scene/resources/image_texture.h" +#include "core/os/os.h" +#include "editor/export/editor_export_preset.h" +class DirAccess; class EditorExportPlugin; +class EditorFileSystemDirectory; +class Image; +class Node; +class RichTextLabel; +class Texture2D; +struct EditorProgress; +struct SharedObject; const String ENV_SCRIPT_ENCRYPTION_KEY = "GODOT_SCRIPT_ENCRYPTION_KEY"; @@ -216,6 +216,7 @@ protected: #endif public: + static String simplify_path(const String &p_path); static Variant get_project_setting(const Ref &p_preset, const StringName &p_name); virtual void get_preset_features(const Ref &p_preset, List *r_features) const = 0; diff --git a/editor/export/editor_export_platform_apple_embedded.h b/editor/export/editor_export_platform_apple_embedded.h index 5acc80b8fc9..5a297ed5f3c 100644 --- a/editor/export/editor_export_platform_apple_embedded.h +++ b/editor/export/editor_export_platform_apple_embedded.h @@ -33,6 +33,7 @@ #include "plugin_config_apple_embedded.h" #include "core/config/project_settings.h" +#include "core/io/dir_access.h" #include "core/io/file_access.h" #include "core/io/image_loader.h" #include "core/io/marshalls.h" diff --git a/editor/export/editor_export_platform_extension.cpp b/editor/export/editor_export_platform_extension.cpp index b185fa4c93e..72d217c6849 100644 --- a/editor/export/editor_export_platform_extension.cpp +++ b/editor/export/editor_export_platform_extension.cpp @@ -30,6 +30,8 @@ #include "editor_export_platform_extension.h" +#include "scene/resources/image_texture.h" + void EditorExportPlatformExtension::_bind_methods() { ClassDB::bind_method(D_METHOD("set_config_error", "error_text"), &EditorExportPlatformExtension::set_config_error); ClassDB::bind_method(D_METHOD("get_config_error"), &EditorExportPlatformExtension::get_config_error); diff --git a/editor/export/editor_export_platform_extension.h b/editor/export/editor_export_platform_extension.h index fcce05015db..87f9424ac70 100644 --- a/editor/export/editor_export_platform_extension.h +++ b/editor/export/editor_export_platform_extension.h @@ -30,8 +30,12 @@ #pragma once -#include "editor_export_platform.h" -#include "editor_export_preset.h" +#include "core/object/gdvirtual.gen.inc" +#include "core/variant/typed_array.h" +#include "editor/export/editor_export_platform.h" +#include "editor/export/editor_export_preset.h" + +class ImageTexture; class EditorExportPlatformExtension : public EditorExportPlatform { GDCLASS(EditorExportPlatformExtension, EditorExportPlatform); diff --git a/editor/export/editor_export_platform_pc.cpp b/editor/export/editor_export_platform_pc.cpp index 2a2983d4337..eca3d781366 100644 --- a/editor/export/editor_export_platform_pc.cpp +++ b/editor/export/editor_export_platform_pc.cpp @@ -31,6 +31,8 @@ #include "editor_export_platform_pc.h" #include "core/config/project_settings.h" +#include "core/io/dir_access.h" +#include "core/os/shared_object.h" #include "scene/resources/image_texture.h" void EditorExportPlatformPC::get_preset_features(const Ref &p_preset, List *r_features) const { diff --git a/editor/export/editor_export_platform_pc.h b/editor/export/editor_export_platform_pc.h index 5760543241b..09747c4a2df 100644 --- a/editor/export/editor_export_platform_pc.h +++ b/editor/export/editor_export_platform_pc.h @@ -32,6 +32,8 @@ #include "editor_export_platform.h" +class ImageTexture; + class EditorExportPlatformPC : public EditorExportPlatform { GDCLASS(EditorExportPlatformPC, EditorExportPlatform); diff --git a/editor/export/editor_export_preset.cpp b/editor/export/editor_export_preset.cpp index 357e3a4ff22..72f33f9fe0f 100644 --- a/editor/export/editor_export_preset.cpp +++ b/editor/export/editor_export_preset.cpp @@ -31,6 +31,7 @@ #include "editor_export.h" #include "core/config/project_settings.h" +#include "core/io/dir_access.h" #include "editor/settings/editor_settings.h" bool EditorExportPreset::_set(const StringName &p_name, const Variant &p_value) { diff --git a/editor/export/project_export.cpp b/editor/export/project_export.cpp index 3cbc4474fd4..f74af068694 100644 --- a/editor/export/project_export.cpp +++ b/editor/export/project_export.cpp @@ -50,6 +50,7 @@ #include "scene/gui/menu_button.h" #include "scene/gui/option_button.h" #include "scene/gui/popup_menu.h" +#include "scene/gui/rich_text_label.h" #include "scene/gui/split_container.h" #include "scene/gui/tab_container.h" #include "scene/gui/texture_rect.h" diff --git a/editor/export/shader_baker_export_plugin.cpp b/editor/export/shader_baker_export_plugin.cpp index 7d1dba6136c..d6d1a8eaac1 100644 --- a/editor/export/shader_baker_export_plugin.cpp +++ b/editor/export/shader_baker_export_plugin.cpp @@ -31,6 +31,7 @@ #include "shader_baker_export_plugin.h" #include "core/config/project_settings.h" +#include "core/io/dir_access.h" #include "core/version.h" #include "editor/editor_node.h" #include "scene/3d/label_3d.h" diff --git a/platform/android/export/export_plugin.cpp b/platform/android/export/export_plugin.cpp index 14f5ef6f0fa..ef06fb81286 100644 --- a/platform/android/export/export_plugin.cpp +++ b/platform/android/export/export_plugin.cpp @@ -801,11 +801,7 @@ Error EditorExportPlatformAndroid::save_apk_so(void *p_userdata, const SharedObj Error EditorExportPlatformAndroid::save_apk_file(void *p_userdata, const String &p_path, const Vector &p_data, int p_file, int p_total, const Vector &p_enc_in_filters, const Vector &p_enc_ex_filters, const Vector &p_key, uint64_t p_seed) { APKExportData *ed = static_cast(p_userdata); - String simplified_path = p_path.simplify_path(); - if (simplified_path.begins_with("uid://")) { - simplified_path = ResourceUID::uid_to_path(simplified_path).simplify_path(); - print_verbose(vformat(R"(UID referenced exported file name "%s" was replaced with "%s".)", p_path, simplified_path)); - } + const String simplified_path = simplify_path(p_path); Vector enc_data; EditorExportPlatform::SavedData sd; diff --git a/platform/android/export/export_plugin.h b/platform/android/export/export_plugin.h index 4fab3f84a9e..541bc417bdf 100644 --- a/platform/android/export/export_plugin.h +++ b/platform/android/export/export_plugin.h @@ -41,6 +41,8 @@ #include "core/os/os.h" #include "editor/export/editor_export_platform.h" +class ImageTexture; + // Optional environment variables for defining confidential information. If any // of these is set, they will override the values set in the credentials file. const String ENV_ANDROID_KEYSTORE_DEBUG_PATH = "GODOT_ANDROID_KEYSTORE_DEBUG_PATH"; diff --git a/platform/android/export/gradle_export_util.cpp b/platform/android/export/gradle_export_util.cpp index a821962ddff..212ee275bdc 100644 --- a/platform/android/export/gradle_export_util.cpp +++ b/platform/android/export/gradle_export_util.cpp @@ -172,11 +172,7 @@ Error store_string_at_path(const String &p_path, const String &p_data) { Error rename_and_store_file_in_gradle_project(void *p_userdata, const String &p_path, const Vector &p_data, int p_file, int p_total, const Vector &p_enc_in_filters, const Vector &p_enc_ex_filters, const Vector &p_key, uint64_t p_seed) { CustomExportData *export_data = static_cast(p_userdata); - String simplified_path = p_path.simplify_path(); - if (simplified_path.begins_with("uid://")) { - simplified_path = ResourceUID::uid_to_path(simplified_path).simplify_path(); - print_verbose(vformat(R"(UID referenced exported file name "%s" was replaced with "%s".)", p_path, simplified_path)); - } + const String simplified_path = EditorExportPlatform::simplify_path(p_path); Vector enc_data; EditorExportPlatform::SavedData sd; diff --git a/platform/android/export/gradle_export_util.h b/platform/android/export/gradle_export_util.h index ea5aabfb92f..96fddd223ba 100644 --- a/platform/android/export/gradle_export_util.h +++ b/platform/android/export/gradle_export_util.h @@ -37,6 +37,7 @@ #include "core/os/os.h" #include "editor/export/editor_export.h" #include "editor/export/editor_export_platform.h" +#include "servers/display/display_server.h" const String GODOT_PROJECT_NAME_XML_STRING = R"( diff --git a/platform/linuxbsd/export/export_plugin.cpp b/platform/linuxbsd/export/export_plugin.cpp index 837cdf710b7..b73c2510c85 100644 --- a/platform/linuxbsd/export/export_plugin.cpp +++ b/platform/linuxbsd/export/export_plugin.cpp @@ -34,6 +34,7 @@ #include "run_icon_svg.gen.h" #include "core/config/project_settings.h" +#include "core/io/dir_access.h" #include "editor/editor_node.h" #include "editor/editor_string_names.h" #include "editor/export/editor_export.h" diff --git a/platform/macos/export/export_plugin.h b/platform/macos/export/export_plugin.h index d67daa459cf..d47d6f960fb 100644 --- a/platform/macos/export/export_plugin.h +++ b/platform/macos/export/export_plugin.h @@ -39,6 +39,7 @@ #include "core/os/os.h" #include "editor/export/editor_export.h" #include "editor/settings/editor_settings.h" +#include "scene/resources/image_texture.h" #include diff --git a/platform/web/export/export_plugin.cpp b/platform/web/export/export_plugin.cpp index 4ea8665a424..7d817a79af9 100644 --- a/platform/web/export/export_plugin.cpp +++ b/platform/web/export/export_plugin.cpp @@ -34,6 +34,7 @@ #include "run_icon_svg.gen.h" #include "core/config/project_settings.h" +#include "core/io/dir_access.h" #include "editor/editor_string_names.h" #include "editor/export/editor_export.h" #include "editor/import/resource_importer_texture_settings.h" diff --git a/platform/web/export/export_plugin.h b/platform/web/export/export_plugin.h index 36828f0defd..2f8efcd240c 100644 --- a/platform/web/export/export_plugin.h +++ b/platform/web/export/export_plugin.h @@ -42,6 +42,8 @@ #include "editor/export/editor_export_platform.h" #include "main/splash.gen.h" +class ImageTexture; + class EditorExportPlatformWeb : public EditorExportPlatform { GDCLASS(EditorExportPlatformWeb, EditorExportPlatform); diff --git a/platform/windows/export/export_plugin.cpp b/platform/windows/export/export_plugin.cpp index dad6f9e1623..a66752aca42 100644 --- a/platform/windows/export/export_plugin.cpp +++ b/platform/windows/export/export_plugin.cpp @@ -35,12 +35,14 @@ #include "template_modifier.h" #include "core/config/project_settings.h" +#include "core/io/dir_access.h" #include "core/io/image_loader.h" #include "editor/editor_node.h" #include "editor/editor_string_names.h" #include "editor/export/editor_export.h" #include "editor/file_system/editor_paths.h" #include "editor/themes/editor_scale.h" +#include "scene/resources/image_texture.h" #include "modules/svg/image_loader_svg.h" diff --git a/platform/windows/export/template_modifier.cpp b/platform/windows/export/template_modifier.cpp index c55d42e9ab6..6a76c33db17 100644 --- a/platform/windows/export/template_modifier.cpp +++ b/platform/windows/export/template_modifier.cpp @@ -31,6 +31,8 @@ #include "template_modifier.h" #include "core/config/project_settings.h" +#include "core/io/dir_access.h" +#include "core/io/image.h" void TemplateModifier::ByteStream::save(uint8_t p_value, Vector &r_bytes) const { save(p_value, r_bytes, 1);