project_files/HedgewarsMobile/Classes/OverlayViewController.m
changeset 4356 d1d26f8963a3
parent 4144 cda2685feeb4
child 4362 8dae325dc625
equal deleted inserted replaced
4354:c4e1820fa792 4356:d1d26f8963a3
    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;
    41 @synthesize popoverController, popupMenu, helpPage, amvc, isNetGame, useClassicMenu, initialOrientation;
    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
       
    47     if (isGameRunning() == NO)
       
    48         return (interfaceOrientation == (UIInterfaceOrientation) self.initialOrientation);
    46     return rotationManager(interfaceOrientation);
    49     return rotationManager(interfaceOrientation);
    47 }
    50 }
    48 
    51 
    49 // 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
    50 -(void) willRotateToInterfaceOrientation:(UIInterfaceOrientation) toInterfaceOrientation duration:(NSTimeInterval) duration{
    53 -(void) willRotateToInterfaceOrientation:(UIInterfaceOrientation) toInterfaceOrientation duration:(NSTimeInterval) duration{
       
    54     if (isGameRunning() == NO)
       
    55         return;
       
    56 
    51     [self dismissPopover];
    57     [self dismissPopover];
    52     if (HW_isPaused() == NO)
    58     if (HW_isPaused() == NO)
    53         HW_pause();
    59         HW_pause();
    54     if (self.amvc.isVisible && IS_DUALHEAD() == NO) {
    60     if (self.amvc.isVisible && IS_DUALHEAD() == NO) {
    55         [self.amvc disappear];
    61         [self.amvc disappear];
    73     }
    79     }
    74 }
    80 }
    75 
    81 
    76 // now restore previous state
    82 // now restore previous state
    77 -(void) didRotateFromInterfaceOrientation:(UIInterfaceOrientation) fromInterfaceOrientation {
    83 -(void) didRotateFromInterfaceOrientation:(UIInterfaceOrientation) fromInterfaceOrientation {
       
    84     if (isGameRunning() == NO)
       
    85         return;
       
    86 
    78     if (wasVisible || IS_DUALHEAD())
    87     if (wasVisible || IS_DUALHEAD())
    79         [self.amvc appearInView:self.view];
    88         [self.amvc appearInView:self.view];
    80     if (HW_isPaused() == YES)
    89     if (HW_isPaused() == YES)
    81         HW_pause();
    90         HW_pause();
    82 
    91 
    83     [super didRotateFromInterfaceOrientation:fromInterfaceOrientation];
    92     [super didRotateFromInterfaceOrientation:fromInterfaceOrientation];
    84 }
    93 }
    85 
    94 
    86 // while in dual head the above rotation functions are not called
    95 // while in dual head the above rotation functions are not called
    87 -(void) dualHeadRotation:(NSNotification *)notification {
    96 -(void) dualHeadRotation:(NSNotification *)notification {
       
    97     if (isGameRunning() == NO)
       
    98         return;
       
    99 
    88     UIDeviceOrientation orientation = [[UIDevice currentDevice] orientation];
   100     UIDeviceOrientation orientation = [[UIDevice currentDevice] orientation];
    89     
   101     
    90     [UIView beginAnimations:@"rotation" context:NULL];
   102     [UIView beginAnimations:@"rotation" context:NULL];
    91     [UIView setAnimationDuration:0.7];
   103     [UIView setAnimationDuration:0.7];
    92     switch (orientation) {
   104     switch (orientation) {