Skip to content

Commit 90cab74

Browse files
committed
Merge pull request #110248 from KoBeWi/unexpected_include_hell
Misc cleanup in EditorExportPlatform
2 parents 38eefba + 1c1c320 commit 90cab74

21 files changed

+63
-42
lines changed

editor/export/editor_export.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@
3333
#include "editor_export_platform.h"
3434
#include "editor_export_plugin.h"
3535

36+
class Timer;
37+
3638
class EditorExport : public Node {
3739
GDCLASS(EditorExport, Node);
3840

editor/export/editor_export_platform.cpp

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,14 @@
3535
#include "core/config/project_settings.h"
3636
#include "core/crypto/crypto_core.h"
3737
#include "core/extension/gdextension.h"
38+
#include "core/io/dir_access.h"
3839
#include "core/io/file_access_encrypted.h"
3940
#include "core/io/file_access_pack.h" // PACK_HEADER_MAGIC, PACK_FORMAT_VERSION
41+
#include "core/io/image.h"
4042
#include "core/io/image_loader.h"
4143
#include "core/io/resource_uid.h"
42-
#include "core/io/zip_io.h"
4344
#include "core/math/random_pcg.h"
45+
#include "core/os/shared_object.h"
4446
#include "core/version.h"
4547
#include "editor/editor_node.h"
4648
#include "editor/editor_string_names.h"
@@ -51,8 +53,10 @@
5153
#include "editor/settings/editor_settings.h"
5254
#include "editor/themes/editor_scale.h"
5355
#include "editor_export_plugin.h"
54-
#include "scene/resources/image_texture.h"
56+
#include "scene/gui/rich_text_label.h"
57+
#include "scene/main/node.h"
5558
#include "scene/resources/packed_scene.h"
59+
#include "scene/resources/texture.h"
5660

5761
class EditorExportSaveProxy {
5862
HashSet<String> saved_paths;
@@ -84,7 +88,7 @@ static int _get_pad(int p_alignment, int p_n) {
8488
return pad;
8589
}
8690

87-
#define PCK_PADDING 16
91+
static constexpr int PCK_PADDING = 16;
8892

8993
Ref<Image> EditorExportPlatform::_load_icon_or_splash_image(const String &p_path, Error *r_error) const {
9094
Ref<Image> image;
@@ -311,11 +315,7 @@ Error EditorExportPlatform::_save_pack_file(void *p_userdata, const String &p_pa
311315

312316
PackData *pd = (PackData *)p_userdata;
313317

314-
String simplified_path = p_path.simplify_path();
315-
if (simplified_path.begins_with("uid://")) {
316-
simplified_path = ResourceUID::uid_to_path(simplified_path).simplify_path();
317-
print_verbose(vformat(R"(UID referenced exported file name "%s" was replaced with "%s".)", p_path, simplified_path));
318-
}
318+
const String simplified_path = simplify_path(p_path);
319319

320320
Ref<FileAccess> ftmp;
321321
if (pd->use_sparse_pck) {
@@ -374,13 +374,7 @@ Error EditorExportPlatform::_save_pack_patch_file(void *p_userdata, const String
374374
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) {
375375
ERR_FAIL_COND_V_MSG(p_total < 1, ERR_PARAMETER_RANGE_ERROR, "Must select at least one file to export.");
376376

377-
String path = p_path.simplify_path();
378-
if (path.begins_with("uid://")) {
379-
path = ResourceUID::uid_to_path(path).simplify_path();
380-
print_verbose(vformat(R"(UID referenced exported file name "%s" was replaced with "%s".)", p_path, path));
381-
}
382-
383-
path = path.replace_first("res://", "");
377+
const String path = simplify_path(p_path).replace_first("res://", "");
384378

385379
ZipData *zd = (ZipData *)p_userdata;
386380

@@ -1046,11 +1040,7 @@ Error EditorExportPlatform::_script_save_file(void *p_userdata, const String &p_
10461040
Callable cb = ((ScriptCallbackData *)p_userdata)->file_cb;
10471041
ERR_FAIL_COND_V(!cb.is_valid(), FAILED);
10481042

1049-
String simplified_path = p_path.simplify_path();
1050-
if (simplified_path.begins_with("uid://")) {
1051-
simplified_path = ResourceUID::uid_to_path(simplified_path).simplify_path();
1052-
print_verbose(vformat(R"(UID referenced exported file name "%s" was replaced with "%s".)", p_path, simplified_path));
1053-
}
1043+
const String simplified_path = simplify_path(p_path);
10541044

10551045
Variant path = simplified_path;
10561046
Variant data = p_data;
@@ -2494,6 +2484,16 @@ Array EditorExportPlatform::get_current_presets() const {
24942484
return ret;
24952485
}
24962486

2487+
String EditorExportPlatform::simplify_path(const String &p_path) {
2488+
if (p_path.begins_with("uid://")) {
2489+
const String path = ResourceUID::uid_to_path(p_path);
2490+
print_verbose(vformat(R"(UID-referenced exported file name "%s" was replaced with "%s".)", p_path, path));
2491+
return path.simplify_path();
2492+
} else {
2493+
return p_path.simplify_path();
2494+
}
2495+
}
2496+
24972497
Variant EditorExportPlatform::get_project_setting(const Ref<EditorExportPreset> &p_preset, const StringName &p_name) {
24982498
if (p_preset.is_valid()) {
24992499
return p_preset->get_project_setting(p_name);

editor/export/editor_export_platform.h

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -30,19 +30,19 @@
3030

3131
#pragma once
3232

33-
class EditorFileSystemDirectory;
34-
struct EditorProgress;
35-
36-
#include "core/config/project_settings.h"
37-
#include "core/io/dir_access.h"
3833
#include "core/io/zip_io.h"
39-
#include "core/os/shared_object.h"
40-
#include "editor_export_preset.h"
41-
#include "scene/gui/rich_text_label.h"
42-
#include "scene/main/node.h"
43-
#include "scene/resources/image_texture.h"
34+
#include "core/os/os.h"
35+
#include "editor/export/editor_export_preset.h"
4436

37+
class DirAccess;
4538
class EditorExportPlugin;
39+
class EditorFileSystemDirectory;
40+
class Image;
41+
class Node;
42+
class RichTextLabel;
43+
class Texture2D;
44+
struct EditorProgress;
45+
struct SharedObject;
4646

4747
const String ENV_SCRIPT_ENCRYPTION_KEY = "GODOT_SCRIPT_ENCRYPTION_KEY";
4848

@@ -216,6 +216,7 @@ class EditorExportPlatform : public RefCounted {
216216
#endif
217217

218218
public:
219+
static String simplify_path(const String &p_path);
219220
static Variant get_project_setting(const Ref<EditorExportPreset> &p_preset, const StringName &p_name);
220221
virtual void get_preset_features(const Ref<EditorExportPreset> &p_preset, List<String> *r_features) const = 0;
221222

editor/export/editor_export_platform_apple_embedded.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
#include "plugin_config_apple_embedded.h"
3434

3535
#include "core/config/project_settings.h"
36+
#include "core/io/dir_access.h"
3637
#include "core/io/file_access.h"
3738
#include "core/io/image_loader.h"
3839
#include "core/io/marshalls.h"

editor/export/editor_export_platform_extension.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@
3030

3131
#include "editor_export_platform_extension.h"
3232

33+
#include "scene/resources/image_texture.h"
34+
3335
void EditorExportPlatformExtension::_bind_methods() {
3436
ClassDB::bind_method(D_METHOD("set_config_error", "error_text"), &EditorExportPlatformExtension::set_config_error);
3537
ClassDB::bind_method(D_METHOD("get_config_error"), &EditorExportPlatformExtension::get_config_error);

editor/export/editor_export_platform_extension.h

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,12 @@
3030

3131
#pragma once
3232

33-
#include "editor_export_platform.h"
34-
#include "editor_export_preset.h"
33+
#include "core/object/gdvirtual.gen.inc"
34+
#include "core/variant/typed_array.h"
35+
#include "editor/export/editor_export_platform.h"
36+
#include "editor/export/editor_export_preset.h"
37+
38+
class ImageTexture;
3539

3640
class EditorExportPlatformExtension : public EditorExportPlatform {
3741
GDCLASS(EditorExportPlatformExtension, EditorExportPlatform);

editor/export/editor_export_platform_pc.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@
3131
#include "editor_export_platform_pc.h"
3232

3333
#include "core/config/project_settings.h"
34+
#include "core/io/dir_access.h"
35+
#include "core/os/shared_object.h"
3436
#include "scene/resources/image_texture.h"
3537

3638
void EditorExportPlatformPC::get_preset_features(const Ref<EditorExportPreset> &p_preset, List<String> *r_features) const {

editor/export/editor_export_platform_pc.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@
3232

3333
#include "editor_export_platform.h"
3434

35+
class ImageTexture;
36+
3537
class EditorExportPlatformPC : public EditorExportPlatform {
3638
GDCLASS(EditorExportPlatformPC, EditorExportPlatform);
3739

editor/export/editor_export_preset.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
#include "editor_export.h"
3232

3333
#include "core/config/project_settings.h"
34+
#include "core/io/dir_access.h"
3435
#include "editor/settings/editor_settings.h"
3536

3637
bool EditorExportPreset::_set(const StringName &p_name, const Variant &p_value) {

editor/export/project_export.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@
5050
#include "scene/gui/menu_button.h"
5151
#include "scene/gui/option_button.h"
5252
#include "scene/gui/popup_menu.h"
53+
#include "scene/gui/rich_text_label.h"
5354
#include "scene/gui/split_container.h"
5455
#include "scene/gui/tab_container.h"
5556
#include "scene/gui/texture_rect.h"

0 commit comments

Comments
 (0)