Fix attack bar render bugs: Invisible beyond world edge; rendered over GUI (e.g. mission panel)
authorWuzzy <Wuzzy2@mail.ru>
Wed, 08 Aug 2018 12:05:19 +0200
changeset 13642 28e4a9db4690
parent 13641 fc8c8910a281
child 13643 039ec6dd304b
Fix attack bar render bugs: Invisible beyond world edge; rendered over GUI (e.g. mission panel)
ChangeLog.txt
hedgewars/uWorld.pas
--- a/ChangeLog.txt	Wed Aug 08 11:40:00 2018 +0200
+++ b/ChangeLog.txt	Wed Aug 08 12:05:19 2018 +0200
@@ -21,6 +21,8 @@
  * Fix projectiles behaving incorrectly with land just behind the wrap world edge
  * Fix extreme amounts of droplets when shooting with minigun into ocean world edge
  * Fix some flakes disappearing in world wrap worlds while moving camera
+ * Fix invisible projectile timer, attack bar, target on other side of wrap world edge
+ * Fix attack bar drawn over GUI elements
  * Fix hog being unable to walk after using sniper rifle without firing both shots
  * Fix video recorder not working when game audio was disabled
  * Fix cursor teleporting to center after leaving game with a video recording
--- a/hedgewars/uWorld.pas	Wed Aug 08 11:40:00 2018 +0200
+++ b/hedgewars/uWorld.pas	Wed Aug 08 12:05:19 2018 +0200
@@ -1163,6 +1163,24 @@
 VisibleTeamsCount:= v;
 end;
 
+procedure RenderAttackBar();
+var i: LongInt;
+    tdx, tdy: Double;
+begin
+    if CurrentTeam <> nil then
+        case AttackBar of
+        2: with CurrentHedgehog^ do
+                begin
+                tdx:= hwSign(Gear^.dX) * Sin(Gear^.Angle * Pi / cMaxAngle);
+                tdy:= - Cos(Gear^.Angle * Pi / cMaxAngle);
+                for i:= (Gear^.Power * 24) div cPowerDivisor downto 0 do
+                    DrawSprite(sprPower,
+                            hwRound(Gear^.X) + GetLaunchX(CurAmmoType, hwSign(Gear^.dX), Gear^.Angle) + LongInt(round(WorldDx + tdx * (24 + i * 2))) - 16,
+                            hwRound(Gear^.Y) + GetLaunchY(CurAmmoType, Gear^.Angle) + LongInt(round(WorldDy + tdy * (24 + i * 2))) - 16,
+                            i)
+                end;
+        end;
+end;
 
 var preShiftWorldDx: LongInt;
 
@@ -1182,7 +1200,6 @@
 var i, t: LongInt;
     spr: TSprite;
     r: TSDL_Rect;
-    tdx, tdy: Double;
     s: shortstring;
     offsetX, offsetY, screenBottom: LongInt;
     replicateToLeft, replicateToRight, tmp: boolean;
@@ -1265,30 +1282,6 @@
 
 DrawWater(255, 0, 0);
 
-(*
-// Attack bar
-    if CurrentTeam <> nil then
-        case AttackBar of
-        //1: begin
-        //r:= StuffPoz[sPowerBar];
-        //{$WARNINGS OFF}
-        //r.w:= (CurrentHedgehog^.Gear^.Power * 256) div cPowerDivisor;
-        //{$WARNINGS ON}
-        //DrawSpriteFromRect(r, cScreenWidth - 272, cScreenHeight - 48, 16, 0, Surface);
-        //end;
-        2: with CurrentHedgehog^ do
-                begin
-                tdx:= hwSign(Gear^.dX) * Sin(Gear^.Angle * Pi / cMaxAngle);
-                tdy:= - Cos(Gear^.Angle * Pi / cMaxAngle);
-                for i:= (Gear^.Power * 24) div cPowerDivisor downto 0 do
-                    DrawSprite(sprPower,
-                            hwRound(Gear^.X) + GetLaunchX(CurAmmoType, hwSign(Gear^.dX), Gear^.Angle) + LongInt(round(WorldDx + tdx * (24 + i * 2))) - 16,
-                            hwRound(Gear^.Y) + GetLaunchY(CurAmmoType, Gear^.Angle) + LongInt(round(WorldDy + tdy * (24 + i * 2))) - 16,
-                            i)
-                end
-        end;
-*)
-
 tmp:= bShowFinger;
 bShowFinger:= false;
 
@@ -1430,6 +1423,23 @@
         end;
     end;
 
+// Attack bar
+if replicateToLeft then
+    begin
+    ShiftWorld(-1);
+    RenderAttackBar();
+    UnshiftWorld();
+    end;
+
+if replicateToRight then
+    begin
+    ShiftWorld(1);
+    RenderAttackBar();
+    UnshiftWorld();
+    end;
+
+RenderAttackBar();
+
 RenderWorldEdge();
 
 // this scale is used to keep the various widgets at the same dimension at all zoom levels
@@ -1753,29 +1763,6 @@
 
 SetScale(zoom);
 
-// Attack bar
-    if CurrentTeam <> nil then
-        case AttackBar of
-(*        1: begin
-        r:= StuffPoz[sPowerBar];
-        {$WARNINGS OFF}
-        r.w:= (CurrentHedgehog^.Gear^.Power * 256) div cPowerDivisor;
-        {$WARNINGS ON}
-        DrawSpriteFromRect(r, cScreenWidth - 272, cScreenHeight - 48, 16, 0, Surface);
-        end;*)
-        2: with CurrentHedgehog^ do
-                begin
-                tdx:= hwSign(Gear^.dX) * Sin(Gear^.Angle * Pi / cMaxAngle);
-                tdy:= - Cos(Gear^.Angle * Pi / cMaxAngle);
-                for i:= (Gear^.Power * 24) div cPowerDivisor downto 0 do
-                    DrawSprite(sprPower,
-                            hwRound(Gear^.X) + GetLaunchX(CurAmmoType, hwSign(Gear^.dX), Gear^.Angle) + LongInt(round(WorldDx + tdx * (24 + i * 2))) - 16,
-                            hwRound(Gear^.Y) + GetLaunchY(CurAmmoType, Gear^.Angle) + LongInt(round(WorldDy + tdy * (24 + i * 2))) - 16,
-                            i)
-                end
-        end;
-
-
 // Cursor
 if isCursorVisible and (not bShowAmmoMenu) then
     begin