prevent the cursor from being shown on the mobile version, and close the menu on tap when the tap is not on the ammo menu
authorXeli
Tue, 07 Feb 2012 18:56:49 +0100
changeset 6648 025473a2c420
parent 6647 26e523c8fe88
child 6649 7f78e8a6db69
prevent the cursor from being shown on the mobile version, and close the menu on tap when the tap is not on the ammo menu
hedgewars/uTouch.pas
hedgewars/uVariables.pas
hedgewars/uWorld.pas
--- a/hedgewars/uTouch.pas	Mon Feb 06 22:59:28 2012 -0500
+++ b/hedgewars/uTouch.pas	Tue Feb 07 18:56:49 2012 +0100
@@ -103,12 +103,7 @@
 case pointerCount of
         1:
         begin
-            moveCursor:= false;
-            if bShowAmmoMenu then
-            begin
-                moveCursor := true;
-                exit;
-            end;
+            moveCursor:= not bShowAmmoMenu;
 
             if isOnCrosshair(finger^) then
             begin
@@ -157,9 +152,6 @@
                 ParseCommand('ljump', true);
                 exit;
             end;
-
-          
-            moveCursor:= true; 
         end;
         2:
         begin
@@ -272,14 +264,20 @@
 yTouchClick:= finger.y;
 timeSinceClick:= SDL_GetTicks;
 
-if bShowAmmoMenu then 
-    begin
-    CursorPoint.X:= finger.x;
-    CursorPoint.Y:= finger.y;
-    doPut(CursorPoint.X, CursorPoint.Y, false); 
-    exit
+if bShowAmmoMenu then
+    begin 
+    if isOnRect(AmmoRect.x, AmmoRect.y, AmmoRect.w, AmmoRect.h, finger) then
+        begin
+        CursorPoint.X:= finger.x;
+        CursorPoint.Y:= finger.y;
+        doPut(CursorPoint.X, CursorPoint.Y, false); 
+        end
+    else
+        bShowAmmoMenu:= false;
+    exit;
     end;
 
+
 if isOnCurrentHog(finger) then
     begin
     bShowAmmoMenu := true;
--- a/hedgewars/uVariables.pas	Mon Feb 06 22:59:28 2012 -0500
+++ b/hedgewars/uVariables.pas	Tue Feb 07 18:56:49 2012 +0100
@@ -155,6 +155,7 @@
     WeaponTooltipTex: PTexture;
     AmmoMenuTex     : PTexture;
     AmmoMenuInvalidated: boolean;
+    AmmoRect: TSDL_Rect;
     HHTexture       : PTexture;
 
 
--- a/hedgewars/uWorld.pas	Mon Feb 06 22:59:28 2012 -0500
+++ b/hedgewars/uWorld.pas	Tue Feb 07 18:56:49 2012 +0100
@@ -65,7 +65,6 @@
     tmpSurface: PSDL_Surface;
     fpsTexture: PTexture;
     timeTexture: PTexture;
-    AmmoRect: TSDL_Rect;
     MenuSpeedX, MenuSpeedY: LongInt;
     FPS: Longword;
     CountTicks: Longword;
@@ -360,7 +359,7 @@
       MENUSPEED = 15;
 var Slot, Pos: LongInt;
     Ammo: PHHAmmo;
-    c,i,g,t,CursorXtmp, CursorYtmp,STurns: LongInt;
+    c,i,g,t,STurns: LongInt;
 begin
 if (TurnTimeLeft = 0) or (not CurrentTeam^.ExtDriven and (((CurAmmoGear = nil)
 or ((Ammoz[CurAmmoGear^.AmmoType].Ammo.Propz and ammoprop_AltAttack) = 0)) and hideAmmoMenu)) then
@@ -423,12 +422,6 @@
 if bShowAmmoMenu then // show ammo menu
     begin
     FollowGear:= nil;
-    if (AMShiftX = 0) and (AMShiftY = 0) then
-{$IFDEF MOBILE}
-        prevPoint.Y:= 0;
-{$ELSE}
-        prevPoint.X:= 0;
-{$ENDIF}
     if (cReducedQuality and rqSlowMenu) <> 0 then
         begin
         AMShiftX:= 0;
@@ -441,6 +434,11 @@
             if AMShiftX < 0 then AMShiftX:= 0;
             dec(AMShiftY, MenuSpeedY);
             if AMShiftY < 0 then AMShiftY:= 0;
+            if (AMShiftX = 0) and (AMShiftY = 0) then
+                begin
+                CursorPoint.X:= AmmoRect.x + AmmoRect.w;
+                CursorPoint.Y:= AmmoRect.y;
+                end;
             end
     end
 else  // hide ammo menu
@@ -561,8 +559,10 @@
 {$ENDIF}
 
     bSelected:= false;
-    if (AMShiftX = 0) and (AMShiftY = 0) then
+{$IFNDEF MOBILE}
+   if (AMShiftX = 0) and (AMShiftY = 0) then
         DrawSprite(sprArrow, CursorPoint.X, cScreenHeight - CursorPoint.Y, (RealTicks shr 6) mod 8);
+{$ENDIF}
 end;
 
 procedure DrawWater(Alpha: byte; OffsetY: LongInt);
@@ -927,7 +927,6 @@
     highlight: Boolean;
     smallScreenOffset, offsetX, offsetY, screenBottom: LongInt;
     VertexBuffer: array [0..3] of TVertex2f;
-    scale: GLFloat;
 begin
 if (cReducedQuality and rqNoBackground) = 0 then
     begin