Initialize cursor position properly when opening ammo menu, prevent "jumping"
authorWuzzy <Wuzzy2@mail.ru>
Fri, 24 May 2019 21:23:36 +0200
changeset 15046 f764394839b2
parent 15045 0dbd06bf90f4
child 15047 586ebee9de41
Initialize cursor position properly when opening ammo menu, prevent "jumping"
hedgewars/uWorld.pas
--- a/hedgewars/uWorld.pas	Fri May 24 19:44:49 2019 +0200
+++ b/hedgewars/uWorld.pas	Fri May 24 21:23:36 2019 +0200
@@ -116,6 +116,22 @@
 {$ENDIF}
       AMSlotPadding = (AMSlotSize - 32) shr 1;
 
+{$IFDEF USE_LANDSCAPE_AMMOMENU}
+      amNumOffsetX = 0;
+      {$IFDEF USE_AM_NUMCOLUMN}
+      amNumOffsetY = AMSlotSize;
+      {$ELSE}
+      amNumOffsetY = 0;
+      {$ENDIF}
+{$ELSE}
+      amNumOffsetY = 0;
+      {$IFDEF USE_AM_NUMCOLUMN}
+      amNumOffsetX = AMSlotSize;
+      {$ELSE}
+      amNumOffsetX = 0;
+      {$ENDIF}
+{$ENDIF}
+
       cSendCursorPosTime = 50;
       cCursorEdgesDist   = 100;
 
@@ -644,6 +660,8 @@
         begin
         AMShiftX:= 0;
         AMShiftY:= 0;
+        CursorPoint.X:= AmmoRect.x + AmmoRect.w - 3;
+        CursorPoint.Y:= cScreenHeight - AmmoRect.y - amNumOffsetY - 1;
         AMState:= AMShowing;
         end
     // "Appear" animation
@@ -659,8 +677,8 @@
             begin
             AMShiftX:= 0;
             AMShiftY:= 0;
-            CursorPoint.X:= AmmoRect.x + AmmoRect.w;
-            CursorPoint.Y:= AmmoRect.y;
+            CursorPoint.X:= AmmoRect.x + AmmoRect.w - 3;
+            CursorPoint.Y:= cScreenHeight - AmmoRect.y - amNumOffsetY - 1;
             AMState:= AMShowing;
             end;
     end;
@@ -671,6 +689,7 @@
         begin
         AMShiftX:= AMShiftTargetX;
         AMShiftY:= AMShiftTargetY;
+        prevPoint:= CursorPoint;
         AMState:= AMHidden;
         end
     // "Disappear" animation
@@ -687,7 +706,6 @@
             AMShiftX:= AMShiftTargetX;
             AMShiftY:= AMShiftTargetY;
             prevPoint:= CursorPoint;
-            //prevTargetPoint:= TargetCursorPoint;
             AMState:= AMHidden;
             end;
     end;
@@ -1974,7 +1992,7 @@
 var PrevSentPointTime: LongWord = 0;
 
 procedure MoveCamera;
-var EdgesDist, wdy, shs,z, amNumOffsetX, amNumOffsetY, dstX: LongInt;
+var EdgesDist, wdy, shs,z, dstX: LongInt;
     inbtwnTrgtAttks: Boolean;
 begin
 {$IFNDEF MOBILE}
@@ -2031,22 +2049,6 @@
 
 if (AMState = AMShowingUp) or (AMState = AMShowing) then
 begin
-{$IFDEF USE_LANDSCAPE_AMMOMENU}
-    amNumOffsetX:= 0;
-    {$IFDEF USE_AM_NUMCOLUMN}
-    amNumOffsetY:= AMSlotSize;
-    {$ELSE}
-    amNumOffsetY:= 0;
-    {$ENDIF}
-{$ELSE}
-    amNumOffsetY:= 0;
-    {$IFDEF USE_AM_NUMCOLUMN}
-    amNumOffsetX:= AMSlotSize;
-    {$ELSE}
-    amNumOffsetX:= 0;
-    {$ENDIF}
-
-{$ENDIF}
     if CursorPoint.X < AmmoRect.x + amNumOffsetX + 3 then//check left
         CursorPoint.X:= AmmoRect.x + amNumOffsetX + 3;
     if CursorPoint.X > AmmoRect.x + AmmoRect.w - 3 then//check right