Use documents directory as game data folder
This commit is contained in:
parent
954b0b1ac3
commit
acaf8769ad
|
@ -271,6 +271,13 @@ target_sources(${EXECUTABLE_NAME} PUBLIC
|
|||
"src/sfall_config.h"
|
||||
)
|
||||
|
||||
if(IOS)
|
||||
target_sources(${EXECUTABLE_NAME} PUBLIC
|
||||
"src/platform/ios/paths.h"
|
||||
"src/platform/ios/paths.mm"
|
||||
)
|
||||
endif()
|
||||
|
||||
if(WIN32)
|
||||
target_compile_definitions(${EXECUTABLE_NAME} PUBLIC
|
||||
_CRT_SECURE_NO_WARNINGS
|
||||
|
|
|
@ -0,0 +1,6 @@
|
|||
#ifndef FALLOUT_PLATFORM_IOS_PATHS_H_
|
||||
#define FALLOUT_PLATFORM_IOS_PATHS_H_
|
||||
|
||||
const char* iOSGetDocumentsPath();
|
||||
|
||||
#endif /* FALLOUT_PLATFORM_IOS_PATHS_H_ */
|
|
@ -0,0 +1,33 @@
|
|||
#include "paths.h"
|
||||
|
||||
#include <Foundation/Foundation.h>
|
||||
|
||||
#include <SDL.h>
|
||||
|
||||
// Modelled after SDL_AndroidGetExternalStoragePath.
|
||||
const char* iOSGetDocumentsPath()
|
||||
{
|
||||
static char* s_iOSDocumentsPath = NULL;
|
||||
|
||||
if (s_iOSDocumentsPath == NULL) {
|
||||
@autoreleasepool {
|
||||
NSArray* array = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
|
||||
|
||||
if ([array count] > 0) {
|
||||
NSString* str = [array objectAtIndex:0];
|
||||
const char* base = [str fileSystemRepresentation];
|
||||
if (base) {
|
||||
const size_t len = SDL_strlen(base) + 2;
|
||||
s_iOSDocumentsPath = (char*)SDL_malloc(len);
|
||||
if (s_iOSDocumentsPath == NULL) {
|
||||
SDL_OutOfMemory();
|
||||
} else {
|
||||
SDL_snprintf(s_iOSDocumentsPath, len, "%s/", base);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return s_iOSDocumentsPath;
|
||||
}
|
|
@ -8,6 +8,10 @@
|
|||
#include "svga.h"
|
||||
#include "window_manager.h"
|
||||
|
||||
#if __APPLE__ && TARGET_OS_IOS
|
||||
#include "platform/ios/paths.h"
|
||||
#endif
|
||||
|
||||
namespace fallout {
|
||||
|
||||
#ifdef _WIN32
|
||||
|
@ -39,6 +43,7 @@ int main(int argc, char* argv[])
|
|||
#if __APPLE__ && TARGET_OS_IOS
|
||||
SDL_SetHint(SDL_HINT_MOUSE_TOUCH_EVENTS, "0");
|
||||
SDL_SetHint(SDL_HINT_TOUCH_MOUSE_EVENTS, "0");
|
||||
chdir(iOSGetDocumentsPath());
|
||||
#endif
|
||||
|
||||
#if __APPLE__ && TARGET_OS_OSX
|
||||
|
|
Loading…
Reference in New Issue