project_files/HedgewarsMobile/Classes/OverlayViewController.m
changeset 4454 42bfc1a70968
parent 4362 8dae325dc625
child 4504 8906b2409d97
equal deleted inserted replaced
4453:15a483b2558a 4454:42bfc1a70968
    36 #define doNotDim()          [dimTimer setFireDate:HIDING_TIME_NEVER]
    36 #define doNotDim()          [dimTimer setFireDate:HIDING_TIME_NEVER]
    37 
    37 
    38 #define removeConfirmationInput()   [[self.view viewWithTag:CONFIRMATION_TAG] removeFromSuperview];
    38 #define removeConfirmationInput()   [[self.view viewWithTag:CONFIRMATION_TAG] removeFromSuperview];
    39 
    39 
    40 @implementation OverlayViewController
    40 @implementation OverlayViewController
    41 @synthesize popoverController, popupMenu, helpPage, amvc, isNetGame, useClassicMenu, initialOrientation;
    41 @synthesize popoverController, popupMenu, helpPage, amvc, isNetGame, useClassicMenu, initialOrientation, containerWindow;
    42 
    42 
    43 #pragma mark -
    43 #pragma mark -
    44 #pragma mark rotation
    44 #pragma mark rotation
    45 -(BOOL) shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation) interfaceOrientation {
    45 -(BOOL) shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation) interfaceOrientation {
    46     // don't rotate until the game is running for performance and synchronization with the sdlview
    46     // don't rotate until the game is running for performance and synchronization with the sdlview
    52 // pause the game and remove objc menus so that animation is smoother
    52 // pause the game and remove objc menus so that animation is smoother
    53 -(void) willRotateToInterfaceOrientation:(UIInterfaceOrientation) toInterfaceOrientation duration:(NSTimeInterval) duration{
    53 -(void) willRotateToInterfaceOrientation:(UIInterfaceOrientation) toInterfaceOrientation duration:(NSTimeInterval) duration{
    54     if (isGameRunning() == NO)
    54     if (isGameRunning() == NO)
    55         return;
    55         return;
    56 
    56 
       
    57     HW_pause();
    57     [self dismissPopover];
    58     [self dismissPopover];
    58     if (HW_isPaused() == NO)
    59 
    59         HW_pause();
       
    60     if (self.amvc.isVisible && IS_DUALHEAD() == NO) {
    60     if (self.amvc.isVisible && IS_DUALHEAD() == NO) {
    61         [self.amvc disappear];
    61         [self.amvc disappear];
    62         wasVisible = YES;
    62         wasVisible = YES;
    63     } else
    63     } else
    64         wasVisible = NO;
    64         wasVisible = NO;
    84     if (isGameRunning() == NO)
    84     if (isGameRunning() == NO)
    85         return;
    85         return;
    86 
    86 
    87     if (wasVisible || IS_DUALHEAD())
    87     if (wasVisible || IS_DUALHEAD())
    88         [self.amvc appearInView:self.view];
    88         [self.amvc appearInView:self.view];
    89     if (HW_isPaused() == YES)
    89     HW_pauseToggle();
    90         HW_pause();
       
    91 
    90 
    92     [super didRotateFromInterfaceOrientation:fromInterfaceOrientation];
    91     [super didRotateFromInterfaceOrientation:fromInterfaceOrientation];
    93 }
    92 }
    94 
    93 
    95 // while in dual head the above rotation functions are not called
    94 // while in dual head the above rotation functions are not called
   201         [[NSNotificationCenter defaultCenter] addObserver:self
   200         [[NSNotificationCenter defaultCenter] addObserver:self
   202                                                  selector:@selector(numberOfScreensDecreased)
   201                                                  selector:@selector(numberOfScreensDecreased)
   203                                                      name:UIScreenDidDisconnectNotification
   202                                                      name:UIScreenDidDisconnectNotification
   204                                                    object:nil];
   203                                                    object:nil];
   205     }
   204     }
       
   205     
       
   206     self.containerWindow = [[UIApplication sharedApplication] keyWindow];
   206 
   207 
   207     // present the overlay
   208     // present the overlay
   208     [UIView beginAnimations:@"showing overlay" context:NULL];
   209     [UIView beginAnimations:@"showing overlay" context:NULL];
   209     [UIView setAnimationDuration:2];
   210     [UIView setAnimationDuration:2];
   210     self.view.alpha = 1;
   211     self.view.alpha = 1;
   218                                                        delegate:nil
   219                                                        delegate:nil
   219                                               cancelButtonTitle:@"Ok"
   220                                               cancelButtonTitle:@"Ok"
   220                                               otherButtonTitles:nil];
   221                                               otherButtonTitles:nil];
   221         [alert show];
   222         [alert show];
   222         [alert release];
   223         [alert release];
   223         if (HW_isPaused() == NO)
   224         HW_pause();
   224             HW_pause();
       
   225     }
   225     }
   226 }
   226 }
   227 
   227 
   228 -(void) numberOfScreensDecreased {
   228 -(void) numberOfScreensDecreased {
   229     if (initialScreenCount == 2) {
   229     if (initialScreenCount == 2) {
   491 // on ipad just dismiss it, on iphone transtion to the right
   491 // on ipad just dismiss it, on iphone transtion to the right
   492 -(void) dismissPopover {
   492 -(void) dismissPopover {
   493     if (YES == isPopoverVisible) {
   493     if (YES == isPopoverVisible) {
   494         isPopoverVisible = NO;
   494         isPopoverVisible = NO;
   495         if (HW_isPaused())
   495         if (HW_isPaused())
   496             HW_pause();
   496             HW_pauseToggle();
   497 
   497 
   498         if (IS_IPAD()) {
   498         if (IS_IPAD()) {
   499             [(InGameMenuViewController *)[[self popoverController] contentViewController] removeChat];
   499             [(InGameMenuViewController *)[[self popoverController] contentViewController] removeChat];
   500             [self.popoverController dismissPopoverAnimated:YES];
   500             [self.popoverController dismissPopoverAnimated:YES];
   501         } else {
   501         } else {