project_files/HedgewarsMobile/Classes/MainMenuViewController.m
changeset 3701 8c449776ebe6
parent 3697 d5b30d6373fc
child 3703 12d17c6e8855
equal deleted inserted replaced
3699:e5e2cbc90891 3701:8c449776ebe6
    13 #import "SplitViewRootController.h"
    13 #import "SplitViewRootController.h"
    14 #import "CommodityFunctions.h"
    14 #import "CommodityFunctions.h"
    15 #import "SDL_mixer.h"
    15 #import "SDL_mixer.h"
    16 
    16 
    17 @implementation MainMenuViewController
    17 @implementation MainMenuViewController
    18 @synthesize versionLabel;
    18 @synthesize versionLabel, gameConfigViewController, settingsViewController;
    19 
    19 
    20 -(BOOL) shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation) interfaceOrientation {
    20 -(BOOL) shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation) interfaceOrientation {
    21     return rotationManager(interfaceOrientation);
    21     return rotationManager(interfaceOrientation);
    22 }
    22 }
    23 
    23 
    24 - (void)didReceiveMemoryWarning {
    24 - (void)didReceiveMemoryWarning {
    25     // Releases the view if it doesn't have a superview.
    25     // Releases the view if it doesn't have a superview.
    26     [super didReceiveMemoryWarning];
    26     [super didReceiveMemoryWarning];
    27     if (settingsViewController.view.superview == nil)
    27     if (self.settingsViewController.view.superview == nil)
    28         settingsViewController = nil;
    28         self.settingsViewController = nil;
    29     if (gameConfigViewController.view.superview == nil)
    29     if (self.gameConfigViewController.view.superview == nil)
    30         gameConfigViewController = nil;
    30         self.gameConfigViewController = nil;
    31     MSG_MEMCLEAN();
    31     MSG_MEMCLEAN();
    32 }
    32 }
    33 
    33 
    34 // using a different thread for audio 'cos it's slow
    34 // using a different thread for audio 'cos it's slow
    35 -(void) initAudioThread {
    35 -(void) initAudioThread {
   116     UIAlertView *alert;
   116     UIAlertView *alert;
   117     NSString *debugStr;
   117     NSString *debugStr;
   118 
   118 
   119     switch (button.tag) {
   119     switch (button.tag) {
   120         case 0:
   120         case 0:
   121             gameConfigViewController = [[GameConfigViewController alloc] initWithNibName:@"GameConfigViewController" bundle:nil];
   121             if (nil == self.gameConfigViewController) {
       
   122                 GameConfigViewController *gcvc = [[GameConfigViewController alloc] initWithNibName:@"GameConfigViewController" bundle:nil];
       
   123                 self.gameConfigViewController = gcvc;
       
   124                 [gcvc release];
       
   125             }
   122 
   126 
   123             [self presentModalViewController:gameConfigViewController animated:YES];
   127             [self presentModalViewController:self.gameConfigViewController animated:YES];
   124             break;
   128             break;
   125         case 2:
   129         case 2:
   126             if (nil == settingsViewController) {
   130             if (nil == self.settingsViewController) {
   127                 settingsViewController = [[SplitViewRootController alloc] initWithNibName:nil bundle:nil];
   131                 SplitViewRootController *svrc = [[SplitViewRootController alloc] initWithNibName:nil bundle:nil];
   128                 settingsViewController.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
   132                 svrc.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
       
   133                 self.settingsViewController = svrc;
       
   134                 [svrc release];
   129             }
   135             }
   130 
   136 
   131             [self presentModalViewController:settingsViewController animated:YES];
   137             [self presentModalViewController:self.settingsViewController animated:YES];
   132             break;
   138             break;
   133         case 3:
   139         case 3:
   134             debugStr = [[NSString alloc] initWithContentsOfFile:DEBUG_FILE()];
   140             debugStr = [[NSString alloc] initWithContentsOfFile:DEBUG_FILE()];
   135             UITextView *scroll = [[UITextView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.height, self.view.frame.size.width)];
   141             UITextView *scroll = [[UITextView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.height, self.view.frame.size.width)];
   136             scroll.text = debugStr;
   142             scroll.text = debugStr;
   160 // allows child controllers to return to the main controller
   166 // allows child controllers to return to the main controller
   161 -(void) dismissModalViewController {
   167 -(void) dismissModalViewController {
   162     [self dismissModalViewControllerAnimated:YES];
   168     [self dismissModalViewControllerAnimated:YES];
   163 }
   169 }
   164 
   170 
   165 
       
   166 -(void) viewDidUnload {
   171 -(void) viewDidUnload {
   167     self.versionLabel = nil;
   172     self.versionLabel = nil;
   168     gameConfigViewController = nil;
   173     self.gameConfigViewController = nil;
   169     settingsViewController = nil;
   174     self.settingsViewController = nil;
   170     MSG_DIDUNLOAD();
   175     MSG_DIDUNLOAD();
   171     [super viewDidUnload];
   176     [super viewDidUnload];
   172 }
   177 }
   173 
   178 
   174 -(void) dealloc {
   179 -(void) dealloc {