project_files/HedgewarsMobile/Classes/GameConfigViewController.m
changeset 4351 9d155da5b417
parent 4150 050163c35c83
child 4362 8dae325dc625
equal deleted inserted replaced
4348:d4f659e96a4a 4351:9d155da5b417
   155 
   155 
   156     // play if there's room for enough hogs in the selected map
   156     // play if there's room for enough hogs in the selected map
   157     int hogs = 0;
   157     int hogs = 0;
   158     for (NSDictionary *teamData in teamConfigViewController.listOfSelectedTeams)
   158     for (NSDictionary *teamData in teamConfigViewController.listOfSelectedTeams)
   159         hogs += [[teamData objectForKey:@"number"] intValue];
   159         hogs += [[teamData objectForKey:@"number"] intValue];
   160     
       
   161     if (hogs > self.mapConfigViewController.maxHogs) {
   160     if (hogs > self.mapConfigViewController.maxHogs) {
   162         UIAlertView *alert = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"Too many hogs",@"")
   161         UIAlertView *alert = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"Too many hogs",@"")
   163                                                         message:NSLocalizedString(@"The map is too small for that many hogs",@"")
   162                                                         message:NSLocalizedString(@"The map is too small for that many hogs",@"")
   164                                                        delegate:nil
   163                                                        delegate:nil
   165                                               cancelButtonTitle:NSLocalizedString(@"Ok, got it",@"")
   164                                               cancelButtonTitle:NSLocalizedString(@"Ok, got it",@"")
   191         [alert show];
   190         [alert show];
   192         [alert release];
   191         [alert release];
   193         return NO;
   192         return NO;
   194     }
   193     }
   195 
   194 
   196     // play if the gameflags are set correctly (divideteam works only with 2 teams
   195     // play if the gameflags are set correctly (divideteam works only with 2 teams)
   197     NSString *schemePath = [[NSString alloc] initWithFormat:@"%@/%@",SCHEMES_DIRECTORY(),self.schemeWeaponConfigViewController.selectedScheme];
   196     NSString *schemePath = [[NSString alloc] initWithFormat:@"%@/%@",SCHEMES_DIRECTORY(),self.schemeWeaponConfigViewController.selectedScheme];
   198     NSArray *gameFlags = [[NSDictionary dictionaryWithContentsOfFile:schemePath] objectForKey:@"gamemod"];
   197     NSArray *gameFlags = [[NSDictionary dictionaryWithContentsOfFile:schemePath] objectForKey:@"gamemod"];
   199     [schemePath release];
   198     [schemePath release];
   200     if ([[gameFlags objectAtIndex:2] boolValue] && [self.teamConfigViewController.listOfSelectedTeams count] != 2) {
   199     if ([[gameFlags objectAtIndex:2] boolValue] && [self.teamConfigViewController.listOfSelectedTeams count] != 2) {
   201         UIAlertView *alert = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"Scheme mismatch",@"")
   200         UIAlertView *alert = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"Scheme mismatch",@"")
   365         // this must be loaded & added in order to auto set default scheme and ammo
   364         // this must be loaded & added in order to auto set default scheme and ammo
   366         self.schemeWeaponConfigViewController = [[SchemeWeaponConfigViewController alloc] initWithStyle:UITableViewStyleGrouped];
   365         self.schemeWeaponConfigViewController = [[SchemeWeaponConfigViewController alloc] initWithStyle:UITableViewStyleGrouped];
   367         [self.view addSubview:self.schemeWeaponConfigViewController.view];
   366         [self.view addSubview:self.schemeWeaponConfigViewController.view];
   368     }
   367     }
   369     [self.view addSubview:self.mapConfigViewController.view];
   368     [self.view addSubview:self.mapConfigViewController.view];
       
   369     self.mapConfigViewController.externalController = schemeWeaponConfigViewController;
   370 
   370 
   371     [super viewDidLoad];
   371     [super viewDidLoad];
   372 }
   372 }
   373 
   373 
   374 -(void) viewWillAppear:(BOOL)animated {
   374 -(void) viewWillAppear:(BOOL)animated {