Merge pull request #71542 from bruvzg/export_project_settings

[Export] Use project settings overrides with the target preset features instead of current platform features.
This commit is contained in:
Thaddeus Crews 2025-04-09 08:51:47 -05:00
commit a8598cd8e2
No known key found for this signature in database
GPG Key ID: 8C6E5FEB5FC03CCC
22 changed files with 251 additions and 123 deletions

View File

@ -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<String> &p_features) const {
_THREAD_SAFE_METHOD_
StringName name = p_name;
if (feature_overrides.has(name)) {
const LocalVector<Pair<StringName, StringName>> &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);

View File

@ -193,6 +193,7 @@ public:
List<String> 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<String> &p_features) const;
bool is_using_datapack() const;
bool is_project_loaded() const;

View File

@ -121,6 +121,7 @@
</method>
<method name="get_forced_export_files" qualifiers="static">
<return type="PackedStringArray" />
<param index="0" name="preset" type="EditorExportPreset" />
<description>
Returns array of core file names that always should be exported regardless of preset config.
</description>

View File

@ -121,6 +121,13 @@
Returns export preset name.
</description>
</method>
<method name="get_project_setting">
<return type="Variant" />
<param index="0" name="name" type="StringName" />
<description>
Returns the value of the setting identified by [param name] using export preset feature tag overrides instead of current OS features.
</description>
</method>
<method name="get_script_export_mode" qualifiers="const">
<return type="int" />
<description>

View File

@ -114,6 +114,14 @@
[/codeblocks]
</description>
</method>
<method name="get_setting_with_override_and_custom_features" qualifiers="const">
<return type="Variant" />
<param index="0" name="name" type="StringName" />
<param index="1" name="features" type="PackedStringArray" />
<description>
Similar to [method get_setting_with_override], but applies feature tag overrides instead of current OS features.
</description>
</method>
<method name="globalize_path" qualifiers="const">
<return type="String" />
<param index="0" name="path" type="String" />

View File

@ -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<String> forced_export = EditorExportPlatform::get_forced_export_files();
Vector<String> forced_export = EditorExportPlatform::get_forced_export_files(Ref<EditorExportPreset>());
for (int i = 0; i < forced_export.size(); i++) {
_add_custom_file(forced_export[i], files_to_send, cached_files);
}

View File

@ -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<String> EditorExportPlatform::_get_forced_export_files_bind_compat_71542() {
return get_forced_export_files(Ref<EditorExportPreset>());
}
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

View File

@ -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"
@ -946,7 +948,7 @@ Dictionary EditorExportPlatform::get_internal_export_files(const Ref<EditorExpor
Dictionary files;
// Text server support data.
if (TS->has_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()) {
@ -992,13 +994,13 @@ Dictionary EditorExportPlatform::get_internal_export_files(const Ref<EditorExpor
return files;
}
Vector<String> EditorExportPlatform::get_forced_export_files() {
Vector<String> EditorExportPlatform::get_forced_export_files(const Ref<EditorExportPreset> &p_preset) {
Vector<String> 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);
}
@ -1110,7 +1112,7 @@ Error EditorExportPlatform::export_project_files(const Ref<EditorExportPreset> &
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);
@ -1253,7 +1255,7 @@ Error EditorExportPlatform::export_project_files(const Ref<EditorExportPreset> &
HashMap<String, FileExportCache> 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
@ -1565,7 +1567,7 @@ Error EditorExportPlatform::export_project_files(const Ref<EditorExportPreset> &
}
}
Vector<String> forced_export = get_forced_export_files();
Vector<String> forced_export = get_forced_export_files(p_preset);
for (int i = 0; i < forced_export.size(); i++) {
Vector<uint8_t> array;
if (GDExtension::get_extension_list_config_file() == forced_export[i]) {
@ -2464,6 +2466,14 @@ Array EditorExportPlatform::get_current_presets() const {
return ret;
}
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);
} else {
return GLOBAL_GET(p_name);
}
}
void EditorExportPlatform::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_os_name"), &EditorExportPlatform::get_os_name);
@ -2502,7 +2512,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);

View File

@ -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<Image> _load_icon_or_splash_image(const String &p_path, Error *r_error) const;
#ifndef DISABLE_DEPRECATED
static Vector<String> _get_forced_export_files_bind_compat_71542();
static void _bind_compatibility_methods();
#endif
public:
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;
struct ExportOption {
@ -280,7 +287,7 @@ public:
Dictionary get_internal_export_files(const Ref<EditorExportPreset> &p_preset, bool p_debug);
static Vector<String> get_forced_export_files();
static Vector<String> get_forced_export_files(const Ref<EditorExportPreset> &p_preset);
virtual bool fill_log_messages(RichTextLabel *p_log, Error p_err);

View File

@ -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<String> ftr_list;
platform->get_platform_features(&ftr_list);
platform->get_preset_features(this, &ftr_list);
Vector<String> features;
for (const String &E : ftr_list) {
features.push_back(E);
}
if (!get_custom_features().is_empty()) {
Vector<String> 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);

View File

@ -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;

View File

@ -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.

View File

@ -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<EditorExportPreset> &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<EditorExportPreset> &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<EditorExportPreset> &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<EditorExportP
return gradle_build_directory.path_join(p_export_format == EXPORT_FORMAT_AAB ? AAB_ASSETS_DIRECTORY : APK_ASSETS_DIRECTORY);
}
bool EditorExportPlatformAndroid::is_package_name_valid(const String &p_package, String *r_error) const {
String pname = get_package_name(p_package);
bool EditorExportPlatformAndroid::is_package_name_valid(const Ref<EditorExportPreset> &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<EditorExportPreset> &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<EditorExportPreset> &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 Ref<EditorExportPrese
}
}
if (_uses_vulkan()) {
if (_uses_vulkan(p_preset)) {
// Require vulkan hardware level 1 support
FeatureInfo vulkan_level = {
"android.hardware.vulkan.level", // name
@ -984,7 +983,7 @@ void EditorExportPlatformAndroid::_get_manifest_info(const Ref<EditorExportPrese
MetadataInfo rendering_method_metadata = {
"org.godotengine.rendering.method",
GLOBAL_GET("rendering/renderer/rendering_method.mobile")
p_preset->get_project_setting("rendering/renderer/rendering_method.mobile")
};
r_metadata.append(rendering_method_metadata);
@ -1121,7 +1120,7 @@ void EditorExportPlatformAndroid::_fix_manifest(const Ref<EditorExportPreset> &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<EditorExportPreset> &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<String> perms;
Vector<FeatureInfo> features;
@ -1206,7 +1205,7 @@ void EditorExportPlatformAndroid::_fix_manifest(const Ref<EditorExportPreset> &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<EditorExportPreset> &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<EditorExportPreset> &
Vector<String> 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<EditorExportPreset> &
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<EditorExportPreset> &p_preset, Ref<Image> &icon, Ref<Image> &foreground, Ref<Image> &background, Ref<Image> &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<EditorExportPreset>(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<EditorExportPreset> &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<EditorExportPreset> &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 Ref<Edit
}
}
String current_renderer = GLOBAL_GET("rendering/renderer/rendering_method.mobile");
String current_renderer = get_project_setting(p_preset, "rendering/renderer/rendering_method.mobile");
if (current_renderer == "forward_plus") {
// Warning only, so don't override `valid`.
err += vformat(TTR("The \"%s\" renderer is designed for Desktop devices, and is not suitable for Android devices."), current_renderer);
err += "\n";
}
if (_uses_vulkan() && min_sdk_int < VULKAN_MIN_SDK_VERSION) {
if (_uses_vulkan(p_preset) && min_sdk_int < VULKAN_MIN_SDK_VERSION) {
// Warning only, so don't override `valid`.
err += vformat(TTR("\"Min SDK\" should be greater or equal to %d for the \"%s\" renderer."), VULKAN_MIN_SDK_VERSION, current_renderer);
err += "\n";
}
String package_name = p_preset->get("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<String> EditorExportPlatformAndroid::get_binary_extensions(const Ref<Editor
String EditorExportPlatformAndroid::get_apk_expansion_fullpath(const Ref<EditorExportPreset> &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 Ref<EditorExportP
print_verbose("Android sdk path: " + sdk_path);
// TODO: should we use "package/name" or "application/config/name"?
String project_name = get_project_name(p_preset->get("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 Ref<EditorExportP
String build_path = ProjectSettings::get_singleton()->globalize_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");

View File

@ -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<EditorExportPreset> &p_preset, const String &p_name) const;
String get_package_name(const String &p_package) const;
String get_package_name(const Ref<EditorExportPreset> &p_preset, const String &p_package) const;
String get_valid_basename() const;
String get_valid_basename(const Ref<EditorExportPreset> &p_preset) const;
String get_assets_directory(const Ref<EditorExportPreset> &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<EditorExportPreset> &p_preset, const String &p_package, String *r_error = nullptr) const;
bool is_project_name_valid(const Ref<EditorExportPreset> &p_preset) const;
static bool _should_compress_asset(const String &p_path, const Vector<uint8_t> &p_data);
@ -189,7 +189,7 @@ class EditorExportPlatformAndroid : public EditorExportPlatform {
static Vector<ABI> get_enabled_abis(const Ref<EditorExportPreset> &p_preset);
static bool _uses_vulkan();
bool _uses_vulkan(const Ref<EditorExportPreset> &p_preset) const;
protected:
void _notification(int p_what);

View File

@ -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<EditorExportPreset> &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<EditorExportPreset> &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<EditorExportPreset> &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<EditorExportPreset> &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<EditorExportPreset> &p_preset) {
}
String _get_activity_tag(const Ref<EditorExportPlatform> &p_export_platform, const Ref<EditorExportPreset> &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(
" <activity android:name=\".GodotApp\" "
"tools:replace=\"android:screenOrientation,android:excludeFromRecents,android:resizeableActivity\" "
@ -274,7 +273,7 @@ String _get_activity_tag(const Ref<EditorExportPlatform> &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 += " <intent-filter>\n"
" <action android:name=\"android.intent.action.MAIN\" />\n"

View File

@ -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<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);
// Creates strings.xml files inside the gradle project for different locales.
Error _create_project_name_strings_files(const Ref<EditorExportPreset> &p_preset, const String &project_name, const String &p_gradle_build_dir);
Error _create_project_name_strings_files(const Ref<EditorExportPreset> &p_preset, const String &p_project_name, const String &p_gradle_build_dir, const Dictionary &p_appnames);
String bool_to_string(bool v);

View File

@ -423,8 +423,8 @@ HashMap<String, Variant> 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<EditorExportPreset> &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<EditorExportPreset> &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<EditorExportPreset> &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<EditorExportPreset> &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<EditorExportPreset> &p_
strnew += lines[i].replace("$launch_screen_background_color", value) + "\n";
} else if (lines[i].contains("$pbx_locale_file_reference")) {
String locale_files;
Vector<String> translations = GLOBAL_GET("internationalization/locale/translations");
Vector<String> translations = get_project_setting(p_preset, "internationalization/locale/translations");
if (translations.size() > 0) {
HashSet<String> languages;
for (const String &E : translations) {
@ -738,7 +738,7 @@ void EditorExportPlatformIOS::_fix_config_file(const Ref<EditorExportPreset> &p_
strnew += lines[i].replace("$pbx_locale_file_reference", locale_files);
} else if (lines[i].contains("$pbx_locale_build_reference")) {
String locale_files;
Vector<String> translations = GLOBAL_GET("internationalization/locale/translations");
Vector<String> translations = get_project_setting(p_preset, "internationalization/locale/translations");
if (translations.size() > 0) {
HashSet<String> languages;
for (const String &E : translations) {
@ -957,7 +957,7 @@ Error EditorExportPlatformIOS::_export_icons(const Ref<EditorExportPreset> &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<EditorExportPreset> &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<Image> 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<EditorExpor
Error err = OK;
Ref<Image> 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 Ref<EditorExportPres
print_line("Static framework: " + library_to_use);
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";
}
@ -2281,14 +2281,12 @@ Error EditorExportPlatformIOS::_export_project_helper(const Ref<EditorExportPres
return ERR_FILE_NOT_FOUND;
}
// Generate translations files.
Dictionary appnames = GLOBAL_GET("application/config/name_localized");
Dictionary appnames = get_project_setting(p_preset, "application/config/name_localized");
Dictionary camera_usage_descriptions = p_preset->get("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<String> translations = GLOBAL_GET("internationalization/locale/translations");
Vector<String> 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<EditorExportPres
Ref<FileAccess> 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 Ref<EditorExp
}
}
String rendering_method = GLOBAL_GET("rendering/renderer/rendering_method.mobile");
String rendering_driver = GLOBAL_GET("rendering/rendering_device/driver.ios");
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.ios");
if ((rendering_method == "forward_plus" || rendering_method == "mobile") && rendering_driver == "metal") {
float version = p_preset->get("application/min_ios_version").operator String().to_float();
if (version < 14.0) {

View File

@ -80,8 +80,8 @@ Error EditorExportPlatformLinuxBSD::export_project(const Ref<EditorExportPreset>
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";
}

View File

@ -821,7 +821,7 @@ void EditorExportPlatformMacOS::_fix_plist(const Ref<EditorExportPreset> &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<EditorExportPreset> &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<EditorExportPreset> &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<EditorExportPreset> &p
Dictionary removable_volumes_usage_descriptions = p_preset->get("privacy/removable_volumes_usage_description_localized");
Dictionary copyrights = p_preset->get("application/copyright_localized");
Vector<String> translations = GLOBAL_GET("internationalization/locale/translations");
Vector<String> 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<EditorExportPreset> &p
Ref<FileAccess> 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<EditorExportPreset> &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<EditorExportPreset> &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<EditorExportPreset> &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";
}

View File

@ -164,15 +164,15 @@ void EditorExportPlatformWeb::_fix_html(Vector<uint8_t> &p_html, const Ref<Edito
const String custom_head_include = p_preset->get("html/head_include");
HashMap<String, String> 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<String> 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<uint8_t> &p_html, const Ref<Edito
_replace_strings(replaces, p_html);
}
Error EditorExportPlatformWeb::_add_manifest_icon(const String &p_path, const String &p_icon, int p_size, Array &r_arr) {
Error EditorExportPlatformWeb::_add_manifest_icon(const Ref<EditorExportPreset> &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<EditorExportPreset> &p_preset, const String p_path, const Vector<SharedObject> &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<EditorExportPreset> &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<EditorExportPreset> &p_p
html.resize(0);
// Export splash (why?)
Ref<Image> splash = _get_project_splash();
Ref<Image> 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<EditorExportPreset> &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<Image> favicon = _get_project_icon();
Ref<Image> 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));

View File

@ -75,11 +75,11 @@ class EditorExportPlatformWeb : public EditorExportPlatform {
return name;
}
Ref<Image> _get_project_icon() const {
Ref<Image> _get_project_icon(const Ref<EditorExportPreset> &p_preset) const {
Error err = OK;
Ref<Image> 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<Image> _get_project_splash() const {
Ref<Image> _get_project_splash(const Ref<EditorExportPreset> &p_preset) const {
Error err = OK;
Ref<Image> 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<String, String> &p_replaces, Vector<uint8_t> &r_template);
void _fix_html(Vector<uint8_t> &p_html, const Ref<EditorExportPreset> &p_preset, const String &p_name, bool p_debug, BitField<EditorExportPlatform::DebugFlags> p_flags, const Vector<SharedObject> 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<EditorExportPreset> &p_preset, const String &p_path, const String &p_icon, int p_size, Array &r_arr);
Error _build_pwa(const Ref<EditorExportPreset> &p_preset, const String p_path, const Vector<SharedObject> &p_shared_objects);
Error _write_or_error(const uint8_t *p_content, int p_len, String p_path);

View File

@ -218,8 +218,8 @@ Error EditorExportPlatformWindows::export_project(const Ref<EditorExportPreset>
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<EditorExportPreset>
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<EditorExportPreset>
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 Ref<EditorExportPreset
String icon_path;
if (p_preset->get("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);