Browse Source

Merge pull request #110248 from KoBeWi/unexpected_include_hell

Misc cleanup in EditorExportPlatform
Thaddeus Crews 1 tháng trước cách đây
mục cha
commit
90cab74af9

+ 2 - 0
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);
 

+ 20 - 20
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<String> 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<Image> EditorExportPlatform::_load_icon_or_splash_image(const String &p_path, Error *r_error) const {
 	Ref<Image> 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<FileAccess> 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<uint8_t> &p_data, int p_file, int p_total, const Vector<String> &p_enc_in_filters, const Vector<String> &p_enc_ex_filters, const Vector<uint8_t> &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<EditorExportPreset> &p_preset, const StringName &p_name) {
 	if (p_preset.is_valid()) {
 		return p_preset->get_project_setting(p_name);

+ 11 - 10
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<EditorExportPreset> &p_preset, const StringName &p_name);
 	virtual void get_preset_features(const Ref<EditorExportPreset> &p_preset, List<String> *r_features) const = 0;
 

+ 1 - 0
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"

+ 2 - 0
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);

+ 6 - 2
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);

+ 2 - 0
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<EditorExportPreset> &p_preset, List<String> *r_features) const {

+ 2 - 0
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);
 

+ 1 - 0
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) {

+ 1 - 0
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"

+ 1 - 0
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"

+ 1 - 5
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<uint8_t> &p_data, int p_file, int p_total, const Vector<String> &p_enc_in_filters, const Vector<String> &p_enc_ex_filters, const Vector<uint8_t> &p_key, uint64_t p_seed) {
 	APKExportData *ed = static_cast<APKExportData *>(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<uint8_t> enc_data;
 	EditorExportPlatform::SavedData sd;

+ 2 - 0
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";

+ 1 - 5
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<uint8_t> &p_data, int p_file, int p_total, const Vector<String> &p_enc_in_filters, const Vector<String> &p_enc_ex_filters, const Vector<uint8_t> &p_key, uint64_t p_seed) {
 	CustomExportData *export_data = static_cast<CustomExportData *>(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<uint8_t> enc_data;
 	EditorExportPlatform::SavedData sd;

+ 1 - 0
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"(<?xml version="1.0" encoding="utf-8"?>
 <!--WARNING: THIS FILE WILL BE OVERWRITTEN AT BUILD TIME-->

+ 1 - 0
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"

+ 1 - 0
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 <sys/stat.h>
 

+ 1 - 0
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"

+ 2 - 0
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);
 

+ 2 - 0
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"
 

+ 2 - 0
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<uint8_t> &r_bytes) const {
 	save(p_value, r_bytes, 1);