project_files/HedgewarsMobile/Classes/GameConfigViewController.m
changeset 4362 8dae325dc625
parent 4349 8efa91f98274
child 4504 8906b2409d97
--- a/project_files/HedgewarsMobile/Classes/GameConfigViewController.m	Sun Nov 28 01:58:43 2010 +0100
+++ b/project_files/HedgewarsMobile/Classes/GameConfigViewController.m	Sun Nov 28 23:49:09 2010 +0100
@@ -38,12 +38,7 @@
 }
 
 -(IBAction) buttonPressed:(id) sender {
-    // works even if it's not actually a button
-    UIButton *theButton;
-    if (IS_IPAD())
-        theButton = [[(NSNotification *)sender userInfo] objectForKey:@"sender"];
-    else
-        theButton = (UIButton *)sender;
+    UIButton *theButton = (UIButton *)sender;
 
     switch (theButton.tag) {
         case 0:
@@ -171,7 +166,7 @@
     // play if there aren't too many teams
     if ([self.teamConfigViewController.listOfSelectedTeams count] > HW_getMaxNumberOfTeams()) {
         UIAlertView *alert = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"Too many teams",@"")
-                                                        message:NSLocalizedString(@"Max six teams are allowed in the same game",@"")
+                                                        message:NSLocalizedString(@"You exceeded the maximum number of tems allowed in a game",@"")
                                                        delegate:nil
                                               cancelButtonTitle:NSLocalizedString(@"Ok, got it",@"")
                                               otherButtonTitles:nil];
@@ -234,38 +229,17 @@
     // finally launch game and remove this controller
     DLog(@"sending config %@", gameDictionary);
 
-    if ([[gameDictionary allKeys] count] == 11) {
-        NSDictionary *allDataNecessary = [NSDictionary dictionaryWithObjectsAndKeys:gameDictionary,@"game_dictionary", @"",@"savefile",
-                                                                                    [NSNumber numberWithBool:NO],@"netgame", nil];
-        // let's hide all the views while the game is on
+    NSDictionary *allDataNecessary = [NSDictionary dictionaryWithObjectsAndKeys:gameDictionary,@"game_dictionary", @"",@"savefile",
+                                      [NSNumber numberWithBool:NO],@"netgame", nil];
+    if (IS_IPAD())
+        [[SDLUIKitDelegate sharedAppDelegate] startSDLgame:allDataNecessary];
+    else {
+        // this causes a sporadic crash on the ipad but without this rotation doesn't work on iphone
         UIViewController *dummy = [[UIViewController alloc] init];
         [self presentModalViewController:dummy animated:NO];
         [[SDLUIKitDelegate sharedAppDelegate] startSDLgame:allDataNecessary];
         [self dismissModalViewControllerAnimated:NO];
         [dummy release];
-    } else {
-        DLog(@"gameconfig data not complete!!");
-        [self.parentViewController dismissModalViewControllerAnimated:YES];
-
-        // present an alert to the user, with an image on the ipad (too big for the iphone)
-        NSString *msg = NSLocalizedString(@"Something went wrong with your configuration. Please try again.",@"");
-        if (IS_IPAD())
-            msg = [msg stringByAppendingString:@"\n\n\n\n\n\n\n\n"];    // this makes space for the image
-
-        UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Whoops"
-                                                        message:msg
-                                                       delegate:nil
-                                              cancelButtonTitle:@"Ok"
-                                              otherButtonTitles:nil];
-
-        if (IS_IPAD()) {
-            UIImageView *deniedImg = [[UIImageView alloc] initWithImage:[UIImage imageWithContentsOfFile:@"denied.png"]];
-            deniedImg.frame = CGRectMake(25, 80, 240, 160);
-            [alert addSubview:deniedImg];
-            [deniedImg release];
-        }
-        [alert show];
-        [alert release];
     }
 
 }
@@ -311,12 +285,6 @@
     self.view.frame = CGRectMake(0, 0, screen.size.height, screen.size.width);
 
     if (IS_IPAD()) {
-        [[NSNotificationCenter defaultCenter] addObserver:self
-                                                 selector:@selector(buttonPressed:)
-                                                     name:@"buttonPressed"
-                                                   object:nil];
-        srandom(time(NULL));
-
         // load other controllers
         if (self.mapConfigViewController == nil)
             self.mapConfigViewController = [[MapConfigViewController alloc] initWithNibName:@"MapConfigViewController-iPad" bundle:nil];
@@ -357,6 +325,7 @@
         self.teamConfigViewController.view.frame = CGRectMake(348, 200, 328, 480);
         self.schemeWeaponConfigViewController.view.frame = CGRectMake(10, 70, 300, 600);
 
+        self.mapConfigViewController.parentController = self;
     } else {
         // this is the visible controller
         if (self.mapConfigViewController == nil)
@@ -420,7 +389,6 @@
 }
 
 -(void) viewDidUnload {
-    [[NSNotificationCenter defaultCenter] removeObserver:self];
     self.imgContainer = nil;
     self.mapConfigViewController = nil;
     self.teamConfigViewController = nil;