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): centre the command grid in the field its plate paints

Olcay Seygan3d87a3babf6b
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 397fe860e..e38e6a0dc 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -383,7 +383,7 @@ found and fixed — EA's own, not port damage.**
- The writing on screen grows with your monitor now. Every panel is stretched to your resolution and always was, but the text inside it stayed the size it was drawn at in 2003, and what growth there was stopped dead at twice - so on a 2560 wide screen a command bar three times its original size still wore eight point lettering. The keys on the build buttons, the prices and the build times were the worst of it: at 2K they were drawn, and unreadable.
- The strip of everything your base is building follows the screen too, instead of staying a row of postage stamps under a command bar three times its size.
-- On a widescreen monitor the command bar is three pieces instead of one stretched strip. It was drawn for a 4:3 screen and every measurement in it is multiplied by your resolution separately across and down, so at 16:9 the whole thing came out a third wider than it is tall: square build pictures as rectangles, and one slab of metal across the entire bottom edge. The radar now sits hard in the left corner, the build grid in the middle, the selected unit's panel hard in the right corner, each at the size it was drawn at, and the battlefield shows through the two gaps that opens. At 4:3 the three pieces meet and it is the bar it has always been. The three pieces reach the screen: the paintings stop a pixel or two inside their own edges, which left a hairline of ground down both sides and along the bottom, and anything that close to an edge is now that edge. The American middle piece stands on the bottom edge like the other two sides' do, instead of hanging ten units high with a band of battlefield under the build grid, and your money now sits in the middle of its readout instead of riding the top rim of it. A one-pixel light line that stood off the right edge of that same piece at 1920x1080, from the top of the frame to the bottom, is gone too.
+- On a widescreen monitor the command bar is three pieces instead of one stretched strip. It was drawn for a 4:3 screen and every measurement in it is multiplied by your resolution separately across and down, so at 16:9 the whole thing came out a third wider than it is tall: square build pictures as rectangles, and one slab of metal across the entire bottom edge. The radar now sits hard in the left corner, the build grid in the middle, the selected unit's panel hard in the right corner, each at the size it was drawn at, and the battlefield shows through the two gaps that opens. At 4:3 the three pieces meet and it is the bar it has always been. The three pieces reach the screen: the paintings stop a pixel or two inside their own edges, which left a hairline of ground down both sides and along the bottom, and anything that close to an edge is now that edge. The American middle piece stands on the bottom edge like the other two sides' do, instead of hanging ten units high with a band of battlefield under the build grid, your money now sits in the middle of its readout instead of riding the top rim of it, and the build buttons are centred in the panel they are drawn on instead of pushing against its left edge with a strip of empty metal on the right. A one-pixel light line that stood off the right edge of that same piece at 1920x1080, from the top of the frame to the bottom, is gone too.
- Widescreen resolutions are back in the options menu.
- Borderless fullscreen: start with `-borderless` and the game fills the screen at your desktop resolution with no frame and no display mode change, so alt-tab is instant, nothing on the desktop gets shuffled around behind it, and a second monitor stays usable. Screen-edge scrolling works there, the way it does in fullscreen. The loading picture still opens as its own small window with your desktop around it, and the game only takes the screen once it has something to draw.
- Fullscreen, borderless and windowed are one saved setting now, so borderless no longer means adding a switch to your shortcut every time. `WindowMode` in `Options.ini` takes 0, 1 or 2 in that order; a switch on the command line still wins for that one run.
diff --git a/GeneralsMD/Code/GameEngine/Include/GameClient/ControlBar.h b/GeneralsMD/Code/GameEngine/Include/GameClient/ControlBar.h
index 5cebb691e..c9eb69ab5 100644
--- a/GeneralsMD/Code/GameEngine/Include/GameClient/ControlBar.h
+++ b/GeneralsMD/Code/GameEngine/Include/GameClient/ControlBar.h
@@ -896,7 +896,8 @@ public:
protected:
/// place one window and its descendants inside 'panel'; see layoutPanels
void placeInPanel( GameWindow *win, Int panel,
- Int oldParentX, Int oldParentY, Int newParentX, Int newParentY );
+ Int oldParentX, Int oldParentY, Int newParentX, Int newParentY,
+ Int shiftX = 0 );
void updateRadarAttackGlow ( void );
@@ -1284,6 +1285,7 @@ struct ControlBarPlate
const char *filename; ///< the targa, which is all the Image needs
IRegion2D design; ///< the 800x600 rectangle of the painting this piece is
Int readoutShiftY; ///< design units the money readout moves to sit in this art's box
+ Int gridShiftX; ///< design units the command grid moves to centre in this art's field
};
/** The plate 'panel' wears while the bar is dressed in 'side'. A general's scheme names a side
diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/ControlBar/ControlBar.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/ControlBar/ControlBar.cpp
index 269df6752..bd6d60d99 100644
--- a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/ControlBar/ControlBar.cpp
+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/ControlBar/ControlBar.cpp
@@ -1451,8 +1451,13 @@ static const ControlBarPlateSet thePlateSets[] =
the command buttons (494-589) exactly where it stands, and its money box does not line
up with the scheme's readout. So it stands on the bottom of the screen, where a plate
belongs, and the readout moves the ten units down into the box - the box's dark
- interior measures 448.5 to 465.4, and the 19-unit readout centres on 457. */
- { "RebornBarAmericaCenter.tga", { { 180, 429 }, { 623, 599 } }, 10 },
+ interior measures 448.5 to 465.4, and the 19-unit readout centres on 457.
+
+ The grid moves the same way and for the same reason. The painting's striped field
+ runs 224.6 to 614.2, and the fourteen command buttons are 223 to 603: the first
+ column overhangs the left bezel by a unit and a half while eleven units stand empty
+ on the right. Six to the right centres the block in the field. */
+ { "RebornBarAmericaCenter.tga", { { 180, 429 }, { 623, 599 } }, 10, 6 },
{ "RebornBarAmericaRight.tga", { { 610, 433 }, { 800, 599 } } },
}
},
@@ -1509,7 +1514,8 @@ static const char *shortWindowName( GameWindow *win )
//-------------------------------------------------------------------------------------------------
void ControlBar::placeInPanel( GameWindow *win, Int panel,
Int oldParentX, Int oldParentY,
- Int newParentX, Int newParentY )
+ Int newParentX, Int newParentY,
+ Int shiftX )
{
const Real dispW = (Real)TheDisplay->getWidth();
const Real dispH = (Real)TheDisplay->getHeight();
@@ -1545,25 +1551,35 @@ void ControlBar::placeInPanel( GameWindow *win, Int panel,
const char *shortName = shortWindowName( win );
//
- // The unnamed children are the GameWinBlockInput panes: their only job is to keep clicks on the
- // bar out of the world, so they become exactly their panel. CenterBackground blocks input as
- // well as holding the command windows, and is authored full width, so it gets the same
- // treatment - left alone it would swallow every click over the gaps we just opened up.
- //
+ // A plate is its side's own painting rather than a cut of the shipped one, so where it draws the
+ // money box and the grid field is the plate's business and not ControlBarScheme.ini's. Where
+ // the two disagree the plate says by how much and the windows follow the art: the readout drops
+ // into its box, and everything CenterBackground holds - the command grid, the beacon pane, the
+ // observer panes - slides across into the field. See ControlBarPlate.
//
- // A plate is its side's own painting, not a cut of the shipped one, so where it draws the money
- // box is the plate's business and not ControlBarScheme.ini's. Where the two disagree the plate
- // says by how much and the readout follows the art - see ControlBarPlate::readoutShiftY.
- //
- if( strcmp( shortName, "MoneyDisplay" ) == 0 && m_controlBarSchemeManager )
+ const ControlBarPlate *plate = NULL;
+ if( m_controlBarSchemeManager )
{
- const ControlBarPlate *plate = ControlBarPlateForSide( m_controlBarSchemeManager->getCurrentSide(), panel );
+ plate = ControlBarPlateForSide( m_controlBarSchemeManager->getCurrentSide(), panel );
if( plate == NULL )
plate = ControlBarPlateForSide( m_controlBarSchemeManager->getCurrentArtTwinSide(), panel );
- if( plate )
- newY += REAL_TO_INT_FLOOR( plate->readoutShiftY * s );
}
+ newX += shiftX;
+ if( plate && strcmp( shortName, "MoneyDisplay" ) == 0 )
+ newY += REAL_TO_INT_FLOOR( plate->readoutShiftY * s );
+
+ // the grid shift starts at CenterBackground and is inherited by everything under it
+ Int childShiftX = shiftX;
+ if( strcmp( shortName, "CenterBackground" ) == 0 )
+ childShiftX = plate ? REAL_TO_INT_FLOOR( plate->gridShiftX * s ) : 0;
+
+ //
+ // The unnamed children are the GameWinBlockInput panes: their only job is to keep clicks on the
+ // bar out of the world, so they become exactly their panel. CenterBackground blocks input as
+ // well as holding the command windows, and is authored full width, so it gets the same
+ // treatment - left alone it would swallow every click over the gaps we just opened up.
+ //
if( shortName[ 0 ] == 0 || strcmp( shortName, "CenterBackground" ) == 0 )
{
newX = m_panelRect[ panel ].lo.x;
@@ -1585,7 +1601,7 @@ void ControlBar::placeInPanel( GameWindow *win, Int panel,
place.placedH = newH;
for( GameWindow *child = win->winGetChild(); child; child = child->winGetNext() )
- placeInPanel( child, panel, oldX, oldY, newX, newY );
+ placeInPanel( child, panel, oldX, oldY, newX, newY, childShiftX );
} // end placeInPanel
diff --git a/GeneralsMD/Code/Tests/test_gameengine.cpp b/GeneralsMD/Code/Tests/test_gameengine.cpp
index 1dde67a37..aa0e7c9f9 100644
--- a/GeneralsMD/Code/Tests/test_gameengine.cpp
+++ b/GeneralsMD/Code/Tests/test_gameengine.cpp
@@ -7844,32 +7844,38 @@ TEST(a_plate_covers_the_windows_its_panel_is_responsible_for)
}
}
-TEST(the_money_readout_follows_the_plate_that_paints_its_box)
-{
- /* A plate is its side's own painting rather than a cut of the shipped bar, so the money box is
- where the plate draws it and not where ControlBarScheme.ini puts the readout. On the American
- centre plate the two are ten design units apart: the box's dark interior measures 448.5 to
- 465.4 and the readout is 19 units tall, so it centres on 457 - ten below the scheme's 447.5.
- China and GLA draw their boxes where the scheme expects and shift nothing. */
- struct Expect { const char *side; Int shift; };
+TEST(the_grid_and_the_readout_follow_the_plate_that_paints_them)
+{
+ /* A plate is its side's own painting rather than a cut of the shipped bar, so the money box and
+ the grid field are where the plate draws them and not where ControlBarScheme.ini and the .wnd
+ put the windows. On the American centre plate both disagree, and both were measured off the
+ targa: the box's dark interior runs 448.5 to 465.4 and the 19-unit readout centres on 457,
+ ten below the scheme's 447.5; the striped field runs 224.6 to 614.2 and the fourteen command
+ buttons are 223 to 603, so the block sits six units left of centre in it. China and GLA
+ paint theirs where the windows already are and shift nothing. */
+ struct Expect { const char *side; Int readout; Int grid; };
static const Expect expected[] =
{
- { "America", 10 }, { "China", 0 }, { "GLA", 0 }, { NULL, 0 }
+ { "America", 10, 6 }, { "China", 0, 0 }, { "GLA", 0, 0 }, { NULL, 0, 0 }
};
- // what ControlBarScheme.ini gives the readout, before any plate has its say
+ // what ControlBarScheme.ini gives the readout and the .wnd gives the button block
const Int schemeTop = 438, schemeBottom = 457;
+ const Int gridLeft = 223, gridRight = 603;
for( const Expect *e = expected; e->side; e++ )
{
const ControlBarPlate *plate = ControlBarPlateForSide( AsciiString( e->side ), ControlBar::CB_PANEL_CENTER );
CHECK( plate != NULL );
- CHECK_EQ( plate->readoutShiftY, e->shift );
+ CHECK_EQ( plate->readoutShiftY, e->readout );
+ CHECK_EQ( plate->gridShiftX, e->grid );
- // wherever it ends up, the readout has to land on the plate rather than off the top or the
- // bottom of it - a shift big enough to hang it in the battlefield is the failure to catch
+ // wherever they end up, both have to land on the plate rather than off an edge of it - a
+ // shift big enough to hang either one in the battlefield is the failure to catch
CHECK( schemeTop + plate->readoutShiftY >= plate->design.lo.y );
CHECK( schemeBottom + plate->readoutShiftY <= plate->design.hi.y );
+ CHECK( gridLeft + plate->gridShiftX >= plate->design.lo.x );
+ CHECK( gridRight + plate->gridShiftX <= plate->design.hi.x );
}
}