From c6739f64dfe178d34704275c4fd40eba5669ccce Mon Sep 17 00:00:00 2001 From: bruvzg <7645683+bruvzg@users.noreply.github.com> Date: Tue, 17 Jan 2023 09:52:17 +0200 Subject: [PATCH] [Export] Use project settings overrides with the target preset features instead of current platform features. --- core/config/project_settings.cpp | 24 ++++++ core/config/project_settings.h | 1 + doc/classes/EditorExportPlatform.xml | 1 + doc/classes/EditorExportPreset.xml | 7 ++ doc/classes/ProjectSettings.xml | 8 ++ editor/debugger/editor_file_server.cpp | 2 +- .../export/editor_export_platform.compat.inc | 41 ++++++++++ editor/export/editor_export_platform.cpp | 26 +++++-- editor/export/editor_export_platform.h | 9 ++- editor/export/editor_export_preset.cpp | 24 ++++++ editor/export/editor_export_preset.h | 2 + .../4.4-stable.expected | 7 ++ platform/android/export/export_plugin.cpp | 75 +++++++++---------- platform/android/export/export_plugin.h | 12 +-- .../android/export/gradle_export_util.cpp | 15 ++-- platform/android/export/gradle_export_util.h | 2 +- platform/ios/export/export_plugin.cpp | 40 +++++----- platform/linuxbsd/export/export_plugin.cpp | 4 +- platform/macos/export/export_plugin.cpp | 24 +++--- platform/web/export/export_plugin.cpp | 26 +++---- platform/web/export/export_plugin.h | 10 +-- platform/windows/export/export_plugin.cpp | 14 ++-- 22 files changed, 251 insertions(+), 123 deletions(-) create mode 100644 editor/export/editor_export_platform.compat.inc diff --git a/core/config/project_settings.cpp b/core/config/project_settings.cpp index 9902ad9e937..03e64d0a2bf 100644 --- a/core/config/project_settings.cpp +++ b/core/config/project_settings.cpp @@ -359,6 +359,29 @@ bool ProjectSettings::_get(const StringName &p_name, Variant &r_ret) const { return true; } +Variant ProjectSettings::get_setting_with_override_and_custom_features(const StringName &p_name, const Vector &p_features) const { + _THREAD_SAFE_METHOD_ + + StringName name = p_name; + if (feature_overrides.has(name)) { + const LocalVector> &overrides = feature_overrides[name]; + for (uint32_t i = 0; i < overrides.size(); i++) { + if (p_features.has(String(overrides[i].first).to_lower())) { + if (props.has(overrides[i].second)) { + name = overrides[i].second; + break; + } + } + } + } + + if (!props.has(name)) { + WARN_PRINT("Property not found: " + String(name)); + return Variant(); + } + return props[name].variant; +} + Variant ProjectSettings::get_setting_with_override(const StringName &p_name) const { _THREAD_SAFE_METHOD_ @@ -1411,6 +1434,7 @@ void ProjectSettings::_bind_methods() { ClassDB::bind_method(D_METHOD("get_setting", "name", "default_value"), &ProjectSettings::get_setting, DEFVAL(Variant())); ClassDB::bind_method(D_METHOD("get_setting_with_override", "name"), &ProjectSettings::get_setting_with_override); ClassDB::bind_method(D_METHOD("get_global_class_list"), &ProjectSettings::get_global_class_list); + ClassDB::bind_method(D_METHOD("get_setting_with_override_and_custom_features", "name", "features"), &ProjectSettings::get_setting_with_override_and_custom_features); ClassDB::bind_method(D_METHOD("set_order", "name", "position"), &ProjectSettings::set_order); ClassDB::bind_method(D_METHOD("get_order", "name"), &ProjectSettings::get_order); ClassDB::bind_method(D_METHOD("set_initial_value", "name", "value"), &ProjectSettings::set_initial_value); diff --git a/core/config/project_settings.h b/core/config/project_settings.h index af4a3dcecef..65fa72eaec8 100644 --- a/core/config/project_settings.h +++ b/core/config/project_settings.h @@ -193,6 +193,7 @@ public: List get_input_presets() const { return input_presets; } Variant get_setting_with_override(const StringName &p_name) const; + Variant get_setting_with_override_and_custom_features(const StringName &p_name, const Vector &p_features) const; bool is_using_datapack() const; bool is_project_loaded() const; diff --git a/doc/classes/EditorExportPlatform.xml b/doc/classes/EditorExportPlatform.xml index 8a7427758cc..ef38ffe0b60 100644 --- a/doc/classes/EditorExportPlatform.xml +++ b/doc/classes/EditorExportPlatform.xml @@ -121,6 +121,7 @@ + Returns array of core file names that always should be exported regardless of preset config. diff --git a/doc/classes/EditorExportPreset.xml b/doc/classes/EditorExportPreset.xml index 0ec3a63f74f..a2d08f45c93 100644 --- a/doc/classes/EditorExportPreset.xml +++ b/doc/classes/EditorExportPreset.xml @@ -121,6 +121,13 @@ Returns export preset name. + + + + + Returns the value of the setting identified by [param name] using export preset feature tag overrides instead of current OS features. + + diff --git a/doc/classes/ProjectSettings.xml b/doc/classes/ProjectSettings.xml index da48e20a74f..f05f9f42f79 100644 --- a/doc/classes/ProjectSettings.xml +++ b/doc/classes/ProjectSettings.xml @@ -114,6 +114,14 @@ [/codeblocks] + + + + + + Similar to [method get_setting_with_override], but applies feature tag overrides instead of current OS features. + + diff --git a/editor/debugger/editor_file_server.cpp b/editor/debugger/editor_file_server.cpp index 37e9c72e755..999bb68ff6b 100644 --- a/editor/debugger/editor_file_server.cpp +++ b/editor/debugger/editor_file_server.cpp @@ -200,7 +200,7 @@ void EditorFileServer::poll() { // Scan files to send. _scan_files_changed(EditorFileSystem::get_singleton()->get_filesystem(), tags, files_to_send, cached_files); // Add forced export files - Vector forced_export = EditorExportPlatform::get_forced_export_files(); + Vector forced_export = EditorExportPlatform::get_forced_export_files(Ref()); for (int i = 0; i < forced_export.size(); i++) { _add_custom_file(forced_export[i], files_to_send, cached_files); } diff --git a/editor/export/editor_export_platform.compat.inc b/editor/export/editor_export_platform.compat.inc new file mode 100644 index 00000000000..fca3300a167 --- /dev/null +++ b/editor/export/editor_export_platform.compat.inc @@ -0,0 +1,41 @@ +/**************************************************************************/ +/* editor_export_platform.compat.inc */ +/**************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* https://godotengine.org */ +/**************************************************************************/ +/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */ +/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */ +/* */ +/* Permission is hereby granted, free of charge, to any person obtaining */ +/* a copy of this software and associated documentation files (the */ +/* "Software"), to deal in the Software without restriction, including */ +/* without limitation the rights to use, copy, modify, merge, publish, */ +/* distribute, sublicense, and/or sell copies of the Software, and to */ +/* permit persons to whom the Software is furnished to do so, subject to */ +/* the following conditions: */ +/* */ +/* The above copyright notice and this permission notice shall be */ +/* included in all copies or substantial portions of the Software. */ +/* */ +/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ +/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ +/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */ +/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ +/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ +/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ +/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +/**************************************************************************/ + +#ifndef DISABLE_DEPRECATED + +Vector EditorExportPlatform::_get_forced_export_files_bind_compat_71542() { + return get_forced_export_files(Ref()); +} + +void EditorExportPlatform::_bind_compatibility_methods() { + ClassDB::bind_compatibility_static_method("EditorExportPlatform", D_METHOD("get_forced_export_files"), &EditorExportPlatform::_get_forced_export_files_bind_compat_71542); +} + +#endif diff --git a/editor/export/editor_export_platform.cpp b/editor/export/editor_export_platform.cpp index d2a82cbf2e1..dbbff35b9b1 100644 --- a/editor/export/editor_export_platform.cpp +++ b/editor/export/editor_export_platform.cpp @@ -30,6 +30,8 @@ #include "editor_export_platform.h" +#include "editor_export_platform.compat.inc" + #include "core/config/project_settings.h" #include "core/crypto/crypto_core.h" #include "core/extension/gdextension.h" @@ -948,7 +950,7 @@ Dictionary EditorExportPlatform::get_internal_export_files(const Refhas_feature(TextServer::FEATURE_USE_SUPPORT_DATA) && (bool)GLOBAL_GET("internationalization/locale/include_text_server_data")) { + if (TS->has_feature(TextServer::FEATURE_USE_SUPPORT_DATA) && (bool)get_project_setting(p_preset, "internationalization/locale/include_text_server_data")) { String ts_name = TS->get_support_data_filename(); String ts_target = "res://" + ts_name; if (!ts_name.is_empty()) { @@ -994,13 +996,13 @@ Dictionary EditorExportPlatform::get_internal_export_files(const Ref EditorExportPlatform::get_forced_export_files() { +Vector EditorExportPlatform::get_forced_export_files(const Ref &p_preset) { Vector files; files.push_back(ProjectSettings::get_singleton()->get_global_class_list_path()); - String icon = ResourceUID::ensure_path(GLOBAL_GET("application/config/icon")); - String splash = ResourceUID::ensure_path(GLOBAL_GET("application/boot_splash/image")); + String icon = ResourceUID::ensure_path(get_project_setting(p_preset, "application/config/icon")); + String splash = ResourceUID::ensure_path(get_project_setting(p_preset, "application/boot_splash/image")); if (!icon.is_empty() && FileAccess::exists(icon)) { files.push_back(icon); } @@ -1112,7 +1114,7 @@ Error EditorExportPlatform::export_project_files(const Ref & continue; } - String autoload_path = GLOBAL_GET(pi.name); + String autoload_path = get_project_setting(p_preset, pi.name); if (autoload_path.begins_with("*")) { autoload_path = autoload_path.substr(1); @@ -1255,7 +1257,7 @@ Error EditorExportPlatform::export_project_files(const Ref & HashMap export_cache; String export_base_path = ProjectSettings::get_singleton()->get_project_data_path().path_join("exported/") + itos(custom_resources_hash); - bool convert_text_to_binary = GLOBAL_GET("editor/export/convert_text_resources_to_binary"); + bool convert_text_to_binary = get_project_setting(p_preset, "editor/export/convert_text_resources_to_binary"); if (convert_text_to_binary || !customize_resources_plugins.is_empty() || !customize_scenes_plugins.is_empty()) { // See if we have something to open @@ -1567,7 +1569,7 @@ Error EditorExportPlatform::export_project_files(const Ref & } } - Vector forced_export = get_forced_export_files(); + Vector forced_export = get_forced_export_files(p_preset); for (int i = 0; i < forced_export.size(); i++) { Vector array; if (GDExtension::get_extension_list_config_file() == forced_export[i]) { @@ -2466,6 +2468,14 @@ Array EditorExportPlatform::get_current_presets() const { return ret; } +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); + } else { + return GLOBAL_GET(p_name); + } +} + void EditorExportPlatform::_bind_methods() { ClassDB::bind_method(D_METHOD("get_os_name"), &EditorExportPlatform::get_os_name); @@ -2504,7 +2514,7 @@ void EditorExportPlatform::_bind_methods() { ClassDB::bind_method(D_METHOD("get_internal_export_files", "preset", "debug"), &EditorExportPlatform::get_internal_export_files); - ClassDB::bind_static_method("EditorExportPlatform", D_METHOD("get_forced_export_files"), &EditorExportPlatform::get_forced_export_files); + ClassDB::bind_static_method("EditorExportPlatform", D_METHOD("get_forced_export_files", "preset"), &EditorExportPlatform::get_forced_export_files); BIND_ENUM_CONSTANT(EXPORT_MESSAGE_NONE); BIND_ENUM_CONSTANT(EXPORT_MESSAGE_INFO); diff --git a/editor/export/editor_export_platform.h b/editor/export/editor_export_platform.h index 252c26e9e92..19f6256931e 100644 --- a/editor/export/editor_export_platform.h +++ b/editor/export/editor_export_platform.h @@ -33,6 +33,7 @@ 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" @@ -203,7 +204,13 @@ protected: Ref _load_icon_or_splash_image(const String &p_path, Error *r_error) const; +#ifndef DISABLE_DEPRECATED + static Vector _get_forced_export_files_bind_compat_71542(); + static void _bind_compatibility_methods(); +#endif + public: + 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; struct ExportOption { @@ -280,7 +287,7 @@ public: Dictionary get_internal_export_files(const Ref &p_preset, bool p_debug); - static Vector get_forced_export_files(); + static Vector get_forced_export_files(const Ref &p_preset); virtual bool fill_log_messages(RichTextLabel *p_log, Error p_err); diff --git a/editor/export/editor_export_preset.cpp b/editor/export/editor_export_preset.cpp index 3464d0a011b..f6bec00ad9a 100644 --- a/editor/export/editor_export_preset.cpp +++ b/editor/export/editor_export_preset.cpp @@ -60,6 +60,29 @@ bool EditorExportPreset::_get(const StringName &p_name, Variant &r_ret) const { return false; } +Variant EditorExportPreset::get_project_setting(const StringName &p_name) { + List ftr_list; + platform->get_platform_features(&ftr_list); + platform->get_preset_features(this, &ftr_list); + + Vector features; + for (const String &E : ftr_list) { + features.push_back(E); + } + + if (!get_custom_features().is_empty()) { + Vector tmp_custom_list = get_custom_features().split(","); + + for (int i = 0; i < tmp_custom_list.size(); i++) { + String f = tmp_custom_list[i].strip_edges(); + if (!f.is_empty()) { + features.push_back(f); + } + } + } + return ProjectSettings::get_singleton()->get_setting_with_override_and_custom_features(p_name, features); +} + void EditorExportPreset::_bind_methods() { ClassDB::bind_method(D_METHOD("_get_property_warning", "name"), &EditorExportPreset::_get_property_warning); @@ -70,6 +93,7 @@ void EditorExportPreset::_bind_methods() { ClassDB::bind_method(D_METHOD("get_customized_files_count"), &EditorExportPreset::get_customized_files_count); ClassDB::bind_method(D_METHOD("has_export_file", "path"), &EditorExportPreset::has_export_file); ClassDB::bind_method(D_METHOD("get_file_export_mode", "path", "default"), &EditorExportPreset::get_file_export_mode, DEFVAL(MODE_FILE_NOT_CUSTOMIZED)); + ClassDB::bind_method(D_METHOD("get_project_setting", "name"), &EditorExportPreset::get_project_setting); ClassDB::bind_method(D_METHOD("get_preset_name"), &EditorExportPreset::get_name); ClassDB::bind_method(D_METHOD("is_runnable"), &EditorExportPreset::is_runnable); diff --git a/editor/export/editor_export_preset.h b/editor/export/editor_export_preset.h index 5de0ebf929c..1d41dbcb586 100644 --- a/editor/export/editor_export_preset.h +++ b/editor/export/editor_export_preset.h @@ -125,6 +125,8 @@ public: void set_file_export_mode(const String &p_path, FileExportMode p_mode); FileExportMode get_file_export_mode(const String &p_path, FileExportMode p_default = MODE_FILE_NOT_CUSTOMIZED) const; + Variant get_project_setting(const StringName &p_name); + void set_name(const String &p_name); String get_name() const; diff --git a/misc/extension_api_validation/4.4-stable.expected b/misc/extension_api_validation/4.4-stable.expected index ceafe8269b5..d5e9e91e0d2 100644 --- a/misc/extension_api_validation/4.4-stable.expected +++ b/misc/extension_api_validation/4.4-stable.expected @@ -41,3 +41,10 @@ Validate extension JSON: Error: Field 'classes/RichTextLabel/methods/push_table/ Validate extension JSON: Error: Field 'classes/TreeItem/methods/add_button/arguments': size changed value in new API, from 5 to 6. Added optional arguments. Compatibility methods registered. + + +GH-71542 +-------- +Validate extension JSON: JSON file: Field was added in a way that breaks compatibility 'classes/EditorExportPlatform/methods/get_forced_export_files': arguments + +Optional argument added. Compatibility methods registered. diff --git a/platform/android/export/export_plugin.cpp b/platform/android/export/export_plugin.cpp index 2ab56394c2b..78190e30d1f 100644 --- a/platform/android/export/export_plugin.cpp +++ b/platform/android/export/export_plugin.cpp @@ -33,7 +33,6 @@ #include "logo_svg.gen.h" #include "run_icon_svg.gen.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" @@ -478,12 +477,12 @@ void EditorExportPlatformAndroid::_update_preset_status() { } #endif -String EditorExportPlatformAndroid::get_project_name(const String &p_name) const { +String EditorExportPlatformAndroid::get_project_name(const Ref &p_preset, const String &p_name) const { String aname; if (!p_name.is_empty()) { aname = p_name; } else { - aname = GLOBAL_GET("application/config/name"); + aname = get_project_setting(p_preset, "application/config/name"); } if (aname.is_empty()) { @@ -493,17 +492,17 @@ String EditorExportPlatformAndroid::get_project_name(const String &p_name) const return aname; } -String EditorExportPlatformAndroid::get_package_name(const String &p_package) const { +String EditorExportPlatformAndroid::get_package_name(const Ref &p_preset, const String &p_package) const { String pname = p_package; - String name = get_valid_basename(); + String name = get_valid_basename(p_preset); pname = pname.replace("$genname", name); return pname; } // Returns the project name without invalid characters // or the "noname" string if all characters are invalid. -String EditorExportPlatformAndroid::get_valid_basename() const { - String basename = GLOBAL_GET("application/config/name"); +String EditorExportPlatformAndroid::get_valid_basename(const Ref &p_preset) const { + String basename = get_project_setting(p_preset, "application/config/name"); basename = basename.to_lower(); String name; @@ -531,8 +530,8 @@ String EditorExportPlatformAndroid::get_assets_directory(const Ref &p_preset, const String &p_package, String *r_error) const { + String pname = get_package_name(p_preset, p_package); if (pname.length() == 0) { if (r_error) { @@ -594,12 +593,12 @@ bool EditorExportPlatformAndroid::is_package_name_valid(const String &p_package, return true; } -bool EditorExportPlatformAndroid::is_project_name_valid() const { +bool EditorExportPlatformAndroid::is_project_name_valid(const Ref &p_preset) const { // Get the original project name and convert to lowercase. - String basename = GLOBAL_GET("application/config/name"); + String basename = get_project_setting(p_preset, "application/config/name"); basename = basename.to_lower(); // Check if there are invalid characters. - if (basename != get_valid_basename()) { + if (basename != get_valid_basename(p_preset)) { return false; } return true; @@ -858,9 +857,9 @@ bool EditorExportPlatformAndroid::_has_manage_external_storage_permission(const return p_permissions.has("android.permission.MANAGE_EXTERNAL_STORAGE"); } -bool EditorExportPlatformAndroid::_uses_vulkan() { - String rendering_method = GLOBAL_GET("rendering/renderer/rendering_method.mobile"); - String rendering_driver = GLOBAL_GET("rendering/rendering_device/driver.android"); +bool EditorExportPlatformAndroid::_uses_vulkan(const Ref &p_preset) const { + String rendering_method = get_project_setting(p_preset, "rendering/renderer/rendering_method.mobile"); + String rendering_driver = get_project_setting(p_preset, "rendering/rendering_device/driver.android"); return (rendering_method == "forward_plus" || rendering_method == "mobile") && rendering_driver == "vulkan"; } @@ -964,7 +963,7 @@ void EditorExportPlatformAndroid::_get_manifest_info(const Refget_project_setting("rendering/renderer/rendering_method.mobile") }; r_metadata.append(rendering_method_metadata); @@ -1121,7 +1120,7 @@ void EditorExportPlatformAndroid::_fix_manifest(const Ref &p String package_name = p_preset->get("package/unique_name"); const int screen_orientation = - _get_android_orientation_value(DisplayServer::ScreenOrientation(int(GLOBAL_GET("display/window/handheld/orientation")))); + _get_android_orientation_value(DisplayServer::ScreenOrientation(int(get_project_setting(p_preset, "display/window/handheld/orientation")))); bool screen_support_small = p_preset->get("screen/support_small"); bool screen_support_normal = p_preset->get("screen/support_normal"); @@ -1132,7 +1131,7 @@ void EditorExportPlatformAndroid::_fix_manifest(const Ref &p int app_category = p_preset->get("package/app_category"); bool retain_data_on_uninstall = p_preset->get("package/retain_data_on_uninstall"); bool exclude_from_recents = p_preset->get("package/exclude_from_recents"); - bool is_resizeable = bool(GLOBAL_GET("display/window/size/resizable")); + bool is_resizeable = bool(get_project_setting(p_preset, "display/window/size/resizable")); Vector perms; Vector features; @@ -1206,7 +1205,7 @@ void EditorExportPlatformAndroid::_fix_manifest(const Ref &p //replace project information if (tname == "manifest" && attrname == "package") { - string_table.write[attr_value] = get_package_name(package_name); + string_table.write[attr_value] = get_package_name(p_preset, package_name); } if (tname == "manifest" && attrname == "versionCode") { @@ -1254,7 +1253,7 @@ void EditorExportPlatformAndroid::_fix_manifest(const Ref &p } if (tname == "provider" && attrname == "authorities") { - string_table.write[attr_value] = get_package_name(package_name) + String(".fileprovider"); + string_table.write[attr_value] = get_package_name(p_preset, package_name) + String(".fileprovider"); } if (tname == "supports-screens") { @@ -1701,7 +1700,7 @@ void EditorExportPlatformAndroid::_fix_resources(const Ref & Vector string_table; String package_name = p_preset->get("package/name"); - Dictionary appnames = GLOBAL_GET("application/config/name_localized"); + Dictionary appnames = get_project_setting(p_preset, "application/config/name_localized"); for (uint32_t i = 0; i < string_count; i++) { uint32_t offset = decode_uint32(&r_manifest[string_table_begins + i * 4]); @@ -1712,14 +1711,14 @@ void EditorExportPlatformAndroid::_fix_resources(const Ref & if (str.begins_with("godot-project-name")) { if (str == "godot-project-name") { //project name - str = get_project_name(package_name); + str = get_project_name(p_preset, package_name); } else { String lang = str.substr(str.rfind_char('-') + 1).replace("-", "_"); if (appnames.has(lang)) { str = appnames[lang]; } else { - str = get_project_name(package_name); + str = get_project_name(p_preset, package_name); } } } @@ -1811,7 +1810,7 @@ void EditorExportPlatformAndroid::_process_launcher_icons(const String &p_file_n } void EditorExportPlatformAndroid::load_icon_refs(const Ref &p_preset, Ref &icon, Ref &foreground, Ref &background, Ref &monochrome) { - String project_icon_path = GLOBAL_GET("application/config/icon"); + String project_icon_path = get_project_setting(p_preset, "application/config/icon"); Error err = OK; @@ -1940,7 +1939,7 @@ String EditorExportPlatformAndroid::get_export_option_warning(const EditorExport String pn = p_preset->get("package/unique_name"); String pn_err; - if (!is_package_name_valid(pn, &pn_err)) { + if (!is_package_name_valid(Ref(p_preset), pn, &pn_err)) { return TTR("Invalid package name:") + " " + pn_err; } } else if (p_name == "gesture/swipe_to_dismiss") { @@ -2289,7 +2288,7 @@ Error EditorExportPlatformAndroid::run(const Ref &p_preset, args.push_back("--user"); args.push_back("0"); } - args.push_back(get_package_name(package_name)); + args.push_back(get_package_name(p_preset, package_name)); output.clear(); err = OS::get_singleton()->execute(adb, args, &output, &rv, true); @@ -2394,16 +2393,16 @@ Error EditorExportPlatformAndroid::run(const Ref &p_preset, // Going with implicit launch first based on the LAUNCHER category and the app's package. args.push_back("-c"); args.push_back("android.intent.category.LAUNCHER"); - args.push_back(get_package_name(package_name)); + args.push_back(get_package_name(p_preset, package_name)); output.clear(); err = OS::get_singleton()->execute(adb, args, &output, &rv, true); print_verbose(output); if (err || rv != 0 || output.contains("Error: Activity not started")) { // The implicit launch failed, let's try an explicit launch by specifying the component name before giving up. - const String component_name = get_package_name(package_name) + "/com.godot.game.GodotApp"; + const String component_name = get_package_name(p_preset, package_name) + "/com.godot.game.GodotApp"; print_line("Implicit launch failed.. Trying explicit launch using", component_name); - args.erase(get_package_name(package_name)); + args.erase(get_package_name(p_preset, package_name)); args.push_back("-n"); args.push_back(component_name); @@ -2920,23 +2919,23 @@ bool EditorExportPlatformAndroid::has_valid_project_configuration(const Refget("package/unique_name"); - if (package_name.contains("$genname") && !is_project_name_valid()) { + if (package_name.contains("$genname") && !is_project_name_valid(p_preset)) { // Warning only, so don't override `valid`. - err += vformat(TTR("The project name does not meet the requirement for the package name format and will be updated to \"%s\". Please explicitly specify the package name if needed."), get_valid_basename()); + err += vformat(TTR("The project name does not meet the requirement for the package name format and will be updated to \"%s\". Please explicitly specify the package name if needed."), get_valid_basename(p_preset)); err += "\n"; } @@ -2954,7 +2953,7 @@ List EditorExportPlatformAndroid::get_binary_extensions(const Ref &p_preset, const String &p_path) { int version_code = p_preset->get("version/code"); String package_name = p_preset->get("package/unique_name"); - String apk_file_name = "main." + itos(version_code) + "." + get_package_name(package_name) + ".obb"; + String apk_file_name = "main." + itos(version_code) + "." + get_package_name(p_preset, package_name) + ".obb"; String fullpath = p_path.get_base_dir().path_join(apk_file_name); return fullpath; } @@ -3436,8 +3435,8 @@ Error EditorExportPlatformAndroid::export_project_helper(const Refget("package/name")); - err = _create_project_name_strings_files(p_preset, project_name, gradle_build_directory); //project name localization. + String project_name = get_project_name(p_preset, p_preset->get("package/name")); + err = _create_project_name_strings_files(p_preset, project_name, gradle_build_directory, get_project_setting(p_preset, "application/config/name_localized")); //project name localization. if (err != OK) { add_message(EXPORT_MESSAGE_ERROR, TTR("Export"), TTR("Unable to overwrite res/*.xml files with project name.")); } @@ -3498,7 +3497,7 @@ Error EditorExportPlatformAndroid::export_project_helper(const Refglobalize_path(gradle_build_directory); build_command = build_path.path_join(build_command); - String package_name = get_package_name(p_preset->get("package/unique_name")); + String package_name = get_package_name(p_preset, p_preset->get("package/unique_name")); String version_code = itos(p_preset->get("version/code")); String version_name = p_preset->get_version("version/name"); String min_sdk_version = p_preset->get("gradle_build/min_sdk"); diff --git a/platform/android/export/export_plugin.h b/platform/android/export/export_plugin.h index 8fdc8b7af5c..aefb74abcd7 100644 --- a/platform/android/export/export_plugin.h +++ b/platform/android/export/export_plugin.h @@ -104,16 +104,16 @@ class EditorExportPlatformAndroid : public EditorExportPlatform { void _update_preset_status(); #endif - String get_project_name(const String &p_name) const; + String get_project_name(const Ref &p_preset, const String &p_name) const; - String get_package_name(const String &p_package) const; + String get_package_name(const Ref &p_preset, const String &p_package) const; - String get_valid_basename() const; + String get_valid_basename(const Ref &p_preset) const; String get_assets_directory(const Ref &p_preset, int p_export_format) const; - bool is_package_name_valid(const String &p_package, String *r_error = nullptr) const; - bool is_project_name_valid() const; + bool is_package_name_valid(const Ref &p_preset, const String &p_package, String *r_error = nullptr) const; + bool is_project_name_valid(const Ref &p_preset) const; static bool _should_compress_asset(const String &p_path, const Vector &p_data); @@ -189,7 +189,7 @@ class EditorExportPlatformAndroid : public EditorExportPlatform { static Vector get_enabled_abis(const Ref &p_preset); - static bool _uses_vulkan(); + bool _uses_vulkan(const Ref &p_preset) const; protected: void _notification(int p_what); diff --git a/platform/android/export/gradle_export_util.cpp b/platform/android/export/gradle_export_util.cpp index fad964269c4..26d12884ba4 100644 --- a/platform/android/export/gradle_export_util.cpp +++ b/platform/android/export/gradle_export_util.cpp @@ -200,10 +200,10 @@ String _android_xml_escape(const String &p_string) { } // Creates strings.xml files inside the gradle project for different locales. -Error _create_project_name_strings_files(const Ref &p_preset, const String &project_name, const String &p_gradle_build_dir) { - print_verbose("Creating strings resources for supported locales for project " + project_name); +Error _create_project_name_strings_files(const Ref &p_preset, const String &p_project_name, const String &p_gradle_build_dir, const Dictionary &p_appnames) { + print_verbose("Creating strings resources for supported locales for project " + p_project_name); // Stores the string into the default values directory. - String processed_default_xml_string = vformat(GODOT_PROJECT_NAME_XML_STRING, _android_xml_escape(project_name)); + String processed_default_xml_string = vformat(GODOT_PROJECT_NAME_XML_STRING, _android_xml_escape(p_project_name)); store_string_at_path(p_gradle_build_dir.path_join("res/values/godot_project_name_string.xml"), processed_default_xml_string); // Searches the Gradle project res/ directory to find all supported locales @@ -215,7 +215,6 @@ Error _create_project_name_strings_files(const Ref &p_preset return ERR_CANT_OPEN; } da->list_dir_begin(); - Dictionary appnames = GLOBAL_GET("application/config/name_localized"); while (true) { String file = da->get_next(); if (file.is_empty()) { @@ -227,8 +226,8 @@ Error _create_project_name_strings_files(const Ref &p_preset } String locale = file.replace("values-", "").replace("-r", "_"); String locale_directory = p_gradle_build_dir.path_join("res/" + file + "/godot_project_name_string.xml"); - if (appnames.has(locale)) { - String locale_project_name = appnames[locale]; + if (p_appnames.has(locale)) { + String locale_project_name = p_appnames[locale]; String processed_xml_string = vformat(GODOT_PROJECT_NAME_XML_STRING, _android_xml_escape(locale_project_name)); print_verbose("Storing project name for locale " + locale + " under " + locale_directory); store_string_at_path(locale_directory, processed_xml_string); @@ -264,7 +263,7 @@ String _get_screen_sizes_tag(const Ref &p_preset) { } String _get_activity_tag(const Ref &p_export_platform, const Ref &p_preset, bool p_debug) { - String orientation = _get_android_orientation_label(DisplayServer::ScreenOrientation(int(GLOBAL_GET("display/window/handheld/orientation")))); + String orientation = _get_android_orientation_label(DisplayServer::ScreenOrientation(int(p_export_platform->get_project_setting(p_preset, "display/window/handheld/orientation")))); String manifest_activity_text = vformat( " &p_export_platform, con "android:resizeableActivity=\"%s\">\n", bool_to_string(p_preset->get("package/exclude_from_recents")), orientation, - bool_to_string(bool(GLOBAL_GET("display/window/size/resizable")))); + bool_to_string(bool(p_export_platform->get_project_setting(p_preset, "display/window/size/resizable")))); manifest_activity_text += " \n" " \n" diff --git a/platform/android/export/gradle_export_util.h b/platform/android/export/gradle_export_util.h index 340902432a3..045e7f14b8b 100644 --- a/platform/android/export/gradle_export_util.h +++ b/platform/android/export/gradle_export_util.h @@ -100,7 +100,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); // Creates strings.xml files inside the gradle project for different locales. -Error _create_project_name_strings_files(const Ref &p_preset, const String &project_name, const String &p_gradle_build_dir); +Error _create_project_name_strings_files(const Ref &p_preset, const String &p_project_name, const String &p_gradle_build_dir, const Dictionary &p_appnames); String bool_to_string(bool v); diff --git a/platform/ios/export/export_plugin.cpp b/platform/ios/export/export_plugin.cpp index dac5136995b..ab13f23a0a9 100644 --- a/platform/ios/export/export_plugin.cpp +++ b/platform/ios/export/export_plugin.cpp @@ -423,8 +423,8 @@ HashMap EditorExportPlatformIOS::get_custom_project_settings(co switch (image_scale_mode) { case 0: { - String logo_path = GLOBAL_GET("application/boot_splash/image"); - bool is_on = GLOBAL_GET("application/boot_splash/fullsize"); + String logo_path = get_project_setting(p_preset, "application/boot_splash/image"); + bool is_on = get_project_setting(p_preset, "application/boot_splash/fullsize"); // If custom logo is not specified, Godot does not scale default one, so we should do the same. value = (is_on && logo_path.length() > 0) ? "scaleAspectFit" : "center"; } break; @@ -586,7 +586,7 @@ void EditorExportPlatformIOS::_fix_config_file(const Ref &p_ } else if (lines[i].contains("$interface_orientations")) { String orientations; const DisplayServer::ScreenOrientation screen_orientation = - DisplayServer::ScreenOrientation(int(GLOBAL_GET("display/window/handheld/orientation"))); + DisplayServer::ScreenOrientation(int(get_project_setting(p_preset, "display/window/handheld/orientation"))); switch (screen_orientation) { case DisplayServer::SCREEN_LANDSCAPE: @@ -624,7 +624,7 @@ void EditorExportPlatformIOS::_fix_config_file(const Ref &p_ } else if (lines[i].contains("$ipad_interface_orientations")) { String orientations; const DisplayServer::ScreenOrientation screen_orientation = - DisplayServer::ScreenOrientation(int(GLOBAL_GET("display/window/handheld/orientation"))); + DisplayServer::ScreenOrientation(int(get_project_setting(p_preset, "display/window/handheld/orientation"))); switch (screen_orientation) { case DisplayServer::SCREEN_LANDSCAPE: @@ -693,8 +693,8 @@ void EditorExportPlatformIOS::_fix_config_file(const Ref &p_ switch (image_scale_mode) { case 0: { - String logo_path = GLOBAL_GET("application/boot_splash/image"); - bool is_on = GLOBAL_GET("application/boot_splash/fullsize"); + String logo_path = get_project_setting(p_preset, "application/boot_splash/image"); + bool is_on = get_project_setting(p_preset, "application/boot_splash/fullsize"); // If custom logo is not specified, Godot does not scale default one, so we should do the same. value = (is_on && logo_path.length() > 0) ? "scaleAspectFit" : "center"; } break; @@ -706,7 +706,7 @@ void EditorExportPlatformIOS::_fix_config_file(const Ref &p_ strnew += lines[i].replace("$launch_screen_image_mode", value) + "\n"; } else if (lines[i].contains("$launch_screen_background_color")) { bool use_custom = p_preset->get("storyboard/use_custom_bg_color"); - Color color = use_custom ? p_preset->get("storyboard/custom_bg_color") : GLOBAL_GET("application/boot_splash/bg_color"); + Color color = use_custom ? p_preset->get("storyboard/custom_bg_color") : get_project_setting(p_preset, "application/boot_splash/bg_color"); const String value_format = "red=\"$red\" green=\"$green\" blue=\"$blue\" alpha=\"$alpha\""; Dictionary value_dictionary; @@ -719,7 +719,7 @@ void EditorExportPlatformIOS::_fix_config_file(const Ref &p_ strnew += lines[i].replace("$launch_screen_background_color", value) + "\n"; } else if (lines[i].contains("$pbx_locale_file_reference")) { String locale_files; - Vector translations = GLOBAL_GET("internationalization/locale/translations"); + Vector translations = get_project_setting(p_preset, "internationalization/locale/translations"); if (translations.size() > 0) { HashSet languages; for (const String &E : translations) { @@ -738,7 +738,7 @@ void EditorExportPlatformIOS::_fix_config_file(const Ref &p_ strnew += lines[i].replace("$pbx_locale_file_reference", locale_files); } else if (lines[i].contains("$pbx_locale_build_reference")) { String locale_files; - Vector translations = GLOBAL_GET("internationalization/locale/translations"); + Vector translations = get_project_setting(p_preset, "internationalization/locale/translations"); if (translations.size() > 0) { HashSet languages; for (const String &E : translations) { @@ -957,7 +957,7 @@ Error EditorExportPlatformIOS::_export_icons(const Ref &p_pr return ERR_CANT_OPEN; } - Color boot_bg_color = GLOBAL_GET("application/boot_splash/bg_color"); + Color boot_bg_color = get_project_setting(p_preset, "application/boot_splash/bg_color"); enum IconColorMode { ICON_NORMAL, @@ -999,7 +999,7 @@ Error EditorExportPlatformIOS::_export_icons(const Ref &p_pr continue; } // Resize main app icon. - icon_path = GLOBAL_GET("application/config/icon"); + icon_path = get_project_setting(p_preset, "application/config/icon"); Error err = OK; Ref img = _load_icon_or_splash_image(icon_path, &err); if (err != OK || img.is_null() || img->is_empty()) { @@ -1133,7 +1133,7 @@ Error EditorExportPlatformIOS::_export_loading_screen_file(const Ref splash; - const String splash_path = GLOBAL_GET("application/boot_splash/image"); + const String splash_path = get_project_setting(p_preset, "application/boot_splash/image"); if (!splash_path.is_empty()) { splash = _load_icon_or_splash_image(splash_path, &err); @@ -2119,8 +2119,8 @@ Error EditorExportPlatformIOS::_export_project_helper(const Refget("privacy/camera_usage_description_localized"); Dictionary microphone_usage_descriptions = p_preset->get("privacy/microphone_usage_description_localized"); Dictionary photolibrary_usage_descriptions = p_preset->get("privacy/photolibrary_usage_description_localized"); - Vector translations = GLOBAL_GET("internationalization/locale/translations"); + Vector translations = get_project_setting(p_preset, "internationalization/locale/translations"); if (translations.size() > 0) { { String fname = binary_dir + "/en.lproj"; @@ -2296,7 +2294,7 @@ Error EditorExportPlatformIOS::_export_project_helper(const Ref f = FileAccess::open(fname + "/InfoPlist.strings", FileAccess::WRITE); f->store_line("/* Localized versions of Info.plist keys */"); f->store_line(""); - f->store_line("CFBundleDisplayName = \"" + GLOBAL_GET("application/config/name").operator String() + "\";"); + f->store_line("CFBundleDisplayName = \"" + get_project_setting(p_preset, "application/config/name").operator String() + "\";"); f->store_line("NSCameraUsageDescription = \"" + p_preset->get("privacy/camera_usage_description").operator String() + "\";"); f->store_line("NSMicrophoneUsageDescription = \"" + p_preset->get("privacy/microphone_usage_description").operator String() + "\";"); f->store_line("NSPhotoLibraryUsageDescription = \"" + p_preset->get("privacy/photolibrary_usage_description").operator String() + "\";"); @@ -2539,8 +2537,8 @@ bool EditorExportPlatformIOS::has_valid_export_configuration(const Refget("application/min_ios_version").operator String().to_float(); if (version < 14.0) { diff --git a/platform/linuxbsd/export/export_plugin.cpp b/platform/linuxbsd/export/export_plugin.cpp index b2a4b5432c6..d3a6d5c6bf5 100644 --- a/platform/linuxbsd/export/export_plugin.cpp +++ b/platform/linuxbsd/export/export_plugin.cpp @@ -80,8 +80,8 @@ Error EditorExportPlatformLinuxBSD::export_project(const Ref bool export_as_zip = p_path.ends_with("zip"); String pkg_name; - if (String(GLOBAL_GET("application/config/name")) != "") { - pkg_name = String(GLOBAL_GET("application/config/name")); + if (String(get_project_setting(p_preset, "application/config/name")) != "") { + pkg_name = String(get_project_setting(p_preset, "application/config/name")); } else { pkg_name = "Unnamed"; } diff --git a/platform/macos/export/export_plugin.cpp b/platform/macos/export/export_plugin.cpp index db4acd3f306..d59b6e0ef83 100644 --- a/platform/macos/export/export_plugin.cpp +++ b/platform/macos/export/export_plugin.cpp @@ -821,7 +821,7 @@ void EditorExportPlatformMacOS::_fix_plist(const Ref &p_pres if (lines[i].contains("$binary")) { strnew += lines[i].replace("$binary", p_binary) + "\n"; } else if (lines[i].contains("$name")) { - strnew += lines[i].replace("$name", GLOBAL_GET("application/config/name")) + "\n"; + strnew += lines[i].replace("$name", get_project_setting(p_preset, "application/config/name")) + "\n"; } else if (lines[i].contains("$bundle_identifier")) { strnew += lines[i].replace("$bundle_identifier", p_preset->get("application/bundle_identifier")) + "\n"; } else if (lines[i].contains("$short_version")) { @@ -1564,8 +1564,8 @@ Error EditorExportPlatformMacOS::export_project(const Ref &p String binary_to_use = "godot_macos_" + String(p_debug ? "debug" : "release") + "." + architecture; String pkg_name; - if (String(GLOBAL_GET("application/config/name")) != "") { - pkg_name = String(GLOBAL_GET("application/config/name")); + if (String(get_project_setting(p_preset, "application/config/name")) != "") { + pkg_name = String(get_project_setting(p_preset, "application/config/name")); } else { pkg_name = "Unnamed"; } @@ -1658,7 +1658,7 @@ Error EditorExportPlatformMacOS::export_project(const Ref &p } } - Dictionary appnames = GLOBAL_GET("application/config/name_localized"); + Dictionary appnames = get_project_setting(p_preset, "application/config/name_localized"); Dictionary microphone_usage_descriptions = p_preset->get("privacy/microphone_usage_description_localized"); Dictionary camera_usage_descriptions = p_preset->get("privacy/camera_usage_description_localized"); Dictionary location_usage_descriptions = p_preset->get("privacy/location_usage_description_localized"); @@ -1672,7 +1672,7 @@ Error EditorExportPlatformMacOS::export_project(const Ref &p Dictionary removable_volumes_usage_descriptions = p_preset->get("privacy/removable_volumes_usage_description_localized"); Dictionary copyrights = p_preset->get("application/copyright_localized"); - Vector translations = GLOBAL_GET("internationalization/locale/translations"); + Vector translations = get_project_setting(p_preset, "internationalization/locale/translations"); if (translations.size() > 0) { { String fname = tmp_app_path_name + "/Contents/Resources/en.lproj"; @@ -1680,7 +1680,7 @@ Error EditorExportPlatformMacOS::export_project(const Ref &p Ref f = FileAccess::open(fname + "/InfoPlist.strings", FileAccess::WRITE); f->store_line("/* Localized versions of Info.plist keys */"); f->store_line(""); - f->store_line("CFBundleDisplayName = \"" + GLOBAL_GET("application/config/name").operator String() + "\";"); + f->store_line("CFBundleDisplayName = \"" + get_project_setting(p_preset, "application/config/name").operator String() + "\";"); if (!((String)p_preset->get("privacy/microphone_usage_description")).is_empty()) { f->store_line("NSMicrophoneUsageDescription = \"" + p_preset->get("privacy/microphone_usage_description").operator String() + "\";"); } @@ -1779,7 +1779,7 @@ Error EditorExportPlatformMacOS::export_project(const Ref &p int export_angle = p_preset->get("application/export_angle"); bool include_angle_libs = false; if (export_angle == 0) { - include_angle_libs = String(GLOBAL_GET("rendering/gl_compatibility/driver.macos")) == "opengl3_angle"; + include_angle_libs = String(get_project_setting(p_preset, "rendering/gl_compatibility/driver.macos")) == "opengl3_angle"; } else if (export_angle == 1) { include_angle_libs = true; } @@ -1867,10 +1867,10 @@ Error EditorExportPlatformMacOS::export_project(const Ref &p String icon_path; if (p_preset->get("application/icon") != "") { icon_path = p_preset->get("application/icon"); - } else if (GLOBAL_GET("application/config/macos_native_icon") != "") { - icon_path = GLOBAL_GET("application/config/macos_native_icon"); + } else if (get_project_setting(p_preset, "application/config/macos_native_icon") != "") { + icon_path = get_project_setting(p_preset, "application/config/macos_native_icon"); } else { - icon_path = GLOBAL_GET("application/config/icon"); + icon_path = get_project_setting(p_preset, "application/config/icon"); } if (!icon_path.is_empty()) { @@ -2568,8 +2568,8 @@ Error EditorExportPlatformMacOS::run(const Ref &p_preset, in } String pkg_name; - if (String(ProjectSettings::get_singleton()->get("application/config/name")) != "") { - pkg_name = String(ProjectSettings::get_singleton()->get("application/config/name")); + if (String(get_project_setting(p_preset, "application/config/name")) != "") { + pkg_name = String(get_project_setting(p_preset, "application/config/name")); } else { pkg_name = "Unnamed"; } diff --git a/platform/web/export/export_plugin.cpp b/platform/web/export/export_plugin.cpp index 30fbc31bd78..6614a9210db 100644 --- a/platform/web/export/export_plugin.cpp +++ b/platform/web/export/export_plugin.cpp @@ -164,15 +164,15 @@ void EditorExportPlatformWeb::_fix_html(Vector &p_html, const Refget("html/head_include"); HashMap replaces; replaces["$GODOT_URL"] = p_name + ".js"; - replaces["$GODOT_PROJECT_NAME"] = GLOBAL_GET("application/config/name"); + replaces["$GODOT_PROJECT_NAME"] = get_project_setting(p_preset, "application/config/name"); replaces["$GODOT_HEAD_INCLUDE"] = head_include + custom_head_include; replaces["$GODOT_CONFIG"] = str_config; - replaces["$GODOT_SPLASH_COLOR"] = "#" + Color(GLOBAL_GET("application/boot_splash/bg_color")).to_html(false); + replaces["$GODOT_SPLASH_COLOR"] = "#" + Color(get_project_setting(p_preset, "application/boot_splash/bg_color")).to_html(false); LocalVector godot_splash_classes; - godot_splash_classes.push_back("show-image--" + String(GLOBAL_GET("application/boot_splash/show_image"))); - godot_splash_classes.push_back("fullsize--" + String(GLOBAL_GET("application/boot_splash/fullsize"))); - godot_splash_classes.push_back("use-filter--" + String(GLOBAL_GET("application/boot_splash/use_filter"))); + godot_splash_classes.push_back("show-image--" + String(get_project_setting(p_preset, "application/boot_splash/show_image"))); + godot_splash_classes.push_back("fullsize--" + String(get_project_setting(p_preset, "application/boot_splash/fullsize"))); + godot_splash_classes.push_back("use-filter--" + String(get_project_setting(p_preset, "application/boot_splash/use_filter"))); replaces["$GODOT_SPLASH_CLASSES"] = String(" ").join(godot_splash_classes); replaces["$GODOT_SPLASH"] = p_name + ".png"; @@ -185,7 +185,7 @@ void EditorExportPlatformWeb::_fix_html(Vector &p_html, const Ref &p_preset, const String &p_path, const String &p_icon, int p_size, Array &r_arr) { const String name = p_path.get_file().get_basename(); const String icon_name = vformat("%s.%dx%d.png", name, p_size, p_size); const String icon_dest = p_path.get_base_dir().path_join(icon_name); @@ -202,7 +202,7 @@ Error EditorExportPlatformWeb::_add_manifest_icon(const String &p_path, const St icon->resize(p_size, p_size); } } else { - icon = _get_project_icon(); + icon = _get_project_icon(p_preset); icon->resize(p_size, p_size); } const Error err = icon->save_png(icon_dest); @@ -219,7 +219,7 @@ Error EditorExportPlatformWeb::_add_manifest_icon(const String &p_path, const St } Error EditorExportPlatformWeb::_build_pwa(const Ref &p_preset, const String p_path, const Vector &p_shared_objects) { - String proj_name = GLOBAL_GET("application/config/name"); + String proj_name = get_project_setting(p_preset, "application/config/name"); if (proj_name.is_empty()) { proj_name = "Godot Game"; } @@ -308,19 +308,19 @@ Error EditorExportPlatformWeb::_build_pwa(const Ref &p_prese Array icons_arr; const String icon144_path = p_preset->get("progressive_web_app/icon_144x144"); - err = _add_manifest_icon(p_path, icon144_path, 144, icons_arr); + err = _add_manifest_icon(p_preset, p_path, icon144_path, 144, icons_arr); if (err != OK) { // Message is supplied by the subroutine method. return err; } const String icon180_path = p_preset->get("progressive_web_app/icon_180x180"); - err = _add_manifest_icon(p_path, icon180_path, 180, icons_arr); + err = _add_manifest_icon(p_preset, p_path, icon180_path, 180, icons_arr); if (err != OK) { // Message is supplied by the subroutine method. return err; } const String icon512_path = p_preset->get("progressive_web_app/icon_512x512"); - err = _add_manifest_icon(p_path, icon512_path, 512, icons_arr); + err = _add_manifest_icon(p_preset, p_path, icon512_path, 512, icons_arr); if (err != OK) { // Message is supplied by the subroutine method. return err; @@ -561,7 +561,7 @@ Error EditorExportPlatformWeb::export_project(const Ref &p_p html.resize(0); // Export splash (why?) - Ref splash = _get_project_splash(); + Ref splash = _get_project_splash(p_preset); const String splash_png_path = base_path + ".png"; if (splash->save_png(splash_png_path) != OK) { add_message(EXPORT_MESSAGE_ERROR, TTR("Export"), vformat(TTR("Could not write file: \"%s\"."), splash_png_path)); @@ -571,7 +571,7 @@ Error EditorExportPlatformWeb::export_project(const Ref &p_p // Save a favicon that can be accessed without waiting for the project to finish loading. // This way, the favicon can be displayed immediately when loading the page. if (export_icon) { - Ref favicon = _get_project_icon(); + Ref favicon = _get_project_icon(p_preset); const String favicon_png_path = base_path + ".icon.png"; if (favicon->save_png(favicon_png_path) != OK) { add_message(EXPORT_MESSAGE_ERROR, TTR("Export"), vformat(TTR("Could not write file: \"%s\"."), favicon_png_path)); diff --git a/platform/web/export/export_plugin.h b/platform/web/export/export_plugin.h index 20a92649f14..5e6f6fa8181 100644 --- a/platform/web/export/export_plugin.h +++ b/platform/web/export/export_plugin.h @@ -75,11 +75,11 @@ class EditorExportPlatformWeb : public EditorExportPlatform { return name; } - Ref _get_project_icon() const { + Ref _get_project_icon(const Ref &p_preset) const { Error err = OK; Ref icon; icon.instantiate(); - const String icon_path = String(GLOBAL_GET("application/config/icon")).strip_edges(); + const String icon_path = String(get_project_setting(p_preset, "application/config/icon")).strip_edges(); if (!icon_path.is_empty()) { icon = _load_icon_or_splash_image(icon_path, &err); } @@ -89,11 +89,11 @@ class EditorExportPlatformWeb : public EditorExportPlatform { return icon; } - Ref _get_project_splash() const { + Ref _get_project_splash(const Ref &p_preset) const { Error err = OK; Ref splash; splash.instantiate(); - const String splash_path = String(GLOBAL_GET("application/boot_splash/image")).strip_edges(); + const String splash_path = String(get_project_setting(p_preset, "application/boot_splash/image")).strip_edges(); if (!splash_path.is_empty()) { splash = _load_icon_or_splash_image(splash_path, &err); } @@ -106,7 +106,7 @@ class EditorExportPlatformWeb : public EditorExportPlatform { Error _extract_template(const String &p_template, const String &p_dir, const String &p_name, bool pwa); void _replace_strings(const HashMap &p_replaces, Vector &r_template); void _fix_html(Vector &p_html, const Ref &p_preset, const String &p_name, bool p_debug, BitField p_flags, const Vector p_shared_objects, const Dictionary &p_file_sizes); - Error _add_manifest_icon(const String &p_path, const String &p_icon, int p_size, Array &r_arr); + Error _add_manifest_icon(const Ref &p_preset, const String &p_path, const String &p_icon, int p_size, Array &r_arr); Error _build_pwa(const Ref &p_preset, const String p_path, const Vector &p_shared_objects); Error _write_or_error(const uint8_t *p_content, int p_len, String p_path); diff --git a/platform/windows/export/export_plugin.cpp b/platform/windows/export/export_plugin.cpp index d180a293009..c7171c00bb0 100644 --- a/platform/windows/export/export_plugin.cpp +++ b/platform/windows/export/export_plugin.cpp @@ -218,8 +218,8 @@ Error EditorExportPlatformWindows::export_project(const Ref bool embedded = p_preset->get("binary_format/embed_pck"); String pkg_name; - if (String(ProjectSettings::get_singleton()->get("application/config/name")) != "") { - pkg_name = String(ProjectSettings::get_singleton()->get("application/config/name")); + if (String(get_project_setting(p_preset, "application/config/name")) != "") { + pkg_name = String(get_project_setting(p_preset, "application/config/name")); } else { pkg_name = "Unnamed"; } @@ -248,7 +248,7 @@ Error EditorExportPlatformWindows::export_project(const Ref int export_angle = p_preset->get("application/export_angle"); bool include_angle_libs = false; if (export_angle == 0) { - include_angle_libs = (String(GLOBAL_GET("rendering/gl_compatibility/driver.windows")) == "opengl3_angle") && (String(GLOBAL_GET("rendering/renderer/rendering_method")) == "gl_compatibility"); + include_angle_libs = (String(get_project_setting(p_preset, "rendering/gl_compatibility/driver.windows")) == "opengl3_angle") && (String(get_project_setting(p_preset, "rendering/renderer/rendering_method")) == "gl_compatibility"); } else if (export_angle == 1) { include_angle_libs = true; } @@ -268,7 +268,7 @@ Error EditorExportPlatformWindows::export_project(const Ref bool agility_sdk_multiarch = p_preset->get("application/d3d12_agility_sdk_multiarch"); bool include_d3d12_extra_libs = false; if (export_d3d12 == 0) { - include_d3d12_extra_libs = (String(GLOBAL_GET("rendering/rendering_device/driver.windows")) == "d3d12") && (String(GLOBAL_GET("rendering/renderer/rendering_method")) != "gl_compatibility"); + include_d3d12_extra_libs = (String(get_project_setting(p_preset, "rendering/rendering_device/driver.windows")) == "d3d12") && (String(get_project_setting(p_preset, "rendering/renderer/rendering_method")) != "gl_compatibility"); } else if (export_d3d12 == 1) { include_d3d12_extra_libs = true; } @@ -531,10 +531,10 @@ Error EditorExportPlatformWindows::_rcedit_add_data(const Refget("application/icon") != "") { icon_path = p_preset->get("application/icon"); - } else if (GLOBAL_GET("application/config/windows_native_icon") != "") { - icon_path = GLOBAL_GET("application/config/windows_native_icon"); + } else if (get_project_setting(p_preset, "application/config/windows_native_icon") != "") { + icon_path = get_project_setting(p_preset, "application/config/windows_native_icon"); } else { - icon_path = GLOBAL_GET("application/config/icon"); + icon_path = get_project_setting(p_preset, "application/config/icon"); } icon_path = ProjectSettings::get_singleton()->globalize_path(icon_path);