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): classic dialogs in the 16:9 hud frame, shell boxed 4:3

Olcay Seygan598e02d60c1b
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 2a0adab6f..20505e597 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1089,7 +1089,7 @@ 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. On a 16:9 or 21:9 screen 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. The command bar runs edge to edge up to 16:9, as it always did. Past that, on 21:9 or 32:9, the match's own furniture keeps the 16:9 layout in the middle of the screen: the bar, your general's powers beside it, the promotion screen, the superweapon countdowns and the messages sit where a 16:9 screen has them, and the battlefield runs on past both ends, 320 pixels either side at 2560x1080. On 16:10 and anything wider the bar is one painted for 16:9, so it is not pulled out of shape the way EA's 4:3 one was: the radar and your selection sit at its two ends, the build grid has a longer field, the money box is in the middle and the power bar is nearly twice as long. A 4:3 or 5:4 screen keeps EA's bar as it was. The wide bar is the work of moddb_dev, from the "C&C Generals HD User Interface" mod on ModDB, itself built on pWn3d_1337's Operation Firestorm interface, and it is here with its author's permission. 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.
+- 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. On a 16:9 or 21:9 screen every menu outside a match sits in a 4:3 frame in the middle at its drawn shape, backdrop and border included, with black down both sides the way a 4:3 game looks on a wide monitor; in a match the options and save screens keep that 4:3 frame over the battlefield. The command bar runs edge to edge up to 16:9, as it always did. Past that, on 21:9 or 32:9, the match's own furniture keeps the 16:9 layout in the middle of the screen: the bar, your general's powers beside it, the build tooltip over it, the promotion screen, the superweapon countdowns, the messages, the chat line, the quit menu and diplomacy sit where a 16:9 screen has them, and the battlefield runs on past both ends, 320 pixels either side at 2560x1080. On 16:10 and anything wider the bar is one painted for 16:9, so it is not pulled out of shape the way EA's 4:3 one was: the radar and your selection sit at its two ends, the build grid has a longer field, the money box is in the middle and the power bar is nearly twice as long. A 4:3 or 5:4 screen keeps EA's bar as it was. The wide bar is the work of moddb_dev, from the "C&C Generals HD User Interface" mod on ModDB, itself built on pWn3d_1337's Operation Firestorm interface, and it is here with its author's permission. 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 climb the right edge of the screen from the top of the bar, one over the other, as they did in 1.04, and the empty strip above them no longer swallows clicks on the battlefield. 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.
diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GameWindowManagerScript.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GameWindowManagerScript.cpp
index e0939d018..9c5d18a67 100644
--- a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GameWindowManagerScript.cpp
+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GameWindowManagerScript.cpp
@@ -504,9 +504,15 @@ static Bool parseTooltip( char *token, WinInstanceData *instData,
* and adjust to make the screen rect coords relative to any parent
* if present */
//=============================================================================
-// Whether the layout being read is fitted into the 4:3 box rather than stretched to the screen:
-// set by winCreateFromScript for each file, read by parseScreenRect for each window in it.
-static Bool theLayoutFits = FALSE;
+// How the layout being read is put on the screen: set by winCreateFromScript for each file, read by
+// parseScreenRect for each window in it.
+enum LayoutPlacement
+{
+ LAYOUT_STRETCH, ///< stretched to the whole screen, x and y apart, as EA shipped every layout
+ LAYOUT_FIT, ///< one scale, centred in the 4:3 box
+ LAYOUT_HUD ///< stretched as EA shipped it, over the Classic HUD's 16:9 frame (TheHudRect)
+};
+static LayoutPlacement theLayoutPlacement = LAYOUT_STRETCH;
// The menus are fitted in both interfaces: the shell's screens and the dialogs a match opens over the
// battlefield, all centred on a 4:3 panel of their own. The stretch EA shipped drew every panel, logo
@@ -537,16 +543,39 @@ static Bool barLaysOutItself( const char *filename )
return FALSE;
}
-static Bool layoutFits( const char *filename )
+// The Classic interface's in-match furniture that stands with the command bar, in its 16:9 frame:
+// the build tooltip over the bar, the chat line, the quit menu and diplomacy. Matched on the file's
+// own name, whatever folder it was asked for under.
+static Bool classicHudLayout( const char *filename )
+{
+ const char *name = filename;
+ for( const char *c = filename; *c; c++ )
+ if( *c == '/' || *c == '\\' )
+ name = c + 1;
+ static const char *const hud[] =
+ {
+ "controlbarpopupdescription.wnd", "ingamechat.wnd", "quitmenu.wnd", "quitnosave.wnd", "diplomacy.wnd"
+ };
+ for( Int i = 0; i < (Int)ARRAY_SIZE( hud ); i++ )
+ if( stricmp( name, hud[ i ] ) == 0 )
+ return TRUE;
+ return FALSE;
+}
+
+static LayoutPlacement layoutPlacement( const char *filename )
{
if( TheGlobalData == NULL || filename == NULL )
- return FALSE;
+ return LAYOUT_STRETCH;
// "Menus/X.wnd" as the shell names them, or the whole "Window\\Menus\\X.wnd"
if( startsWithFolder( filename, "window" ) )
filename += 7;
if( TheGlobalData->isClassicUI() )
- return !barLaysOutItself( filename );
- return startsWithFolder( filename, "menus" );
+ {
+ if( barLaysOutItself( filename ) )
+ return LAYOUT_STRETCH;
+ return classicHudLayout( filename ) ? LAYOUT_HUD : LAYOUT_FIT;
+ }
+ return startsWithFolder( filename, "menus" ) ? LAYOUT_FIT : LAYOUT_STRETCH;
}
static Bool parseScreenRect( char *token, char *buffer,
@@ -586,13 +615,23 @@ static Bool parseScreenRect( char *token, char *buffer,
//
// Fit: one scale both ways, the smaller, with the layout's 4:3 area centred, so a
// panel, a logo or a medal keeps the shape it was drawn in. A window that covers the whole
- // layout - within two pixels, as a few parents are drawn - still fills the screen: it is the
- // backdrop, or the parent everything else sits in. At 4:3 the scales are equal and the offsets
- // nothing, and this is the stretch to the pixel.
+ // layout - within two pixels, as a few parents are drawn - still fills the screen in Reforged: it
+ // is the backdrop, or the parent everything else sits in. Classic keeps the backdrop in the box
+ // with the rest, black down both sides (W3DDisplay::draw). At 4:3 the scales are equal and the
+ // offsets nothing, and this is the stretch to the pixel.
//
const Bool fullScreen = screenRegion.lo.x <= 2 && screenRegion.lo.y <= 2 &&
screenRegion.hi.x >= createRes.x - 2 && screenRegion.hi.y >= createRes.y - 2;
- if( theLayoutFits && !fullScreen )
+ if( theLayoutPlacement == LAYOUT_HUD )
+ {
+ const UIRect hud = TheHudRect();
+ const Real hudScaleX = (Real)hud.w / (Real)createRes.x;
+ screenRegion.lo.x = (Int)((Real)screenRegion.lo.x * hudScaleX) + hud.x;
+ screenRegion.lo.y = (Int)((Real)screenRegion.lo.y * yScale);
+ screenRegion.hi.x = (Int)((Real)screenRegion.hi.x * hudScaleX) + hud.x;
+ screenRegion.hi.y = (Int)((Real)screenRegion.hi.y * yScale);
+ }
+ else if( theLayoutPlacement == LAYOUT_FIT && ( !fullScreen || TheGlobalData->isClassicUI() ) )
{
const Real scale = min( xScale, yScale );
const Real left = ((Real)TheDisplay->getWidth() - (Real)createRes.x * scale) / 2.0f;
@@ -2806,7 +2845,7 @@ GameWindow *GameWindowManager::winCreateFromScript( AsciiString filenameString,
// Reset the window stack
resetWindowStack();
resetWindowDefaults();
- theLayoutFits = layoutFits( filename );
+ theLayoutPlacement = layoutPlacement( filename );
//
// get the filename from the parameter, if it doesn't contain a '\' it is
diff --git a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DInGameUI.cpp b/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DInGameUI.cpp
index 5c37a22d3..ffd3b0858 100644
--- a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DInGameUI.cpp
+++ b/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DInGameUI.cpp
@@ -56,6 +56,7 @@
#include "GameClient/ControlBar.h"
#include "GameClient/Image.h"
#include "GameClient/Mouse.h"
+#include "GameClient/Shell.h"
#include "W3DDevice/GameClient/W3DAssetManager.h"
#include "W3DDevice/GameClient/W3DGUICallbacks.h"
#include "W3DDevice/GameClient/W3DInGameUI.h"
@@ -540,6 +541,26 @@ void W3DInGameUI::draw( void )
TheWindowManager->winRepaint();
+ //
+ // The Classic interface's shell screens and load screens stand in the 4:3 box, backdrop and all,
+ // and the screen past it on a wide display is black, as a 4:3 game shown on it is. The shell map
+ // behind the main menu is cut off there too.
+ //
+ if( TheGlobalData->isClassicUI() && ( ( TheShell && TheShell->isShellActive() ) || !matchOnScreen ) )
+ {
+ const UIRect box = TheUIRect();
+ const Int screenW = TheDisplay->getWidth();
+ const Int screenH = TheDisplay->getHeight();
+ const Color black = GameMakeColor( 0, 0, 0, 255 );
+ if( box.x > 0 )
+ {
+ TheDisplay->drawFillRect( 0, 0, box.x, screenH, black );
+ TheDisplay->drawFillRect( box.x + box.w, 0, screenW - box.x - box.w, screenH, black );
+ }
+ if( box.y > 0 )
+ TheDisplay->drawFillRect( 0, 0, screenW, box.y, black );
+ }
+
#ifdef DEBUG_LOGGING
tWinEnd = Clock_Ticks();
freq = Clock_Ticks_Per_Second();