diff options
author | bruvzg <7645683+bruvzg@users.noreply.github.com> | 2019-05-17 16:43:56 +0300 |
---|---|---|
committer | bruvzg <7645683+bruvzg@users.noreply.github.com> | 2019-05-24 14:23:57 +0300 |
commit | 2b9ed68d6a261bdabf4a6a3e205e42471c38d443 (patch) | |
tree | 6037d6c38d26d45c3488241fa168672c696aa689 /main/main.cpp | |
parent | c088386c5b5e7631ce670cb4fa0e6563d29d0973 (diff) |
Add native window/taskbar icon support for Windows and macOS.
Co-authored-by: Markus Törnqvist <mjt@nysv.org>
Diffstat (limited to 'main/main.cpp')
-rw-r--r-- | main/main.cpp | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/main/main.cpp b/main/main.cpp index da77962c8a..9a156102e5 100644 --- a/main/main.cpp +++ b/main/main.cpp @@ -1189,6 +1189,12 @@ Error Main::setup2(Thread::ID p_main_tid_override) { GLOBAL_DEF("application/config/icon", String()); ProjectSettings::get_singleton()->set_custom_property_info("application/config/icon", PropertyInfo(Variant::STRING, "application/config/icon", PROPERTY_HINT_FILE, "*.png,*.webp")); + GLOBAL_DEF("application/config/macos_native_icon", String()); + ProjectSettings::get_singleton()->set_custom_property_info("application/config/macos_native_icon", PropertyInfo(Variant::STRING, "application/config/macos_native_icon", PROPERTY_HINT_FILE, "*.icns")); + + GLOBAL_DEF("application/config/windows_native_icon", String()); + ProjectSettings::get_singleton()->set_custom_property_info("application/config/windows_native_icon", PropertyInfo(Variant::STRING, "application/config/windows_native_icon", PROPERTY_HINT_FILE, "*.ico")); + InputDefault *id = Object::cast_to<InputDefault>(Input::get_singleton()); if (id) { if (bool(GLOBAL_DEF("input_devices/pointing/emulate_touch_from_mouse", false)) && !(editor || project_manager)) { @@ -1739,8 +1745,24 @@ bool Main::start() { ERR_FAIL_COND_V(!scene, false) sml->add_current_scene(scene); +#ifdef OSX_ENABLED + String mac_iconpath = GLOBAL_DEF("application/config/macos_native_icon", "Variant()"); + if (mac_iconpath != "") { + OS::get_singleton()->set_native_icon(mac_iconpath); + hasicon = true; + } +#endif + +#ifdef WINDOWS_ENABLED + String win_iconpath = GLOBAL_DEF("application/config/windows_native_icon", "Variant()"); + if (win_iconpath != "") { + OS::get_singleton()->set_native_icon(win_iconpath); + hasicon = true; + } +#endif + String iconpath = GLOBAL_DEF("application/config/icon", "Variant()"); - if (iconpath != "") { + if ((iconpath != "") && (!hasicon)) { Ref<Image> icon; icon.instance(); if (ImageLoader::load_image(iconpath, icon) == OK) { |