project_files/HedgewarsMobile/Classes/OverlayViewController.m
changeset 4855 2480ab325057
parent 4541 c77c4f5d49d3
child 4856 dbc256913b35
equal deleted inserted replaced
4854:881c8232b66a 4855:2480ab325057
    33 #define HIDING_TIME_DEFAULT [NSDate dateWithTimeIntervalSinceNow:2.7]
    33 #define HIDING_TIME_DEFAULT [NSDate dateWithTimeIntervalSinceNow:2.7]
    34 #define HIDING_TIME_NEVER   [NSDate dateWithTimeIntervalSinceNow:10000]
    34 #define HIDING_TIME_NEVER   [NSDate dateWithTimeIntervalSinceNow:10000]
    35 #define doDim()             [dimTimer setFireDate: (IS_DUALHEAD()) ? HIDING_TIME_NEVER : HIDING_TIME_DEFAULT]
    35 #define doDim()             [dimTimer setFireDate: (IS_DUALHEAD()) ? HIDING_TIME_NEVER : HIDING_TIME_DEFAULT]
    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 removeInputWidget() [[self.view viewWithTag:CONFIRMATION_TAG] removeFromSuperview]; \
       
    39                             [[self.view viewWithTag:GRENADE_TAG] removeFromSuperview];
    39 
    40 
    40 @implementation OverlayViewController
    41 @implementation OverlayViewController
    41 @synthesize popoverController, popupMenu, helpPage, amvc, isNetGame, useClassicMenu, initialOrientation, containerWindow;
    42 @synthesize popoverController, popupMenu, helpPage, amvc, isNetGame, useClassicMenu, initialOrientation, containerWindow;
    42 
    43 
    43 #pragma mark -
    44 #pragma mark -
   208     // present the overlay
   209     // present the overlay
   209     [UIView beginAnimations:@"showing overlay" context:NULL];
   210     [UIView beginAnimations:@"showing overlay" context:NULL];
   210     [UIView setAnimationDuration:2];
   211     [UIView setAnimationDuration:2];
   211     self.view.alpha = 1;
   212     self.view.alpha = 1;
   212     [UIView commitAnimations];
   213     [UIView commitAnimations];
       
   214     
       
   215     doDim();
   213 }
   216 }
   214 
   217 
   215 -(void) numberOfScreensIncreased {
   218 -(void) numberOfScreensIncreased {
   216     if (initialScreenCount == 1) {
   219     if (initialScreenCount == 1) {
   217         UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"New display detected"
   220         UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"New display detected"
   399             HW_pause();
   402             HW_pause();
   400             if (self.amvc.isVisible && IS_DUALHEAD() == NO) {
   403             if (self.amvc.isVisible && IS_DUALHEAD() == NO) {
   401                 doDim();
   404                 doDim();
   402                 [self.amvc disappear];
   405                 [self.amvc disappear];
   403             }
   406             }
   404             removeConfirmationInput();
   407             removeInputWidget();
   405             [self showPopover];
   408             [self showPopover];
   406             break;
   409             break;
   407         case 11:
   410         case 11:
   408             playSound(@"clickSound");
   411             playSound(@"clickSound");
   409             clearView();
   412             clearView();
   410             removeConfirmationInput();
   413             removeInputWidget();
   411             
   414             
   412             if (IS_DUALHEAD() || self.useClassicMenu == NO) {
   415             if (IS_DUALHEAD() || self.useClassicMenu == NO) {
   413                 if (self.amvc == nil)
   416                 if (self.amvc == nil)
   414                     self.amvc = [[AmmoMenuViewController alloc] init];
   417                     self.amvc = [[AmmoMenuViewController alloc] init];
   415                 setAmmoMenuInstance(amvc);
   418                 setAmmoMenuInstance(amvc);
   437     HW_preciseSet(NO);
   440     HW_preciseSet(NO);
   438 }
   441 }
   439 
   442 
   440 -(void) sendHWClick {
   443 -(void) sendHWClick {
   441     HW_click();
   444     HW_click();
   442     removeConfirmationInput();
   445     removeInputWidget();
   443     doDim();
   446     doDim();
   444 }
   447 }
   445 
   448 
   446 -(void) setGrenadeTime:(id) sender {
   449 -(void) setGrenadeTime:(id) sender {
   447     UISegmentedControl *theSegment = (UISegmentedControl *)sender;
   450     UISegmentedControl *theSegment = (UISegmentedControl *)sender;
   539         [self.amvc disappear];
   542         [self.amvc disappear];
   540     }
   543     }
   541     // reset default dimming
   544     // reset default dimming
   542     doDim();
   545     doDim();
   543 
   546 
       
   547     // remove other widgets
       
   548     removeInputWidget();
       
   549 
   544     HW_setPianoSound([allTouches count]);
   550     HW_setPianoSound([allTouches count]);
   545 
   551 
   546     switch ([allTouches count]) {
   552     switch ([allTouches count]) {
   547         case 1:
   553         case 1:
   548             removeConfirmationInput();
       
   549             startingPoint = [[[allTouches allObjects] objectAtIndex:0] locationInView:self.view];
   554             startingPoint = [[[allTouches allObjects] objectAtIndex:0] locationInView:self.view];
   550             if (2 == [[[allTouches allObjects] objectAtIndex:0] tapCount])
   555             if (2 == [[[allTouches allObjects] objectAtIndex:0] tapCount])
   551                 HW_zoomReset();
   556                 HW_zoomReset();
   552             break;
   557             break;
   553         case 2:
   558         case 2: