project_files/HedgewarsMobile/Classes/MainMenuViewController.m
changeset 3893 568bfd083465
parent 3891 f8f0d0ceb19c
child 3903 db01c37494af
equal deleted inserted replaced
3891:f8f0d0ceb19c 3893:568bfd083465
    25 #import "SDL_mixer.h"
    25 #import "SDL_mixer.h"
    26 #import "PascalImports.h"
    26 #import "PascalImports.h"
    27 #import "GameConfigViewController.h"
    27 #import "GameConfigViewController.h"
    28 #import "SplitViewRootController.h"
    28 #import "SplitViewRootController.h"
    29 #import "AboutViewController.h"
    29 #import "AboutViewController.h"
       
    30 #import "SavedGamesViewController.h"
    30 
    31 
    31 @implementation MainMenuViewController
    32 @implementation MainMenuViewController
    32 @synthesize versionLabel, gameConfigViewController, settingsViewController, aboutViewController;
    33 @synthesize versionLabel, gameConfigViewController, settingsViewController, aboutViewController, savedGamesViewController;
    33 
    34 
    34 -(BOOL) shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation) interfaceOrientation {
    35 -(BOOL) shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation) interfaceOrientation {
    35     return rotationManager(interfaceOrientation);
    36     return rotationManager(interfaceOrientation);
    36 }
    37 }
    37 
    38 
   228 
   229 
   229 #pragma mark -
   230 #pragma mark -
   230 -(IBAction) switchViews:(id) sender {
   231 -(IBAction) switchViews:(id) sender {
   231     UIButton *button = (UIButton *)sender;
   232     UIButton *button = (UIButton *)sender;
   232     UIAlertView *alert;
   233     UIAlertView *alert;
   233     NSString *xib;
   234     NSString *xib = nil;
       
   235     NSString *debugStr = nil;
   234 
   236 
   235     playSound(@"clickSound");
   237     playSound(@"clickSound");
   236     switch (button.tag) {
   238     switch (button.tag) {
   237         case 0:
   239         case 0:
   238             if (nil == self.gameConfigViewController) {
   240             if (nil == self.gameConfigViewController) {
   258             }
   260             }
   259 
   261 
   260             [self presentModalViewController:self.settingsViewController animated:YES];
   262             [self presentModalViewController:self.settingsViewController animated:YES];
   261             break;
   263             break;
   262         case 3:
   264         case 3:
   263             if (nil == self.aboutViewController) {
   265 #ifdef DEBUG
   264                 AboutViewController *about = [[AboutViewController alloc] initWithNibName:@"AboutViewController" bundle:nil];
       
   265                 about.modalTransitionStyle = UIModalTransitionStyleCoverVertical;
       
   266                 about.modalPresentationStyle = UIModalPresentationFormSheet;
       
   267                 self.aboutViewController = about;
       
   268                 [about release];
       
   269             }
       
   270             
       
   271             [self presentModalViewController:self.aboutViewController animated:YES];
       
   272             /*
       
   273             debugStr = [[NSString alloc] initWithContentsOfFile:DEBUG_FILE()];
   266             debugStr = [[NSString alloc] initWithContentsOfFile:DEBUG_FILE()];
   274             UITextView *scroll = [[UITextView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.height, self.view.frame.size.width)];
   267             UITextView *scroll = [[UITextView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.height, self.view.frame.size.width)];
   275             scroll.text = debugStr;
   268             scroll.text = debugStr;
   276             [debugStr release];
   269             [debugStr release];
   277             scroll.editable = NO;
   270             scroll.editable = NO;
   281             btn.backgroundColor = [UIColor blackColor];
   274             btn.backgroundColor = [UIColor blackColor];
   282             btn.frame = CGRectMake(self.view.frame.size.height-70, 0, 70, 70);
   275             btn.frame = CGRectMake(self.view.frame.size.height-70, 0, 70, 70);
   283             [scroll addSubview:btn];
   276             [scroll addSubview:btn];
   284             [self.view addSubview:scroll];
   277             [self.view addSubview:scroll];
   285             [scroll release];
   278             [scroll release];
   286             */
   279 #else
       
   280             if (nil == self.aboutViewController) {
       
   281                 AboutViewController *about = [[AboutViewController alloc] initWithNibName:@"AboutViewController" bundle:nil];
       
   282                 about.modalTransitionStyle = UIModalTransitionStyleCoverVertical;
       
   283                 about.modalPresentationStyle = UIModalPresentationFormSheet;
       
   284                 self.aboutViewController = about;
       
   285                 [about release];
       
   286             }
       
   287             
       
   288             [self presentModalViewController:self.aboutViewController animated:YES];
       
   289 #endif
       
   290             break;
       
   291         case 4:
       
   292             if (nil == self.savedGamesViewController) {
       
   293                 SavedGamesViewController *savedgames = [[SavedGamesViewController alloc] initWithNibName:@"SavedGamesViewController" bundle:nil];
       
   294                 savedgames.modalTransitionStyle = UIModalTransitionStyleCoverVertical;
       
   295                 savedgames.modalPresentationStyle = UIModalPresentationFormSheet;
       
   296                 self.savedGamesViewController = savedgames;
       
   297                 [savedgames release];
       
   298             }
       
   299             
       
   300             [self presentModalViewController:self.savedGamesViewController animated:YES];
   287             break;
   301             break;
   288         default:
   302         default:
   289             alert = [[UIAlertView alloc] initWithTitle:@"Not Yet Implemented"
   303             alert = [[UIAlertView alloc] initWithTitle:@"Not Yet Implemented"
   290                                                message:@"Sorry, this feature is not yet implemented"
   304                                                message:@"Sorry, this feature is not yet implemented"
   291                                               delegate:nil
   305                                               delegate:nil
   306     [[NSNotificationCenter defaultCenter] removeObserver:self];
   320     [[NSNotificationCenter defaultCenter] removeObserver:self];
   307     self.versionLabel = nil;
   321     self.versionLabel = nil;
   308     self.gameConfigViewController = nil;
   322     self.gameConfigViewController = nil;
   309     self.settingsViewController = nil;
   323     self.settingsViewController = nil;
   310     self.aboutViewController = nil;
   324     self.aboutViewController = nil;
       
   325     self.savedGamesViewController = nil;
   311     MSG_DIDUNLOAD();
   326     MSG_DIDUNLOAD();
   312     [super viewDidUnload];
   327     [super viewDidUnload];
   313 }
   328 }
   314 
   329 
   315 -(void) dealloc {
   330 -(void) dealloc {
   316     [versionLabel release];
   331     [versionLabel release];
   317     [settingsViewController release];
   332     [settingsViewController release];
   318     [gameConfigViewController release];
   333     [gameConfigViewController release];
   319     [aboutViewController release];
   334     [aboutViewController release];
       
   335     [savedGamesViewController release];
   320     [super dealloc];
   336     [super dealloc];
   321 }
   337 }
   322 
   338 
   323 @end
   339 @end