don't make the confirmation button disappear, present an alert if game doesn't start
authorkoda
Fri, 16 Jul 2010 00:18:03 +0200
changeset 3646 a3271158d93b
parent 3644 42c5684289ae
child 3647 0d0df215fb52
don't make the confirmation button disappear, present an alert if game doesn't start
project_files/HedgewarsMobile/Classes/GameConfigViewController.m
project_files/HedgewarsMobile/Classes/OverlayViewController.h
project_files/HedgewarsMobile/Classes/OverlayViewController.m
project_files/HedgewarsMobile/Hedgewars.xcodeproj/project.pbxproj
project_files/HedgewarsMobile/Resources/denied.png
--- a/project_files/HedgewarsMobile/Classes/GameConfigViewController.m	Thu Jul 15 04:31:25 2010 +0200
+++ b/project_files/HedgewarsMobile/Classes/GameConfigViewController.m	Fri Jul 16 00:18:03 2010 +0200
@@ -164,6 +164,26 @@
         DLog(@"gameconfig data not complete!!\nmapConfigViewController = %@\nteamConfigViewController = %@\nschemeWeaponConfigViewController = %@\n",
              mapConfigViewController, teamConfigViewController, schemeWeaponConfigViewController);
         [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 (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
+            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 (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
+            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];
     }
 
 }
--- a/project_files/HedgewarsMobile/Classes/OverlayViewController.h	Thu Jul 15 04:31:25 2010 +0200
+++ b/project_files/HedgewarsMobile/Classes/OverlayViewController.h	Fri Jul 16 00:18:03 2010 +0200
@@ -8,10 +8,6 @@
 
 #import <UIKit/UIKit.h>
 
-#define CONFIRMATION_TAG 5959
-#define ANIMATION_DURATION 0.25
-#define removeConfirmationInput()   [[self.view viewWithTag:CONFIRMATION_TAG] removeFromSuperview]; 
-
 @class PopoverMenuViewController;
 
 @interface OverlayViewController : UIViewController {
--- a/project_files/HedgewarsMobile/Classes/OverlayViewController.m	Thu Jul 15 04:31:25 2010 +0200
+++ b/project_files/HedgewarsMobile/Classes/OverlayViewController.m	Fri Jul 16 00:18:03 2010 +0200
@@ -17,7 +17,12 @@
 
 #define HIDING_TIME_DEFAULT [NSDate dateWithTimeIntervalSinceNow:2.7]
 #define HIDING_TIME_NEVER   [NSDate dateWithTimeIntervalSinceNow:10000]
+#define doDim()             [dimTimer setFireDate:HIDING_TIME_DEFAULT]
+#define doNotDim()          [dimTimer setFireDate:HIDING_TIME_NEVER]
 
+#define CONFIRMATION_TAG 5959
+#define ANIMATION_DURATION 0.25
+#define removeConfirmationInput()   [[self.view viewWithTag:CONFIRMATION_TAG] removeFromSuperview]; 
 
 @implementation OverlayViewController
 @synthesize popoverController, popupMenu;
@@ -189,7 +194,7 @@
 // set the overlay visible and put off the timer for enough time
 -(void) activateOverlay {
     self.view.alpha = 1;
-    [dimTimer setFireDate:HIDING_TIME_NEVER];
+    doNotDim();
 }
 
 // dim the overlay when there's no more input for a certain amount of time
@@ -216,7 +221,7 @@
             break;
     }
 
-    [dimTimer setFireDate:HIDING_TIME_DEFAULT];
+    doDim();
 }
 
 // issue certain action based on the tag of the button 
@@ -352,6 +357,9 @@
     }
     */
     
+    // reset default dimming
+    doDim();
+    
     switch ([allTouches count]) {
         case 1:            
             removeConfirmationInput();
@@ -403,6 +411,9 @@
                     [UIView setAnimationDuration:ANIMATION_DURATION];
                     [self.view viewWithTag:CONFIRMATION_TAG].alpha = 1;
                     [UIView commitAnimations];
+                    
+                    // keep the overlay active, or the button will fade
+                    doNotDim();
                 }
             break;
         case 2:
@@ -419,6 +430,7 @@
 -(void) sendHWClick {
     HW_click();
     removeConfirmationInput();
+    doDim();
 }
 
 -(void) touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event {
--- a/project_files/HedgewarsMobile/Hedgewars.xcodeproj/project.pbxproj	Thu Jul 15 04:31:25 2010 +0200
+++ b/project_files/HedgewarsMobile/Hedgewars.xcodeproj/project.pbxproj	Fri Jul 16 00:18:03 2010 +0200
@@ -29,6 +29,7 @@
 		611F4D4B11B27A9900F9759A /* uScript.pas in Sources */ = {isa = PBXBuildFile; fileRef = 611F4D4A11B27A9900F9759A /* uScript.pas */; };
 		61272334117DF764005B90CF /* libSDL_image.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 61272333117DF752005B90CF /* libSDL_image.a */; };
 		61272339117DF778005B90CF /* MobileCoreServices.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 61272338117DF778005B90CF /* MobileCoreServices.framework */; };
+		6129B9F711EFB04D0017E305 /* denied.png in Resources */ = {isa = PBXBuildFile; fileRef = 6129B9F611EFB04D0017E305 /* denied.png */; };
 		61370653117B1D50004EE44A /* Entitlements-Distribution.plist in Resources */ = {isa = PBXBuildFile; fileRef = 61370652117B1D50004EE44A /* Entitlements-Distribution.plist */; };
 		61536CCF11CE836E00D87A7E /* libfreetype_x86.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 61798917114AAF2100BA94A9 /* libfreetype_x86.a */; };
 		61536DF411CEAE7100D87A7E /* GameConfigViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = 6165924A11CA9CB400D6E256 /* GameConfigViewController.xib */; };
@@ -250,6 +251,7 @@
 		611FD9CB1155A28C00C2203D /* HedgewarsTitle.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = HedgewarsTitle.png; path = ../../QTfrontend/res/HedgewarsTitle.png; sourceTree = SOURCE_ROOT; };
 		6127232E117DF752005B90CF /* SDL_image.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = SDL_image.xcodeproj; path = "../../../Library/SDL-1.3/SDL_image/Xcode_iPhone/SDL_image.xcodeproj"; sourceTree = SOURCE_ROOT; };
 		61272338117DF778005B90CF /* MobileCoreServices.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = MobileCoreServices.framework; path = System/Library/Frameworks/MobileCoreServices.framework; sourceTree = SDKROOT; };
+		6129B9F611EFB04D0017E305 /* denied.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = denied.png; path = Resources/denied.png; sourceTree = "<group>"; };
 		61370652117B1D50004EE44A /* Entitlements-Distribution.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = "Entitlements-Distribution.plist"; sourceTree = "<group>"; };
 		614E333D11DE9A93009DBA4E /* VGSHandlers.inc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.pascal; name = VGSHandlers.inc; path = ../../hedgewars/VGSHandlers.inc; sourceTree = SOURCE_ROOT; };
 		6163EE7C11CC2600001C0453 /* SingleWeaponViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SingleWeaponViewController.h; sourceTree = "<group>"; };
@@ -529,6 +531,7 @@
 		29B97317FDCFA39411CA2CEA /* Resources */ = {
 			isa = PBXGroup;
 			children = (
+				6129B9F611EFB04D0017E305 /* denied.png */,
 				61F7A42811E2905C0040BA66 /* Icons */,
 				61F903FA11DF58680068B24D /* Frontend-iPad */,
 				61F903E311DF584D0068B24D /* Frontend-iPhone */,
@@ -1056,6 +1059,7 @@
 				6183D83E11E2BCE200A88903 /* LI-ipad-Landscape.png in Resources */,
 				6183D83F11E2BCE200A88903 /* LI-iphone-Landscape.png in Resources */,
 				619C09EA11E8B8D600F1DF16 /* title_small.png in Resources */,
+				6129B9F711EFB04D0017E305 /* denied.png in Resources */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;
 		};
Binary file project_files/HedgewarsMobile/Resources/denied.png has changed