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): money plate follows the figure's width

Olcay Seygan01eddaac40d8
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 24ddc45a6..49e5e4a1e 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -625,7 +625,7 @@ A third pass went through the generals' powers, promotions and unit abilities.
- A minimised command bar stays minimised. Changing seats, or clicking another player's unit while watching, put the whole bar back up over the battlefield you had just cleared. A new match still opens with the bar up.
- The command bar's frame is drawn new, in the same steel as the boards. Each panel holds one thing and is exactly its size, the radar, the command grid, the portrait with the experience bar, and wears a steel border outside it. Grey for America, red for China, sand for GLA. It slides and minimises with the bar, and like the boards it is a page in the Window folder; take the page away and the old painted bar comes back.
- The command bar is laid out anew, all of it running rightwards from the bottom left corner, and it is smaller: at 1920x1080 it stands 248 pixels tall where the old bar took 312, and it ends a third of the way across, so the rest of the screen's bottom edge is battlefield but for the general's powers in the corner. The radar sits in the corner, taller than before so its top lines up with the power bar's, with your general's experience bar standing beside it, and on its top edge the under-attack light, the skills key with your rank's stars on that, and over the stars the idle worker button whenever a worker stands idle. Next to it is one grid of eighteen buttons, six across and three down, and every button is its own key: Q W E R T Y over A S D F G H over Z X C V B N. No more two-key building shortcuts and no second bars: a dozer's buildings, a factory's units, a unit's abilities and upgrades and its orders all share the grid, each a single press. The orders stay put whatever you select. For a unit, A attacks, S stops, D attack-moves, V moves, Z ejects the passengers, X guards and C holds position; for a building, N sells it, B sets its rally point and Z empties its garrison. Workers keep three of their own: N clears mines on every side's worker and dozer, H swaps a GLA worker between real and fake buildings, and B is the Demolition worker's suicide charge. Everything else packs into the top left corner, two rows at a time, Q A W Z S E X D R C and on, so the buildings you reach for most sit under your fingers; what a building makes comes first and its upgrades after. Only the buttons your selection has are drawn, and with nothing selected the grid stays as a plate of bare steel. Its buttons are a fifth bigger than the rest of the bar's, so what you build stands out. Attack, hold position and move are buttons now, where no unit ever had one, with pictures painted to sit among the game's own: a crosshair on a red plate over a burning sky, a raised palm on a blue one, an arrow on a green diamond. V, or a click on the arrow, is a move for the left button: the next click on the ground sends the selection there, and a left drag lays them out along the line you draw. Beside the grid, on the bottom edge of the screen, runs a portrait bar only as long as what it holds. Select one unit and its upgrades follow its portrait; select a group and the bar holds every kind of unit in it once, each with how many you have, the one Tab has picked lit and the rest dimmed. The power bar lies along the top of the grid, and your money sits on its left end, so both are one glance from the buttons you spend them on. The Legacy mouse and keyboard and the W A S D camera are gone from the Options screen: there is one way to play, and an Options.ini that still names them loads as it always did.
-- Every panel of the bar is only as big as what it holds now, and stands on the bottom of the screen. The radar's border runs out to the screen's left edge. The power bar lies in a steel groove of its own along the top of the command grid, twenty cells that light up from the left with your production and fill the groove when full, the consumption marked by a white needle across it. The money stands on the power bar's left end in a steel plate of its own, the figure in a dark well. Everything the old painting filled round them is battlefield again, and a click there lands on the battlefield.
+- Every panel of the bar is only as big as what it holds now, and stands on the bottom of the screen. The radar's border runs out to the screen's left edge. The power bar lies in a steel groove of its own along the top of the command grid, twenty cells that light up from the left with your production and fill the groove when full, the consumption marked by a white needle across it. The money stands on the power bar's left end in a steel plate of its own, the figure in a dark well that is only as wide as the figure. It widens the moment your money gains a digit and waits three seconds before it narrows again, so it keeps still while the figure bobs around 10000 as you build. Everything the old painting filled round them is battlefield again, and a click there lands on the battlefield.
- The bar's own buttons are drawn to match, steel caps lit gold under the pointer and pressed in when pushed. The menu is a small square with three bars in the screen's top left corner. The idle worker button is a key like the smoke signals', a hard hat on it, in a steel tab over your rank's stars, where it no longer hides the end of the power bar. Each button stands in its own dark cell with steel running between them, and the steel is laid over the edge of every picture the way a frame holds a card, the whole picture showing inside it. The production queue and the general's powers are framed the same way. The power bar is sunk into the same steel as the build grid, lying along its top, and is as long as the grid on every side, where it used to change length from one faction to the next. The build grid's panel no longer carries an empty strip down its left side. There is no chat button any more: Enter opens the chat as it always did. The beacon button is gone from the bar too; the smoke signals over the radar are how you point your team at a spot. The portrait sits in the radar's lit steel too. The experience bar beside it is ten gold rungs in a sunk groove, climbing from the bottom as you earn your way to the next rank, and your rank stands in a steel tab on the portrait's top right corner, a key sunk in it like the idle worker's with one star for every rank there is, gold up to the one you hold. A watcher has nothing to promote and no longer gets the tab, which used to hang half into the screen's corner. Its button goes with it: a watcher who clicked a unit used to find an empty patch of screen there that still showed the promotions tooltip and opened the promotion screen. The portrait's grid is steel between dark cells on every side, where America's was drawn in blue lines that matched nothing else on the bar. That key is the promotions button: point at it and it comes up with a gold rim, it blinks bright in your side's own steel while you have a promotion to spend, and a click opens the promotion screen. That screen is rebuilt in the same steel and half its old size: each rank's promotions stand in a grid of build-button cells five wide, like the command grid, an empty place a dark hole, each rank in a steel well of its own with its heading, the wells a plate's thickness apart, the grid's steel laid over the edge of every picture so the picture sits in its cell like a card in a frame, your rank and the points to spend on one line over the experience bar, and Done in the last row's spare place. A gold rim marks what you have bought and a light one what you can buy now. It comes up the way the Esc menu does, the battlefield behind it dimmed to 65% black and the screen fading in over an eighth of a second; the side's old painted screen no longer fades in over it for the first nine frames. The bar has no minimise arrow any more: it is only as big as what it holds. The radar sits sunk in a bezel of lit steel, bright along the top and shadowed down the right, and the build grid and the money wear the same steel, the figure in a dark window of its own, and the under-attack light is a long red lamp set in a steel tab on its top left corner, dark until you are hit and then blinking. No words on it, so it reads the same in any language.
- The general's powers you have bought and can fire, the column that climbed the right edge of the screen, stand in the bottom right corner now in a tray of the bar's own steel. The first sits in the corner against the right edge of the screen, and each one you gain takes the place to the left of the last, three to a row before a new row starts above, so the tray is only ever as big as what you hold and an empty one takes no room at all. Each power sits on a dark cell three quarters the size of a build button, where the side's old tray art used to frame it. It is always out; there is no button to fold it away.
- Three buttons sit side by side in a step of the radar's own steel, on its top edge: the smoke signals Alt+Z, X and C send. Press one and the pointer turns to a cross; your next click puts the signal there, on the ground or on the radar, and a right click or Escape takes it back; until now a button dropped its smoke in the middle of your view. Every signal now leaves a mark on the ground in your colour for ten seconds, and the radar ping lasts as long: crossed swords to attack, a shield to defend, an eye to look, each in a ring a few tanks across, fading out over its last two seconds. Each is a key sunk into the steel with a sharp white picture on it instead of a word: a crosshair to attack, a shield to defend, an eye to look. Point at one and it comes up out of its well as lit steel with a gold rim, and it sinks in darker while you hold the button down. They rise into place one after another from the bottom of the screen when the match starts. A game with nobody on your side to see the smoke, a skirmish against the computer or a replay, has no signal buttons at all.
diff --git a/GeneralsMD/Code/GameEngine/Include/GameClient/InGameUI.h b/GeneralsMD/Code/GameEngine/Include/GameClient/InGameUI.h
index 123036565..f3dc5179b 100644
--- a/GeneralsMD/Code/GameEngine/Include/GameClient/InGameUI.h
+++ b/GeneralsMD/Code/GameEngine/Include/GameClient/InGameUI.h
@@ -349,6 +349,27 @@ struct SpectatorSuperweapon
const CommandButton *button; ///< the power's own, for its tooltip card; NULL for a power with none
};
+/** The money plate's width as it follows the figure's: see InGameUI_moneyPlateWidth. All zero is a
+ * plate never drawn. */
+struct MoneyPlateWidth
+{
+ Int target; ///< the width the plate settles at
+ Int shown; ///< the width it was last drawn at
+ Int easeFrom; ///< the width a shrink eases down from
+ UnsignedInt easeStartMs;
+ Bool easing;
+ Int pendingWidth; ///< the widest a narrower figure has needed while a shrink waits
+ UnsignedInt pendingSinceMs;
+ Bool pending;
+};
+
+/** The width to draw the money plate at, `needed` the width the figure takes now, `nowMs` the
+ * client's clock. A wider figure widens it at once; a narrower one has to hold for
+ * MONEY_SHRINK_HOLD_MS before the plate eases down to it over MONEY_SHRINK_EASE_MS, and anything
+ * wider in that wait calls the shrink off. Never narrower than `needed`. */
+enum { MONEY_SHRINK_HOLD_MS = 3000, MONEY_SHRINK_EASE_MS = 200 };
+Int InGameUI_moneyPlateWidth( MoneyPlateWidth &plate, Int needed, UnsignedInt nowMs );
+
// ------------------------------------------------------------------------------------------------
/** Basic functionality common to all in-game user interfaces */
// ------------------------------------------------------------------------------------------------
@@ -1517,6 +1538,7 @@ protected:
DisplayString * m_peaceCountdownDisplayString; ///< the big digit of its last ten seconds
Int m_lastMoneyDisplayed; ///< so the money gadget is only written when the amount changes
Int m_lastEarningDisplayed; ///< or the money earned a second beside it
+ MoneyPlateWidth m_moneyPlate; ///< the money plate's width, following the figure's
UnsignedInt m_hudDrawCount; ///< rendered frames counted by drawHudOverlay itself
UnsignedInt m_hudLastSampleFrame; ///< m_hudDrawCount the fps sample was last refreshed on
UnsignedInt m_hudLastSampleMs; ///< wall clock of that sample
diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/InGameUI.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/InGameUI.cpp
index 0f5881db1..353e5c0d3 100644
--- a/GeneralsMD/Code/GameEngine/Source/GameClient/InGameUI.cpp
+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/InGameUI.cpp
@@ -1188,6 +1188,7 @@ InGameUI::InGameUI()
m_peaceCountdownDisplayString = NULL;
m_lastMoneyDisplayed = -1;
m_lastEarningDisplayed = 0;
+ m_moneyPlate = MoneyPlateWidth();
m_hudDrawCount = 0;
m_hudLastSampleFrame = 0;
m_hudLastSampleMs = 0;
@@ -11089,8 +11090,8 @@ enum
IDLE_TAB_WIDTH = 38, ///< the idle worker's key in a tab on the skills key's, with its rim
IDLE_TAB_HEIGHT = 22,
POWER_WIDTH = 12, ///< the power bar's groove along the command grid's top, frame and lip
- MONEY_WIDTH = 104, ///< the money's well in its plate on the power bar's panel
- MONEY_HEIGHT = 18,
+ MONEY_TEXT_MARGIN = 5, ///< the money's well each side of its figure, which sets the well's width
+ MONEY_HEIGHT = 18, ///< the money's well in its plate on the power bar's panel
MONEY_PLATE_BORDER = 5, ///< the plate's steel round the well
SKILL_GRID_GAP = 12, ///< between the general's powers' tray and what it stands on
SKILL_TRAY_BORDER = 6, ///< the tray's steel round its cells
@@ -11312,16 +11313,66 @@ static IRegion2D gridCell( const IRegion2D &box, Int column, Int row, Int width,
return cell;
}
+//-------------------------------------------------------------------------------------------------
+/** Three seconds: the income beside the money changes once a second, so a figure bouncing across a
+ * digit, or an income flickering between +9/s and +10/s, never holds narrower for three updates in
+ * a row and the plate keeps still; a real drop, a building paid for, has settled by then and the
+ * plate follows while the eye is back on the battlefield. The ease is short enough to read as a
+ * settle, and every page pixel it moves lays the page out again. */
+Int InGameUI_moneyPlateWidth( MoneyPlateWidth &plate, Int needed, UnsignedInt nowMs )
+{
+ if( needed >= plate.target )
+ {
+ plate.target = needed;
+ plate.pending = FALSE;
+ }
+ else if( !plate.pending )
+ {
+ plate.pending = TRUE;
+ plate.pendingSinceMs = nowMs;
+ plate.pendingWidth = needed;
+ }
+ else
+ {
+ plate.pendingWidth = max( plate.pendingWidth, needed );
+ if( nowMs - plate.pendingSinceMs >= MONEY_SHRINK_HOLD_MS )
+ {
+ plate.easeFrom = plate.shown;
+ plate.easeStartMs = nowMs;
+ plate.easing = TRUE;
+ plate.target = plate.pendingWidth;
+ plate.pending = FALSE;
+ }
+ }
+
+ plate.shown = plate.target;
+ if( plate.easing )
+ {
+ const UnsignedInt elapsed = nowMs - plate.easeStartMs;
+ if( elapsed >= MONEY_SHRINK_EASE_MS )
+ plate.easing = FALSE;
+ else
+ {
+ // eased out: quick at first, settling onto the new width
+ const Real left = 1.0f - (Real)elapsed / MONEY_SHRINK_EASE_MS;
+ plate.shown = max( plate.target, plate.target + REAL_TO_INT( ( plate.easeFrom - plate.target ) * left * left ) );
+ }
+ }
+ return plate.shown;
+}
+
//-------------------------------------------------------------------------------------------------
/** The money, a steel plate standing on the power bar's panel `powerBox` at its left end with the
- * figure in a dark well, the owner's place of 2026-09-28. The money's window is moved into the
- * well, cut to its line of text. Written as moneyplate and moneyblock. */
+ * figure in a dark well `wellWidth` screen pixels wide, the owner's place of 2026-09-28. The
+ * money's window is moved into the well, cut to its line of text. Written as moneyplate and
+ * moneyblock. */
//-------------------------------------------------------------------------------------------------
-static void putMoney( HtmlValues &values, const IRegion2D &powerBox, Bool shown )
+static void putMoney( HtmlValues &values, const IRegion2D &powerBox, Int wellWidth, Bool shown )
{
const Real scale = ControlBarHudScale();
const Int border = REAL_TO_INT( MONEY_PLATE_BORDER * scale );
- const IRegion2D plate = tabOn( powerBox, MONEY_WIDTH + 2 * MONEY_PLATE_BORDER, MONEY_HEIGHT + 2 * MONEY_PLATE_BORDER, FALSE );
+ IRegion2D plate = tabOn( powerBox, 0, MONEY_HEIGHT + 2 * MONEY_PLATE_BORDER, FALSE );
+ plate.hi.x = plate.lo.x + wellWidth + 2 * border;
IRegion2D money = plate;
money.lo.x += border;
money.hi.x -= border;
@@ -11595,7 +11646,13 @@ Bool InGameUI::drawControlBarPage( const IRegion2D *panels, const Bool *shown, I
putFrame( values, "powerpanel", power, powerBox, centreShown );
putPowerGroove( values, power, centreShown );
putPowerBar( values, lists[ "powercells" ] ); // after the groove, which it divides into cells
- putMoney( values, powerBox, centreShown && !controlBarWindow( "MoneyDisplay" )->winIsHidden() );
+ // the money's well is as wide as the figure and a margin each side, following it through
+ // InGameUI_moneyPlateWidth on the client's clock
+ GameWindow *moneyWindow = controlBarWindow( "MoneyDisplay" );
+ const Int moneyNeeded = ( (TextData *)moneyWindow->winGetUserData() )->text->getWidth()
+ + 2 * REAL_TO_INT( MONEY_TEXT_MARGIN * scale );
+ putMoney( values, powerBox, InGameUI_moneyPlateWidth( m_moneyPlate, moneyNeeded, nowMs ),
+ centreShown && !moneyWindow->winIsHidden() );
// each command button to its place. A click only reaches a window inside every one of its parents,
// so the buttons' two cover the whole frame; the page's solids still decide what is battlefield
diff --git a/GeneralsMD/Code/Tests/test_gameengine.cpp b/GeneralsMD/Code/Tests/test_gameengine.cpp
index bb316cc6a..311f8aad5 100644
--- a/GeneralsMD/Code/Tests/test_gameengine.cpp
+++ b/GeneralsMD/Code/Tests/test_gameengine.cpp
@@ -3170,6 +3170,46 @@ TEST(controlbar_command_places_follow_the_owners_drawing)
CHECK_EQ( places[ slot ], bossPlaces[ slot ] );
}
+/* The money plate follows its figure's width: wider at once, narrower only once the narrower figure
+ has held for MONEY_SHRINK_HOLD_MS, and then eased down over MONEY_SHRINK_EASE_MS. */
+TEST(the_money_plate_grows_at_once_and_shrinks_only_after_a_hold)
+{
+ const Int WIDE = 120, NARROW = 100;
+ const UnsignedInt START = 100000;
+
+ MoneyPlateWidth plate = MoneyPlateWidth();
+ CHECK_EQ( InGameUI_moneyPlateWidth( plate, NARROW, START ), NARROW );
+ CHECK_EQ( InGameUI_moneyPlateWidth( plate, WIDE, START + 16 ), WIDE );
+
+ // narrower: held until the hold is up, then eased, never under the figure, and settled at the end
+ UnsignedInt now = START + 1000;
+ CHECK_EQ( InGameUI_moneyPlateWidth( plate, NARROW, now ), WIDE );
+ CHECK_EQ( InGameUI_moneyPlateWidth( plate, NARROW, now + MONEY_SHRINK_HOLD_MS - 1 ), WIDE );
+ CHECK_EQ( InGameUI_moneyPlateWidth( plate, NARROW, now + MONEY_SHRINK_HOLD_MS ), WIDE );
+ Int last = WIDE;
+ for( UnsignedInt step = 16; step < MONEY_SHRINK_EASE_MS; step += 16 )
+ {
+ const Int width = InGameUI_moneyPlateWidth( plate, NARROW, now + MONEY_SHRINK_HOLD_MS + step );
+ CHECK( width <= last && width >= NARROW );
+ last = width;
+ }
+ CHECK_EQ( InGameUI_moneyPlateWidth( plate, NARROW, now + MONEY_SHRINK_HOLD_MS + MONEY_SHRINK_EASE_MS ), NARROW );
+
+ // a wider figure in the wait calls the shrink off, and the next narrower one starts the wait again
+ now += 10000;
+ CHECK_EQ( InGameUI_moneyPlateWidth( plate, WIDE, now ), WIDE );
+ CHECK_EQ( InGameUI_moneyPlateWidth( plate, NARROW, now + 1000 ), WIDE );
+ CHECK_EQ( InGameUI_moneyPlateWidth( plate, WIDE, now + 2500 ), WIDE );
+ CHECK_EQ( InGameUI_moneyPlateWidth( plate, NARROW, now + 3000 ), WIDE );
+ CHECK_EQ( InGameUI_moneyPlateWidth( plate, NARROW, now + 3000 + MONEY_SHRINK_HOLD_MS - 1 ), WIDE );
+
+ // 9990 and 10010 in turn every second while building: the plate never moves
+ now += 20000;
+ for( Int second = 0; second < 30; second++ )
+ for( UnsignedInt frame = 0; frame < 1000; frame += 16 )
+ CHECK_EQ( InGameUI_moneyPlateWidth( plate, second % 2 ? NARROW : WIDE, now + second * 1000 + frame ), WIDE );
+}
+
/* CommandMapReforged.ini binds COMMAND_SLOTnn to the key of place nn - 1: the grid reads Q W E R T Y,
A S D F G H, Z X C V B N, so a place's key is where the owner put it on 2026-09-28 - a unit's attack
on A, stop on S, attack move on D, eject on Z, guard on X, hold on C, move on V; a building's sell