project_files/HedgewarsMobile/Classes/OverlayViewController.m
changeset 4861 91f889289a47
parent 4856 dbc256913b35
child 4920 bc3c077e15a2
equal deleted inserted replaced
4860:4f9d05416fd6 4861:91f889289a47
   184     [[NSNotificationCenter defaultCenter] addObserver:self
   184     [[NSNotificationCenter defaultCenter] addObserver:self
   185                                              selector:@selector(showHelp:)
   185                                              selector:@selector(showHelp:)
   186                                                  name:@"show help ingame"
   186                                                  name:@"show help ingame"
   187                                                object:nil];
   187                                                object:nil];
   188 
   188 
   189     [[NSNotificationCenter defaultCenter] addObserver:self
       
   190                                              selector:@selector(cleanup)
       
   191                                                  name:@"remove overlay"
       
   192                                                object:nil];
       
   193 
       
   194     // for iOS >= 3.2
   189     // for iOS >= 3.2
   195     if ([UIScreen respondsToSelector:@selector(screens)]) {
   190     if ([UIScreen respondsToSelector:@selector(screens)]) {
   196         [[NSNotificationCenter defaultCenter] addObserver:self
   191         [[NSNotificationCenter defaultCenter] addObserver:self
   197                                                  selector:@selector(numberOfScreensIncreased)
   192                                                  selector:@selector(numberOfScreensIncreased)
   198                                                      name:UIScreenDidConnectNotification
   193                                                      name:UIScreenDidConnectNotification
   233                                                        delegate:nil
   228                                                        delegate:nil
   234                                               cancelButtonTitle:@"Ok"
   229                                               cancelButtonTitle:@"Ok"
   235                                               otherButtonTitles:nil];
   230                                               otherButtonTitles:nil];
   236         [alert show];
   231         [alert show];
   237         [alert release];
   232         [alert release];
   238         [self cleanup];
   233         HW_terminate(NO);
   239     }
   234     }
   240 }
   235 }
   241 
   236 
   242 
   237 
   243 -(void) showHelp:(id) sender {
   238 -(void) showHelp:(id) sender {
   253     [self.view addSubview:helpPage.view];
   248     [self.view addSubview:helpPage.view];
   254     [UIView beginAnimations:@"helpingame" context:NULL];
   249     [UIView beginAnimations:@"helpingame" context:NULL];
   255     self.helpPage.view.alpha = 1;
   250     self.helpPage.view.alpha = 1;
   256     [UIView commitAnimations];
   251     [UIView commitAnimations];
   257     doNotDim();
   252     doNotDim();
   258 }
       
   259 
       
   260 -(void) cleanup {
       
   261     [self dismissPopover];
       
   262     setGameRunning(NO);
       
   263     HW_terminate(NO);
       
   264     [self.view removeFromSuperview];
       
   265 }
   253 }
   266 
   254 
   267 -(void) didReceiveMemoryWarning {
   255 -(void) didReceiveMemoryWarning {
   268     if (self.popupMenu.view.superview == nil)
   256     if (self.popupMenu.view.superview == nil)
   269         self.popupMenu = nil;
   257         self.popupMenu = nil;
   455 #pragma mark -
   443 #pragma mark -
   456 #pragma mark other menu
   444 #pragma mark other menu
   457 // present a further check before closing game
   445 // present a further check before closing game
   458 -(void) actionSheet:(UIActionSheet *)actionSheet didDismissWithButtonIndex:(NSInteger) buttonIndex {
   446 -(void) actionSheet:(UIActionSheet *)actionSheet didDismissWithButtonIndex:(NSInteger) buttonIndex {
   459     if ([actionSheet cancelButtonIndex] != buttonIndex)
   447     if ([actionSheet cancelButtonIndex] != buttonIndex)
   460         [self cleanup];
   448         HW_terminate(NO);
   461     else
   449     else
   462         HW_pause();
   450         HW_pause();
   463 }
   451 }
   464 
   452 
   465 // show up a popover containing a popupMenuViewController; we hook it with setPopoverContentSize
   453 // show up a popover containing a popupMenuViewController; we hook it with setPopoverContentSize