1
0
mirror of https://github.com/godotengine/godot.git synced 2025-11-04 12:00:25 +00:00

[Export] Use project settings overrides with the target preset features instead of current platform features.

This commit is contained in:
bruvzg
2023-01-17 09:52:17 +02:00
committed by Pāvels Nadtočajevs
parent 4248411baf
commit c6739f64df
22 changed files with 251 additions and 123 deletions

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