Display current health in top right corner
authorWuzzy <Wuzzy2@mail.ru>
Thu, 16 May 2019 02:07:29 +0200
changeset 14964 bcecb3349948
parent 14963 2d5f1dc637da
child 14965 cf21a45a62bd
Display current health in top right corner
ChangeLog.txt
hedgewars/uTypes.pas
hedgewars/uVariables.pas
hedgewars/uWorld.pas
share/hedgewars/Data/Graphics/HealthHUD.png
share/hedgewars/Data/Missions/Training/Basic_Training_-_Movement.lua
--- a/ChangeLog.txt	Wed May 15 20:40:37 2019 +0200
+++ b/ChangeLog.txt	Thu May 16 02:07:29 2019 +0200
@@ -78,6 +78,7 @@
  * Fix birdy being drawn behind hedgehogs and objects
 
 Game HUD:
+ + Display current hog health at top right corner
  + Colorize switching arrows, pointing arrow and target cross in clan color
  + Skip ammo menu animation when playing with turn time of 10s or less
  + Don't show crate spawn message for initial crates in missions
--- a/hedgewars/uTypes.pas	Wed May 15 20:40:37 2019 +0200
+++ b/hedgewars/uTypes.pas	Thu May 16 02:07:29 2019 +0200
@@ -92,7 +92,8 @@
             sprFrozenHog, sprAmRubber, sprBoing, sprCustom1, sprCustom2, sprCustom3, sprCustom4,
             sprCustom5, sprCustom6, sprCustom7, sprCustom8, sprFrozenAirMine, sprAirMine, sprHandAirMine,
             sprFlakeL, sprSDFlakeL, sprCloudL, sprSDCloudL, sprCreeper, sprHandCreeper, sprMinigun,
-            sprSliderInverted, sprFingerBack, sprFingerBackInv, sprTargetPBack, sprTargetPBackInv
+            sprSliderInverted, sprFingerBack, sprFingerBackInv, sprTargetPBack, sprTargetPBackInv,
+            sprHealthHud
             );
 
     // Gears that interact with other Gears and/or Land
--- a/hedgewars/uVariables.pas	Wed May 15 20:40:37 2019 +0200
+++ b/hedgewars/uVariables.pas	Thu May 16 02:07:29 2019 +0200
@@ -220,6 +220,7 @@
     cZoomDelta      : real;
     cZoomDeltaSmall : real;
     cMinMaxZoomLevelDelta : real;
+    cDemoClockFPSOffsetY : LongInt;
 
 
     flagMakeCapture : boolean;
@@ -822,7 +823,9 @@
             (FileName:    'TargetpBack'; Path: ptGraphics; AltPath: ptNone; Texture: nil; Surface: nil;
             Width:  32; Height: 32; imageWidth: 0; imageHeight: 0; saveSurf: false; critical: true; checkSum: false; priority: tpMedium; getDimensions: false; getImageDimensions: true),// sprTargetPBack
             (FileName:    'TargetpBackInv'; Path: ptGraphics; AltPath: ptNone; Texture: nil; Surface: nil;
-            Width:  32; Height: 32; imageWidth: 0; imageHeight: 0; saveSurf: false; critical: true; checkSum: false; priority: tpMedium; getDimensions: false; getImageDimensions: true)// sprTargetPBackInv
+            Width:  32; Height: 32; imageWidth: 0; imageHeight: 0; saveSurf: false; critical: true; checkSum: false; priority: tpMedium; getDimensions: false; getImageDimensions: true),// sprTargetPBackInv
+            (FileName:    'HealthHUD'; Path: ptGraphics; AltPath: ptNone; Texture: nil; Surface: nil;
+            Width:  18; Height: 18; imageWidth: 0; imageHeight: 0; saveSurf: false; critical: true; checkSum: false; priority: tpMedium; getDimensions: false; getImageDimensions: true)// sprHealthHud
             );
 
 
@@ -2825,6 +2828,8 @@
 
     cMinMaxZoomLevelDelta:= cMaxZoomLevel - cMinZoomLevel;
 
+    cDemoClockFPSOffsetY := 0;
+
     // int, longint longword and byte
     CursorMovementX     := 0;
     CursorMovementY     := 0;
--- a/hedgewars/uWorld.pas	Wed May 15 20:40:37 2019 +0200
+++ b/hedgewars/uWorld.pas	Thu May 16 02:07:29 2019 +0200
@@ -1584,6 +1584,26 @@
 if (UIDisplay = uiAll) and (isNotHiddenByCinematic) then
     RenderTeamsHealth;
 
+// Current hedgehog health in top left corner
+if ((UIDisplay = uiAll) or (UIDisplay = uiNoTeams)) and (isNotHiddenByCinematic) and
+        ((GameFlags and gfInvulnerable) = 0) and
+        (CurrentHedgehog <> nil) and (CurrentHedgehog^.Gear <> nil) and
+        (CurrentHedgehog^.HealthTagTex <> nil) and
+        ((CurrentHedgehog^.Gear^.State and gstHHDriven) <> 0) then
+    begin
+    t:= 10;
+    i:= t;
+{$IFDEF USE_TOUCH_INTERFACE}
+    i:= t + pauseButton.frame.y + pauseButton.frame.h;
+{$ENDIF}
+    DrawTexture(cScreenWidth div 2 - CurrentHedgehog^.HealthTagTex^.w - 16, i, CurrentHedgehog^.HealthTagTex);
+    DrawSprite(sprHealthHud, (cScreenWidth div 2 - CurrentHedgehog^.HealthTagTex^.w - 36), i, 0);
+    inc(t, CurrentHedgehog^.HealthTagTex^.h);
+    cDemoClockFPSOffsetY:= t;
+    end
+else
+    cDemoClockFPSOffsetY:= 0;
+
 // Wind bar
 if (UIDisplay <> uiNone) and (isNotHiddenByCinematic) then
     begin
@@ -1734,11 +1754,11 @@
 
 // FPS and demo replay time
 {$IFDEF USE_TOUCH_INTERFACE}
-offsetX:= pauseButton.frame.y + pauseButton.frame.h + 12;
+offsetY:= cDemoClockFPSOffsetY + 10 + pauseButton.frame.y + pauseButton.frame.h;
 {$ELSE}
-offsetX:= 10;
+offsetY:= cDemoClockFPSOffsetY + 10;
 {$ENDIF}
-offsetY:= cOffsetY;
+offsetX:= cOffsetY;
 if (RM = rmDefault) or (RM = rmRightEye) then
     begin
     inc(Frames);
@@ -1769,11 +1789,11 @@
         SDL_FreeSurface(tmpSurface)
         end;
 
-    if timeTexture <> nil then
-        DrawTexture((cScreenWidth shr 1) - 20 - timeTexture^.w - offsetY, offsetX + timeTexture^.h+5, timeTexture);
+    if (timeTexture <> nil) and (UIDisplay <> uiNone) then
+        DrawTexture((cScreenWidth shr 1) - 20 - timeTexture^.w - offsetX, offsetY, timeTexture);
 
     // FPS counter
-    if cShowFPS then
+    if cShowFPS and (UIDisplay <> uiNone) then
         begin
         if CountTicks >= 1000 then
             begin
@@ -1788,7 +1808,13 @@
             SDL_FreeSurface(tmpSurface)
             end;
         if fpsTexture <> nil then
-            DrawTexture((cScreenWidth shr 1) - 20 - fpsTexture^.w - offsetY, offsetX, fpsTexture);
+            begin
+            if timeTexture <> nil then
+                i:= fpsTexture^.h + 5
+            else
+                i:= 0;
+            DrawTexture((cScreenWidth shr 1) - 60 - offsetX, offsetY + i, fpsTexture);
+            end;
         end;
 end;
 
Binary file share/hedgewars/Data/Graphics/HealthHUD.png has changed
--- a/share/hedgewars/Data/Missions/Training/Basic_Training_-_Movement.lua	Wed May 15 20:40:37 2019 +0200
+++ b/share/hedgewars/Data/Missions/Training/Basic_Training_-_Movement.lua	Thu May 16 02:07:29 2019 +0200
@@ -408,8 +408,9 @@
 			loc("Zoom: [Pinch] with 2 fingers")
 		end
 		ShowMission(loc("Basic Movement Training"), loc("Health"), loc("You just got yourself some extra health.|The more health your hedgehogs have, the better!").."|"..
+		loc("The health of your current hedgehog|is shown at the top right corner.").."|"..
 		loc("Now go to the next crate.").."|"..
-		ctrl, 2, 10000)
+		ctrl, 2, 11500)
 	elseif gear == crates[10] then
 		-- FIXME: This crate is unused in touch atm
 		ShowMission(loc("Basic Movement Training"), loc("Turning Around"),