20 #import "CreationChamber.h" |
20 #import "CreationChamber.h" |
21 |
21 |
22 |
22 |
23 @implementation CreationChamber |
23 @implementation CreationChamber |
24 |
24 |
|
25 #pragma mark Checking status |
|
26 +(void) createFirstLaunch { |
|
27 DLog(@"Creating necessary files"); |
|
28 NSInteger index; |
|
29 |
|
30 // SAVES - just delete and overwrite |
|
31 if ([[NSFileManager defaultManager] fileExistsAtPath:SAVES_DIRECTORY()]) |
|
32 [[NSFileManager defaultManager] removeItemAtPath:SAVES_DIRECTORY() error:NULL]; |
|
33 [[NSFileManager defaultManager] createDirectoryAtPath:SAVES_DIRECTORY() |
|
34 withIntermediateDirectories:NO |
|
35 attributes:nil |
|
36 error:NULL]; |
|
37 |
|
38 // SCREENSHOTS - just create it the first time |
|
39 if ([[NSFileManager defaultManager] fileExistsAtPath:SCREENSHOTS_DIRECTORY()] == NO) |
|
40 [[NSFileManager defaultManager] createDirectoryAtPath:SCREENSHOTS_DIRECTORY() |
|
41 withIntermediateDirectories:NO |
|
42 attributes:nil |
|
43 error:NULL]; |
|
44 |
|
45 // SETTINGS - nsuserdefaults ftw |
|
46 [self createSettings]; |
|
47 |
|
48 // TEAMS - update exisiting teams with new format |
|
49 NSArray *teamNames = [[NSArray alloc] initWithObjects:@"Edit Me!",@"Ninjas",@"Pirates",@"Robots",nil]; |
|
50 index = 0; |
|
51 for (NSString *name in teamNames) |
|
52 [self createTeamNamed:name ofType:index++ controlledByAI:[name isEqualToString:@"Robots"]]; |
|
53 [teamNames release]; |
|
54 |
|
55 // SCHEMES - always overwrite and delete custom ones |
|
56 if ([[NSFileManager defaultManager] fileExistsAtPath:SCHEMES_DIRECTORY()] == YES) |
|
57 [[NSFileManager defaultManager] removeItemAtPath:SCHEMES_DIRECTORY() error:NULL]; |
|
58 NSArray *schemeNames = [[NSArray alloc] initWithObjects:@"Default",@"Pro Mode",@"Shoppa",@"Clean Slate", |
|
59 @"Minefield",@"Barrel Mayhem",@"Tunnel Hogs",@"Fort Mode",@"Timeless", |
|
60 @"Thinking with Portals",@"King Mode",nil]; |
|
61 index = 0; |
|
62 for (NSString *name in schemeNames) |
|
63 [self createSchemeNamed:name ofType:index++]; |
|
64 [schemeNames release]; |
|
65 |
|
66 // WEAPONS - always overwrite as merge is not needed (missing weaps are 0ed automatically) |
|
67 NSArray *weaponNames = [[NSArray alloc] initWithObjects:@"Default",@"Crazy",@"Pro Mode",@"Shoppa",@"Clean Slate", |
|
68 @"Minefield",@"Thinking with Portals",nil]; |
|
69 index = 0; |
|
70 for (NSString *name in weaponNames) |
|
71 [self createWeaponNamed:name ofType:index++]; |
|
72 [weaponNames release]; |
|
73 } |
|
74 |
25 #pragma mark Settings |
75 #pragma mark Settings |
26 +(void) createSettings { |
76 +(void) createSettings { |
27 NSUserDefaults *settings = [NSUserDefaults standardUserDefaults]; |
77 NSUserDefaults *settings = [NSUserDefaults standardUserDefaults]; |
28 [settings setObject:[NSNumber numberWithBool:NO] forKey:@"alternate"]; |
78 [settings setObject:[NSNumber numberWithBool:NO] forKey:@"alternate"]; |
29 [settings setObject:[NSNumber numberWithBool:YES] forKey:@"music"]; |
79 [settings setObject:[NSNumber numberWithBool:YES] forKey:@"music"]; |
39 [settings synchronize]; |
89 [settings synchronize]; |
40 } |
90 } |
41 |
91 |
42 #pragma mark Teams |
92 #pragma mark Teams |
43 +(void) createTeamNamed:(NSString *)nameWithoutExt { |
93 +(void) createTeamNamed:(NSString *)nameWithoutExt { |
44 [CreationChamber createTeamNamed:nameWithoutExt ofType:0 controlledByAI:NO]; |
94 [self createTeamNamed:nameWithoutExt ofType:0 controlledByAI:NO]; |
45 } |
95 } |
46 |
96 |
47 +(void) createTeamNamed:(NSString *)nameWithoutExt ofType:(NSInteger) type { |
97 +(void) createTeamNamed:(NSString *)nameWithoutExt ofType:(NSInteger) type { |
48 [CreationChamber createTeamNamed:nameWithoutExt ofType:type controlledByAI:NO]; |
98 [self createTeamNamed:nameWithoutExt ofType:type controlledByAI:NO]; |
49 } |
99 } |
50 |
100 |
51 +(void) createTeamNamed:(NSString *)nameWithoutExt ofType:(NSInteger) type controlledByAI:(BOOL) shouldAITakeOver { |
101 +(void) createTeamNamed:(NSString *)nameWithoutExt ofType:(NSInteger) type controlledByAI:(BOOL) shouldAITakeOver { |
52 NSString *teamsDirectory = TEAMS_DIRECTORY(); |
102 NSString *teamsDirectory = TEAMS_DIRECTORY(); |
53 |
103 |