iOS: Fix not storing data in application support directory, fix texture pack only loading on subsequent runs and not first

Previously the iOS app wrote to the bundle directory, which while that worked on the simulator, wouldn't work on an actual device since the directory was readonly
This commit is contained in:
UnknownShadow200 2022-05-21 22:46:04 +10:00
parent 8de57e42e9
commit dac033e00b
3 changed files with 10 additions and 21 deletions

View File

@ -417,7 +417,7 @@ static void Game_Load(void) {
}
Game_DefaultZipMissing = false;
TexturePack_ExtractCurrent(false);
TexturePack_ExtractCurrent(true);
if (Game_DefaultZipMissing) {
Window_ShowDialog("Missing file",
"default.zip is missing, try downloading resources first.\n\nThe game will still run, but without any textures");

View File

@ -32,6 +32,8 @@ void Gfx_Create(void) {
glGetIntegerv(GL_MAX_TEXTURE_SIZE, &Gfx.MaxTexWidth);
Gfx.MaxTexHeight = Gfx.MaxTexWidth;
Gfx.Created = true;
/* necessary for android which "loses" context when window is closed */
Gfx.LostContext = false;
GLBackend_Init();
Gfx_RestoreState();

View File

@ -122,6 +122,7 @@ static cc_bool kb_active;
Platform_LogConst("APPEAR");
[UIView animateWithDuration:interval animations:^{
[view_handle layoutIfNeeded];
[controller viewWillTransitionToSize:view_handle.frame.size withTransitionCoordinator:nil];
}];
}
@ -509,28 +510,14 @@ int Platform_GetCommandLineArgs(int argc, STRING_REF char** argv, cc_string* arg
}
cc_result Platform_SetDefaultCurrentDirectory(int argc, char **argv) {
// TODO this is the API should actually be using.. eventually
/*NSArray* array = NSSearchPathForDirectoriesInDomains(NSApplicationSupportDirectory, NSUserDomainMask, YES);
if ([array count] <= 0) return ERR_NOT_SUPPORTED;
// https://developer.apple.com/library/archive/documentation/FileManagement/Conceptual/FileSystemProgrammingGuide/FileSystemOverview/FileSystemOverview.html
NSArray* array = NSSearchPathForDirectoriesInDomains(NSApplicationSupportDirectory, NSUserDomainMask, YES);
if (array.count <= 0) return ERR_NOT_SUPPORTED;
NSString* str = [array objectAtIndex:0];
const char* name = [str fileSystemRepresentation];
return chdir(name) == -1 ? errno : 0;*/
NSString* str = [array objectAtIndex:0];
const char* path = [str fileSystemRepresentation];
char path[NATIVE_STR_LEN + 1] = { 0 };
uint32_t size = NATIVE_STR_LEN;
if (_NSGetExecutablePath(path, &size)) return ERR_INVALID_ARGUMENT;
// despite what you'd assume, size is NOT changed to length of path
int len = String_CalcLen(path, NATIVE_STR_LEN);
// get rid of filename at end of directory
for (int i = len - 1; i >= 0; i--, len--)
{
if (path[i] == '/') break;
}
path[len] = '\0';
mkdir(path, S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH);
return chdir(path) == -1 ? errno : 0;
}