cocoaTouch/MainMenuViewController.m
changeset 3335 2520ee7a5484
parent 3332 3c90a923f156
child 3356 3ae3fccb439e
equal deleted inserted replaced
3334:f94a52a763d4 3335:2520ee7a5484
    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];
    32 	[super dealloc];
    30 	[super dealloc];
    33 }
    31 }
    34 
    32 
    35 -(void) viewDidUnload {
    33 -(void) viewDidUnload {
    36     self.cover = nil;
    34     self.cover = nil;
       
    35     self.versionLabel = nil;
    37 	[super viewDidUnload];
    36 	[super viewDidUnload];
    38 }
    37 }
    39 
    38 
    40 -(void) viewDidLoad {
    39 -(void) viewDidLoad {
    41     char *ver;
    40     char *ver;
    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];