diff options
author | bruvzg <7645683+bruvzg@users.noreply.github.com> | 2021-05-13 09:25:09 +0300 |
---|---|---|
committer | bruvzg <7645683+bruvzg@users.noreply.github.com> | 2021-05-13 09:25:09 +0300 |
commit | 11ccfad1aabec468fd92e1b567f3f9d94b5acc4b (patch) | |
tree | 03f76795e046d4fd94b8f486709ddd638648d1c9 /platform/osx | |
parent | b283447bfd5c8d1f6a6566bda57f89c1b87a3e0e (diff) |
[macOS] Prefer .app bundle icon over the default one.
Diffstat (limited to 'platform/osx')
-rw-r--r-- | platform/osx/os_osx.h | 1 | ||||
-rw-r--r-- | platform/osx/os_osx.mm | 20 |
2 files changed, 17 insertions, 4 deletions
diff --git a/platform/osx/os_osx.h b/platform/osx/os_osx.h index d57940775d..fdf099ec03 100644 --- a/platform/osx/os_osx.h +++ b/platform/osx/os_osx.h @@ -80,6 +80,7 @@ public: virtual String get_data_path() const override; virtual String get_cache_path() const override; virtual String get_bundle_resource_dir() const override; + virtual String get_bundle_icon_path() const override; virtual String get_godot_dir_name() const override; virtual String get_system_dir(SystemDir p_dir) const override; diff --git a/platform/osx/os_osx.mm b/platform/osx/os_osx.mm index e6feda5a9b..789b6b44d3 100644 --- a/platform/osx/os_osx.mm +++ b/platform/osx/os_osx.mm @@ -216,14 +216,26 @@ String OS_OSX::get_cache_path() const { } String OS_OSX::get_bundle_resource_dir() const { + String ret; + NSBundle *main = [NSBundle mainBundle]; - NSString *resourcePath = [main resourcePath]; + if (main) { + NSString *resourcePath = [main resourcePath]; + ret.parse_utf8([resourcePath UTF8String]); + } + return ret; +} - char *utfs = strdup([resourcePath UTF8String]); +String OS_OSX::get_bundle_icon_path() const { String ret; - ret.parse_utf8(utfs); - free(utfs); + NSBundle *main = [NSBundle mainBundle]; + if (main) { + NSString *iconPath = [[main infoDictionary] objectForKey:@"CFBundleIconFile"]; + if (iconPath) { + ret.parse_utf8([iconPath UTF8String]); + } + } return ret; } |