353 */ |
353 */ |
354 |
354 |
355 if (currentPosition.y < screen.size.width - 130 || (currentPosition.x > 130 && currentPosition.x < screen.size.height - 130)) { |
355 if (currentPosition.y < screen.size.width - 130 || (currentPosition.x > 130 && currentPosition.x < screen.size.height - 130)) { |
356 switch ([touches count]) { |
356 switch ([touches count]) { |
357 case 1: |
357 case 1: |
358 DLog(@"X:%d Y:%d", HWX(currentPosition.x), HWY(currentPosition.y)); |
358 //DLog(@"X:%d Y:%d", HWX(currentPosition.x), HWY(currentPosition.y)); |
359 HW_setCursor(HWX(currentPosition.x), HWY(currentPosition.y)); |
359 // this is a single touch/tap |
|
360 isSingleClick = YES; |
|
361 // save were the click event will take place |
|
362 pointWhereToClick = currentPosition; |
|
363 |
|
364 [[self.view viewWithTag:5599] removeFromSuperview]; |
360 if (2 == [touch tapCount]) |
365 if (2 == [touch tapCount]) |
361 HW_zoomReset(); |
366 HW_zoomReset(); |
362 break; |
367 break; |
363 case 2: |
368 case 2: |
364 // pinching |
369 // pinching |
372 } |
377 } |
373 } |
378 } |
374 } |
379 } |
375 |
380 |
376 -(void) touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event { |
381 -(void) touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event { |
|
382 CGRect screen = [[UIScreen mainScreen] bounds]; |
|
383 //HW_allKeysUp(); |
|
384 if (HW_isAmmoOpen()) { |
|
385 // if we're in the menu we just click in the point |
|
386 HW_setCursor(HWX(pointWhereToClick.x), HWY(pointWhereToClick.y)); |
|
387 HW_click(); |
|
388 } else |
|
389 if (isSingleClick) { |
|
390 // if they tapped in the screen we trick the system so that camera doesn't move |
|
391 HW_saveCursor(FALSE); |
|
392 HW_setCursor(HWX(pointWhereToClick.x), HWY(pointWhereToClick.y)); |
|
393 HW_click(); |
|
394 HW_saveCursor(TRUE); |
|
395 |
|
396 // and remove the label (if any) |
|
397 [[self.view viewWithTag:5599] removeFromSuperview]; |
|
398 } else { |
|
399 // TODO: only do this if the weapon does require a further click |
|
400 // if no click, then ask for tapping again |
|
401 CGPoint currentPosition = [[touches anyObject] locationInView:self.view]; |
|
402 UILabel *tapAgain = [[UILabel alloc] initWithFrame:CGRectMake(currentPosition.x-100, currentPosition.y + 10, 200, 25)]; |
|
403 tapAgain.text = NSLocalizedString(@"Tap again to confirm",@"from the overlay"); |
|
404 tapAgain.backgroundColor = [UIColor clearColor]; |
|
405 tapAgain.tag = 5599; |
|
406 tapAgain.textColor = [UIColor blueColor]; |
|
407 tapAgain.textAlignment = UITextAlignmentCenter; |
|
408 tapAgain.font = [UIFont boldSystemFontOfSize:[UIFont labelFontSize]]; |
|
409 [self.view addSubview:tapAgain]; |
|
410 [tapAgain release]; |
|
411 } |
|
412 |
|
413 pointWhereToClick = CGPointZero; |
377 initialDistanceForPinching = 0; |
414 initialDistanceForPinching = 0; |
378 //HW_allKeysUp(); |
415 isSingleClick = NO; |
379 HW_click(); |
|
380 } |
416 } |
381 |
417 |
382 -(void) touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event { |
418 -(void) touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event { |
383 // this can happen if the user puts more than 5 touches on the screen at once, or perhaps in other circumstances |
419 // this can happen if the user puts more than 5 touches on the screen at once, or perhaps in other circumstances |
384 [self touchesEnded:touches withEvent:event]; |
420 [self touchesEnded:touches withEvent:event]; |
391 CGPoint currentPosition; |
427 CGPoint currentPosition; |
392 UITouch *touch = [touches anyObject]; |
428 UITouch *touch = [touches anyObject]; |
393 |
429 |
394 switch ([touches count]) { |
430 switch ([touches count]) { |
395 case 1: |
431 case 1: |
|
432 isSingleClick = NO; |
|
433 currentPosition = [touch locationInView:self.view]; |
396 if (HW_isAmmoOpen()) { |
434 if (HW_isAmmoOpen()) { |
397 currentPosition = [touch locationInView:self.view]; |
|
398 DLog(@"X:%d Y:%d", HWX(currentPosition.x), HWY(currentPosition.y)); |
435 DLog(@"X:%d Y:%d", HWX(currentPosition.x), HWY(currentPosition.y)); |
|
436 HW_setCursor(HWX(currentPosition.x), HWY(currentPosition.y)); |
|
437 pointWhereToClick = currentPosition; |
|
438 } else { |
|
439 DLog(@"x: %f y: %f -> X:%d Y:%d", currentPosition.x, currentPosition.y, HWX(currentPosition.x), HWY(currentPosition.y)); |
399 HW_setCursor(HWX(currentPosition.x), HWY(currentPosition.y)); |
440 HW_setCursor(HWX(currentPosition.x), HWY(currentPosition.y)); |
400 } |
441 } |
401 break; |
442 break; |
402 case 2: |
443 case 2: |
403 twoTouches = [touches allObjects]; |
444 twoTouches = [touches allObjects]; |