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): show a building going up in its owner colour

Olcay Seygandcb4ec7b88aa
diff --git a/CHANGELOG.md b/CHANGELOG.md
index bac336fbe..90be7e800 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -330,10 +330,11 @@ found and fixed — EA's own, not port damage.**
## Health bars
- A health bar keeps its size against the unit at any resolution. It was a fixed number of pixels wide and three tall, so the bigger the screen the thinner the thread over a tank.
-- Health bars are in the owner's colour instead of green to red.
+- Health bars are in the owner's colour instead of green to red. A building going up fills its bar in that same colour as it rises, so a glance across the map says whose expansion it is - the seconds written over it already say it is not finished. A disabled building keeps the blue.
- 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.
- 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 8425cd0c1..81d8e285f 100644
--- a/GeneralsMD/Code/GameEngine/Source/GameClient/Drawable.cpp
+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/Drawable.cpp
@@ -4165,11 +4165,11 @@ void Drawable::drawHealthBar(const IRegion2D* healthBarRegion)
//
// what color will we use for the health bar based on our ratio, this makes it
- // slowly go from green to red, (or from blue to cyan if under construction, or disabled)
+ // slowly go from green to red, (or from blue to cyan if disabled)
//
Color color, outlineColor;
- if( obj->getStatusBits().test( OBJECT_STATUS_UNDER_CONSTRUCTION ) || (obj->isDisabled() && !obj->isDisabledByType(DISABLED_HELD)) )
+ if( obj->isDisabled() && !obj->isDisabledByType(DISABLED_HELD) )
{
color = GameMakeColor( 0, healthRatio * 255.0f, 255, 255 );//blue to cyan
outlineColor = GameMakeColor( 0, healthRatio * 128.0f, 128, 255 );//dark blue to dark cyan
@@ -4186,8 +4186,10 @@ void Drawable::drawHealthBar(const IRegion2D* healthBarRegion)
// means the same thing everywhere on screen.
//
// The outline stays a darkened version of the same colour, so a light player colour
- // still reads against light terrain. The under-construction / disabled blue above keeps
- // its own colour: that is a state, not an owner, and it applies to your own buildings.
+ // still reads against light terrain. A building going up fills its bar in the same
+ // colour as it builds - whose site it is answers a glance across the map, and the
+ // seconds written over it (drawConstructPercent) already say it is not finished. The
+ // disabled blue above keeps its own colour: that is a state nothing else signals.
//
UnsignedByte r, g, b, a;
GameGetColorComponents( obj->getControllingPlayer()->getPlayerColor(), &r, &g, &b, &a );
@@ -4254,26 +4256,22 @@ void Drawable::drawHealthBar(const IRegion2D* healthBarRegion)
//
TheGameClient->addHealthBarPickRegion( this, *healthBarRegion );
- // draw the health box outline
+ // 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
TheDisplay->drawOpenRect( healthBarRegion->lo.x, healthBarRegion->lo.y, healthBoxWidth, healthBoxHeight,
- healthBoxOutlineSize, outlineColor );
+ healthBoxOutlineSize,
+ isSelected() ? GameMakeColor( 255, 255, 255, 255 ) : outlineColor );
// draw a filled bar for the health
TheDisplay->drawFillRect( healthBarRegion->lo.x + 1, healthBarRegion->lo.y + 1,
(healthBoxWidth - 2) * healthRatio, healthBoxHeight - 2,
color );
- // selected drawables get a white overline (1px gap above the bar; below collides with the container pips) so they stand out now that all bars are always on
- // (+1: drawOpenRect covers width+1 columns, drawFillRect only width)
- if( isSelected() )
- TheDisplay->drawFillRect( healthBarRegion->lo.x, healthBarRegion->lo.y - 2, healthBoxWidth + 1, 1,
- GameMakeColor( 255, 255, 255, 255 ) );
-
// 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;
- // own producers show a yellow production-progress bar above the (selection) line, with seconds left at its top-left
+ // own producers show a yellow production-progress bar above the health bar, with seconds left at its top-left
ProductionUpdateInterface *pu = showsOwnerDetail( obj ) ? obj->getProductionUpdateInterface() : NULL;
const ProductionEntry *pe = pu ? pu->firstProduction() : NULL;
if( pe )
diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GameWindowManager.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GameWindowManager.cpp
index 46fc6bd16..583bb23e9 100644
--- a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GameWindowManager.cpp
+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GameWindowManager.cpp
@@ -2890,6 +2890,8 @@ void GameWindowManager::assignDefaultGadgetLook( GameWindow *gadget,
static Color lightGray = TheWindowManager->winMakeColor( 192, 192, 192, alpha );
static Color black = TheWindowManager->winMakeColor( 0, 0, 0, alpha );
static Color white = TheWindowManager->winMakeColor( 254, 254, 254, alpha );
+ // a cool off-white: a progress bar filled in pure white swallows its own white frame
+ static Color offWhite = TheWindowManager->winMakeColor( 228, 236, 240, alpha );
static Color enabledText = white;
static Color enabledTextBorder = darkGray;
static Color disabledText = darkGray;
@@ -3481,7 +3483,7 @@ void GameWindowManager::assignDefaultGadgetLook( GameWindow *gadget,
GadgetProgressBarSetEnabledImageRight( gadget, winFindImage( "ProgressBarEnabledRightEnd" ) );
GadgetProgressBarSetEnabledImageCenter( gadget, winFindImage( "ProgressBarEnabledRepeatingCenter" ) );
GadgetProgressBarSetEnabledImageSmallCenter( gadget, winFindImage( "ProgressBarEnabledSmallRepeatingCenter" ) );
- GadgetProgressBarSetEnabledBarColor( gadget, yellow );
+ GadgetProgressBarSetEnabledBarColor( gadget, offWhite );
GadgetProgressBarSetEnabledBarBorderColor( gadget, white );
GadgetProgressBarSetEnabledBarImageLeft( gadget, winFindImage( "ProgressBarEnabledBarLeftEnd" ) );
GadgetProgressBarSetEnabledBarImageRight( gadget, winFindImage( "ProgressBarEnabledBarRightEnd" ) );