# HG changeset patch # User koda # Date 1278780167 -7200 # Node ID 38d3e31556d3c5f47e6f2630e2a6b11e15177b33 # Parent 93d260c96635c6bec8b8889ce3d5ec312fe40b17 improvements to touch interface (tap to select weap, don't move camera for spourious taps, ask for confirmation when using click-weapons) diff -r 93d260c96635 -r 38d3e31556d3 hedgewars/PascalExports.pas --- a/hedgewars/PascalExports.pas Sat Jul 10 15:39:07 2010 +0200 +++ b/hedgewars/PascalExports.pas Sat Jul 10 18:42:47 2010 +0200 @@ -20,6 +20,8 @@ implementation {$IFDEF HWLIBRARY} +var xx, yy: LongInt; + // retrieve protocol information procedure HW_versionInfo(netProto: PShortInt; versionStr: Ppchar); cdecl; export; begin @@ -174,6 +176,18 @@ CursorPoint.Y:= y; end; +procedure HW_saveCursor(reset: boolean); cdecl; export; +begin + if reset then + begin + CursorPoint.X:= xx; + CursorPoint.Y:= yy; + end + else + xx:= CursorPoint.X; + yy:= CursorPoint.Y; +end; + function HW_isAmmoOpen:boolean; cdecl; export; begin exit(bShowAmmoMenu); diff -r 93d260c96635 -r 38d3e31556d3 project_files/HedgewarsMobile/Classes/GameConfigViewController.m --- a/project_files/HedgewarsMobile/Classes/GameConfigViewController.m Sat Jul 10 15:39:07 2010 +0200 +++ b/project_files/HedgewarsMobile/Classes/GameConfigViewController.m Sat Jul 10 18:42:47 2010 +0200 @@ -162,6 +162,7 @@ } else { DLog(@"gameconfig data not complete!!\nmapConfigViewController = %@\nteamConfigViewController = %@\nschemeWeaponConfigViewController = %@\n", mapConfigViewController, teamConfigViewController, schemeWeaponConfigViewController); + [self.parentViewController dismissModalViewControllerAnimated:YES]; } } diff -r 93d260c96635 -r 38d3e31556d3 project_files/HedgewarsMobile/Classes/OverlayViewController.h --- a/project_files/HedgewarsMobile/Classes/OverlayViewController.h Sat Jul 10 15:39:07 2010 +0200 +++ b/project_files/HedgewarsMobile/Classes/OverlayViewController.h Sat Jul 10 18:42:47 2010 +0200 @@ -19,7 +19,10 @@ PopoverMenuViewController *popupMenu; BOOL isPopoverVisible; + // touch section + BOOL isSingleClick; CGFloat initialDistanceForPinching; + CGPoint pointWhereToClick; } @property (nonatomic,retain) id popoverController; diff -r 93d260c96635 -r 38d3e31556d3 project_files/HedgewarsMobile/Classes/OverlayViewController.m --- a/project_files/HedgewarsMobile/Classes/OverlayViewController.m Sat Jul 10 15:39:07 2010 +0200 +++ b/project_files/HedgewarsMobile/Classes/OverlayViewController.m Sat Jul 10 18:42:47 2010 +0200 @@ -355,8 +355,13 @@ 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)); - HW_setCursor(HWX(currentPosition.x), HWY(currentPosition.y)); + //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; @@ -374,9 +379,40 @@ } -(void) touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event { - initialDistanceForPinching = 0; + CGRect screen = [[UIScreen mainScreen] bounds]; //HW_allKeysUp(); - HW_click(); + 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 { + // TODO: only do this if the weapon does require a further click + // if no click, then ask for tapping again + 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]; + } + + pointWhereToClick = CGPointZero; + initialDistanceForPinching = 0; + isSingleClick = NO; } -(void) touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event { @@ -393,10 +429,15 @@ switch ([touches count]) { case 1: + isSingleClick = NO; + currentPosition = [touch locationInView:self.view]; if (HW_isAmmoOpen()) { - currentPosition = [touch locationInView:self.view]; DLog(@"X:%d Y:%d", HWX(currentPosition.x), HWY(currentPosition.y)); HW_setCursor(HWX(currentPosition.x), HWY(currentPosition.y)); + pointWhereToClick = currentPosition; + } else { + DLog(@"x: %f y: %f -> X:%d Y:%d", currentPosition.x, currentPosition.y, HWX(currentPosition.x), HWY(currentPosition.y)); + HW_setCursor(HWX(currentPosition.x), HWY(currentPosition.y)); } break; case 2: diff -r 93d260c96635 -r 38d3e31556d3 project_files/HedgewarsMobile/Classes/PascalImports.h --- a/project_files/HedgewarsMobile/Classes/PascalImports.h Sat Jul 10 15:39:07 2010 +0200 +++ b/project_files/HedgewarsMobile/Classes/PascalImports.h Sat Jul 10 18:42:47 2010 +0200 @@ -55,6 +55,7 @@ void HW_setLandscape(BOOL); void HW_setCursor(int x, int y); + void HW_saveCursor(BOOL reset); BOOL HW_isAmmoOpen(void); #ifdef __cplusplus } diff -r 93d260c96635 -r 38d3e31556d3 project_files/HedgewarsMobile/Hedgewars.xcodeproj/project.pbxproj --- a/project_files/HedgewarsMobile/Hedgewars.xcodeproj/project.pbxproj Sat Jul 10 15:39:07 2010 +0200 +++ b/project_files/HedgewarsMobile/Hedgewars.xcodeproj/project.pbxproj Sat Jul 10 18:42:47 2010 +0200 @@ -119,6 +119,7 @@ 61799289114AE08700BA94A9 /* Data in Resources */ = {isa = PBXBuildFile; fileRef = 61798A5E114AE08600BA94A9 /* Data */; }; 6183D83E11E2BCE200A88903 /* LI-ipad-Landscape.png in Resources */ = {isa = PBXBuildFile; fileRef = 6183D83C11E2BCE200A88903 /* LI-ipad-Landscape.png */; }; 6183D83F11E2BCE200A88903 /* LI-iphone-Landscape.png in Resources */ = {isa = PBXBuildFile; fileRef = 6183D83D11E2BCE200A88903 /* LI-iphone-Landscape.png */; }; + 619C09EA11E8B8D600F1DF16 /* title_small.png in Resources */ = {isa = PBXBuildFile; fileRef = 619C09E911E8B8D600F1DF16 /* title_small.png */; }; 61A1188511683A8C00359010 /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 61A117FE1168322700359010 /* CoreGraphics.framework */; }; 61A118D311683CD100359010 /* HedgewarsTitle.png in Resources */ = {isa = PBXBuildFile; fileRef = 611FD9CB1155A28C00C2203D /* HedgewarsTitle.png */; }; 61C3255B1179A384001E70B1 /* OpenAL.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 61C3255A1179A384001E70B1 /* OpenAL.framework */; }; @@ -378,6 +379,7 @@ 6183D83C11E2BCE200A88903 /* LI-ipad-Landscape.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "LI-ipad-Landscape.png"; path = "Resources/Icons/LI-ipad-Landscape.png"; sourceTree = ""; }; 6183D83D11E2BCE200A88903 /* LI-iphone-Landscape.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "LI-iphone-Landscape.png"; path = "Resources/Icons/LI-iphone-Landscape.png"; sourceTree = ""; }; 618736B8118CA28600123B23 /* GearDrawing.inc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.pascal; name = GearDrawing.inc; path = ../../hedgewars/GearDrawing.inc; sourceTree = SOURCE_ROOT; }; + 619C09E911E8B8D600F1DF16 /* title_small.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = title_small.png; path = "Resources/Frontend-iPhone/title_small.png"; sourceTree = ""; }; 61A117FE1168322700359010 /* CoreGraphics.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreGraphics.framework; path = System/Library/Frameworks/CoreGraphics.framework; sourceTree = SDKROOT; }; 61C3251D1179A300001E70B1 /* libopenalbridge.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libopenalbridge.a; sourceTree = BUILT_PRODUCTS_DIR; }; 61C3255A1179A384001E70B1 /* OpenAL.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = OpenAL.framework; path = System/Library/Frameworks/OpenAL.framework; sourceTree = SDKROOT; }; @@ -765,6 +767,7 @@ 61F903E311DF584D0068B24D /* Frontend-iPhone */ = { isa = PBXGroup; children = ( + 619C09E911E8B8D600F1DF16 /* title_small.png */, 61F903E411DF58550068B24D /* backgroundBottom.png */, 61F903E511DF58550068B24D /* backgroundCenter.png */, 61F903E611DF58550068B24D /* backgroundLeft.png */, @@ -1052,6 +1055,7 @@ 61F7A43E11E290650040BA66 /* iTunesArtwork.png in Resources */, 6183D83E11E2BCE200A88903 /* LI-ipad-Landscape.png in Resources */, 6183D83F11E2BCE200A88903 /* LI-iphone-Landscape.png in Resources */, + 619C09EA11E8B8D600F1DF16 /* title_small.png in Resources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff -r 93d260c96635 -r 38d3e31556d3 project_files/HedgewarsMobile/Resources/Frontend-iPhone/title.png Binary file project_files/HedgewarsMobile/Resources/Frontend-iPhone/title.png has changed diff -r 93d260c96635 -r 38d3e31556d3 project_files/HedgewarsMobile/Resources/Frontend-iPhone/title_small.png Binary file project_files/HedgewarsMobile/Resources/Frontend-iPhone/title_small.png has changed diff -r 93d260c96635 -r 38d3e31556d3 project_files/HedgewarsMobile/Resources/MainMenuViewController-iPhone.xib --- a/project_files/HedgewarsMobile/Resources/MainMenuViewController-iPhone.xib Sat Jul 10 15:39:07 2010 +0200 +++ b/project_files/HedgewarsMobile/Resources/MainMenuViewController-iPhone.xib Sat Jul 10 18:42:47 2010 +0200 @@ -12,6 +12,7 @@ YES + YES @@ -46,7 +47,6 @@ 274 {{0, 21}, {480, 278}} - 3 MCAwAA @@ -62,9 +62,8 @@ 293 - {{121, 25}, {240, 52}} + {{118, 25}, {240, 52}} - NO NO 4 @@ -72,7 +71,7 @@ IBCocoaTouchFramework NSImage - title.png + title_small.png @@ -80,7 +79,6 @@ 289 {{240, 102}, {220, 52}} - 1 MCAwIDAgMAA @@ -117,7 +115,6 @@ 265 {{240, 177}, {220, 52}} - 1 MCAwIDAgMAA @@ -145,7 +142,6 @@ 260 {{12, 144}, {220, 52}} - 1 MCAwIDAgMAA @@ -173,7 +169,6 @@ 292 {{37, 102}, {168, 21}} - NO YES NO @@ -198,7 +193,6 @@ 269 {{209, 237}, {59, 52}} - NO NO 2 @@ -222,7 +216,6 @@ 290 {480, 17} - NO NO 4 @@ -238,7 +231,6 @@ 266 {{0, 297}, {480, 23}} - NO NO 4 @@ -254,7 +246,6 @@ 292 {{20, 270}, {18, 19}} - NO 3 IBCocoaTouchFramework @@ -273,7 +264,6 @@ {480, 320} - 1 MCAwIDAAA @@ -366,13 +356,13 @@ - + @@ -793,7 +783,7 @@ playButton.png settingsButton.png storeButton.png - title.png + title_small.png YES @@ -802,7 +792,7 @@ {480, 21} {217, 51} {216, 51} - {57, 51} + {61, 59} {216, 51} {262, 84}