diff options
Diffstat (limited to 'platform/ios')
-rw-r--r-- | platform/ios/app_delegate.mm | 9 | ||||
-rw-r--r-- | platform/ios/export/export_plugin.cpp | 6 | ||||
-rw-r--r-- | platform/ios/godot_ios.mm | 8 | ||||
-rw-r--r-- | platform/ios/os_ios.h | 6 | ||||
-rw-r--r-- | platform/ios/os_ios.mm | 33 |
5 files changed, 25 insertions, 37 deletions
diff --git a/platform/ios/app_delegate.mm b/platform/ios/app_delegate.mm index fb183d52d4..3ebd530585 100644 --- a/platform/ios/app_delegate.mm +++ b/platform/ios/app_delegate.mm @@ -45,7 +45,7 @@ extern int gargc; extern char **gargv; -extern int ios_main(int, char **, String, String); +extern int ios_main(int, char **); extern void ios_finish(); @implementation AppDelegate @@ -66,12 +66,7 @@ static ViewController *mainViewController = nil; // Create a full-screen window self.window = [[UIWindow alloc] initWithFrame:windowBounds]; - NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); - NSString *documentsDirectory = [paths objectAtIndex:0]; - paths = NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES); - NSString *cacheDirectory = [paths objectAtIndex:0]; - - int err = ios_main(gargc, gargv, String::utf8([documentsDirectory UTF8String]), String::utf8([cacheDirectory UTF8String])); + int err = ios_main(gargc, gargv); if (err != 0) { // bail, things did not go very well for us, should probably output a message on screen with our error code... diff --git a/platform/ios/export/export_plugin.cpp b/platform/ios/export/export_plugin.cpp index 0dad4a2c1c..33f1071077 100644 --- a/platform/ios/export/export_plugin.cpp +++ b/platform/ios/export/export_plugin.cpp @@ -666,7 +666,7 @@ Error EditorExportPlatformIOS::_export_loading_screen_file(const Ref<EditorExpor Ref<Image> image; String image_path = p_dest_dir.path_join("splash@2x.png"); image.instantiate(); - Error err = image->load(custom_launch_image_2x); + Error err = ImageLoader::load_image(custom_launch_image_2x, image); if (err) { image.unref(); @@ -680,7 +680,7 @@ Error EditorExportPlatformIOS::_export_loading_screen_file(const Ref<EditorExpor image.unref(); image_path = p_dest_dir.path_join("splash@3x.png"); image.instantiate(); - err = image->load(custom_launch_image_3x); + err = ImageLoader::load_image(custom_launch_image_3x, image); if (err) { image.unref(); @@ -697,7 +697,7 @@ Error EditorExportPlatformIOS::_export_loading_screen_file(const Ref<EditorExpor if (!splash_path.is_empty()) { splash.instantiate(); - const Error err = splash->load(splash_path); + const Error err = ImageLoader::load_image(splash_path, splash); if (err) { splash.unref(); } diff --git a/platform/ios/godot_ios.mm b/platform/ios/godot_ios.mm index 5f3e786b8a..abe7c59ce2 100644 --- a/platform/ios/godot_ios.mm +++ b/platform/ios/godot_ios.mm @@ -38,10 +38,6 @@ static OS_IOS *os = nullptr; -int add_path(int, char **); -int add_cmdline(int, char **); -int ios_main(int, char **, String); - int add_path(int p_argc, char **p_args) { NSString *str = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"godot_path"]; if (!str) { @@ -74,7 +70,7 @@ int add_cmdline(int p_argc, char **p_args) { return p_argc; } -int ios_main(int argc, char **argv, String data_dir, String cache_dir) { +int ios_main(int argc, char **argv) { size_t len = strlen(argv[0]); while (len--) { @@ -95,7 +91,7 @@ int ios_main(int argc, char **argv, String data_dir, String cache_dir) { char cwd[512]; getcwd(cwd, sizeof(cwd)); printf("cwd %s\n", cwd); - os = new OS_IOS(data_dir, cache_dir); + os = new OS_IOS(); // We must override main when testing is enabled TEST_MAIN_OVERRIDE diff --git a/platform/ios/os_ios.h b/platform/ios/os_ios.h index 400040875f..3560de7486 100644 --- a/platform/ios/os_ios.h +++ b/platform/ios/os_ios.h @@ -71,9 +71,6 @@ private: virtual void finalize() override; - String user_data_dir; - String cache_dir; - bool is_focused = false; void deinitialize_modules(); @@ -81,7 +78,7 @@ private: public: static OS_IOS *get_singleton(); - OS_IOS(String p_data_dir, String p_cache_dir); + OS_IOS(); ~OS_IOS(); void initialize_modules(); @@ -106,7 +103,6 @@ public: virtual Error shell_open(String p_uri) override; - void set_user_data_dir(String p_dir); virtual String get_user_data_dir() const override; virtual String get_cache_path() const override; diff --git a/platform/ios/os_ios.mm b/platform/ios/os_ios.mm index b6b94d2f5e..9a8cfc2593 100644 --- a/platform/ios/os_ios.mm +++ b/platform/ios/os_ios.mm @@ -90,7 +90,7 @@ OS_IOS *OS_IOS::get_singleton() { return (OS_IOS *)OS::get_singleton(); } -OS_IOS::OS_IOS(String p_data_dir, String p_cache_dir) { +OS_IOS::OS_IOS() { for (int i = 0; i < ios_init_callbacks_count; ++i) { ios_init_callbacks[i](); } @@ -101,11 +101,6 @@ OS_IOS::OS_IOS(String p_data_dir, String p_cache_dir) { main_loop = nullptr; - // can't call set_data_dir from here, since it requires DirAccess - // which is initialized in initialize_core - user_data_dir = p_data_dir; - cache_dir = p_cache_dir; - Vector<Logger *> loggers; loggers.push_back(memnew(SyslogLogger)); #ifdef DEBUG_ENABLED @@ -130,8 +125,6 @@ void OS_IOS::alert(const String &p_alert, const String &p_title) { void OS_IOS::initialize_core() { OS_Unix::initialize_core(); - - set_user_data_dir(user_data_dir); } void OS_IOS::initialize() { @@ -273,18 +266,26 @@ Error OS_IOS::shell_open(String p_uri) { return OK; } -void OS_IOS::set_user_data_dir(String p_dir) { - Ref<DirAccess> da = DirAccess::open(p_dir); - user_data_dir = da->get_current_dir(); - printf("setting data dir to %s from %s\n", user_data_dir.utf8().get_data(), p_dir.utf8().get_data()); -} - String OS_IOS::get_user_data_dir() const { - return user_data_dir; + static String ret; + if (ret.is_empty()) { + NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); + if (paths && [paths count] >= 1) { + ret.parse_utf8([[paths firstObject] UTF8String]); + } + } + return ret; } String OS_IOS::get_cache_path() const { - return cache_dir; + static String ret; + if (ret.is_empty()) { + NSArray *paths = NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES); + if (paths && [paths count] >= 1) { + ret.parse_utf8([[paths firstObject] UTF8String]); + } + } + return ret; } String OS_IOS::get_locale() const { |