project_files/HedgewarsMobile/Classes/OverlayViewController.m
changeset 3598 a8aa06bae895
parent 3551 d4de36b3801a
child 3599 715a43602da8
equal deleted inserted replaced
3597:978c30ef50fc 3598:a8aa06bae895
   126                                          repeats:YES];
   126                                          repeats:YES];
   127     
   127     
   128     // add timer too runloop, otherwise it doesn't work
   128     // add timer too runloop, otherwise it doesn't work
   129     [[NSRunLoop currentRunLoop] addTimer:dimTimer forMode:NSDefaultRunLoopMode];
   129     [[NSRunLoop currentRunLoop] addTimer:dimTimer forMode:NSDefaultRunLoopMode];
   130     
   130     
   131     // listen for dismissal of the popover (see below)
       
   132     [[NSNotificationCenter defaultCenter] addObserver:self
       
   133                                              selector:@selector(dismissPopover)
       
   134                                                  name:@"dismissPopover"
       
   135                                                object:nil];
       
   136     
       
   137     [[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications];   
   131     [[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications];   
   138     [[NSNotificationCenter defaultCenter] addObserver:self
   132     [[NSNotificationCenter defaultCenter] addObserver:self
   139                                              selector:@selector(didRotate:)
   133                                              selector:@selector(didRotate:)
   140                                                  name:@"UIDeviceOrientationDidChangeNotification"
   134                                                  name:UIDeviceOrientationDidChangeNotification
   141                                                object:nil];
   135                                                object:nil];
   142 
   136 
   143     //self.view.transform = CGAffineTransformRotate(self.view.transform, (M_PI/2.0)); 
       
   144     [UIView beginAnimations:@"showing overlay" context:NULL];
   137     [UIView beginAnimations:@"showing overlay" context:NULL];
   145     [UIView setAnimationDuration:1];
   138     [UIView setAnimationDuration:1];
   146     self.view.alpha = 1;
   139     self.view.alpha = 1;
   147     [UIView commitAnimations];
   140     [UIView commitAnimations];
       
   141 
       
   142     // set initial orientation
       
   143     [self didRotate:[NSNotification notificationWithName:UIDeviceOrientationDidChangeNotification object:nil]];
       
   144 
       
   145     // to put the slider vertical...
       
   146     //slider.transform = CGAffineTransformMakeRotation(M_PI * 0.5);
   148 }
   147 }
   149 
   148 
   150 -(void) viewDidUnload {
   149 -(void) viewDidUnload {
   151     self.writeChatTextField = nil;
   150     self.writeChatTextField = nil;
   152     self.popoverController = nil;
   151     self.popoverController = nil;
   317     }
   316     }
   318     if (writeChatTextField) {
   317     if (writeChatTextField) {
   319         [self.writeChatTextField resignFirstResponder];
   318         [self.writeChatTextField resignFirstResponder];
   320         [dimTimer setFireDate:HIDING_TIME_DEFAULT];
   319         [dimTimer setFireDate:HIDING_TIME_DEFAULT];
   321     }
   320     }
   322             
   321     
   323     switch ([touches count]) {
   322     if (currentPosition.y < screen.size.width - 120) {
   324         case 1:
   323         switch ([touches count]) {
   325             DLog(@"X:%d Y:%d", HWX(currentPosition.x), HWY(currentPosition.y));
   324             case 1:
   326             HW_setCursor(HWX(currentPosition.x), HWY(currentPosition.y));
   325                 DLog(@"X:%d Y:%d", HWX(currentPosition.x), HWY(currentPosition.y));
   327             break;
   326                 HW_setCursor(HWX(currentPosition.x), HWY(currentPosition.y));
   328         case 2:
   327                 break;
   329             if (2 == [touch tapCount] && currentPosition.y < screen.size.width - 100) {
   328             case 2:
   330                 HW_ammoMenu();
   329                 if (2 == [touch tapCount]) {
   331                 //HW_zoomReset();
   330                     HW_ammoMenu();
   332             }
   331                     //HW_zoomReset();
   333             
   332                 }
   334             // pinching
   333                 
   335             twoTouches = [touches allObjects];
   334                 // pinching
   336             UITouch *first = [twoTouches objectAtIndex:0];
   335                 twoTouches = [touches allObjects];
   337             UITouch *second = [twoTouches objectAtIndex:1];
   336                 UITouch *first = [twoTouches objectAtIndex:0];
   338             initialDistanceForPinching = distanceBetweenPoints([first locationInView:self.view], [second locationInView:self.view]);
   337                 UITouch *second = [twoTouches objectAtIndex:1];
   339             break;
   338                 initialDistanceForPinching = distanceBetweenPoints([first locationInView:self.view], [second locationInView:self.view]);
   340         default:
   339                 break;
   341             break;
   340             default:
   342     }
   341                 break;
   343 
   342         }
       
   343     }
   344 }
   344 }
   345 
   345 
   346 -(void) touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event {
   346 -(void) touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event {
   347     initialDistanceForPinching = 0;
   347     initialDistanceForPinching = 0;
   348     //HW_allKeysUp();
   348     //HW_allKeysUp();