improvements to touch interface (tap to select weap, don't move camera for spourious taps, ask for confirmation when using click-weapons)
authorkoda
Sat, 10 Jul 2010 18:42:47 +0200
changeset 3635 38d3e31556d3
parent 3634 93d260c96635
child 3636 c0d82112f479
improvements to touch interface (tap to select weap, don't move camera for spourious taps, ask for confirmation when using click-weapons)
hedgewars/PascalExports.pas
project_files/HedgewarsMobile/Classes/GameConfigViewController.m
project_files/HedgewarsMobile/Classes/OverlayViewController.h
project_files/HedgewarsMobile/Classes/OverlayViewController.m
project_files/HedgewarsMobile/Classes/PascalImports.h
project_files/HedgewarsMobile/Hedgewars.xcodeproj/project.pbxproj
project_files/HedgewarsMobile/Resources/Frontend-iPhone/title.png
project_files/HedgewarsMobile/Resources/Frontend-iPhone/title_small.png
project_files/HedgewarsMobile/Resources/MainMenuViewController-iPhone.xib
--- 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);
--- 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];
     }
 
 }
--- 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;
--- 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:
--- 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
 }
--- 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 = "<group>"; };
 		6183D83D11E2BCE200A88903 /* LI-iphone-Landscape.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "LI-iphone-Landscape.png"; path = "Resources/Icons/LI-iphone-Landscape.png"; sourceTree = "<group>"; };
 		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 = "<group>"; };
 		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;
 		};
Binary file project_files/HedgewarsMobile/Resources/Frontend-iPhone/title.png has changed
Binary file project_files/HedgewarsMobile/Resources/Frontend-iPhone/title_small.png has changed
--- 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 @@
 		</object>
 		<object class="NSMutableArray" key="IBDocument.EditedObjectIDs">
 			<bool key="EncodedWithXMLCoder">YES</bool>
+			<integer value="1"/>
 		</object>
 		<object class="NSArray" key="IBDocument.PluginDependencies">
 			<bool key="EncodedWithXMLCoder">YES</bool>
@@ -46,7 +47,6 @@
 						<int key="NSvFlags">274</int>
 						<string key="NSFrame">{{0, 21}, {480, 278}}</string>
 						<reference key="NSSuperview" ref="191373211"/>
-						<reference key="NSWindow"/>
 						<object class="NSColor" key="IBUIBackgroundColor">
 							<int key="NSColorSpace">3</int>
 							<bytes key="NSWhite">MCAwAA</bytes>
@@ -62,9 +62,8 @@
 					<object class="IBUIImageView" id="171108356">
 						<reference key="NSNextResponder" ref="191373211"/>
 						<int key="NSvFlags">293</int>
-						<string key="NSFrame">{{121, 25}, {240, 52}}</string>
+						<string key="NSFrame">{{118, 25}, {240, 52}}</string>
 						<reference key="NSSuperview" ref="191373211"/>
-						<reference key="NSWindow"/>
 						<bool key="IBUIOpaque">NO</bool>
 						<bool key="IBUIClearsContextBeforeDrawing">NO</bool>
 						<int key="IBUIContentMode">4</int>
@@ -72,7 +71,7 @@
 						<string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
 						<object class="NSCustomResource" key="IBUIImage">
 							<string key="NSClassName">NSImage</string>
-							<string key="NSResourceName">title.png</string>
+							<string key="NSResourceName">title_small.png</string>
 						</object>
 					</object>
 					<object class="IBUIButton" id="124270424">
@@ -80,7 +79,6 @@
 						<int key="NSvFlags">289</int>
 						<string key="NSFrame">{{240, 102}, {220, 52}}</string>
 						<reference key="NSSuperview" ref="191373211"/>
-						<reference key="NSWindow"/>
 						<object class="NSColor" key="IBUIBackgroundColor">
 							<int key="NSColorSpace">1</int>
 							<bytes key="NSRGB">MCAwIDAgMAA</bytes>
@@ -117,7 +115,6 @@
 						<int key="NSvFlags">265</int>
 						<string key="NSFrame">{{240, 177}, {220, 52}}</string>
 						<reference key="NSSuperview" ref="191373211"/>
-						<reference key="NSWindow"/>
 						<object class="NSColor" key="IBUIBackgroundColor">
 							<int key="NSColorSpace">1</int>
 							<bytes key="NSRGB">MCAwIDAgMAA</bytes>
@@ -145,7 +142,6 @@
 						<int key="NSvFlags">260</int>
 						<string key="NSFrame">{{12, 144}, {220, 52}}</string>
 						<reference key="NSSuperview" ref="191373211"/>
-						<reference key="NSWindow"/>
 						<object class="NSColor" key="IBUIBackgroundColor">
 							<int key="NSColorSpace">1</int>
 							<bytes key="NSRGB">MCAwIDAgMAA</bytes>
@@ -173,7 +169,6 @@
 						<int key="NSvFlags">292</int>
 						<string key="NSFrame">{{37, 102}, {168, 21}}</string>
 						<reference key="NSSuperview" ref="191373211"/>
-						<reference key="NSWindow"/>
 						<bool key="IBUIOpaque">NO</bool>
 						<bool key="IBUIClipsSubviews">YES</bool>
 						<bool key="IBUIUserInteractionEnabled">NO</bool>
@@ -198,7 +193,6 @@
 						<int key="NSvFlags">269</int>
 						<string key="NSFrame">{{209, 237}, {59, 52}}</string>
 						<reference key="NSSuperview" ref="191373211"/>
-						<reference key="NSWindow"/>
 						<bool key="IBUIOpaque">NO</bool>
 						<bool key="IBUIClearsContextBeforeDrawing">NO</bool>
 						<int key="IBUITag">2</int>
@@ -222,7 +216,6 @@
 						<int key="NSvFlags">290</int>
 						<string key="NSFrameSize">{480, 17}</string>
 						<reference key="NSSuperview" ref="191373211"/>
-						<reference key="NSWindow"/>
 						<bool key="IBUIOpaque">NO</bool>
 						<bool key="IBUIClearsContextBeforeDrawing">NO</bool>
 						<int key="IBUIContentMode">4</int>
@@ -238,7 +231,6 @@
 						<int key="NSvFlags">266</int>
 						<string key="NSFrame">{{0, 297}, {480, 23}}</string>
 						<reference key="NSSuperview" ref="191373211"/>
-						<reference key="NSWindow"/>
 						<bool key="IBUIOpaque">NO</bool>
 						<bool key="IBUIClearsContextBeforeDrawing">NO</bool>
 						<int key="IBUIContentMode">4</int>
@@ -254,7 +246,6 @@
 						<int key="NSvFlags">292</int>
 						<string key="NSFrame">{{20, 270}, {18, 19}}</string>
 						<reference key="NSSuperview" ref="191373211"/>
-						<reference key="NSWindow"/>
 						<bool key="IBUIOpaque">NO</bool>
 						<int key="IBUITag">3</int>
 						<string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
@@ -273,7 +264,6 @@
 				</object>
 				<string key="NSFrameSize">{480, 320}</string>
 				<reference key="NSSuperview"/>
-				<reference key="NSWindow"/>
 				<object class="NSColor" key="IBUIBackgroundColor">
 					<int key="NSColorSpace">1</int>
 					<bytes key="NSRGB">MCAwIDAAA</bytes>
@@ -366,13 +356,13 @@
 							<reference ref="249993817"/>
 							<reference ref="533529472"/>
 							<reference ref="821240857"/>
-							<reference ref="171108356"/>
 							<reference ref="936485487"/>
 							<reference ref="753723574"/>
 							<reference ref="124270424"/>
 							<reference ref="745970938"/>
 							<reference ref="836337039"/>
 							<reference ref="818907840"/>
+							<reference ref="171108356"/>
 						</object>
 						<reference key="parent" ref="0"/>
 					</object>
@@ -793,7 +783,7 @@
 				<string>playButton.png</string>
 				<string>settingsButton.png</string>
 				<string>storeButton.png</string>
-				<string>title.png</string>
+				<string>title_small.png</string>
 			</object>
 			<object class="NSMutableArray" key="dict.values">
 				<bool key="EncodedWithXMLCoder">YES</bool>
@@ -802,7 +792,7 @@
 				<string>{480, 21}</string>
 				<string>{217, 51}</string>
 				<string>{216, 51}</string>
-				<string>{57, 51}</string>
+				<string>{61, 59}</string>
 				<string>{216, 51}</string>
 				<string>{262, 84}</string>
 			</object>