project_files/HedgewarsMobile/Classes/MainMenuViewController.m
branchios-revival
changeset 11217 e68b3e392091
parent 11181 a515139fc8de
child 11225 eb600ab27fb9
equal deleted inserted replaced
11216:76fd61a88c1e 11217:e68b3e392091
    18 
    18 
    19 
    19 
    20 #import "MainMenuViewController.h"
    20 #import "MainMenuViewController.h"
    21 #import <QuartzCore/QuartzCore.h>
    21 #import <QuartzCore/QuartzCore.h>
    22 #import "GameConfigViewController.h"
    22 #import "GameConfigViewController.h"
    23 #import "SettingsContainerViewController.h"
    23 #import "MGSplitViewController.h"
       
    24 #import "SettingsBaseViewController.h"
    24 #import "AboutViewController.h"
    25 #import "AboutViewController.h"
    25 #import "SavedGamesViewController.h"
    26 #import "SavedGamesViewController.h"
    26 #import "RestoreViewController.h"
    27 #import "RestoreViewController.h"
    27 #import "MissionTrainingViewController.h"
    28 #import "MissionTrainingViewController.h"
    28 #import "Appirater.h"
    29 #import "Appirater.h"
    29 #import "ServerProtocolNetwork.h"
    30 #import "ServerProtocolNetwork.h"
    30 #import "GameInterfaceBridge.h"
    31 #import "GameInterfaceBridge.h"
       
    32 
       
    33 #import "SettingsBaseViewController.h"
       
    34 #import "GeneralSettingsViewController.h"
       
    35 #import "TeamSettingsViewController.h"
       
    36 #import "WeaponSettingsViewController.h"
       
    37 #import "SchemeSettingsViewController.h"
       
    38 #import "SupportViewController.h"
    31 
    39 
    32 #ifdef DEBUG
    40 #ifdef DEBUG
    33 #import "GameLogViewController.h"
    41 #import "GameLogViewController.h"
    34 #endif
    42 #endif
    35 
    43 
   118 
   126 
   119             [self presentViewController:gcvc animated:YES completion:nil];
   127             [self presentViewController:gcvc animated:YES completion:nil];
   120             [gcvc release];
   128             [gcvc release];
   121             break;
   129             break;
   122         case 2:
   130         case 2:
   123             {
   131             if (IS_IPAD())
   124                 SettingsContainerViewController *svrc = [[SettingsContainerViewController alloc] initWithNibName:nil bundle:nil];
   132             {
   125                 svrc.modalTransitionStyle = UIModalTransitionStyleCoverVertical;
   133                 // the contents on the right of the splitview, setting targetController to nil to avoid creating the table
   126 
   134                 SettingsBaseViewController *rightController = [[SettingsBaseViewController alloc] init];
   127                 [self presentViewController:svrc animated:YES completion:nil];
   135                 rightController.targetController = nil;
   128                 [svrc release];
   136                 UINavigationController *rightNavController = [[UINavigationController alloc] initWithRootViewController:rightController];
       
   137                 [rightController release];
       
   138                 
       
   139                 // the contens on the left of the splitview, setting targetController that will receive push/pop actions
       
   140                 SettingsBaseViewController *leftController = [[SettingsBaseViewController alloc] init];
       
   141                 leftController.targetController = rightNavController.topViewController;
       
   142                 UINavigationController *leftNavController = [[UINavigationController alloc] initWithRootViewController:leftController];
       
   143                 [leftController release];
       
   144                 
       
   145                 MGSplitViewController *splitViewRootController = [[MGSplitViewController alloc] init];
       
   146                 splitViewRootController.delegate = nil;
       
   147                 splitViewRootController.showsMasterInPortrait = YES;
       
   148                 splitViewRootController.viewControllers = [NSArray arrayWithObjects:leftNavController, rightNavController, nil];
       
   149                 [leftNavController release];
       
   150                 [rightNavController release];
       
   151 
       
   152                 [self presentViewController:splitViewRootController animated:YES completion:nil];
       
   153                 [splitViewRootController release];
       
   154             }
       
   155             else
       
   156             {
       
   157                 NSMutableArray *tabBarNavigationControllers = [[NSMutableArray alloc] initWithCapacity:5];
       
   158                 
       
   159                 UIViewController *generalSettingsViewController = [[GeneralSettingsViewController alloc] initWithStyle:UITableViewStyleGrouped];
       
   160                 generalSettingsViewController.tabBarItem = [self tabBarItemWithTitle:NSLocalizedString(@"General",@"") imageName:@"flower" selectedImageName:@"flower_filled"];
       
   161                 UINavigationController *generalNavController = [[UINavigationController alloc] initWithRootViewController:generalSettingsViewController];
       
   162                 [generalSettingsViewController release];
       
   163                 [tabBarNavigationControllers addObject:generalNavController];
       
   164                 [generalNavController release];
       
   165                 
       
   166                 UIViewController *teamSettingsViewController = [[TeamSettingsViewController alloc] initWithStyle:UITableViewStyleGrouped];
       
   167                 teamSettingsViewController.tabBarItem = [self tabBarItemWithTitle:NSLocalizedString(@"Teams",@"") imageName:@"teams" selectedImageName:@"teams_filled"];
       
   168                 UINavigationController *teamNavController = [[UINavigationController alloc] initWithRootViewController:teamSettingsViewController];
       
   169                 [teamSettingsViewController release];
       
   170                 [tabBarNavigationControllers addObject:teamNavController];
       
   171                 [teamNavController release];
       
   172                 
       
   173                 UIViewController *weaponSettingsViewController = [[WeaponSettingsViewController alloc] initWithStyle:UITableViewStyleGrouped];
       
   174                 weaponSettingsViewController.tabBarItem = [self tabBarItemWithTitle:NSLocalizedString(@"Weapons",@"") imageName:@"bullet" selectedImageName:@"bullet_filled"];
       
   175                 UINavigationController *weaponNavController = [[UINavigationController alloc] initWithRootViewController:weaponSettingsViewController];
       
   176                 [weaponSettingsViewController release];
       
   177                 [tabBarNavigationControllers addObject:weaponNavController];
       
   178                 [weaponNavController release];
       
   179                 
       
   180                 UIViewController *schemeSettingsViewController = [[SchemeSettingsViewController alloc] initWithStyle:UITableViewStyleGrouped];
       
   181                 schemeSettingsViewController.tabBarItem = [self tabBarItemWithTitle:NSLocalizedString(@"Schemes",@"") imageName:@"target" selectedImageName:@"target_filled"];
       
   182                 UINavigationController *schemeNavController = [[UINavigationController alloc] initWithRootViewController:schemeSettingsViewController];
       
   183                 [schemeSettingsViewController release];
       
   184                 [tabBarNavigationControllers addObject:schemeNavController];
       
   185                 [schemeNavController release];
       
   186                 
       
   187                 UIViewController *supportViewController = [[SupportViewController alloc] initWithStyle:UITableViewStyleGrouped];
       
   188                 supportViewController.tabBarItem = [self tabBarItemWithTitle:NSLocalizedString(@"Support",@"") imageName:@"heart" selectedImageName:@"heart_filled"];
       
   189                 UINavigationController *supportNavController = [[UINavigationController alloc] initWithRootViewController:supportViewController];
       
   190                 [supportViewController release];
       
   191                 [tabBarNavigationControllers addObject:supportNavController];
       
   192                 [supportNavController release];
       
   193                 
       
   194                 UITabBarController *settingsTabController = [[UITabBarController alloc] init];
       
   195                 settingsTabController.viewControllers = tabBarNavigationControllers;
       
   196                 [tabBarNavigationControllers release];
       
   197                 
       
   198                 [self presentViewController:settingsTabController animated:YES completion:nil];
       
   199                 [settingsTabController release];
   129             }
   200             }
   130             break;
   201             break;
   131         case 3:
   202         case 3:
   132 #ifdef DEBUG
   203 #ifdef DEBUG
   133             {
   204             {
   187             [alert release];
   258             [alert release];
   188             break;
   259             break;
   189     }
   260     }
   190 }
   261 }
   191 
   262 
       
   263 - (UITabBarItem *)tabBarItemWithTitle: (NSString *)title
       
   264                             imageName: (NSString *)imageName
       
   265                     selectedImageName: (NSString *)selectedImageName
       
   266 {
       
   267     return [[[UITabBarItem alloc] initWithTitle:title
       
   268                                           image:[UIImage imageNamed:imageName]
       
   269                                   selectedImage:[UIImage imageNamed:selectedImageName]] autorelease];
       
   270 }
       
   271 
   192 #pragma mark -
   272 #pragma mark -
   193 -(void) viewDidUnload {
   273 -(void) viewDidUnload {
   194     MSG_DIDUNLOAD();
   274     MSG_DIDUNLOAD();
   195     [super viewDidUnload];
   275     [super viewDidUnload];
   196 }
   276 }