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(gameengine): frame a selected unit health bar from outside

Olcay Seygan98b5c8ba6834
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 90be7e800..82bcf34df 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -334,7 +334,7 @@ found and fixed — EA's own, not port damage.**
- A building's bar sits above its roof rather than inside its art.
- Every garrisonable building shows how full it is, whoever holds it.
- A vehicle's load stays private.
-- What you have selected wears a white frame around its bar, so a selection is still readable in a crowd where every unit carries a bar.
+- What you have selected wears a white frame just outside its bar, so a selection is still readable in a crowd where every unit carries a bar - and the bar itself keeps its owner colour all the way round.
- Lamps, barrels, rocks and bushes no longer wear health bars.
- Bridges no longer float a health bar over the middle of the river. There was never anything under it: the span is part of the terrain, and the bar belonged to an invisible marker standing in the water.
- The bar is part of the unit now: click it and you select whoever it belongs to. Zoomed out, an infantryman is a few pixels of helmet under a bar that is far easier to hit, and a unit half behind a building still has its bar in the clear. It only answers clicks that would have missed everything anyway, so it never takes a click away from the unit you were actually pointing at, and right-clicking bare ground under a bar still orders a move.
diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/Drawable.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/Drawable.cpp
index 81d8e285f..4313d4ee9 100644
--- a/GeneralsMD/Code/GameEngine/Source/GameClient/Drawable.cpp
+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/Drawable.cpp
@@ -4256,11 +4256,18 @@ void Drawable::drawHealthBar(const IRegion2D* healthBarRegion)
//
TheGameClient->addHealthBarPickRegion( this, *healthBarRegion );
- // draw the health box outline - white on a selected drawable, so a selection still reads in a
- // crowd where every unit carries a bar, without reserving a row above the bar for a marker
+ // draw the health box outline
TheDisplay->drawOpenRect( healthBarRegion->lo.x, healthBarRegion->lo.y, healthBoxWidth, healthBoxHeight,
- healthBoxOutlineSize,
- isSelected() ? GameMakeColor( 255, 255, 255, 255 ) : outlineColor );
+ healthBoxOutlineSize, outlineColor );
+
+ // a selected drawable wears a white frame one pixel outside its bar, so a selection still
+ // reads in a crowd where every unit carries a bar, without reserving a row above the bar for
+ // a marker. It sits outside rather than replacing the outline, so the bar keeps its owner
+ // colour all the way round.
+ if( isSelected() )
+ TheDisplay->drawOpenRect( healthBarRegion->lo.x - 1, healthBarRegion->lo.y - 1,
+ healthBoxWidth + 2, healthBoxHeight + 2,
+ healthBoxOutlineSize, GameMakeColor( 255, 255, 255, 255 ) );
// draw a filled bar for the health
TheDisplay->drawFillRect( healthBarRegion->lo.x + 1, healthBarRegion->lo.y + 1,