cocoaTouch/MainMenuViewController.m
changeset 3356 3ae3fccb439e
parent 3335 2520ee7a5484
child 3364 e5403e2bf02c
equal deleted inserted replaced
3355:dc9e61e67484 3356:3ae3fccb439e
     7 //
     7 //
     8 
     8 
     9 #import "MainMenuViewController.h"
     9 #import "MainMenuViewController.h"
    10 #import "SDL_uikitappdelegate.h"
    10 #import "SDL_uikitappdelegate.h"
    11 #import "PascalImports.h"
    11 #import "PascalImports.h"
       
    12 #import "GameConfigViewController.h"
    12 #import "SplitViewRootController.h"
    13 #import "SplitViewRootController.h"
    13 #import "CommodityFunctions.h"
    14 #import "CommodityFunctions.h"
    14 
    15 
    15 @implementation MainMenuViewController
    16 @implementation MainMenuViewController
    16 @synthesize cover, versionLabel;
    17 @synthesize cover, versionLabel;
    20 }
    21 }
    21 
    22 
    22 - (void)didReceiveMemoryWarning {
    23 - (void)didReceiveMemoryWarning {
    23 	// Releases the view if it doesn't have a superview.
    24 	// Releases the view if it doesn't have a superview.
    24 	[super didReceiveMemoryWarning];
    25 	[super didReceiveMemoryWarning];
    25 }
       
    26 
       
    27 - (void)dealloc {
       
    28     [versionLabel release];
       
    29     [cover release];
       
    30 	[super dealloc];
       
    31 }
       
    32 
       
    33 -(void) viewDidUnload {
       
    34     self.cover = nil;
       
    35     self.versionLabel = nil;
       
    36 	[super viewDidUnload];
       
    37 }
    26 }
    38 
    27 
    39 -(void) viewDidLoad {
    28 -(void) viewDidLoad {
    40     char *ver;
    29     char *ver;
    41     HW_versionInfo(NULL, &ver);
    30     HW_versionInfo(NULL, &ver);
   135 }
   124 }
   136 
   125 
   137 #pragma mark -
   126 #pragma mark -
   138 -(IBAction) switchViews:(id) sender {
   127 -(IBAction) switchViews:(id) sender {
   139     UIButton *button = (UIButton *)sender;
   128     UIButton *button = (UIButton *)sender;
   140     SplitViewRootController *splitViewController;
       
   141     UIAlertView *alert;
   129     UIAlertView *alert;
       
   130     NSString *configNibName;
   142     
   131     
   143     switch (button.tag) {
   132     switch (button.tag) {
   144         case 0:
   133         case 0:
   145             [[SDLUIKitDelegate sharedAppDelegate] startSDLgame];
   134             if (nil == gameConfigViewController) {
       
   135                 if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
       
   136                     configNibName = @"GameConfigViewController-iPad";
       
   137                 else
       
   138                     configNibName = @"GameConfigViewController-iPhone";
       
   139 
       
   140                 gameConfigViewController = [[GameConfigViewController alloc] initWithNibName:configNibName
       
   141                                                                                       bundle:nil];
       
   142 #ifdef __IPHONE_3_2
       
   143                 if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
       
   144                     gameConfigViewController.modalTransitionStyle = UIModalTransitionStylePartialCurl;
       
   145 #endif
       
   146             }
       
   147             
       
   148             [self presentModalViewController:gameConfigViewController animated:YES];    
   146             break;
   149             break;
   147         case 2:
   150         case 2:
   148             // for now this controller is just to simplify code management
   151             if (nil == splitRootViewController) {
   149             splitViewController = [[SplitViewRootController alloc] initWithNibName:nil bundle:nil];
   152                 splitRootViewController = [[SplitViewRootController alloc] initWithNibName:nil bundle:nil];
   150             splitViewController.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
   153                 splitRootViewController.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
   151             [self presentModalViewController:splitViewController animated:YES];
   154             }
       
   155             
       
   156             [self presentModalViewController:splitRootViewController animated:YES];
   152             break;
   157             break;
   153         default:
   158         default:
   154             alert = [[UIAlertView alloc] initWithTitle:@"Not Yet Implemented"
   159             alert = [[UIAlertView alloc] initWithTitle:@"Not Yet Implemented"
   155                                                message:@"Sorry, this feature is not yet implemented"
   160                                                message:@"Sorry, this feature is not yet implemented"
   156                                               delegate:nil
   161                                               delegate:nil
   160             [alert release];
   165             [alert release];
   161             break;
   166             break;
   162     }
   167     }
   163 }
   168 }
   164 
   169 
       
   170 // allows child controllers to return to the main controller
   165 -(void) dismissModalViewController {
   171 -(void) dismissModalViewController {
   166     [self dismissModalViewControllerAnimated:YES];
   172     [self dismissModalViewControllerAnimated:YES];
   167 }
   173 }
   168 
   174 
       
   175 
       
   176 -(void) viewDidUnload {
       
   177     self.cover = nil;
       
   178     self.versionLabel = nil;
       
   179     gameConfigViewController = nil;
       
   180     splitRootViewController = nil;
       
   181 	[super viewDidUnload];
       
   182 }
       
   183 
       
   184 -(void) dealloc {
       
   185     [versionLabel release];
       
   186     [cover release];
       
   187     [splitRootViewController release];
       
   188     [gameConfigViewController release];
       
   189 	[super dealloc];
       
   190 }
       
   191 
   169 @end
   192 @end