@@ -222,6 +222,7 @@ static const int icon_densities_count = 6;
222
222
static const char *launcher_icon_option = PNAME(" launcher_icons/main_192x192" );
223
223
static const char *launcher_adaptive_icon_foreground_option = PNAME(" launcher_icons/adaptive_foreground_432x432" );
224
224
static const char *launcher_adaptive_icon_background_option = PNAME(" launcher_icons/adaptive_background_432x432" );
225
+ static const char *launcher_adaptive_icon_monochrome_option = PNAME(" launcher_icons/adaptive_monochrome_432x432" );
225
226
226
227
static const LauncherIcon launcher_icons[icon_densities_count] = {
227
228
{ " res/mipmap-xxxhdpi-v4/icon.png" , 192 },
@@ -250,6 +251,15 @@ static const LauncherIcon launcher_adaptive_icon_backgrounds[icon_densities_coun
250
251
{ " res/mipmap/icon_background.png" , 432 }
251
252
};
252
253
254
+ static const LauncherIcon launcher_adaptive_icon_monochromes[icon_densities_count] = {
255
+ { " res/mipmap-xxxhdpi-v4/icon_monochrome.png" , 432 },
256
+ { " res/mipmap-xxhdpi-v4/icon_monochrome.png" , 324 },
257
+ { " res/mipmap-xhdpi-v4/icon_monochrome.png" , 216 },
258
+ { " res/mipmap-hdpi-v4/icon_monochrome.png" , 162 },
259
+ { " res/mipmap-mdpi-v4/icon_monochrome.png" , 108 },
260
+ { " res/mipmap/icon_monochrome.png" , 432 }
261
+ };
262
+
253
263
static const int EXPORT_FORMAT_APK = 0 ;
254
264
static const int EXPORT_FORMAT_AAB = 1 ;
255
265
@@ -1644,12 +1654,13 @@ void EditorExportPlatformAndroid::_process_launcher_icons(const String &p_file_n
1644
1654
}
1645
1655
}
1646
1656
1647
- void EditorExportPlatformAndroid::load_icon_refs (const Ref<EditorExportPreset> &p_preset, Ref<Image> &icon, Ref<Image> &foreground, Ref<Image> &background) {
1657
+ void EditorExportPlatformAndroid::load_icon_refs (const Ref<EditorExportPreset> &p_preset, Ref<Image> &icon, Ref<Image> &foreground, Ref<Image> &background, Ref<Image> &monochrome ) {
1648
1658
String project_icon_path = GLOBAL_GET (" application/config/icon" );
1649
1659
1650
1660
icon.instantiate ();
1651
1661
foreground.instantiate ();
1652
1662
background.instantiate ();
1663
+ monochrome.instantiate ();
1653
1664
1654
1665
// Regular icon: user selection -> project icon -> default.
1655
1666
String path = static_cast <String>(p_preset->get (launcher_icon_option)).strip_edges ();
@@ -1677,12 +1688,20 @@ void EditorExportPlatformAndroid::load_icon_refs(const Ref<EditorExportPreset> &
1677
1688
print_verbose (" Loading adaptive background icon from " + path);
1678
1689
ImageLoader::load_image (path, background);
1679
1690
}
1691
+
1692
+ // Adaptive monochrome: user selection -> default.
1693
+ path = static_cast <String>(p_preset->get (launcher_adaptive_icon_monochrome_option)).strip_edges ();
1694
+ if (!path.is_empty ()) {
1695
+ print_verbose (" Loading adaptive monochrome icon from " + path);
1696
+ ImageLoader::load_image (path, background);
1697
+ }
1680
1698
}
1681
1699
1682
1700
void EditorExportPlatformAndroid::_copy_icons_to_gradle_project (const Ref<EditorExportPreset> &p_preset,
1683
1701
const Ref<Image> &p_main_image,
1684
1702
const Ref<Image> &p_foreground,
1685
- const Ref<Image> &p_background) {
1703
+ const Ref<Image> &p_background,
1704
+ const Ref<Image> &p_monochrome) {
1686
1705
String gradle_build_dir = ExportTemplateManager::get_android_build_directory (p_preset);
1687
1706
1688
1707
// Prepare images to be resized for the icons. If some image ends up being uninitialized,
@@ -1711,6 +1730,14 @@ void EditorExportPlatformAndroid::_copy_icons_to_gradle_project(const Ref<Editor
1711
1730
launcher_adaptive_icon_backgrounds[i].dimensions , data);
1712
1731
store_file_at_path (gradle_build_dir.path_join (launcher_adaptive_icon_backgrounds[i].export_path ), data);
1713
1732
}
1733
+
1734
+ if (p_monochrome.is_valid () && !p_monochrome->is_empty ()) {
1735
+ print_verbose (" Processing launcher adaptive icon p_monochrome for dimension " + itos (launcher_adaptive_icon_monochromes[i].dimensions ) + " into " + launcher_adaptive_icon_monochromes[i].export_path );
1736
+ Vector<uint8_t > data;
1737
+ _process_launcher_icons (launcher_adaptive_icon_monochromes[i].export_path , p_monochrome,
1738
+ launcher_adaptive_icon_monochromes[i].dimensions , data);
1739
+ store_file_at_path (gradle_build_dir.path_join (launcher_adaptive_icon_monochromes[i].export_path ), data);
1740
+ }
1714
1741
}
1715
1742
}
1716
1743
@@ -1875,6 +1902,7 @@ void EditorExportPlatformAndroid::get_export_options(List<ExportOption> *r_optio
1875
1902
r_options->push_back (ExportOption (PropertyInfo (Variant::STRING, launcher_icon_option, PROPERTY_HINT_FILE, " *.png" ), " " ));
1876
1903
r_options->push_back (ExportOption (PropertyInfo (Variant::STRING, launcher_adaptive_icon_foreground_option, PROPERTY_HINT_FILE, " *.png" ), " " ));
1877
1904
r_options->push_back (ExportOption (PropertyInfo (Variant::STRING, launcher_adaptive_icon_background_option, PROPERTY_HINT_FILE, " *.png" ), " " ));
1905
+ r_options->push_back (ExportOption (PropertyInfo (Variant::STRING, launcher_adaptive_icon_monochrome_option, PROPERTY_HINT_FILE, " *.png" ), " " ));
1878
1906
1879
1907
r_options->push_back (ExportOption (PropertyInfo (Variant::BOOL, " graphics/opengl_debug" ), false ));
1880
1908
@@ -3035,8 +3063,9 @@ Error EditorExportPlatformAndroid::export_project_helper(const Ref<EditorExportP
3035
3063
Ref<Image> main_image;
3036
3064
Ref<Image> foreground;
3037
3065
Ref<Image> background;
3066
+ Ref<Image> monochrome;
3038
3067
3039
- load_icon_refs (p_preset, main_image, foreground, background);
3068
+ load_icon_refs (p_preset, main_image, foreground, background, monochrome );
3040
3069
3041
3070
Vector<uint8_t > command_line_flags;
3042
3071
// Write command line flags into the command_line_flags variable.
@@ -3107,7 +3136,7 @@ Error EditorExportPlatformAndroid::export_project_helper(const Ref<EditorExportP
3107
3136
add_message (EXPORT_MESSAGE_ERROR, TTR (" Export" ), TTR (" Unable to overwrite res/*.xml files with project name." ));
3108
3137
}
3109
3138
// Copies the project icon files into the appropriate Gradle project directory.
3110
- _copy_icons_to_gradle_project (p_preset, main_image, foreground, background);
3139
+ _copy_icons_to_gradle_project (p_preset, main_image, foreground, background, monochrome );
3111
3140
// Write an AndroidManifest.xml file into the Gradle project directory.
3112
3141
_write_tmp_manifest (p_preset, p_give_internet, p_debug);
3113
3142
@@ -3446,6 +3475,11 @@ Error EditorExportPlatformAndroid::export_project_helper(const Ref<EditorExportP
3446
3475
_process_launcher_icons (file, background, launcher_adaptive_icon_backgrounds[i].dimensions , data);
3447
3476
}
3448
3477
}
3478
+ if (monochrome.is_valid () && !monochrome->is_empty ()) {
3479
+ if (file == launcher_adaptive_icon_monochromes[i].export_path ) {
3480
+ _process_launcher_icons (file, monochrome, launcher_adaptive_icon_monochromes[i].dimensions , data);
3481
+ }
3482
+ }
3449
3483
}
3450
3484
}
3451
3485
0 commit comments