Modified system path defaults to utilize the User vs Res architecture. After reading some comments of the forum I realized I had implemented this all according to 0.16's design and not the new split architecture. All 'core_' zip files are now placed under 'Res' as before, but any other zip file will be put under the 'User' directory
This commit is contained in:
@@ -107,11 +107,11 @@ JFileSystem::JFileSystem(const string & _userPath, const string & _systemPath)
|
|||||||
|
|
||||||
#ifdef IOS
|
#ifdef IOS
|
||||||
NSArray *paths = NSSearchPathForDirectoriesInDomains( NSDocumentDirectory, NSUserDomainMask, YES);
|
NSArray *paths = NSSearchPathForDirectoriesInDomains( NSDocumentDirectory, NSUserDomainMask, YES);
|
||||||
NSString *documentsDirectory = [[paths objectAtIndex:0] stringByAppendingString: @"/Res"];
|
NSString *documentsDirectory = [paths objectAtIndex:0];
|
||||||
|
|
||||||
userPath = [documentsDirectory cStringUsingEncoding:1];
|
userPath = [[documentsDirectory stringByAppendingString: @"/User/"] cStringUsingEncoding:1];
|
||||||
userPath += "/";
|
systemPath = [[documentsDirectory stringByAppendingString: @"/Res/"] cStringUsingEncoding:1];
|
||||||
systemPath = "";
|
|
||||||
#elif defined (ANDROID)
|
#elif defined (ANDROID)
|
||||||
userPath = "/sdcard/Wagic/Res/";
|
userPath = "/sdcard/Wagic/Res/";
|
||||||
systemPath = "";
|
systemPath = "";
|
||||||
|
|||||||
@@ -22,7 +22,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
check for any zip files dropped into the documents directory. If so move them into the "Res" directory.
|
check for any zip files dropped into the documents directory. If so move them into the "User" directory.
|
||||||
check for a "core" zip file in the Res directory. If it exists, then return YES. Otherwise, return NO.
|
check for a "core" zip file in the Res directory. If it exists, then return YES. Otherwise, return NO.
|
||||||
*/
|
*/
|
||||||
- (BOOL) hasResourceFiles
|
- (BOOL) hasResourceFiles
|
||||||
@@ -32,18 +32,26 @@
|
|||||||
NSArray *paths = NSSearchPathForDirectoriesInDomains( NSDocumentDirectory, NSUserDomainMask, YES);
|
NSArray *paths = NSSearchPathForDirectoriesInDomains( NSDocumentDirectory, NSUserDomainMask, YES);
|
||||||
NSString *docsPath = [paths objectAtIndex: 0];
|
NSString *docsPath = [paths objectAtIndex: 0];
|
||||||
NSArray *docsPathContents = [[NSFileManager defaultManager] contentsOfDirectoryAtPath: docsPath error:nil];
|
NSArray *docsPathContents = [[NSFileManager defaultManager] contentsOfDirectoryAtPath: docsPath error:nil];
|
||||||
NSArray *resourceZipFiles = [docsPathContents filteredArrayUsingPredicate:[NSPredicate predicateWithFormat:@"self ENDSWITH '.zip'"]];
|
NSCompoundPredicate *compoundPredicate = [[NSCompoundPredicate alloc] initWithType:NSAndPredicateType subpredicates: [NSArray arrayWithObjects: [NSPredicate predicateWithFormat:@"self ENDSWITH '.zip'"], [NSPredicate predicateWithFormat:@"NOT (self BEGINSWITH 'core_')"], nil]];
|
||||||
|
|
||||||
|
NSArray *resourceZipFiles = [docsPathContents filteredArrayUsingPredicate: compoundPredicate];
|
||||||
|
NSString *userPath = [NSString stringWithFormat: @"%@/User", docsPath];
|
||||||
NSString *resPath = [NSString stringWithFormat: @"%@/Res", docsPath];
|
NSString *resPath = [NSString stringWithFormat: @"%@/Res", docsPath];
|
||||||
NSError *error = nil;
|
NSError *error = nil;
|
||||||
|
|
||||||
|
if ( ([resourceZipFiles count] > 0 ) && ![fileManager fileExistsAtPath: userPath] )
|
||||||
|
[fileManager createDirectoryAtPath: userPath withIntermediateDirectories: YES attributes:nil error:nil ];
|
||||||
|
|
||||||
for (NSString *zipFile in resourceZipFiles)
|
for (NSString *zipFile in resourceZipFiles)
|
||||||
{
|
{
|
||||||
NSString *oldPath = [NSString stringWithFormat: @"%@/%@", docsPath, zipFile];
|
NSString *oldPath = [NSString stringWithFormat: @"%@/%@", docsPath, zipFile];
|
||||||
NSString *newPath = [NSString stringWithFormat: @"%@/%@", resPath, zipFile];
|
NSString *newPath = [NSString stringWithFormat: @"%@/%@", userPath, zipFile];
|
||||||
|
|
||||||
[fileManager moveItemAtPath: oldPath toPath:newPath error: &error];
|
[fileManager moveItemAtPath: oldPath toPath:newPath error: &error];
|
||||||
if ( error != nil )
|
if ( error != nil )
|
||||||
{
|
{
|
||||||
NSLog(@"Error happened while trying to move %@ to %@: \n%@", oldPath, newPath, [error localizedDescription]);
|
NSLog(@"Error happened while trying to move %@ to %@: \n%@", oldPath, newPath, [error localizedDescription]);
|
||||||
|
error = nil;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ static NSString *kDownloadFileName = @"core_017_iOS.zip";
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// No longer needed.
|
||||||
- (void) unpackageResources
|
- (void) unpackageResources
|
||||||
{
|
{
|
||||||
[self.downloadMessageStatus setText: @"Installing Game Resource Files"];
|
[self.downloadMessageStatus setText: @"Installing Game Resource Files"];
|
||||||
@@ -93,12 +93,16 @@ static NSString *kDownloadFileName = @"core_017_iOS.zip";
|
|||||||
{
|
{
|
||||||
NSArray *paths = NSSearchPathForDirectoriesInDomains( NSDocumentDirectory,
|
NSArray *paths = NSSearchPathForDirectoriesInDomains( NSDocumentDirectory,
|
||||||
NSUserDomainMask, YES);
|
NSUserDomainMask, YES);
|
||||||
NSString *userResourceDirectory = [[paths objectAtIndex:0] stringByAppendingString: @"/Res"];
|
NSString *systemResourceDirectory = [[paths objectAtIndex:0] stringByAppendingString: @"/Res"];
|
||||||
NSString *downloadFilePath = [userResourceDirectory stringByAppendingString: [NSString stringWithFormat: @"/%@", kDownloadFileName]];
|
NSString *userResourceDirectory = [[paths objectAtIndex: 0] stringByAppendingString: @"/User"];
|
||||||
|
NSString *downloadFilePath = [systemResourceDirectory stringByAppendingString: [NSString stringWithFormat: @"/%@", kDownloadFileName]];
|
||||||
NSError *error = nil;
|
NSError *error = nil;
|
||||||
// make sure Res directory exists
|
// make sure Res directory exists
|
||||||
if ( ![[NSFileManager defaultManager] fileExistsAtPath: userResourceDirectory] )
|
if ( ![[NSFileManager defaultManager] fileExistsAtPath: systemResourceDirectory] )
|
||||||
[[NSFileManager defaultManager] createDirectoryAtPath:userResourceDirectory withIntermediateDirectories: YES attributes:nil error: &error];
|
[[NSFileManager defaultManager] createDirectoryAtPath:systemResourceDirectory withIntermediateDirectories: YES attributes:nil error: &error];
|
||||||
|
// make sure the User directory exists as well
|
||||||
|
if ( ![[NSFileManager defaultManager] fileExistsAtPath: userResourceDirectory] )
|
||||||
|
[[NSFileManager defaultManager] createDirectoryAtPath: userResourceDirectory withIntermediateDirectories: YES attributes:nil error: &error];
|
||||||
|
|
||||||
// if an error occurred while creating the directory, game can't really run so do something
|
// if an error occurred while creating the directory, game can't really run so do something
|
||||||
// TODO: throw out a notification and deal with error
|
// TODO: throw out a notification and deal with error
|
||||||
@@ -123,7 +127,7 @@ static NSString *kDownloadFileName = @"core_017_iOS.zip";
|
|||||||
[request setAllowCompressedResponse: YES];
|
[request setAllowCompressedResponse: YES];
|
||||||
|
|
||||||
[request setCompletionBlock:^{
|
[request setCompletionBlock:^{
|
||||||
[self unpackageResources];
|
// [self unpackageResources];
|
||||||
wagicAppDelegate *appDelegate = (wagicAppDelegate *)[[UIApplication sharedApplication] delegate];
|
wagicAppDelegate *appDelegate = (wagicAppDelegate *)[[UIApplication sharedApplication] delegate];
|
||||||
NSNotificationCenter *dnc = [NSNotificationCenter defaultCenter];
|
NSNotificationCenter *dnc = [NSNotificationCenter defaultCenter];
|
||||||
[dnc postNotificationName:@"readyToStartGame" object: appDelegate];
|
[dnc postNotificationName:@"readyToStartGame" object: appDelegate];
|
||||||
|
|||||||
@@ -2464,6 +2464,7 @@
|
|||||||
"$(ARCHS_STANDARD_32_BIT)",
|
"$(ARCHS_STANDARD_32_BIT)",
|
||||||
);
|
);
|
||||||
CODE_SIGN_IDENTITY = "iPhone Distribution";
|
CODE_SIGN_IDENTITY = "iPhone Distribution";
|
||||||
|
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Distribution";
|
||||||
COPY_PHASE_STRIP = YES;
|
COPY_PHASE_STRIP = YES;
|
||||||
GCC_PRECOMPILE_PREFIX_HEADER = YES;
|
GCC_PRECOMPILE_PREFIX_HEADER = YES;
|
||||||
GCC_PREFIX_HEADER = wagic_Prefix.pch;
|
GCC_PREFIX_HEADER = wagic_Prefix.pch;
|
||||||
@@ -2494,6 +2495,7 @@
|
|||||||
);
|
);
|
||||||
PRODUCT_NAME = "wagic copy";
|
PRODUCT_NAME = "wagic copy";
|
||||||
PROVISIONING_PROFILE = "";
|
PROVISIONING_PROFILE = "";
|
||||||
|
"PROVISIONING_PROFILE[sdk=iphoneos*]" = "";
|
||||||
SDKROOT = iphoneos;
|
SDKROOT = iphoneos;
|
||||||
VALIDATE_PRODUCT = YES;
|
VALIDATE_PRODUCT = YES;
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user