Simplify ammo menu conditions so it shows up in more states. Should fix issue #465. The part w/ sliding in uworld is main #465 problem.
authornemo
Sun, 04 Nov 2012 17:47:44 -0500
changeset 7964 d00378a37dde
parent 7960 99d5af6997dd
child 7968 be4503361ead
Simplify ammo menu conditions so it shows up in more states. Should fix issue #465. The part w/ sliding in uworld is main #465 problem.
hedgewars/uCommandHandlers.pas
hedgewars/uInputHandler.pas
hedgewars/uVariables.pas
hedgewars/uWorld.pas
--- a/hedgewars/uCommandHandlers.pas	Sun Nov 04 17:27:54 2012 -0500
+++ b/hedgewars/uCommandHandlers.pas	Sun Nov 04 17:47:44 2012 -0500
@@ -598,9 +598,9 @@
 
             if bShowAmmoMenu then
                 bShowAmmoMenu:= false
-            else if ((Gear^.State and (gstAttacking or gstAttacked)) <> 0)
+            else if not(CurrentTeam^.Extdriven) and (((Gear^.State and (gstAttacking or gstAttacked)) <> 0)
             or ((MultiShootAttacks > 0) and ((Ammoz[CurAmmoType].Ammo.Propz and ammoprop_NoRoundEnd) = 0))
-            or ((Gear^.State and gstHHDriven) = 0) then
+            or ((Gear^.State and gstHHDriven) = 0)) then
                 begin
                 end
             else
--- a/hedgewars/uInputHandler.pas	Sun Nov 04 17:27:54 2012 -0500
+++ b/hedgewars/uInputHandler.pas	Sun Nov 04 17:47:44 2012 -0500
@@ -121,7 +121,6 @@
 if not(tkbd[code] xor KeyDown) then exit;
 tkbd[code]:= KeyDown;
 
-hideAmmoMenu:= false;
 Trusted:= (CurrentTeam <> nil)
           and (not CurrentTeam^.ExtDriven)
           and (CurrentHedgehog^.BotLevel = 0);
@@ -155,7 +154,7 @@
 
 if CurrentBinds[code][0] <> #0 then
     begin
-    if (code > 3) and KeyDown and (not ((CurrentBinds[code] = 'put')) or (CurrentBinds[code] = 'ammomenu') or (CurrentBinds[code] = '+cur_u') or (CurrentBinds[code] = '+cur_d') or (CurrentBinds[code] = '+cur_l') or (CurrentBinds[code] = '+cur_r')) then hideAmmoMenu:= true;
+    if (code > 3) and KeyDown and (not ((CurrentBinds[code] = 'put')) or (CurrentBinds[code] = 'ammomenu') or (CurrentBinds[code] = '+cur_u') or (CurrentBinds[code] = '+cur_d') or (CurrentBinds[code] = '+cur_l') or (CurrentBinds[code] = '+cur_r')) and (CurrentTeam <> nil) and (not CurrentTeam^.ExtDriven) then bShowAmmoMenu:= false;
 
     if KeyDown then
         begin
--- a/hedgewars/uVariables.pas	Sun Nov 04 17:27:54 2012 -0500
+++ b/hedgewars/uVariables.pas	Sun Nov 04 17:47:44 2012 -0500
@@ -2509,8 +2509,6 @@
     vobSDFrameTicks, vobSDFramesCount, vobSDCount: Longword;
     vobSDVelocity, vobSDFallSpeed: LongInt;
 
-    hideAmmoMenu: boolean;
-
     ControllerNumControllers: Integer;
     ControllerEnabled: Integer;
     ControllerNumAxes: array[0..5] of Integer;
--- a/hedgewars/uWorld.pas	Sun Nov 04 17:27:54 2012 -0500
+++ b/hedgewars/uWorld.pas	Sun Nov 04 17:47:44 2012 -0500
@@ -511,9 +511,7 @@
     Ammo: PHHAmmo;
     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
-    bShowAmmoMenu:= false;
+if TurnTimeLeft = 0 then bShowAmmoMenu:= false;
 
 // give the assigned ammo to hedgehog
 Ammo:= nil;
@@ -552,16 +550,19 @@
         AmmoRect.x:= (cScreenWidth shr 1) - AmmoRect.w - AMSlotSize;
         AmmoRect.y:= cScreenHeight - (AmmoRect.h + AMSlotSize);
 {$ENDIF}
-    AMShiftTargetX:= (cScreenWidth shr 1) - AmmoRect.x;
-    AMShiftTargetY:= cScreenHeight        - AmmoRect.y;
+    if AMState <> AMShowing then
+        begin
+        AMShiftTargetX:= (cScreenWidth shr 1) - AmmoRect.x;
+        AMShiftTargetY:= cScreenHeight        - AmmoRect.y;
 
-    if (AMAnimType and AMTypeMaskX) <> 0 then AMShiftTargetX:= (cScreenWidth shr 1) - AmmoRect.x
-    else AMShiftTargetX:= 0;
-    if (AMAnimType and AMTypeMaskY) <> 0 then AMShiftTargetY:= cScreenHeight        - AmmoRect.y
-    else AMShiftTargetY:= 0;
+        if (AMAnimType and AMTypeMaskX) <> 0 then AMShiftTargetX:= (cScreenWidth shr 1) - AmmoRect.x
+        else AMShiftTargetX:= 0;
+        if (AMAnimType and AMTypeMaskY) <> 0 then AMShiftTargetY:= cScreenHeight        - AmmoRect.y
+        else AMShiftTargetY:= 0;
 
-    AMShiftX:= AMShiftTargetX;
-    AMShiftY:= AMShiftTargetY;
+        AMShiftX:= AMShiftTargetX;
+        AMShiftY:= AMShiftTargetY
+        end
 end;
 
 AMAnimState:= (RealTicks - AMAnimStartTime) / AMAnimDuration;