diff options
Diffstat (limited to 'platform/osx')
-rw-r--r-- | platform/osx/joypad_osx.h | 2 | ||||
-rw-r--r-- | platform/osx/os_osx.h | 2 | ||||
-rw-r--r-- | platform/osx/os_osx.mm | 40 | ||||
-rw-r--r-- | platform/osx/power_osx.cpp | 2 |
4 files changed, 44 insertions, 2 deletions
diff --git a/platform/osx/joypad_osx.h b/platform/osx/joypad_osx.h index e271f4b947..4bdef8eb83 100644 --- a/platform/osx/joypad_osx.h +++ b/platform/osx/joypad_osx.h @@ -1,5 +1,5 @@ /*************************************************************************/ -/* joypad_osx.h */ +/* joypad_osx.h */ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ diff --git a/platform/osx/os_osx.h b/platform/osx/os_osx.h index 5bfed1ee50..ebaebd84ce 100644 --- a/platform/osx/os_osx.h +++ b/platform/osx/os_osx.h @@ -160,6 +160,8 @@ public: virtual MainLoop *get_main_loop() const; + virtual String get_system_dir(SystemDir p_dir) const; + virtual bool can_draw() const; virtual void set_clipboard(const String &p_text); diff --git a/platform/osx/os_osx.mm b/platform/osx/os_osx.mm index f1260bc088..f502fb9a9c 100644 --- a/platform/osx/os_osx.mm +++ b/platform/osx/os_osx.mm @@ -1327,6 +1327,46 @@ MainLoop *OS_OSX::get_main_loop() const { return main_loop; } +String OS_OSX::get_system_dir(SystemDir p_dir) const { + + NSSearchPathDirectory id = 0; + + switch (p_dir) { + case SYSTEM_DIR_DESKTOP: { + id = NSDesktopDirectory; + } break; + case SYSTEM_DIR_DOCUMENTS: { + id = NSDocumentDirectory; + } break; + case SYSTEM_DIR_DOWNLOADS: { + id = NSDownloadsDirectory; + } break; + case SYSTEM_DIR_MOVIES: { + id = NSMoviesDirectory; + } break; + case SYSTEM_DIR_MUSIC: { + id = NSMusicDirectory; + } break; + case SYSTEM_DIR_PICTURES: { + id = NSPicturesDirectory; + } break; + } + + String ret; + if (id) { + + NSArray *paths = NSSearchPathForDirectoriesInDomains(id, NSUserDomainMask, YES); + if (paths && [paths count] >= 1) { + + char *utfs = strdup([[paths firstObject] UTF8String]); + ret.parse_utf8(utfs); + free(utfs); + } + } + + return ret; +} + bool OS_OSX::can_draw() const { return true; diff --git a/platform/osx/power_osx.cpp b/platform/osx/power_osx.cpp index 24591e48b1..5f3938cb91 100644 --- a/platform/osx/power_osx.cpp +++ b/platform/osx/power_osx.cpp @@ -1,5 +1,5 @@ /*************************************************************************/ -/* power_osx.cpp */ +/* power_osx.cpp */ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ |