Show icon above hedgehog for most ammos without hand image
authorWuzzy <Wuzzy2@mail.ru>
Fri, 17 May 2019 22:57:22 +0200
changeset 15000 e796e9a88394
parent 14999 d9de740e194c
child 15001 7ff86274114e
Show icon above hedgehog for most ammos without hand image
hedgewars/uConsts.pas
hedgewars/uGearsRender.pas
hedgewars/uVariables.pas
--- a/hedgewars/uConsts.pas	Fri May 17 22:23:40 2019 +0200
+++ b/hedgewars/uConsts.pas	Fri May 17 22:57:22 2019 +0200
@@ -338,6 +338,7 @@
     ammoprop_ForceTurnEnd = $00200000; // always ends turn after usage, ignoring inf. attack
     ammoprop_NoTargetAfter= $00400000; // disable target selection after attack
     ammoprop_NoWrapTarget = $00800000; // allow to select target beyond wrap world edge limits
+    ammoprop_ShowSelIcon  = $01000000; // show icon when selected
     ammoprop_NoRoundEnd   = $10000000; // ammo doesn't end turn
 
     AMMO_INFINITE = 100;               // internal representation of infinite ammo count
--- a/hedgewars/uGearsRender.pas	Fri May 17 22:23:40 2019 +0200
+++ b/hedgewars/uGearsRender.pas	Fri May 17 22:57:22 2019 +0200
@@ -207,12 +207,23 @@
 end;
 
 
-procedure DrawAltWeapon(Gear: PGear; sx, sy: LongInt);
+procedure DrawSelectedWeapon(Gear: PGear; sx, sy: LongInt; isAltWeapon: boolean);
 begin
 with Gear^.Hedgehog^ do
     begin
-    if not (((Ammoz[CurAmmoType].Ammo.Propz and ammoprop_AltUse) <> 0) and ((Gear^.State and gstAttacked) = 0)) then
+    if ((Gear^.State and gstAttacked) <> 0) then
+        exit;
+    if (isAltWeapon and ((Ammoz[CurAmmoType].Ammo.Propz and ammoprop_AltUse) = 0)) then
+        exit;
+    if (not isAltWeapon) and (((Ammoz[CurAmmoType].Ammo.Propz and ammoprop_ShowSelIcon) = 0) or (
+            (((Ammoz[CurAmmoType].Ammo.Propz and ammoprop_AttackInMove) = 0) and ((Gear^.State and gstMoving) <> 0)))) then
         exit;
+    if (not isAltWeapon) then
+        begin
+        sy:= sy - 64;
+        if (IsHogFacingLeft(Gear)) then
+            sx:= sx - 61;
+        end;
     DrawTexture(sx + 16, sy + 16, ropeIconTex);
     DrawTextureF(SpritesData[sprAMAmmos].Texture, 0.75, sx + 30, sy + 30, ord(CurAmmoType) - 1, 1, 32, 32);
     end;
@@ -342,10 +353,10 @@
                                 DrawSprite(sprJetpack, sx-32, sy-32, 4);
                             if CurAmmoGear^.Tex <> nil then
                                 DrawTextureCentered(sx, sy - 40, CurAmmoGear^.Tex);
-                            DrawAltWeapon(Gear, sx, sy);
+                            DrawSelectedWeapon(Gear, sx, sy, true);
                             end;
-            gtRope:         DrawAltWeapon(Gear, sx, sy);
-            gtParachute:    DrawAltWeapon(Gear, sx, sy);
+            gtRope:         DrawSelectedWeapon(Gear, sx, sy, true);
+            gtParachute:    DrawSelectedWeapon(Gear, sx, sy, true);
             gtLandGun:      if CurAmmoGear^.Tex <> nil then
                                 DrawTextureCentered(sx, sy - 40, CurAmmoGear^.Tex);
             gtFlamethrower: if CurAmmoGear^.Tex <> nil then
@@ -353,7 +364,11 @@
             gtIceGun:       if CurAmmoGear^.Tex <> nil then
                                 DrawTextureCentered(sx, sy - 40, CurAmmoGear^.Tex);
         end;
-        end;
+        end
+    else if ((Gear^.State and gstHHDriven) <> 0) then
+        begin
+        DrawSelectedWeapon(Gear, sx, sy, false);
+        end
 end;
 
 procedure DrawHH(Gear: PGear; ox, oy: LongInt);
--- a/hedgewars/uVariables.pas	Fri May 17 22:23:40 2019 +0200
+++ b/hedgewars/uVariables.pas	Fri May 17 22:57:22 2019 +0200
@@ -1295,6 +1295,7 @@
                           ammoprop_DontHold or
                           ammoprop_Utility or
                           ammoprop_AltAttack or
+                          ammoprop_ShowSelIcon or
                           ammoprop_NeedUpDown;
                 Count: 2;
                 NumPerTurn: 0;
@@ -1462,6 +1463,7 @@
                           ammoprop_ForwMsgs or
                           ammoprop_NoCrosshair or
                           ammoprop_Utility or
+                          ammoprop_ShowSelIcon or
                           ammoprop_DontHold;
                     Count: 3;
                     NumPerTurn: 0;
@@ -1755,6 +1757,7 @@
                           ammoprop_NoCrosshair or
                           ammoprop_DontHold or
                           ammoprop_AltUse or
+                          ammoprop_ShowSelIcon or
                           ammoprop_Utility or
                           ammoprop_Effect;
                     Count: 1;
@@ -1784,6 +1787,7 @@
                           ammoprop_NoCrosshair or
                           ammoprop_DontHold or
                           ammoprop_AltUse or
+                          ammoprop_ShowSelIcon or
                           ammoprop_Utility or
                           ammoprop_Effect;
                     Count: 1;
@@ -1813,6 +1817,7 @@
                           ammoprop_NoCrosshair or
                           ammoprop_DontHold or
                           ammoprop_AltUse or
+                          ammoprop_ShowSelIcon or
                           ammoprop_Utility or
                           ammoprop_Effect;
                     Count: 1;
@@ -1842,6 +1847,7 @@
                           ammoprop_NoCrosshair or
                           ammoprop_DontHold or
                           ammoprop_AltUse or
+                          ammoprop_ShowSelIcon or
                           ammoprop_Utility or
                           ammoprop_Effect;
                     Count: 1;
@@ -1871,6 +1877,7 @@
                           ammoprop_NoCrosshair or
                           ammoprop_DontHold or
                           ammoprop_AltUse or
+                          ammoprop_ShowSelIcon or
                           ammoprop_Utility or
                           ammoprop_NeedUpDown or
                           ammoprop_Effect;
@@ -1959,6 +1966,7 @@
                           ammoprop_DontHold or
                           ammoprop_Utility or
                           ammoprop_NeedUpDown or
+                          ammoprop_ShowSelIcon or
                           ammoprop_AltAttack;
                 Count: 1;
                 NumPerTurn: 0;
@@ -2012,6 +2020,7 @@
             Ammo: (Propz: ammoprop_ForwMsgs or
                           ammoprop_NoCrosshair or
                           ammoprop_NeedUpDown or
+                          ammoprop_ShowSelIcon or
                           ammoprop_DontHold;
                 Count: 1;
                 NumPerTurn: 0;
@@ -2309,6 +2318,7 @@
             Ammo: (Propz: ammoprop_ForwMsgs or
                           ammoprop_NoCrosshair or
                           ammoprop_Utility or
+                          ammoprop_ShowSelIcon or
                           ammoprop_DontHold or
                           ammoprop_ForceTurnEnd;
                 Count: 2;