cocoaTouch/MainMenuViewController.m
changeset 2743 39d097ac2276
parent 2740 03df0573a9fd
child 2799 558b29bf00c5
equal deleted inserted replaced
2742:21c0d2e69753 2743:39d097ac2276
     9 #import "MainMenuViewController.h"
     9 #import "MainMenuViewController.h"
    10 #import "SDL_uikitappdelegate.h"
    10 #import "SDL_uikitappdelegate.h"
    11 
    11 
    12 @implementation MainMenuViewController
    12 @implementation MainMenuViewController
    13 
    13 
    14 @synthesize versionLabel, settingsViewController;
    14 @synthesize versionLabel, settingsViewController, mainView;
    15 
    15 
    16 /*
    16 /*
    17  // The designated initializer.  Override if you create the controller programmatically and want to perform customization that is not appropriate for viewDidLoad.
    17  // The designated initializer.  Override if you create the controller programmatically and want to perform customization that is not appropriate for viewDidLoad.
    18 - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
    18 - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
    19     if (self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]) {
    19     if (self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]) {
    56 	[super dealloc];
    56 	[super dealloc];
    57 }
    57 }
    58 
    58 
    59 // disable the buttons when to prevent launching twice the game
    59 // disable the buttons when to prevent launching twice the game
    60 -(void) viewWillDisappear:(BOOL)animated {
    60 -(void) viewWillDisappear:(BOOL)animated {
    61 	self.view.userInteractionEnabled = NO;
    61 	self.mainView.userInteractionEnabled = NO;
    62 	[super viewWillDisappear:animated];
    62 	[super viewWillDisappear:animated];
    63 }
    63 }
    64 
    64 
    65 -(void) viewWillAppear:(BOOL)animated {
    65 -(void) viewDidAppear:(BOOL)animated {
    66 	self.view.userInteractionEnabled = YES;
    66 	self.mainView.userInteractionEnabled = YES;
    67 	[super viewWillAppear:animated];
    67 	[super viewDidAppear:animated];
    68 }
    68 }
    69 
    69 
    70 #pragma mark -
    70 #pragma mark -
    71 #pragma mark Action buttons
    71 #pragma mark Action buttons
    72 -(IBAction) startPlaying {
    72 -(IBAction) startPlaying {
    90 		// view not created
    90 		// view not created
    91 		if (nil == self.settingsViewController) {
    91 		if (nil == self.settingsViewController) {
    92 			SettingsViewController *controller = [[SettingsViewController alloc] initWithNibName:@"SettingsViewController"
    92 			SettingsViewController *controller = [[SettingsViewController alloc] initWithNibName:@"SettingsViewController"
    93 												      bundle:nil];
    93 												      bundle:nil];
    94 			self.settingsViewController = controller;
    94 			self.settingsViewController = controller;
       
    95 			self.settingsViewController.parentView = self.mainView;
    95 			[controller release];
    96 			[controller release];
    96 		}
    97 		}
    97 		self.settingsViewController.view.frame = CGRectMake(0, -480, 480, 320);
    98 		self.settingsViewController.view.frame = CGRectMake(0, -320, 480, 320);
    98 
    99 
    99 		[UIView beginAnimations:@"View Switch" context:NULL];
   100 		[UIView beginAnimations:@"View Switch" context:NULL];
   100 		[UIView setAnimationDuration:3];
   101 		[UIView setAnimationDuration:3];
   101 		[UIView setAnimationDuration:UIViewAnimationCurveEaseOut];
   102 		[UIView setAnimationDuration:UIViewAnimationCurveEaseOut];
   102 		self.settingsViewController.view.frame = CGRectMake(0, 0, 480, 320);
   103 		self.settingsViewController.view.frame = CGRectMake(0, 0, 480, 320);
       
   104 		self.mainView.frame = CGRectMake(0, 320, 480, 320);
   103 		
   105 		
   104 		// we have the new controller, let's switch
       
   105 		[self.view addSubview:settingsViewController.view];
   106 		[self.view addSubview:settingsViewController.view];
   106 		[UIView commitAnimations];
   107 		[UIView commitAnimations];
   107 	}
   108 	}
   108 
   109 
   109 }
   110 }