14 |
14 |
15 @implementation MainMenuViewController |
15 @implementation MainMenuViewController |
16 @synthesize cover, versionLabel; |
16 @synthesize cover, versionLabel; |
17 |
17 |
18 -(BOOL) shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation) interfaceOrientation { |
18 -(BOOL) shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation) interfaceOrientation { |
19 return (interfaceOrientation == UIInterfaceOrientationLandscapeRight); |
19 return rotationManager(interfaceOrientation); |
20 } |
20 } |
21 |
21 |
22 - (void)didReceiveMemoryWarning { |
22 - (void)didReceiveMemoryWarning { |
23 // Releases the view if it doesn't have a superview. |
23 // Releases the view if it doesn't have a superview. |
24 self.cover = nil; |
|
25 self.versionLabel = nil; |
|
26 [super didReceiveMemoryWarning]; |
24 [super didReceiveMemoryWarning]; |
27 } |
25 } |
28 |
26 |
29 - (void)dealloc { |
27 - (void)dealloc { |
30 [versionLabel release]; |
28 [versionLabel release]; |
49 selector:@selector(dismissModalViewController) |
48 selector:@selector(dismissModalViewController) |
50 name: @"dismissModalView" |
49 name: @"dismissModalView" |
51 object:nil]; |
50 object:nil]; |
52 |
51 |
53 // initialize some files the first time we load the game |
52 // initialize some files the first time we load the game |
54 NSString *filePath = [[SDLUIKitDelegate sharedAppDelegate] dataFilePath:@"settings.plist"]; |
53 if (!([[NSFileManager defaultManager] fileExistsAtPath:SETTINGS_FILE()])) |
55 if (!([[NSFileManager defaultManager] fileExistsAtPath:filePath])) |
|
56 [NSThread detachNewThreadSelector:@selector(checkFirstRun) toTarget:self withObject:nil]; |
54 [NSThread detachNewThreadSelector:@selector(checkFirstRun) toTarget:self withObject:nil]; |
57 |
55 |
58 [super viewDidLoad]; |
56 [super viewDidLoad]; |
59 } |
57 } |
60 |
58 |
61 // this is called to verify whether it's the first time the app is launched |
59 // this is called to verify whether it's the first time the app is launched |
62 // if it is it blocks user interaction with an alertView until files are created |
60 // if it is it blocks user interaction with an alertView until files are created |
63 -(void) checkFirstRun { |
61 -(void) checkFirstRun { |
64 NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; |
62 NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; |
65 NSLog(@"First time run, creating settings files"); |
63 NSLog(@"First time run, creating settings files at %@", SETTINGS_FILE()); |
66 |
64 |
67 // show a popup with an indicator to make the user wait |
65 // show a popup with an indicator to make the user wait |
68 UIAlertView *alert = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"Please wait",@"") |
66 UIAlertView *alert = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"Please wait",@"") |
69 message:nil |
67 message:nil |
70 delegate:nil |
68 delegate:nil |
90 [saveDict setObject:@"" forKey:@"password"]; |
88 [saveDict setObject:@"" forKey:@"password"]; |
91 [saveDict setObject:[NSNumber numberWithBool:YES] forKey:@"music"]; |
89 [saveDict setObject:[NSNumber numberWithBool:YES] forKey:@"music"]; |
92 [saveDict setObject:[NSNumber numberWithBool:YES] forKey:@"sound"]; |
90 [saveDict setObject:[NSNumber numberWithBool:YES] forKey:@"sound"]; |
93 [saveDict setObject:[NSNumber numberWithBool:NO] forKey:@"alternate"]; |
91 [saveDict setObject:[NSNumber numberWithBool:NO] forKey:@"alternate"]; |
94 |
92 |
95 NSString *filePath = [[SDLUIKitDelegate sharedAppDelegate] dataFilePath:@"settings.plist"]; |
93 [saveDict writeToFile:SETTINGS_FILE() atomically:YES]; |
96 [saveDict writeToFile:filePath atomically:YES]; |
|
97 [saveDict release]; |
94 [saveDict release]; |
98 // create other files |
|
99 |
95 |
100 // ok let the user take control |
96 // ok let the user take control |
101 [alert dismissWithClickedButtonIndex:0 animated:YES]; |
97 [alert dismissWithClickedButtonIndex:0 animated:YES]; |
102 |
98 |
103 [pool release]; |
99 [pool release]; |