# HG changeset patch # User koda # Date 1278866341 -7200 # Node ID 33ee433749ba974f864566e2a6d3a656ba2a8ef3 # Parent 0db298524c3d830813dab71fcf79be4859bac581 touch overlay reworked, improvements to zoom and confirmation diff -r 0db298524c3d -r 33ee433749ba hedgewars/CCHandlers.inc --- a/hedgewars/CCHandlers.inc Sun Jul 11 03:23:26 2010 +0200 +++ b/hedgewars/CCHandlers.inc Sun Jul 11 18:39:01 2010 +0200 @@ -510,10 +510,6 @@ Message:= Message or gm_Weapon; MsgParam:= byte(s[1]); end; - -{$IFDEF IPHONEOS} - savedAmmoType:= TAmmoType(s[1]); -{$ENDIF} end; procedure chTaunt(var s: shortstring); @@ -616,8 +612,8 @@ procedure chPut(var s: shortstring); begin -s:= s; // avoid compiler hint -doPut(0, 0, false) + s:= s; // avoid compiler hint + doPut(0, 0, false); end; procedure chCapture(var s: shortstring); @@ -804,23 +800,15 @@ procedure chZoomIn(var s: shortstring); begin s:= s; // avoid compiler hint -{$IFDEF IPHONEOS} - if ZoomValue < 4.0 then -{$ELSE} - if ZoomValue < 3.0 then -{$ENDIF} - ZoomValue:= ZoomValue + 0.20; + if ZoomValue < cMinZoomLevel then + ZoomValue:= ZoomValue + cZoomDelta; end; procedure chZoomOut(var s: shortstring); begin s:= s; // avoid compiler hint -{$IFDEF IPHONEOS} - if ZoomValue > 0.5 then -{$ELSE} - if ZoomValue > 1.0 then -{$ENDIF} - ZoomValue:= ZoomValue - 0.20; + if ZoomValue > cMaxZoomLevel then + ZoomValue:= ZoomValue - cZoomDelta; end; procedure chZoomReset(var s: shortstring); diff -r 0db298524c3d -r 33ee433749ba hedgewars/PascalExports.pas --- a/hedgewars/PascalExports.pas Sun Jul 11 03:23:26 2010 +0200 +++ b/hedgewars/PascalExports.pas Sun Jul 11 18:39:01 2010 +0200 @@ -197,14 +197,7 @@ function HW_isWeaponRequiringClick: boolean; cdecl; export; begin - exit( (savedAmmoType = amTeleport) or - (savedAmmoType = amBee) or - (savedAmmoType = amAirAttack) or - (savedAmmoType = amMineStrike) or - (savedAmmoType = amGirder) or - (savedAmmoType = amNapalm) or - (savedAmmoType = amPiano) - ) + exit( (CurrentHedgehog^.Gear^.State and gstHHChooseTarget) <> 0 ) end; //amSwitch diff -r 0db298524c3d -r 33ee433749ba hedgewars/uConsts.pas --- a/hedgewars/uConsts.pas Sun Jul 11 03:23:26 2010 +0200 +++ b/hedgewars/uConsts.pas Sun Jul 11 18:39:01 2010 +0200 @@ -297,11 +297,16 @@ {$IFDEF IPHONEOS} cMaxCaptions = 3; - cDefaultZoomLevel = 1.5; - savedAmmoType : TAmmoType = amNothing; + cDefaultZoomLevel = 2.0; + cMaxZoomLevel = 0.5; + cMinZoomLevel = 3.5; + cZoomDelta = 0.20; {$ELSE} cMaxCaptions = 4; cDefaultZoomLevel = 2.0; + cMaxZoomLevel = 1.0; + cMinZoomLevel = 3.0; + cZoomDelta = 0.25; {$ENDIF} cSendEmptyPacketTime = 1000; diff -r 0db298524c3d -r 33ee433749ba hedgewars/uWorld.pas --- a/hedgewars/uWorld.pas Sun Jul 11 03:23:26 2010 +0200 +++ b/hedgewars/uWorld.pas Sun Jul 11 18:39:01 2010 +0200 @@ -48,6 +48,7 @@ procedure ShowMission(caption, subcaption, text: ansistring; icon, time : LongInt); procedure HideMission; procedure ShakeCamera(amount: LongWord); +procedure MoveCamera; implementation uses uStore, uMisc, uTeams, uIO, uKeys, uLocale, uSound, uAmmos, uVisualGears, uChat, uLandTexture, uLand, GLunit; @@ -390,8 +391,6 @@ if AMxShift = 0 then DrawSprite(sprArrow, CursorPoint.X, cScreenHeight - CursorPoint.Y, (RealTicks shr 6) mod 8) end; -procedure MoveCamera; forward; - procedure DrawWater(Alpha: byte; OffsetY: LongInt); var VertexBuffer: array [0..3] of TVertex2f; r: TSDL_Rect; @@ -1012,8 +1011,8 @@ end; procedure MoveCamera; -const PrevSentPointTime: LongWord = 0; var EdgesDist, wdy: LongInt; + PrevSentPointTime: LongWord = 0; begin {$IFNDEF IPHONEOS} if (not (CurrentTeam^.ExtDriven and isCursorVisible and not bShowAmmoMenu)) and cHasFocus then diff -r 0db298524c3d -r 33ee433749ba project_files/HedgewarsMobile/Classes/OverlayViewController.h --- a/project_files/HedgewarsMobile/Classes/OverlayViewController.h Sun Jul 11 03:23:26 2010 +0200 +++ b/project_files/HedgewarsMobile/Classes/OverlayViewController.h Sun Jul 11 18:39:01 2010 +0200 @@ -8,6 +8,9 @@ #import +#define CONFIRMATION_TAG 5959 +#define removeConfirmationInput() [[self.view viewWithTag:CONFIRMATION_TAG] removeFromSuperview] + @class PopoverMenuViewController; @interface OverlayViewController : UIViewController { diff -r 0db298524c3d -r 33ee433749ba project_files/HedgewarsMobile/Classes/OverlayViewController.m --- a/project_files/HedgewarsMobile/Classes/OverlayViewController.m Sun Jul 11 03:23:26 2010 +0200 +++ b/project_files/HedgewarsMobile/Classes/OverlayViewController.m Sun Jul 11 18:39:01 2010 +0200 @@ -257,9 +257,11 @@ HW_tab(); break; case 10: + removeConfirmationInput(); [self showPopover]; break; case 11: + removeConfirmationInput(); HW_ammoMenu(); break; default: @@ -337,10 +339,8 @@ #pragma mark - #pragma mark Custom touch event handling -(void) touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { - NSArray *twoTouches; - UITouch *touch = [touches anyObject]; - CGRect screen = [[UIScreen mainScreen] bounds]; - CGPoint currentPosition = [touch locationInView:self.view]; + NSSet *allTouches = [event allTouches]; + UITouch *touch, *first, *second; if (isPopoverVisible) { [self dismissPopover]; @@ -351,87 +351,98 @@ [dimTimer setFireDate:HIDING_TIME_DEFAULT]; } */ - - if (currentPosition.y < screen.size.width - 130 || (currentPosition.x > 130 && currentPosition.x < screen.size.height - 130)) { - switch ([touches count]) { - case 1: - //DLog(@"X:%d Y:%d", HWX(currentPosition.x), HWY(currentPosition.y)); - // this is a single touch/tap - isSingleClick = YES; - // save were the click event will take place - pointWhereToClick = currentPosition; - - [[self.view viewWithTag:5599] removeFromSuperview]; - if (2 == [touch tapCount]) - HW_zoomReset(); - break; - case 2: - // pinching - twoTouches = [touches allObjects]; - UITouch *first = [twoTouches objectAtIndex:0]; - UITouch *second = [twoTouches objectAtIndex:1]; - initialDistanceForPinching = distanceBetweenPoints([first locationInView:self.view], [second locationInView:self.view]); - break; - default: - break; - } + + switch ([allTouches count]) { + case 1: + touch = [[allTouches allObjects] objectAtIndex:0]; + CGPoint currentPosition = [touch locationInView:self.view]; + + //DLog(@"X:%d Y:%d", HWX(currentPosition.x), HWY(currentPosition.y)); + // this is a single touch/tap + isSingleClick = YES; + // save were the click event will take place + pointWhereToClick = currentPosition; + + removeConfirmationInput(); + if (2 == [touch tapCount]) + HW_zoomReset(); + break; + case 2: + // pinching + first = [[allTouches allObjects] objectAtIndex:0]; + second = [[allTouches allObjects] objectAtIndex:1]; + initialDistanceForPinching = distanceBetweenPoints([first locationInView:self.view], [second locationInView:self.view]); + break; + default: + break; } } + //if (currentPosition.y < screen.size.width - 130 || (currentPosition.x > 130 && currentPosition.x < screen.size.height - 130)) { + -(void) touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event { CGRect screen = [[UIScreen mainScreen] bounds]; - //HW_allKeysUp(); - if (HW_isAmmoOpen()) { - // if we're in the menu we just click in the point - HW_setCursor(HWX(pointWhereToClick.x), HWY(pointWhereToClick.y)); - HW_click(); - } else - if (isSingleClick) { - // if they tapped in the screen we trick the system so that camera doesn't move - HW_saveCursor(FALSE); - HW_setCursor(HWX(pointWhereToClick.x), HWY(pointWhereToClick.y)); - HW_click(); - HW_saveCursor(TRUE); - - // and remove the label (if any) - [[self.view viewWithTag:5599] removeFromSuperview]; - } else { - // if weapon requires a further click, ask for tapping again - if (HW_isWeaponRequiringClick()) { - CGPoint currentPosition = [[touches anyObject] locationInView:self.view]; - UILabel *tapAgain = [[UILabel alloc] initWithFrame:CGRectMake(currentPosition.x-100, currentPosition.y + 10, 200, 25)]; - tapAgain.text = NSLocalizedString(@"Tap again to confirm",@"from the overlay"); - tapAgain.backgroundColor = [UIColor clearColor]; - tapAgain.tag = 5599; - tapAgain.textColor = [UIColor blueColor]; - tapAgain.textAlignment = UITextAlignmentCenter; - tapAgain.font = [UIFont boldSystemFontOfSize:[UIFont labelFontSize]]; - [self.view addSubview:tapAgain]; - [tapAgain release]; - } - } - + NSSet *allTouches = [event allTouches]; + UITouch *touch; + + switch ([allTouches count]) { + case 1: + if (HW_isAmmoOpen()) { + // if we're in the menu we just click in the point + HW_setCursor(HWX(pointWhereToClick.x), HWY(pointWhereToClick.y)); + HW_click(); + } else + if (isSingleClick) { + // if they tapped in the screen we trick the system so that camera doesn't move + HW_saveCursor(FALSE); + HW_setCursor(HWX(pointWhereToClick.x), HWY(pointWhereToClick.y)); + HW_click(); + HW_saveCursor(TRUE); + + // and remove the label (if any) + removeConfirmationInput(); + } else { + // if weapon requires a further click, ask for tapping again + if (HW_isWeaponRequiringClick()) { + touch = [[allTouches allObjects] objectAtIndex:0]; + CGPoint currentPosition = [touch locationInView:self.view]; + UILabel *tapAgain = [[UILabel alloc] initWithFrame:CGRectMake(currentPosition.x-100, currentPosition.y + 10, 200, 25)]; + tapAgain.text = NSLocalizedString(@"Tap again to confirm",@"from the overlay"); + tapAgain.backgroundColor = [UIColor clearColor]; + tapAgain.tag = CONFIRMATION_TAG; + tapAgain.textColor = [UIColor blueColor]; + tapAgain.textAlignment = UITextAlignmentCenter; + tapAgain.font = [UIFont boldSystemFontOfSize:[UIFont labelFontSize]]; + [self.view addSubview:tapAgain]; + [tapAgain release]; + } + } + break; + case 2: + HW_allKeysUp(); + break; + } + pointWhereToClick = CGPointZero; initialDistanceForPinching = 0; isSingleClick = NO; } -(void) touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event { - // this can happen if the user puts more than 5 touches on the screen at once, or perhaps in other circumstances [self touchesEnded:touches withEvent:event]; } -(void) touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event { CGRect screen = [[UIScreen mainScreen] bounds]; + NSSet *allTouches = [event allTouches]; - NSArray *twoTouches; - CGPoint currentPosition; - UITouch *touch = [touches anyObject]; + UITouch *touch, *first, *second; - switch ([touches count]) { + switch ([allTouches count]) { case 1: + touch = [[allTouches allObjects] objectAtIndex:0]; + CGPoint currentPosition = [touch locationInView:self.view]; isSingleClick = NO; - currentPosition = [touch locationInView:self.view]; if (HW_isAmmoOpen()) { // saves the point on which to select the ammo pointWhereToClick = currentPosition; @@ -443,9 +454,8 @@ } break; case 2: - twoTouches = [touches allObjects]; - UITouch *first = [twoTouches objectAtIndex:0]; - UITouch *second = [twoTouches objectAtIndex:1]; + first = [[allTouches allObjects] objectAtIndex:0]; + second = [[allTouches allObjects] objectAtIndex:1]; CGFloat currentDistanceOfPinching = distanceBetweenPoints([first locationInView:self.view], [second locationInView:self.view]); const int pinchDelta = 40; diff -r 0db298524c3d -r 33ee433749ba project_files/HedgewarsMobile/Resources/OverlayViewController.xib --- a/project_files/HedgewarsMobile/Resources/OverlayViewController.xib Sun Jul 11 03:23:26 2010 +0200 +++ b/project_files/HedgewarsMobile/Resources/OverlayViewController.xib Sun Jul 11 18:39:01 2010 +0200 @@ -42,6 +42,40 @@ 274 YES + + + 268 + {{0, 175}, {164, 145}} + + + 3 + MQA + + 2 + + + NO + NO + 0.0 + NO + IBCocoaTouchFramework + + + + 265 + {{337, 193}, {143, 127}} + + + 3 + MQA + + + NO + NO + 0.0 + NO + IBCocoaTouchFramework + 268 @@ -596,6 +630,8 @@ + + @@ -662,6 +698,18 @@ + + 71 + + + safezoneleft + + + 72 + + + safezoneright + @@ -681,6 +729,8 @@ 53.IBPluginDependency 58.IBPluginDependency 67.IBPluginDependency + 71.IBPluginDependency + 72.IBPluginDependency YES @@ -697,6 +747,8 @@ com.apple.InterfaceBuilder.IBCocoaTouchPlugin com.apple.InterfaceBuilder.IBCocoaTouchPlugin com.apple.InterfaceBuilder.IBCocoaTouchPlugin + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + com.apple.InterfaceBuilder.IBCocoaTouchPlugin @@ -715,7 +767,7 @@ - 69 + 72