35 |
35 |
36 -(BOOL) shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation) interfaceOrientation { |
36 -(BOOL) shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation) interfaceOrientation { |
37 return rotationManager(interfaceOrientation); |
37 return rotationManager(interfaceOrientation); |
38 } |
38 } |
39 |
39 |
40 // check if some configuration files are already set; if they are present it means that the current copy must be updated |
|
41 -(void) createNecessaryFiles { |
|
42 DLog(@"Creating necessary files"); |
|
43 NSInteger index; |
|
44 |
|
45 // SAVES - just delete and overwrite |
|
46 if ([[NSFileManager defaultManager] fileExistsAtPath:SAVES_DIRECTORY()]) |
|
47 [[NSFileManager defaultManager] removeItemAtPath:SAVES_DIRECTORY() error:NULL]; |
|
48 [[NSFileManager defaultManager] createDirectoryAtPath:SAVES_DIRECTORY() |
|
49 withIntermediateDirectories:NO |
|
50 attributes:nil |
|
51 error:NULL]; |
|
52 |
|
53 // SCREENSHOTS - just create it the first time |
|
54 if ([[NSFileManager defaultManager] fileExistsAtPath:SCREENSHOTS_DIRECTORY()] == NO) |
|
55 [[NSFileManager defaultManager] createDirectoryAtPath:SCREENSHOTS_DIRECTORY() |
|
56 withIntermediateDirectories:NO |
|
57 attributes:nil |
|
58 error:NULL]; |
|
59 |
|
60 // SETTINGS - nsuserdefaults ftw |
|
61 [CreationChamber createSettings]; |
|
62 |
|
63 // TEAMS - update exisiting teams with new format |
|
64 NSArray *teamNames = [[NSArray alloc] initWithObjects:@"Edit Me!",@"Ninjas",@"Pirates",@"Robots",nil]; |
|
65 index = 0; |
|
66 for (NSString *name in teamNames) |
|
67 [CreationChamber createTeamNamed:name ofType:index++ controlledByAI:[name isEqualToString:@"Robots"]]; |
|
68 [teamNames release]; |
|
69 |
|
70 // SCHEMES - always overwrite and delete custom ones |
|
71 if ([[NSFileManager defaultManager] fileExistsAtPath:SCHEMES_DIRECTORY()] == YES) |
|
72 [[NSFileManager defaultManager] removeItemAtPath:SCHEMES_DIRECTORY() error:NULL]; |
|
73 NSArray *schemeNames = [[NSArray alloc] initWithObjects:@"Default",@"Pro Mode",@"Shoppa",@"Clean Slate", |
|
74 @"Minefield",@"Barrel Mayhem",@"Tunnel Hogs",@"Fort Mode",@"Timeless", |
|
75 @"Thinking with Portals",@"King Mode",nil]; |
|
76 index = 0; |
|
77 for (NSString *name in schemeNames) |
|
78 [CreationChamber createSchemeNamed:name ofType:index++]; |
|
79 [schemeNames release]; |
|
80 |
|
81 // WEAPONS - always overwrite as merge is not needed (missing weaps are 0ed automatically) |
|
82 NSArray *weaponNames = [[NSArray alloc] initWithObjects:@"Default",@"Crazy",@"Pro Mode",@"Shoppa",@"Clean Slate", |
|
83 @"Minefield",@"Thinking with Portals",nil]; |
|
84 index = 0; |
|
85 for (NSString *name in weaponNames) |
|
86 [CreationChamber createWeaponNamed:name ofType:index++]; |
|
87 [weaponNames release]; |
|
88 } |
|
89 |
|
90 #pragma mark - |
40 #pragma mark - |
91 -(void) viewDidLoad { |
41 -(void) viewDidLoad { |
92 self.view.frame = [[UIScreen mainScreen] safeBounds]; |
42 self.view.frame = [[UIScreen mainScreen] safeBounds]; |
93 [super viewDidLoad]; |
43 [super viewDidLoad]; |
94 |
44 |
102 if (trackingVersion == nil || [trackingVersion isEqualToString:version] == NO) { |
52 if (trackingVersion == nil || [trackingVersion isEqualToString:version] == NO) { |
103 // remove any reminder of previous games as saves are going to be wiped out |
53 // remove any reminder of previous games as saves are going to be wiped out |
104 [userDefaults setObject:@"" forKey:@"savedGamePath"]; |
54 [userDefaults setObject:@"" forKey:@"savedGamePath"]; |
105 // update the tracking version with the new one |
55 // update the tracking version with the new one |
106 [userDefaults setObject:version forKey:@"HedgeVersion"]; |
56 [userDefaults setObject:version forKey:@"HedgeVersion"]; |
107 |
|
108 [userDefaults synchronize]; |
57 [userDefaults synchronize]; |
109 [self createNecessaryFiles]; |
58 |
|
59 [CreationChamber createFirstLaunch]; |
110 } |
60 } |
111 |
61 |
112 // prompt for restoring any previous game |
62 // prompt for restoring any previous game |
113 NSString *saveString = [userDefaults objectForKey:@"savedGamePath"]; |
63 NSString *saveString = [userDefaults objectForKey:@"savedGamePath"]; |
114 if (saveString != nil && [saveString isEqualToString:@""] == NO) { |
64 if (saveString != nil && [saveString isEqualToString:@""] == NO) { |