show dual head mode some love
authorkoda
Sat, 05 Feb 2011 22:22:16 +0100
changeset 4924 616b618814b5
parent 4923 c7829611c682
child 4925 3d90fd7f738a
show dual head mode some love
hedgewars/PascalExports.pas
project_files/HedgewarsMobile/Classes/GameSetup.m
project_files/HedgewarsMobile/Classes/InGameMenuViewController.m
project_files/HedgewarsMobile/Classes/OverlayViewController.m
--- a/hedgewars/PascalExports.pas	Sat Feb 05 23:37:25 2011 +0300
+++ b/hedgewars/PascalExports.pas	Sat Feb 05 22:22:16 2011 +0100
@@ -201,7 +201,11 @@
 
 function HW_getSDLWindow: pointer; cdecl; export;
 begin
+{$IFDEF SDL13}
     exit( SDLwindow );
+{$ELSE}
+    exit( nil );
+{$ENDIF}
 end;
 
 // cursor handling
--- a/project_files/HedgewarsMobile/Classes/GameSetup.m	Sat Feb 05 23:37:25 2011 +0300
+++ b/project_files/HedgewarsMobile/Classes/GameSetup.m	Sat Feb 05 22:22:16 2011 +0100
@@ -394,8 +394,10 @@
                 }
                 break;
             case 'q':
-                // game ended, can remove the savefile
+                // game ended, can remove the savefile and the trailing overlay (when dualhead)
                 [[NSFileManager defaultManager] removeItemAtPath:self.savePath error:nil];
+                if (IS_DUALHEAD())
+                    [[NSNotificationCenter defaultCenter] postNotificationName:@"remove overlay" object:nil];
                 break;
             case 'Q':
                 // game exited but not completed, nothing to do (just don't save the message)
--- a/project_files/HedgewarsMobile/Classes/InGameMenuViewController.m	Sat Feb 05 23:37:25 2011 +0300
+++ b/project_files/HedgewarsMobile/Classes/InGameMenuViewController.m	Sat Feb 05 22:22:16 2011 +0100
@@ -82,10 +82,9 @@
         [UIView setAnimationDuration:0.35];
         self.view.frame = CGRectMake(screen.size.height, 0, 200, 170);
         [UIView commitAnimations];
+        [self.view performSelector:@selector(removeFromSuperview) withObject:nil afterDelay:0.35];
     }
 
-    [self.view performSelector:@selector(removeFromSuperview) withObject:nil afterDelay:0.35];
-
     HW_chatEnd();
     SDL_iPhoneKeyboardHide((SDL_Window *)HW_getSDLWindow());
 }
@@ -165,8 +164,11 @@
         [UIView commitAnimations];
     }
 
-    if ([actionSheet cancelButtonIndex] != buttonIndex)
+    if ([actionSheet cancelButtonIndex] != buttonIndex) {
+        if (IS_DUALHEAD())
+            [[NSNotificationCenter defaultCenter] postNotificationName:@"remove overlay" object:nil];
         HW_terminate(NO);
+    }
 }
 
 @end
--- a/project_files/HedgewarsMobile/Classes/OverlayViewController.m	Sat Feb 05 23:37:25 2011 +0300
+++ b/project_files/HedgewarsMobile/Classes/OverlayViewController.m	Sat Feb 05 22:22:16 2011 +0100
@@ -180,12 +180,18 @@
     // add timer to runloop, otherwise it doesn't work
     [[NSRunLoop currentRunLoop] addTimer:dimTimer forMode:NSDefaultRunLoopMode];
 
-    // become listener of some notifications
+    // display the help page, required by the popover on ipad
     [[NSNotificationCenter defaultCenter] addObserver:self
                                              selector:@selector(showHelp:)
                                                  name:@"show help ingame"
                                                object:nil];
 
+    // remove the view, required by the dual head version
+    [[NSNotificationCenter defaultCenter] addObserver:self
+                                             selector:@selector(removeOverlay:)
+                                                 name:@"remove overlay"
+                                               object:nil];
+
     // for iOS >= 3.2
     if ([UIScreen respondsToSelector:@selector(screens)]) {
         [[NSNotificationCenter defaultCenter] addObserver:self
@@ -252,6 +258,13 @@
     doNotDim();
 }
 
+-(void) removeOverlay:(id) sender {
+    [self.popupMenu performSelectorOnMainThread:@selector(dismiss) withObject:nil waitUntilDone:YES];
+    [self.popoverController performSelectorOnMainThread:@selector(dismissPopoverAnimated:) withObject:nil waitUntilDone:YES];
+    [self.view performSelectorOnMainThread:@selector(removeFromSuperview) withObject:nil waitUntilDone:YES];
+    HW_terminate(NO);
+}
+
 -(void) didReceiveMemoryWarning {
     if (self.popupMenu.view.superview == nil)
         self.popupMenu = nil;