Render finger only once in wrap
authorWuzzy <Wuzzy2@mail.ru>
Mon, 30 Sep 2019 10:39:58 +0200
changeset 15460 617f4c092e3d
parent 15459 e9fd2527a457
child 15461 c93dfa4ab904
Render finger only once in wrap
hedgewars/uGears.pas
hedgewars/uGearsRender.pas
hedgewars/uWorld.pas
--- a/hedgewars/uGears.pas	Sun Sep 29 22:23:00 2019 +0200
+++ b/hedgewars/uGears.pas	Mon Sep 30 10:39:58 2019 +0200
@@ -43,6 +43,7 @@
 procedure EndTurnCleanup;
 procedure DrawGears;
 procedure DrawGearsGui;
+procedure DrawFinger;
 procedure FreeGearsList;
 procedure AddMiscGears;
 procedure AssignHHCoords;
@@ -728,6 +729,19 @@
     end;
 end;
 
+procedure DrawFinger;
+var Gear: PGear;
+    x, y: LongInt;
+begin
+if ((CurrentHedgehog <> nil) and (CurrentHedgehog^.Gear <> nil)) then
+    begin
+    Gear:= CurrentHedgehog^.Gear;
+    x:= hwRound(Gear^.X) + WorldDx;
+    y:= hwRound(Gear^.Y) + WorldDy;
+    RenderFinger(Gear, x, y);
+    end;
+end;
+
 procedure FreeGearsList;
 var t, tt: PGear;
 begin
--- a/hedgewars/uGearsRender.pas	Sun Sep 29 22:23:00 2019 +0200
+++ b/hedgewars/uGearsRender.pas	Mon Sep 30 10:39:58 2019 +0200
@@ -38,6 +38,7 @@
 procedure RenderGear(Gear: PGear; x, y: LongInt);
 procedure RenderGearTimer(Gear: PGear; x, y: LongInt);
 procedure RenderGearHealth(Gear: PGear; x, y: LongInt);
+procedure RenderFinger(Gear: PGear; ox, oy: LongInt);
 procedure RenderHHGuiExtras(Gear: PGear; ox, oy: LongInt);
 procedure RenderAirMineGuiExtras(Gear: PGear; ox, oy: LongInt);
 procedure DrawHHOrder();
@@ -238,15 +239,12 @@
 
 end;
 
-// Render some informational GUI next to hedgehog, like fuel and alternate weapon
-procedure RenderHHGuiExtras(Gear: PGear; ox, oy: LongInt);
+procedure RenderFinger(Gear: PGear; ox, oy: LongInt);
 var HH: PHedgehog;
-    sx, sy, tx, ty, t, hogLR: LongInt;
+    tx, ty, t: LongInt;
     dAngle: real;
 begin
     HH:= Gear^.Hedgehog;
-    sx:= ox + 1; // this offset is very common
-    sy:= oy - 3;
     if HH^.Unplaced then
         exit;
     if (Gear^.State and gstHHDeath) <> 0 then
@@ -256,7 +254,7 @@
     if (CinematicScript) then
         exit;
 
-    // render finger (pointing arrow)
+    // render finger (arrow pointing to hog)
     if bShowFinger and ((Gear^.State and gstHHDriven) <> 0) then
         begin
         ty := oy - 32;
@@ -294,6 +292,25 @@
         DrawSpriteRotatedF(sprFinger, tx, ty, RealTicks div 32 mod 16, 1, dAngle);
         untint;
         end;
+end;
+
+
+// Render some informational GUI next to hedgehog, like fuel and alternate weapon
+procedure RenderHHGuiExtras(Gear: PGear; ox, oy: LongInt);
+var HH: PHedgehog;
+    sx, sy, hogLR: LongInt;
+begin
+    HH:= Gear^.Hedgehog;
+    sx:= ox + 1; // this offset is very common
+    sy:= oy - 3;
+    if HH^.Unplaced then
+        exit;
+    if (Gear^.State and gstHHDeath) <> 0 then
+        exit;
+    if (Gear^.State and gstHHGone) <> 0 then
+        exit;
+    if (CinematicScript) then
+        exit;
 
     // render crosshair
     if (CrosshairGear <> nil) and (Gear = CrosshairGear) then
--- a/hedgewars/uWorld.pas	Sun Sep 29 22:23:00 2019 +0200
+++ b/hedgewars/uWorld.pas	Mon Sep 30 10:39:58 2019 +0200
@@ -1299,6 +1299,10 @@
 
 DrawGearsGui();
 
+// Finger (arrow pointing to hedgehog).
+// NOT wrapped like the other stuff because it might be confusing.
+DrawFinger();
+
 // everything after this ChangeDepth will be drawn outside the screen
 // note: negative parallax gears should last very little for a smooth stereo effect
     ChangeDepth(RM, cStereo_Outside);