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.

fix(gameclient): classic power row overlap, square key plates, no secs

Olcay Seygana6bc23e21e5c
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 90acbd0f9..d78bd8f00 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1087,8 +1087,8 @@ The whole HUD is on the hardware. Four colours carry it, and they mean the same
- Display, graphics, effects, audio, controls, interface and network, behind seven buttons across the top. The original screen was one panel with everything on it at once, and it was already full the day it shipped: the language filter, the keyboard button and four camera checkboxes are all still in there, parked off the right edge where nobody can reach them, because there was nowhere left to put them.
- Every setting sits with the ones that do the same kind of job. Display is the screen and its brightness. Graphics is what the picture costs and how sharp it is, with the glow and the lighting in a group of their own instead of mixed in with the anti-aliasing. Effects is what stands in the world: all seven shadow boxes together, cloud shadows included, then the scenery, then smoke. Controls splits the camera, the orders, building placement and the mouse into four groups, and Interface holds the command bar size, the income readout, the health bars, the colours, the order lines and the language. In Classic the screen leaves out the twelve boxes Classic ignores anyway, from zoom to cursor and grid placement to the HUD size and the health bar choice, and closes the gaps they leave, so a box on that screen always does something.
- Classic Graphics, on the Graphics page, puts the game back the way it looked in 2003 in one click: its own textures and ground in place of the upscaled ones, the old hard shadows, the round dark patch under every tree where Reforged lays the tree's own outline on the ground, and no glow or sharpening over the picture. Leave it off and you have Reforged. The rest of the options stay yours either way, and the box takes effect the next time the game starts.
-- Interface, in the launcher, picks between Classic and Reforged. Classic is the command bar, mouse and hotkeys of Zero Hour 1.04 that your hands still remember; Reforged is the console in the middle, right-click orders and the key grid this version built. Every player starts on Classic, and a game started without the launcher is Classic too. The choice is yours alone: two players on different styles still play the same match and the same replay. It takes effect the next time the game starts. Classic's screen is EA's again: the one-piece command bar in each side's own painting, the radar with its flashing under-attack lamp, the beacon button, six lines of messages in the top left that fade as they did, superweapon countdowns written out by name, the old chat line and quit menu, lettering at the old sizes, and Tab opening diplomacy. What it does not do is stretch. On a 16:9 or 21:9 screen the bar, the menus and every dialog sit in a 4:3 frame in the middle at their drawn shape, and the battlefield runs out to both edges past them; at 2560x1080 that is 560 pixels of ground on either side of the bar. The mouse and keys are 1.04's as well. The left button selects and gives the order, so an enemy under it is an attack and a bunker under your infantry is a way in; the right button drops your selection or takes back a half-given order, and a right drag scrolls the map. Ctrl held is force fire. Alt held lays waypoints, and the white path joining them is drawn again. A guard order holds the range it always held, Shift and a number adds that group to what you have selected, and a build button is one unit a click. The keys are your language's own key map from the game's files, with nothing of Reforged's grid laid over it, and a build button's key is the letter 1.04 gave it, taken from the English name in every language, so a Turkish or German player presses the same key an English one does. The letter sits in the button's corner on the dark badge Reforged puts its grid keys on, a size larger and in gold while the button can be pressed; the tooltip's name is plain white with no letter picked out. A structure is selected on its own, as it always was. The radar shows no money piles or tech buildings, and the clock plate, the frame counter and the experience bar under the portrait stay off the screen. So does the peace time plate, though a host's truce still holds. The money readout is the money alone, with no income figure beside it. Health bars and garrison squares look and behave as they do in Reforged, and the Health Bars and empty garrison squares settings are back on Classic's options page. The build buttons are the pictures alone, without the seconds, price and power figures. Those seconds were measured against the wall clock, so on a match running just under full speed a 120 second build read 125. An upgrade bought for a group of buildings goes to the one whose buttons you see. In a network game a Classic player's camera is not sent to observers, as it never was in 1.04. The camera zooms on the middle of the screen ten units a notch, as near and as far as Reforged's camera goes, turns without snapping, and scrolls from the last three pixels of a full screen and not at all in a window, whatever the options say. A move order puts 1.04's animated ring on the ground where it lands, and no marker or line stays behind it. None of it reaches the battle itself: Classic sends the game only the orders 1.04 sent, so a Classic player and a Reforged one share a match, and a replay plays back the same in either.
-- Classic shows what a factory is building again. Select one with anything queued and its queue takes the portrait's place, the unit in production wearing its build clock, and a click on any entry cancels it; the portrait comes back when the queue runs dry. Until now a Classic factory could queue a hundred units with nothing on screen to count them by. The queue stops at nine, the number of slots that show it, and the build buttons grey out at nine as they did in 1.04. Your general's powers sit in one row over the bar, growing to the left, each one tucked a third under the one to its right, where they used to climb the right edge of the screen three to a row. They carry how many are ready and no key letter, and the promotion screen carries no number keys either, since Classic's number keys pick teams. Every button on that screen takes its click again: the right half used to sit under the powers bar's empty frame and the bottom row under the command bar's top edge, and a click there went nowhere.
+- Interface, in the launcher, picks between Classic and Reforged. Classic is the command bar, mouse and hotkeys of Zero Hour 1.04 that your hands still remember; Reforged is the console in the middle, right-click orders and the key grid this version built. Every player starts on Classic, and a game started without the launcher is Classic too. The choice is yours alone: two players on different styles still play the same match and the same replay. It takes effect the next time the game starts. Classic's screen is EA's again: the one-piece command bar in each side's own painting, the radar with its flashing under-attack lamp, the beacon button, six lines of messages in the top left that fade as they did, superweapon countdowns written out by name, the old chat line and quit menu, lettering at the old sizes, and Tab opening diplomacy. What it does not do is stretch. On a 16:9 or 21:9 screen the bar, the menus and every dialog sit in a 4:3 frame in the middle at their drawn shape, and the battlefield runs out to both edges past them; at 2560x1080 that is 560 pixels of ground on either side of the bar. The mouse and keys are 1.04's as well. The left button selects and gives the order, so an enemy under it is an attack and a bunker under your infantry is a way in; the right button drops your selection or takes back a half-given order, and a right drag scrolls the map. Ctrl held is force fire. Alt held lays waypoints, and the white path joining them is drawn again. A guard order holds the range it always held, Shift and a number adds that group to what you have selected, and a build button is one unit a click. The keys are your language's own key map from the game's files, with nothing of Reforged's grid laid over it, and a build button's key is the letter 1.04 gave it, taken from the English name in every language, so a Turkish or German player presses the same key an English one does. The letter sits in the button's corner on the dark badge Reforged puts its grid keys on, in the middle of a square plate the same size for every letter, larger than Reforged's and in gold while the button can be pressed; the tooltip's name is plain white with no letter picked out. A structure is selected on its own, as it always was. The radar shows no money piles or tech buildings, and the clock plate, the frame counter and the experience bar under the portrait stay off the screen. So does the peace time plate, though a host's truce still holds. The money readout is the money alone, with no income figure beside it. Health bars and garrison squares look and behave as they do in Reforged, and the Health Bars and empty garrison squares settings are back on Classic's options page. The build buttons are the pictures alone, without the seconds, price and power figures. Those seconds were measured against the wall clock, so on a match running just under full speed a 120 second build read 125. An upgrade bought for a group of buildings goes to the one whose buttons you see. In a network game a Classic player's camera is not sent to observers, as it never was in 1.04. The camera zooms on the middle of the screen ten units a notch, as near and as far as Reforged's camera goes, turns without snapping, and scrolls from the last three pixels of a full screen and not at all in a window, whatever the options say. A move order puts 1.04's animated ring on the ground where it lands, and no marker or line stays behind it. None of it reaches the battle itself: Classic sends the game only the orders 1.04 sent, so a Classic player and a Reforged one share a match, and a replay plays back the same in either.
+- Classic shows what a factory is building again. Select one with anything queued and its queue takes the portrait's place, the unit in production wearing its build clock, and a click on any entry cancels it; the portrait comes back when the queue runs dry. Until now a Classic factory could queue a hundred units with nothing on screen to count them by. The queue stops at nine, the number of slots that show it, and the build buttons grey out at nine as they did in 1.04. Your general's powers sit in one row over the bar, growing to the left, each tray's right edge tucked under the next one with the picture left whole, where they used to climb the right edge of the screen three to a row. They carry how many are ready, with no key letter and no recharge seconds, and the promotion screen carries no number keys either, since Classic's number keys pick teams. Every button on that screen takes its click again: the right half used to sit under the powers bar's empty frame and the bottom row under the command bar's top edge, and a click there went nowhere.
- Supply piles stop shouting their cash over the whole map. A small pile shows its amount only while your cursor is on it or close by, in a smaller font; a big supply dock keeps its label all the time. Classic has the same labels now, with the radar still leaving the piles off.
- The Esc menu and the general's promotion screen close the way they open, in both interfaces. Both used to vanish in a single frame, and Classic's Esc menu had lost its opening flash as well. Classic plays 1.04's flash and fade, forwards to open and backwards to close; Reforged fades its pages out over a little more than a tenth of a second, as fast as they fade in.
- Every graphics setting is on the Graphics and Effects pages. Shadows, clouds, ground lighting, soft water edges, trees, extra animations, heat haze, texture resolution and the particle limit used to hide in a popup that only opened if you picked Custom from the detail box on another page, so choosing High never showed you what High turns on. Pick a preset now and its settings change in front of you; touch any one of them and the box reads Custom. Texture filtering and the number of anisotropic samples, which needed a text editor, sit there too.
diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/ControlBar/ControlBar.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/ControlBar/ControlBar.cpp
index dcb167b9f..a17922091 100644
--- a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/ControlBar/ControlBar.cpp
+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/ControlBar/ControlBar.cpp
@@ -6481,13 +6481,13 @@ void ControlBar::arrangeSpecialPowerShortcutGrid( void )
//
// Classic keeps every power on the one row the first stands on, growing to the left, each slot
- // a third under the one to its right so the row reads as a fanned stack and eleven powers do
- // not run halfway across the screen. The cover is the right hand third, so the corner the
- // count is drawn in stays clear on every slot
+ // tucked under the one to its right. Only the tray's frame right of the cameo is covered: the
+ // cameo's hole ends 49 pixels into the 60 pixel art, so the next tray starts there and every
+ // picture stays whole
//
const Bool classic = barIsClassic();
if( classic )
- columnStep = columnStep * 2 / 3;
+ columnStep = ( columnStep * 49 + 30 ) / 60;
//
// Classic's bar keeps the authored height, 3..420 of the 800x600 screen, and widened for the
diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/ControlBar/ControlBarCommand.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/ControlBar/ControlBarCommand.cpp
index 730ea4883..5d7e8743e 100644
--- a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/ControlBar/ControlBarCommand.cpp
+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/ControlBar/ControlBarCommand.cpp
@@ -1722,7 +1722,8 @@ CommandAvailability ControlBar::getCommandAvailability( const CommandButton *com
if( frames <= 0.0f && spTemplate )
frames = (Real)spTemplate->getReloadTime();
- GadgetButtonSetSeconds( applyToWin, ControlBar_secondsFromFrames( frames ) );
+ // Classic's power buttons are EA's pictures alone, like its build buttons
+ GadgetButtonSetSeconds( applyToWin, TheGlobalData->isClassicUI() ? 0 : ControlBar_secondsFromFrames( frames ) );
}
// Pro Rules: the power is there and the button stays dead
diff --git a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/GUI/Gadget/W3DPushButton.cpp b/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/GUI/Gadget/W3DPushButton.cpp
index 399f988aa..baa2ed915 100644
--- a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/GUI/Gadget/W3DPushButton.cpp
+++ b/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/GUI/Gadget/W3DPushButton.cpp
@@ -109,7 +109,7 @@ static const Int BADGE_LEAST_POINTS = 6;
static const Real COUNT_BADGE_DESIGN_POINTS = 11.0f;
/** Classic's key letter, the only place its keys are shown. */
-static const Real CLASSIC_KEY_BADGE_DESIGN_POINTS = 10.0f;
+static const Real CLASSIC_KEY_BADGE_DESIGN_POINTS = 12.0f;
// getBadgeFont ===============================================================
/** The font the corner markings wear.
@@ -146,6 +146,7 @@ static GameFont *getBadgeFont( GameWindow *window, Real designPoints = BADGE_DES
static void drawBadge( GameWindow *window, const UnicodeString &text, Real designPoints,
HudReadoutCorner corner, Color color, const UnicodeString &bare = UnicodeString::TheEmptyString );
+static void drawClassicKeyBadge( GameWindow *window, const UnicodeString &text, Color color );
// drawButtonText =============================================================
/** Draw button text to the screen */
@@ -194,8 +195,7 @@ static void drawButtonText( GameWindow *window, WinInstanceData *instData )
if( TheGlobalData->isClassicUI() )
{
const Bool enabled = BitTest( window->winGetStatus(), WIN_STATUS_ENABLED );
- drawBadge( window, text->getText(), CLASSIC_KEY_BADGE_DESIGN_POINTS, HUD_READOUT_TOP_LEFT,
- enabled ? GameMakeColor( 255, 210, 60, 255 ) : textColor );
+ drawClassicKeyBadge( window, text->getText(), enabled ? GameMakeColor( 255, 210, 60, 255 ) : textColor );
return;
}
drawBadge( window, text->getText(), BADGE_DESIGN_POINTS, HUD_READOUT_TOP_LEFT, textColor );
@@ -311,6 +311,39 @@ static void drawBadge( GameWindow *window, const UnicodeString &text, Real desig
} // end drawBadge
+// drawClassicKeyBadge ========================================================
+/** Classic's key letter on a square plate in the button's top left corner, the letter in the
+ * middle of it. The plate is the line's height square whatever the letter, so an "I" and an "M"
+ * stand on the same plate and a row of buttons reads as one set of keys. */
+//=============================================================================
+static void drawClassicKeyBadge( GameWindow *window, const UnicodeString &text, Color color )
+{
+ ICoord2D origin, size;
+ window->winGetScreenPosition( &origin.x, &origin.y );
+ window->winGetSize( &size.x, &size.y );
+
+ DisplayString *badge = badgeString( text, getBadgeFont( window, CLASSIC_KEY_BADGE_DESIGN_POINTS ) );
+ if( badge == NULL )
+ return;
+
+ Int textWidth = 0, textHeight = 0;
+ badge->getSize( &textWidth, &textHeight );
+ if( textWidth <= 0 || textHeight <= 0 )
+ return;
+
+ // one pixel in from the button's edge, never more than half the button
+ const Int side = min( textHeight, min( size.x, size.y ) / 2 );
+ const Int left = origin.x + 1;
+ const Int top = origin.y + 1;
+ TheDisplay->drawFillRect( left, top, side, side, GameMakeColor( 2, 4, 5, 230 ) );
+ TheDisplay->drawOpenRect( left, top, side, side, 1, GameMakeColor( 90, 90, 90, 255 ) );
+
+ IRegion2D plate = { { left, top }, { left + side, top + side } };
+ badge->setClipRegion( &plate );
+ badge->draw( left + ( side - textWidth ) / 2, top + ( side - textHeight ) / 2, color, GameMakeColor( 0, 0, 0, 255 ) );
+
+} // end drawClassicKeyBadge
+
// drawSecondsBadge ===========================================================
/** Draw a small "12s" label in the button's bottom left corner - how long the
* thing on this button takes to build, or how long is left on it. */