feat(client): Add BuildTimerDisplayMode option for build and recharge countdowns - #3217
feat(client): Add BuildTimerDisplayMode option for build and recharge countdowns#3217triatomic wants to merge 3 commits into
Conversation
…on cameos Draws the remaining time over build queue and special power cameos, next to the existing clock sweep: BuildTimerDisplayMode = None ; retail, default BuildTimerDisplayMode = Seconds ; always plain seconds BuildTimerDisplayMode = Auto ; seconds under a minute, M:SS above Covers the head production queue slot (units and upgrades) and special power recharge. Times use an integer frame ceiling so the number never reads one second short. The shared display string is returned to the manager by the W3DDisplayStringManager destructor before teardown. Available in both Zero Hour and Generals: the drawing lives in the shared gadget and W3D push button code.
Formats the build time with the same Auto/Seconds rules as the cameo countdowns and appends it to the tooltip's cost line, separated by a watch glyph - the description window sits directly beneath the cost line in the .wnd layout, so a second line would overlap it. Shown for free items too, which have no cost of their own but still take time to build. Unit times come from calcTimeToBuild, which folds in the current energy penalty, so the tooltip tracks the player's power state; upgrades carry no penalty in the engine. Tooltip times round to nearest in integer math so a fractional BuildTime reads as the number the modder typed, while the live countdowns keep ceiling - a running timer must not show 0 with work left. Follows BuildTimerDisplayMode: with the option at None the tooltip stays retail.
PR Summary by QodoAdd configurable build and recharge timer displays
AI Description
Diagram
High-Level Assessment
Files changed (15)
|
Code Review by Qodo
1. Build time stays stale
|
|
| Filename | Overview |
|---|---|
| Core/GameEngine/Source/GameClient/GUI/ControlBar/ControlBarCommand.cpp | Computes live production and special-power countdown values and forwards them to command-button rendering. |
| Core/GameEngine/Source/GameClient/GUI/GUICallbacks/ControlBarPopupDescription.cpp | Formats build times, appends them to tooltip cost text, and refreshes visible tooltips periodically. |
| Core/GameEngineDevice/Source/W3DDevice/GameClient/GUI/Gadget/W3DPushButton.cpp | Creates, formats, draws, and releases the shared countdown display string. |
| Core/GameEngine/Source/Common/OptionPreferences.cpp | Parses named and numeric values for the new client display mode with a disabled default. |
| Generals/Code/GameEngine/Source/Common/GlobalData.cpp | Initializes and loads the Generals variant’s timer display preference. |
| GeneralsMD/Code/GameEngine/Source/Common/GlobalData.cpp | Initializes and loads the Zero Hour variant’s timer display preference. |
Flowchart
%%{init: {'theme': 'neutral'}}%%
flowchart LR
Options[Options.ini] --> Preferences[OptionPreferences]
Preferences --> GlobalData[Variant GlobalData]
GlobalData --> ControlBar[Control bar timing]
Production[Production state] --> ControlBar
Recharge[Special-power state] --> ControlBar
ControlBar --> Gadget[Push-button countdown]
Gadget --> W3D[W3D display string]
GlobalData --> Tooltip[Build tooltip]
BuildData[Unit or upgrade build time] --> Tooltip
Reviews (2): Last reviewed commit: "fix(client): Refresh the open build tool..." | Re-trigger Greptile
…changes The unit build time folds in the player's energy penalty, but nothing marks the control bar dirty when power production or consumption changes, so an already open tooltip kept showing the old time. The tooltip's own update now repopulates it about once a second while visible - only when the timer display is on, so retail stays as cheap as before.

Adds an opt-in client option drawing remaining build/recharge times on the command bar, plus the matching time in the build tooltip. Defaults off; retail behavior unless set in Options.ini.
BuildTimerDisplayMode —
None(retail, default),Seconds(plain seconds),Auto(seconds under a minute, M:SS above). Covers the head production queue slot (units and upgrades), special power recharge, and the build tooltip, where the time joins the cost line after a watch glyph — shown for free items too, which take time to build but have no cost line of their own.Unit times come from
calcTimeToBuild, so the tooltip and countdown track the player's energy penalty as power changes. Tooltip times round to nearest in integer math (a fractionalBuildTimereads as the number the modder typed); live countdowns ceil (a running timer must not show 0 with work left).The countdown's display string is returned to the manager by the
W3DDisplayStringManagerdestructor before teardown, same pattern as #3216.Works in both Zero Hour and Generals — the drawing lives in the shared gadget and W3D push button code.
These options ship in the Contra mod's engine fork and have been played there; this PR is the port onto current main with the fork's three follow-up fixes folded in. Code was written with LLM assistance and human-reviewed, adapted and playtested by the author.
Prepared for Squash and Merge.