Skip to content

Commit a8598cd

Browse files
committed
Merge pull request #71542 from bruvzg/export_project_settings
[Export] Use project settings overrides with the target preset features instead of current platform features.
2 parents c7fc877 + c6739f6 commit a8598cd

22 files changed

+251
-123
lines changed

core/config/project_settings.cpp

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -359,6 +359,29 @@ bool ProjectSettings::_get(const StringName &p_name, Variant &r_ret) const {
359359
return true;
360360
}
361361

362+
Variant ProjectSettings::get_setting_with_override_and_custom_features(const StringName &p_name, const Vector<String> &p_features) const {
363+
_THREAD_SAFE_METHOD_
364+
365+
StringName name = p_name;
366+
if (feature_overrides.has(name)) {
367+
const LocalVector<Pair<StringName, StringName>> &overrides = feature_overrides[name];
368+
for (uint32_t i = 0; i < overrides.size(); i++) {
369+
if (p_features.has(String(overrides[i].first).to_lower())) {
370+
if (props.has(overrides[i].second)) {
371+
name = overrides[i].second;
372+
break;
373+
}
374+
}
375+
}
376+
}
377+
378+
if (!props.has(name)) {
379+
WARN_PRINT("Property not found: " + String(name));
380+
return Variant();
381+
}
382+
return props[name].variant;
383+
}
384+
362385
Variant ProjectSettings::get_setting_with_override(const StringName &p_name) const {
363386
_THREAD_SAFE_METHOD_
364387

@@ -1411,6 +1434,7 @@ void ProjectSettings::_bind_methods() {
14111434
ClassDB::bind_method(D_METHOD("get_setting", "name", "default_value"), &ProjectSettings::get_setting, DEFVAL(Variant()));
14121435
ClassDB::bind_method(D_METHOD("get_setting_with_override", "name"), &ProjectSettings::get_setting_with_override);
14131436
ClassDB::bind_method(D_METHOD("get_global_class_list"), &ProjectSettings::get_global_class_list);
1437+
ClassDB::bind_method(D_METHOD("get_setting_with_override_and_custom_features", "name", "features"), &ProjectSettings::get_setting_with_override_and_custom_features);
14141438
ClassDB::bind_method(D_METHOD("set_order", "name", "position"), &ProjectSettings::set_order);
14151439
ClassDB::bind_method(D_METHOD("get_order", "name"), &ProjectSettings::get_order);
14161440
ClassDB::bind_method(D_METHOD("set_initial_value", "name", "value"), &ProjectSettings::set_initial_value);

core/config/project_settings.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,7 @@ class ProjectSettings : public Object {
193193
List<String> get_input_presets() const { return input_presets; }
194194

195195
Variant get_setting_with_override(const StringName &p_name) const;
196+
Variant get_setting_with_override_and_custom_features(const StringName &p_name, const Vector<String> &p_features) const;
196197

197198
bool is_using_datapack() const;
198199
bool is_project_loaded() const;

doc/classes/EditorExportPlatform.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,7 @@
121121
</method>
122122
<method name="get_forced_export_files" qualifiers="static">
123123
<return type="PackedStringArray" />
124+
<param index="0" name="preset" type="EditorExportPreset" />
124125
<description>
125126
Returns array of core file names that always should be exported regardless of preset config.
126127
</description>

doc/classes/EditorExportPreset.xml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,13 @@
121121
Returns export preset name.
122122
</description>
123123
</method>
124+
<method name="get_project_setting">
125+
<return type="Variant" />
126+
<param index="0" name="name" type="StringName" />
127+
<description>
128+
Returns the value of the setting identified by [param name] using export preset feature tag overrides instead of current OS features.
129+
</description>
130+
</method>
124131
<method name="get_script_export_mode" qualifiers="const">
125132
<return type="int" />
126133
<description>

doc/classes/ProjectSettings.xml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,14 @@
114114
[/codeblocks]
115115
</description>
116116
</method>
117+
<method name="get_setting_with_override_and_custom_features" qualifiers="const">
118+
<return type="Variant" />
119+
<param index="0" name="name" type="StringName" />
120+
<param index="1" name="features" type="PackedStringArray" />
121+
<description>
122+
Similar to [method get_setting_with_override], but applies feature tag overrides instead of current OS features.
123+
</description>
124+
</method>
117125
<method name="globalize_path" qualifiers="const">
118126
<return type="String" />
119127
<param index="0" name="path" type="String" />

editor/debugger/editor_file_server.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ void EditorFileServer::poll() {
200200
// Scan files to send.
201201
_scan_files_changed(EditorFileSystem::get_singleton()->get_filesystem(), tags, files_to_send, cached_files);
202202
// Add forced export files
203-
Vector<String> forced_export = EditorExportPlatform::get_forced_export_files();
203+
Vector<String> forced_export = EditorExportPlatform::get_forced_export_files(Ref<EditorExportPreset>());
204204
for (int i = 0; i < forced_export.size(); i++) {
205205
_add_custom_file(forced_export[i], files_to_send, cached_files);
206206
}
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
/**************************************************************************/
2+
/* editor_export_platform.compat.inc */
3+
/**************************************************************************/
4+
/* This file is part of: */
5+
/* GODOT ENGINE */
6+
/* https://godotengine.org */
7+
/**************************************************************************/
8+
/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */
9+
/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
10+
/* */
11+
/* Permission is hereby granted, free of charge, to any person obtaining */
12+
/* a copy of this software and associated documentation files (the */
13+
/* "Software"), to deal in the Software without restriction, including */
14+
/* without limitation the rights to use, copy, modify, merge, publish, */
15+
/* distribute, sublicense, and/or sell copies of the Software, and to */
16+
/* permit persons to whom the Software is furnished to do so, subject to */
17+
/* the following conditions: */
18+
/* */
19+
/* The above copyright notice and this permission notice shall be */
20+
/* included in all copies or substantial portions of the Software. */
21+
/* */
22+
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
23+
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
24+
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */
25+
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
26+
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
27+
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
28+
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
29+
/**************************************************************************/
30+
31+
#ifndef DISABLE_DEPRECATED
32+
33+
Vector<String> EditorExportPlatform::_get_forced_export_files_bind_compat_71542() {
34+
return get_forced_export_files(Ref<EditorExportPreset>());
35+
}
36+
37+
void EditorExportPlatform::_bind_compatibility_methods() {
38+
ClassDB::bind_compatibility_static_method("EditorExportPlatform", D_METHOD("get_forced_export_files"), &EditorExportPlatform::_get_forced_export_files_bind_compat_71542);
39+
}
40+
41+
#endif

editor/export/editor_export_platform.cpp

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

3131
#include "editor_export_platform.h"
3232

33+
#include "editor_export_platform.compat.inc"
34+
3335
#include "core/config/project_settings.h"
3436
#include "core/crypto/crypto_core.h"
3537
#include "core/extension/gdextension.h"
@@ -946,7 +948,7 @@ Dictionary EditorExportPlatform::get_internal_export_files(const Ref<EditorExpor
946948
Dictionary files;
947949

948950
// Text server support data.
949-
if (TS->has_feature(TextServer::FEATURE_USE_SUPPORT_DATA) && (bool)GLOBAL_GET("internationalization/locale/include_text_server_data")) {
951+
if (TS->has_feature(TextServer::FEATURE_USE_SUPPORT_DATA) && (bool)get_project_setting(p_preset, "internationalization/locale/include_text_server_data")) {
950952
String ts_name = TS->get_support_data_filename();
951953
String ts_target = "res://" + ts_name;
952954
if (!ts_name.is_empty()) {
@@ -992,13 +994,13 @@ Dictionary EditorExportPlatform::get_internal_export_files(const Ref<EditorExpor
992994
return files;
993995
}
994996

995-
Vector<String> EditorExportPlatform::get_forced_export_files() {
997+
Vector<String> EditorExportPlatform::get_forced_export_files(const Ref<EditorExportPreset> &p_preset) {
996998
Vector<String> files;
997999

9981000
files.push_back(ProjectSettings::get_singleton()->get_global_class_list_path());
9991001

1000-
String icon = ResourceUID::ensure_path(GLOBAL_GET("application/config/icon"));
1001-
String splash = ResourceUID::ensure_path(GLOBAL_GET("application/boot_splash/image"));
1002+
String icon = ResourceUID::ensure_path(get_project_setting(p_preset, "application/config/icon"));
1003+
String splash = ResourceUID::ensure_path(get_project_setting(p_preset, "application/boot_splash/image"));
10021004
if (!icon.is_empty() && FileAccess::exists(icon)) {
10031005
files.push_back(icon);
10041006
}
@@ -1110,7 +1112,7 @@ Error EditorExportPlatform::export_project_files(const Ref<EditorExportPreset> &
11101112
continue;
11111113
}
11121114

1113-
String autoload_path = GLOBAL_GET(pi.name);
1115+
String autoload_path = get_project_setting(p_preset, pi.name);
11141116

11151117
if (autoload_path.begins_with("*")) {
11161118
autoload_path = autoload_path.substr(1);
@@ -1253,7 +1255,7 @@ Error EditorExportPlatform::export_project_files(const Ref<EditorExportPreset> &
12531255
HashMap<String, FileExportCache> export_cache;
12541256
String export_base_path = ProjectSettings::get_singleton()->get_project_data_path().path_join("exported/") + itos(custom_resources_hash);
12551257

1256-
bool convert_text_to_binary = GLOBAL_GET("editor/export/convert_text_resources_to_binary");
1258+
bool convert_text_to_binary = get_project_setting(p_preset, "editor/export/convert_text_resources_to_binary");
12571259

12581260
if (convert_text_to_binary || !customize_resources_plugins.is_empty() || !customize_scenes_plugins.is_empty()) {
12591261
// See if we have something to open
@@ -1565,7 +1567,7 @@ Error EditorExportPlatform::export_project_files(const Ref<EditorExportPreset> &
15651567
}
15661568
}
15671569

1568-
Vector<String> forced_export = get_forced_export_files();
1570+
Vector<String> forced_export = get_forced_export_files(p_preset);
15691571
for (int i = 0; i < forced_export.size(); i++) {
15701572
Vector<uint8_t> array;
15711573
if (GDExtension::get_extension_list_config_file() == forced_export[i]) {
@@ -2464,6 +2466,14 @@ Array EditorExportPlatform::get_current_presets() const {
24642466
return ret;
24652467
}
24662468

2469+
Variant EditorExportPlatform::get_project_setting(const Ref<EditorExportPreset> &p_preset, const StringName &p_name) {
2470+
if (p_preset.is_valid()) {
2471+
return p_preset->get_project_setting(p_name);
2472+
} else {
2473+
return GLOBAL_GET(p_name);
2474+
}
2475+
}
2476+
24672477
void EditorExportPlatform::_bind_methods() {
24682478
ClassDB::bind_method(D_METHOD("get_os_name"), &EditorExportPlatform::get_os_name);
24692479

@@ -2502,7 +2512,7 @@ void EditorExportPlatform::_bind_methods() {
25022512

25032513
ClassDB::bind_method(D_METHOD("get_internal_export_files", "preset", "debug"), &EditorExportPlatform::get_internal_export_files);
25042514

2505-
ClassDB::bind_static_method("EditorExportPlatform", D_METHOD("get_forced_export_files"), &EditorExportPlatform::get_forced_export_files);
2515+
ClassDB::bind_static_method("EditorExportPlatform", D_METHOD("get_forced_export_files", "preset"), &EditorExportPlatform::get_forced_export_files);
25062516

25072517
BIND_ENUM_CONSTANT(EXPORT_MESSAGE_NONE);
25082518
BIND_ENUM_CONSTANT(EXPORT_MESSAGE_INFO);

editor/export/editor_export_platform.h

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
class EditorFileSystemDirectory;
3434
struct EditorProgress;
3535

36+
#include "core/config/project_settings.h"
3637
#include "core/io/dir_access.h"
3738
#include "core/io/zip_io.h"
3839
#include "core/os/shared_object.h"
@@ -203,7 +204,13 @@ class EditorExportPlatform : public RefCounted {
203204

204205
Ref<Image> _load_icon_or_splash_image(const String &p_path, Error *r_error) const;
205206

207+
#ifndef DISABLE_DEPRECATED
208+
static Vector<String> _get_forced_export_files_bind_compat_71542();
209+
static void _bind_compatibility_methods();
210+
#endif
211+
206212
public:
213+
static Variant get_project_setting(const Ref<EditorExportPreset> &p_preset, const StringName &p_name);
207214
virtual void get_preset_features(const Ref<EditorExportPreset> &p_preset, List<String> *r_features) const = 0;
208215

209216
struct ExportOption {
@@ -280,7 +287,7 @@ class EditorExportPlatform : public RefCounted {
280287

281288
Dictionary get_internal_export_files(const Ref<EditorExportPreset> &p_preset, bool p_debug);
282289

283-
static Vector<String> get_forced_export_files();
290+
static Vector<String> get_forced_export_files(const Ref<EditorExportPreset> &p_preset);
284291

285292
virtual bool fill_log_messages(RichTextLabel *p_log, Error p_err);
286293

editor/export/editor_export_preset.cpp

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,29 @@ bool EditorExportPreset::_get(const StringName &p_name, Variant &r_ret) const {
6060
return false;
6161
}
6262

63+
Variant EditorExportPreset::get_project_setting(const StringName &p_name) {
64+
List<String> ftr_list;
65+
platform->get_platform_features(&ftr_list);
66+
platform->get_preset_features(this, &ftr_list);
67+
68+
Vector<String> features;
69+
for (const String &E : ftr_list) {
70+
features.push_back(E);
71+
}
72+
73+
if (!get_custom_features().is_empty()) {
74+
Vector<String> tmp_custom_list = get_custom_features().split(",");
75+
76+
for (int i = 0; i < tmp_custom_list.size(); i++) {
77+
String f = tmp_custom_list[i].strip_edges();
78+
if (!f.is_empty()) {
79+
features.push_back(f);
80+
}
81+
}
82+
}
83+
return ProjectSettings::get_singleton()->get_setting_with_override_and_custom_features(p_name, features);
84+
}
85+
6386
void EditorExportPreset::_bind_methods() {
6487
ClassDB::bind_method(D_METHOD("_get_property_warning", "name"), &EditorExportPreset::_get_property_warning);
6588

@@ -70,6 +93,7 @@ void EditorExportPreset::_bind_methods() {
7093
ClassDB::bind_method(D_METHOD("get_customized_files_count"), &EditorExportPreset::get_customized_files_count);
7194
ClassDB::bind_method(D_METHOD("has_export_file", "path"), &EditorExportPreset::has_export_file);
7295
ClassDB::bind_method(D_METHOD("get_file_export_mode", "path", "default"), &EditorExportPreset::get_file_export_mode, DEFVAL(MODE_FILE_NOT_CUSTOMIZED));
96+
ClassDB::bind_method(D_METHOD("get_project_setting", "name"), &EditorExportPreset::get_project_setting);
7397

7498
ClassDB::bind_method(D_METHOD("get_preset_name"), &EditorExportPreset::get_name);
7599
ClassDB::bind_method(D_METHOD("is_runnable"), &EditorExportPreset::is_runnable);

0 commit comments

Comments
 (0)