project_files/HedgewarsMobile/Classes/OverlayViewController.m
changeset 4924 616b618814b5
parent 4920 bc3c077e15a2
child 4935 27fb500dd6b1
--- 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;