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): shell menus fill the screen again, no black bars

Olcay Seygan21e8b2362f1f
diff --git a/CHANGELOG.md b/CHANGELOG.md
index de91bfb63..6c99079e0 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 few boxes Classic ignores anyway, from smooth motion to the HUD size and the order lines, 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 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. In a match nothing is pulled out of shape and nothing waits in a frame in the middle. The command bar comes in three pieces at every resolution: the radar stands on the left edge of the screen, the build grid in the middle and your selection on the right edge, each at the size a 4:3 screen of the same height gives it, with battlefield between them on anything wider. At 1920x1080 a build button is 90 by 79 pixels, the shape it was drawn, where EA's stretched bar made it 120 by 79, and on a 5120x1440 screen the radar is still in the corner your eye goes to, not 1280 pixels in from it. Your general's powers climb the right edge, the build tooltip and the chat line sit over the radar, diplomacy opens in the top left, the messages run from the top left corner and the superweapon countdowns from the top right, all at that same size, as they stood on a 4:3 screen. 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 as fast as Reforged's, about fourteen notches from the ground to the whole map where 1.04 took eighty, on the middle of the screen unless you tick Zoom to Cursor, as near and as far as Reforged's camera goes, turns without snapping unless you tick Snap Camera Rotation, and scrolls from the last three pixels of a full screen and not at all in a window, whatever the options say. It runs past the edge of the map as far as Reforged's camera does, 200 units unless `CameraBoundaryMargin` says otherwise, so a base in a corner comes to the middle of the screen in either interface. 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 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. The menus outside a match fill the screen as 1.04's did; in a match the options and save screens keep their drawn shape in the middle, over the battlefield. The match's own furniture is never pulled out of shape and never waits in a frame in the middle. The command bar comes in three pieces at every resolution: the radar stands on the left edge of the screen, the build grid in the middle and your selection on the right edge, each at the size a 4:3 screen of the same height gives it, with battlefield between them on anything wider. At 1920x1080 a build button is 90 by 79 pixels, the shape it was drawn, where EA's stretched bar made it 120 by 79, and on a 5120x1440 screen the radar is still in the corner your eye goes to, not 1280 pixels in from it. Your general's powers climb the right edge, the build tooltip and the chat line sit over the radar, diplomacy opens in the top left, the messages run from the top left corner and the superweapon countdowns from the top right, all at that same size, as they stood on a 4:3 screen. 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 as fast as Reforged's, about fourteen notches from the ground to the whole map where 1.04 took eighty, on the middle of the screen unless you tick Zoom to Cursor, as near and as far as Reforged's camera goes, turns without snapping unless you tick Snap Camera Rotation, and scrolls from the last three pixels of a full screen and not at all in a window, whatever the options say. It runs past the edge of the map as far as Reforged's camera does, 200 units unless `CameraBoundaryMargin` says otherwise, so a base in a corner comes to the middle of the screen in either interface. 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.
- Classic's command bar lets the battlefield have the ground it shows. A click on the battlefield between its three pieces, or over the sloped shoulders of the build grid's plate, reaches the unit standing there; only the painted metal keeps it. Change the resolution with the bar minimised and the build tooltip used to come back 245 pixels too high at 1920x1080, as far as the bar had dropped; it stays over the radar now.
- 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.
@@ -1229,7 +1229,7 @@ The whole HUD is on the hardware. Four colours carry it, and they mean the same
"leave now", and nothing was listening for it: the handler was switched off in 2003 and never
switched back on, so the X in the corner did nothing and the only way out was the menus. A match
in progress stops recording its replay first.
-- The menus keep their shape on a wide screen. They were drawn for 4:3, and the game has always pulled them out to the edges of whatever it is shown on, so at 16:9 every panel and logo was a third wider than it was drawn. Every menu and every dialog is now drawn at its own shape in the middle, with the backdrop still filling the screen, in Classic and Reforged alike; at 2560x1080 the main menu's buttons stand in a 1440 pixel frame instead of being pulled 2560 wide. The Menu Layout box that once chose between this and the stretch is gone. The battlefield and the Reforged console are laid out as before.
+- The menus fill the screen again, in both interfaces and at every resolution. For a while they stood in a 4:3 frame in the middle, and in Classic the screen past it was black: at 2560x1080 that was 560 pixels of nothing down each side of the main menu, and players read it as a game that had not found their monitor. The main menu, skirmish, LAN, options, the load screens and the score screen are stretched edge to edge the way Zero Hour always drew them. The dialogs a match opens over the battlefield, the Esc menu and the options and save screens among them, keep their drawn shape in the middle, with the battlefield showing round them.
## Soldiers cast real shadows
diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GameWindowManagerScript.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GameWindowManagerScript.cpp
index e05288176..04093119d 100644
--- a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GameWindowManagerScript.cpp
+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GameWindowManagerScript.cpp
@@ -75,6 +75,8 @@
#include "GameClient/GameText.h"
#include "GameClient/HeaderTemplate.h"
#include "GameClient/GlobalLanguage.h"
+#include "GameClient/Shell.h"
+#include "GameLogic/GameLogic.h"
#ifdef _INTERNAL
// for occasional debugging...
@@ -515,12 +517,11 @@ static LayoutPlacement theLayoutPlacement = LAYOUT_STRETCH;
/// where a fitted layout stands: the same fraction of the screen and of the layout, (0.5,0.5) centred
static Coord2D theLayoutAnchor = { 0.5f, 0.5f };
-// 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
-// and medal 1.33x wide on a 16:9 screen, and the MenuLayout option that once kept it is gone. In
-// Reforged the rest of Window/ is the battlefield's own furniture - the command bar, which scales
-// itself (ControlBarUniformScale), and windows that hold a screen edge (the general's powers bar, the
-// build tooltip) or follow the battlefield (chat, diplomacy, the general's promotion screen, replay
+// The dialogs a match opens over the battlefield are fitted in both interfaces, centred on a 4:3 panel
+// of their own; the shell's screens are stretched (layoutIsShellScreen). In Reforged the rest of
+// Window/ is the battlefield's own furniture - the command bar, which scales itself
+// (ControlBarUniformScale), and windows that hold a screen edge (the general's powers bar, the build
+// tooltip) or follow the battlefield (chat, diplomacy, the general's promotion screen, replay
// controls, IME) - and stays stretched.
// Whether a path starts with this folder name (lower case), any case, then '/' or '\\'.
static Bool startsWithFolder( const char *path, const char *folder )
@@ -571,6 +572,23 @@ static Coord2D classicLayoutAnchor( const char *filename )
return anchor;
}
+// The shell's screens, the load screens and the score screen fill the whole screen in both
+// interfaces, stretched as EA shipped them: players took a 4:3 menu between black bars on a wide
+// monitor for a broken game. Only a match's own furniture and the dialogs it opens are fitted. The
+// furniture lies outside Menus/ and is built at startup, while the shell is up, so only a Menus/
+// layout asks whether a match is on screen.
+static Bool layoutIsShellScreen( const char *filename )
+{
+ if( !startsWithFolder( filename, "menus" ) )
+ return FALSE;
+ for( const char *c = filename; *c; c++ )
+ if( strnicmp( c, "loadscreen", 10 ) == 0 || strnicmp( c, "scorescreen", 11 ) == 0 )
+ return TRUE;
+ const Bool inMatch = TheGameLogic && TheGameLogic->isInGame() && !TheGameLogic->isInShellGame() &&
+ !( TheShell && TheShell->isShellActive() );
+ return !inMatch;
+}
+
static LayoutPlacement layoutPlacement( const char *filename )
{
theLayoutAnchor.x = theLayoutAnchor.y = 0.5f;
@@ -579,6 +597,8 @@ static LayoutPlacement layoutPlacement( const char *filename )
// "Menus/X.wnd" as the shell names them, or the whole "Window\\Menus\\X.wnd"
if( startsWithFolder( filename, "window" ) )
filename += 7;
+ if( layoutIsShellScreen( filename ) )
+ return LAYOUT_STRETCH;
if( TheGlobalData->isClassicUI() )
{
if( barLaysOutItself( filename ) )
@@ -627,9 +647,9 @@ 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 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.
+ // is the backdrop, or the parent everything else sits in. Classic keeps a match dialog's backdrop
+ // in the box with the rest, over the battlefield. 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;
diff --git a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DInGameUI.cpp b/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DInGameUI.cpp
index b930cca63..7f78545cb 100644
--- a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DInGameUI.cpp
+++ b/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DInGameUI.cpp
@@ -56,7 +56,6 @@
#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"
@@ -541,26 +540,6 @@ 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();