diff options
Diffstat (limited to 'platform/web/export/export_plugin.cpp')
-rw-r--r-- | platform/web/export/export_plugin.cpp | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/platform/web/export/export_plugin.cpp b/platform/web/export/export_plugin.cpp index a62ccdc2aa..9ffb776c29 100644 --- a/platform/web/export/export_plugin.cpp +++ b/platform/web/export/export_plugin.cpp @@ -34,11 +34,11 @@ #include "run_icon_svg.gen.h" #include "core/config/project_settings.h" -#include "editor/editor_scale.h" #include "editor/editor_settings.h" #include "editor/editor_string_names.h" #include "editor/export/editor_export.h" #include "editor/import/resource_importer_texture_settings.h" +#include "editor/themes/editor_scale.h" #include "scene/resources/image_texture.h" #include "modules/modules_enabled.gen.h" // For mono and svg. @@ -112,7 +112,7 @@ Error EditorExportPlatformWeb::_write_or_error(const uint8_t *p_content, int p_s return OK; } -void EditorExportPlatformWeb::_replace_strings(HashMap<String, String> p_replaces, Vector<uint8_t> &r_template) { +void EditorExportPlatformWeb::_replace_strings(const HashMap<String, String> &p_replaces, Vector<uint8_t> &r_template) { String str_template = String::utf8(reinterpret_cast<const char *>(r_template.ptr()), r_template.size()); String out; Vector<String> lines = str_template.split("\n"); @@ -259,6 +259,7 @@ Error EditorExportPlatformWeb::_build_pwa(const Ref<EditorExportPreset> &p_prese _replace_strings(replaces, sw); Error err = _write_or_error(sw.ptr(), sw.size(), dir.path_join(name + ".service.worker.js")); if (err != OK) { + // Message is supplied by the subroutine method. return err; } @@ -291,16 +292,19 @@ Error EditorExportPlatformWeb::_build_pwa(const Ref<EditorExportPreset> &p_prese const String icon144_path = p_preset->get("progressive_web_app/icon_144x144"); err = _add_manifest_icon(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); 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); if (err != OK) { + // Message is supplied by the subroutine method. return err; } manifest["icons"] = icons_arr; @@ -308,6 +312,7 @@ Error EditorExportPlatformWeb::_build_pwa(const Ref<EditorExportPreset> &p_prese CharString cs = Variant(manifest).to_json_string().utf8(); err = _write_or_error((const uint8_t *)cs.get_data(), cs.length(), dir.path_join(name + ".manifest.json")); if (err != OK) { + // Message is supplied by the subroutine method. return err; } @@ -439,6 +444,11 @@ Error EditorExportPlatformWeb::export_project(const Ref<EditorExportPreset> &p_p const String base_path = p_path.get_basename(); const String base_name = p_path.get_file().get_basename(); + if (!DirAccess::exists(base_dir)) { + add_message(EXPORT_MESSAGE_ERROR, TTR("Export"), vformat(TTR("Target folder does not exist or is inaccessible: \"%s\""), base_dir)); + return ERR_FILE_BAD_PATH; + } + // Find the correct template String template_path = p_debug ? custom_debug : custom_release; template_path = template_path.strip_edges(); @@ -447,10 +457,6 @@ Error EditorExportPlatformWeb::export_project(const Ref<EditorExportPreset> &p_p template_path = find_export_template(_get_template_name(extensions, p_debug)); } - if (!DirAccess::exists(base_dir)) { - return ERR_FILE_BAD_PATH; - } - if (!template_path.is_empty() && !FileAccess::exists(template_path)) { add_message(EXPORT_MESSAGE_ERROR, TTR("Prepare Templates"), vformat(TTR("Template file not found: \"%s\"."), template_path)); return ERR_FILE_NOT_FOUND; @@ -480,6 +486,7 @@ Error EditorExportPlatformWeb::export_project(const Ref<EditorExportPreset> &p_p // Extract templates. error = _extract_template(template_path, base_dir, base_name, pwa); if (error) { + // Message is supplied by the subroutine method. return error; } @@ -510,6 +517,7 @@ Error EditorExportPlatformWeb::export_project(const Ref<EditorExportPreset> &p_p _fix_html(html, p_preset, base_name, p_debug, p_flags, shared_objects, file_sizes); Error err = _write_or_error(html.ptr(), html.size(), p_path); if (err != OK) { + // Message is supplied by the subroutine method. return err; } html.resize(0); @@ -543,6 +551,7 @@ Error EditorExportPlatformWeb::export_project(const Ref<EditorExportPreset> &p_p if (pwa) { err = _build_pwa(p_preset, p_path, shared_objects); if (err != OK) { + // Message is supplied by the subroutine method. return err; } } |