From ac0ed9ce677745ac452cfaf9fd59813a836de7bc Mon Sep 17 00:00:00 2001 From: bruvzg <7645683+bruvzg@users.noreply.github.com> Date: Thu, 17 Nov 2022 23:46:48 +0200 Subject: Windows icon export improvements. Regenerate Windows icon on export to ensure correct icon size order. Add support for using PNG/WebP/SVG files as an icon for Windows exports. Allow using WebP/SVG files as icon for macOS exports. Add option to select generated icons interpolation, and set default interpolation to Lanczos. --- platform/macos/export/export_plugin.cpp | 15 +++++++-------- platform/macos/export/export_plugin.h | 2 +- 2 files changed, 8 insertions(+), 9 deletions(-) (limited to 'platform/macos') diff --git a/platform/macos/export/export_plugin.cpp b/platform/macos/export/export_plugin.cpp index de6016cb9b..b5c2e12a2f 100644 --- a/platform/macos/export/export_plugin.cpp +++ b/platform/macos/export/export_plugin.cpp @@ -116,7 +116,8 @@ void EditorExportPlatformMacOS::get_export_options(List *r_options r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "custom_template/release", PROPERTY_HINT_GLOBAL_FILE, "*.zip"), "")); r_options->push_back(ExportOption(PropertyInfo(Variant::INT, "debug/export_console_script", PROPERTY_HINT_ENUM, "No,Debug Only,Debug and Release"), 1)); - r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "application/icon", PROPERTY_HINT_FILE, "*.png,*.icns"), "")); + r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "application/icon", PROPERTY_HINT_FILE, "*.icns,*.png,*.webp,*.svg"), "")); + r_options->push_back(ExportOption(PropertyInfo(Variant::INT, "application/icon_interpolation", PROPERTY_HINT_ENUM, "Nearest neighbor,Bilinear,Cubic,Trilinear,Lanczos"), 4)); r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "application/bundle_identifier", PROPERTY_HINT_PLACEHOLDER_TEXT, "com.example.game"), "")); r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "application/signature"), "")); r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "application/app_category", PROPERTY_HINT_ENUM, "Business,Developer-tools,Education,Entertainment,Finance,Games,Action-games,Adventure-games,Arcade-games,Board-games,Card-games,Casino-games,Dice-games,Educational-games,Family-games,Kids-games,Music-games,Puzzle-games,Racing-games,Role-playing-games,Simulation-games,Sports-games,Strategy-games,Trivia-games,Word-games,Graphics-design,Healthcare-fitness,Lifestyle,Medical,Music,News,Photography,Productivity,Reference,Social-networking,Sports,Travel,Utilities,Video,Weather"), "Games")); @@ -268,7 +269,7 @@ void _rgba8_to_packbits_encode(int p_ch, int p_size, Vector &p_source, memcpy(&p_dest.write[ofs], result.ptr(), res_size); } -void EditorExportPlatformMacOS::_make_icon(const Ref &p_icon, Vector &p_data) { +void EditorExportPlatformMacOS::_make_icon(const Ref &p_preset, const Ref &p_icon, Vector &p_data) { Ref it = memnew(ImageTexture); Vector data; @@ -302,7 +303,7 @@ void EditorExportPlatformMacOS::_make_icon(const Ref &p_icon, Vector copy = p_icon; // does this make sense? doesn't this just increase the reference count instead of making a copy? Do we even need a copy? copy->convert(Image::FORMAT_RGBA8); - copy->resize(icon_infos[i].size, icon_infos[i].size); + copy->resize(icon_infos[i].size, icon_infos[i].size, (Image::Interpolation)(p_preset->get("application/icon_interpolation").operator int())); if (icon_infos[i].is_png) { // Encode PNG icon. @@ -1268,11 +1269,9 @@ Error EditorExportPlatformMacOS::export_project(const Ref &p icon->get_buffer(&data.write[0], icon->get_length()); } } else { - Ref icon; - icon.instantiate(); - icon->load(iconpath); - if (!icon->is_empty()) { - _make_icon(icon, data); + Ref icon = Image::load_from_file(iconpath); + if (icon.is_valid() && !icon->is_empty()) { + _make_icon(p_preset, icon, data); } } } diff --git a/platform/macos/export/export_plugin.h b/platform/macos/export/export_plugin.h index b6ad587caa..af7570c394 100644 --- a/platform/macos/export/export_plugin.h +++ b/platform/macos/export/export_plugin.h @@ -53,7 +53,7 @@ class EditorExportPlatformMacOS : public EditorExportPlatform { Ref logo; void _fix_plist(const Ref &p_preset, Vector &plist, const String &p_binary); - void _make_icon(const Ref &p_icon, Vector &p_data); + void _make_icon(const Ref &p_preset, const Ref &p_icon, Vector &p_data); Error _notarize(const Ref &p_preset, const String &p_path); Error _code_sign(const Ref &p_preset, const String &p_path, const String &p_ent_path, bool p_warn = true); -- cgit v1.2.3