project_files/HedgewarsMobile/Classes/OverlayViewController.m
changeset 4541 c77c4f5d49d3
parent 4504 8906b2409d97
child 4855 2480ab325057
equal deleted inserted replaced
4540:9b614e420de5 4541:c77c4f5d49d3
   507     }
   507     }
   508 }
   508 }
   509 
   509 
   510 #pragma mark -
   510 #pragma mark -
   511 #pragma mark Custom touch event handling
   511 #pragma mark Custom touch event handling
       
   512 -(BOOL) shouldIgnoreTouch:(NSSet *)allTouches {
       
   513     if (isGameRunning() == NO)
       
   514         return YES;
       
   515 
       
   516     // ignore activity near the dpad and buttons
       
   517     CGPoint touchPoint = [[[allTouches allObjects] objectAtIndex:0] locationInView:self.view];
       
   518     CGSize screen = [[UIScreen mainScreen] bounds].size;
       
   519 
       
   520     if ((touchPoint.x < 160 && touchPoint.y > screen.width - 155 ) || 
       
   521         (touchPoint.x > screen.height - 135 && touchPoint.y > screen.width - 140))
       
   522         return YES;
       
   523     return NO;
       
   524 }
       
   525 
   512 -(void) touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
   526 -(void) touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
   513     NSSet *allTouches = [event allTouches];
   527     NSSet *allTouches = [event allTouches];
   514     UITouch *first, *second;
   528     UITouch *first, *second;
   515 
   529 
   516     if (isGameRunning() == NO)
   530     if ([self shouldIgnoreTouch:allTouches] == YES)
   517         return;
   531         return;
   518 
   532 
   519     // hide in-game menu
   533     // hide in-game menu
   520     if (isPopoverVisible)
   534     if (isPopoverVisible)
   521         [self dismissPopover];
   535         [self dismissPopover];
   550 -(void) touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event {
   564 -(void) touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event {
   551     CGRect screen = [[UIScreen mainScreen] bounds];
   565     CGRect screen = [[UIScreen mainScreen] bounds];
   552     NSSet *allTouches = [event allTouches];
   566     NSSet *allTouches = [event allTouches];
   553     CGPoint currentPosition = [[[allTouches allObjects] objectAtIndex:0] locationInView:self.view];
   567     CGPoint currentPosition = [[[allTouches allObjects] objectAtIndex:0] locationInView:self.view];
   554 
   568 
   555     if (isGameRunning() == NO)
   569     if ([self shouldIgnoreTouch:allTouches] == YES)
   556         return;
   570         return;
   557     
   571 
   558     switch ([allTouches count]) {
   572     switch ([allTouches count]) {
   559         case 1:
   573         case 1:
   560             // if we're in the menu we just click in the point
   574             // if we're in the menu we just click in the point
   561             if (HW_isAmmoMenuOpen()) {
   575             if (HW_isAmmoMenuOpen()) {
   562                 HW_setCursor(HWXZ(currentPosition.x), HWYZ(currentPosition.y));
   576                 HW_setCursor(HWXZ(currentPosition.x), HWYZ(currentPosition.y));
   642     CGRect screen = [[UIScreen mainScreen] bounds];
   656     CGRect screen = [[UIScreen mainScreen] bounds];
   643     NSSet *allTouches = [event allTouches];
   657     NSSet *allTouches = [event allTouches];
   644     int x, y, dx, dy;
   658     int x, y, dx, dy;
   645     UITouch *touch, *first, *second;
   659     UITouch *touch, *first, *second;
   646 
   660 
   647     if (isGameRunning() == NO)
   661     if ([self shouldIgnoreTouch:allTouches] == YES)
   648         return;
   662         return;
   649     
   663 
   650     switch ([allTouches count]) {
   664     switch ([allTouches count]) {
   651         case 1:
   665         case 1:
   652             touch = [[allTouches allObjects] objectAtIndex:0];
   666             touch = [[allTouches allObjects] objectAtIndex:0];
   653             CGPoint currentPosition = [touch locationInView:self.view];
   667             CGPoint currentPosition = [touch locationInView:self.view];
   654 
   668