Skip to content

Zero Hour rebuilt from EA's source: x64, Direct3D 11, VS2022/CMake, ~60 original bugs fixed, an AI that builds a base. Bring your own game.

feat(gameclient): thinner health bars with a dark lost-health stretch

Olcay Seygan198118ffccd0
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 9d294bda9..4bf9a9286 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -8,6 +8,11 @@ found and fixed — EA's own, not port damage.**
---
+## Health bars you can read at a glance
+
+- The bars over units are a third thinner, so a big fight no longer looks like a sheet of red and green stripes over the units underneath.
+- Health a unit has lost now shows as a dark stretch at the end of its bar. It used to be bare ground, so a red bar over red ground, or any team colour over the wrong terrain, looked full when it was half gone.
+
## Jets fly like jets
- The Raptor, King Raptor, MiG, Aurora and Stealth Fighter turn the way a plane turns. The faster a jet flies, the slower it comes round, so at cruise it sweeps a wide arc and only a slow jet turns tight. It no longer slides sideways through a turn. A Raptor's half circle at cruise takes about 3.2 seconds, where it took about 1.7.
diff --git a/GeneralsMD/Code/Data/Cinema/hpbar.txt b/GeneralsMD/Code/Data/Cinema/hpbar.txt
new file mode 100644
index 000000000..3f2b08251
--- /dev/null
+++ b/GeneralsMD/Code/Data/Cinema/hpbar.txt
@@ -0,0 +1,9 @@
+# Scenarios/hpbar.txt: the two groups meeting at 3400,3960, held at a play-like zoom so the bars
+# read at their real size. Several shots because the frame with the most damaged survivors is only
+# known to a second.
+
+0.5 cut 3400 3960 0.8 0 0
+4.0 shot
+5.0 shot
+6.0 shot
+7.0 shot
diff --git a/GeneralsMD/Code/Data/Scenarios/hpbar.txt b/GeneralsMD/Code/Data/Scenarios/hpbar.txt
new file mode 100644
index 000000000..43a70a30d
--- /dev/null
+++ b/GeneralsMD/Code/Data/Scenarios/hpbar.txt
@@ -0,0 +1,21 @@
+# Health bar look: a mixed American group (Crusaders, Rangers, a Humvee) trading fire with Chinese
+# Battlemasters and Red Guard on open ground of Twilight Flame, so a frame a few seconds in shows
+# a dozen bars, most of them partly emptied. Used for the before/after of the bar thickness.
+#
+# generals.exe -win -xres 1920 -yres 1080 -msaa 0 -borderless -turbo -quickstart -noshellmap
+# -observer -multiInstance -noFPSLimit -map "Maps\Twilight Flame\Twilight Flame.map"
+# -autoskirmish 2 -takeover -side 0 FactionAmerica -side 1 FactionChina -seed 7
+# -scenario hpbar -cinema hpbar -maxframes 600
+
+30 spawn 0 AmericaTankCrusader 3 3400 3860 40
+30 spawn 0 AmericaInfantryRanger 6 3330 3800 14
+30 spawn 0 AmericaVehicleHumvee 1 3470 3800
+30 spawn 1 ChinaTankBattleMaster 3 3420 4120 40
+30 spawn 1 ChinaInfantryRedguard 6 3340 4080 14
+45 attackmove 0 * 3400 4100
+45 attackmove 1 * 3400 3820
+
+120 tally 0 *
+120 tally 1 *
+180 tally 0 *
+180 tally 1 *
diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/Drawable.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/Drawable.cpp
index 55ad4314e..f06a59b4f 100644
--- a/GeneralsMD/Code/GameEngine/Source/GameClient/Drawable.cpp
+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/Drawable.cpp
@@ -3281,7 +3281,10 @@ static Bool computeHealthRegion( const Drawable *draw, IRegion2D& region )
// do this so health bar doesn't get too skinny or fat after scaling
//healthBoxHeight = max(3.0f, healthBoxHeight);
- healthBoxHeight = 3.0f * uiScale;
+ // two thirds of the thickness it had: at full height a screen of bars drew the eye away from the
+ // units under them. drawHealthBar still floors it at three pixels, a one pixel fill inside its
+ // outline, and gives the lost health a dark slot so a thin bar still reads.
+ healthBoxHeight = 2.0f * uiScale;
// figure out the final region for the health box
region.lo.x = screenCenter.x - healthBoxWidth * 0.45f;
@@ -4906,10 +4909,17 @@ void Drawable::drawHealthBar(const IRegion2D* healthBarRegion)
healthBoxOutlineSize, GameMakeColor( 255, 255, 255, 255 ) );
// draw a filled bar for the health
+ const Int healthFillWidth = (Int)((healthBoxWidth - 2) * healthRatio);
TheDisplay->drawFillRect( healthBarRegion->lo.x + 1, healthBarRegion->lo.y + 1,
- (healthBoxWidth - 2) * healthRatio, healthBoxHeight - 2,
+ healthFillWidth, healthBoxHeight - 2,
color );
+ // the health already lost is a near black slot rather than bare ground, so the length of the
+ // fill reads at a glance on a thin bar, and in owner colour on a map of the same colour
+ TheDisplay->drawFillRect( healthBarRegion->lo.x + 1 + healthFillWidth, healthBarRegion->lo.y + 1,
+ (healthBoxWidth - 2) - healthFillWidth, healthBoxHeight - 2,
+ GameMakeColor( 10, 10, 10, 190 ) );
+
// bars stack upwards from just above the health bar, each clearing the seconds written over
// the one below it
Int stackY = healthBarRegion->lo.y - 3;