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): sit the American power bar in the rail its plate paints

Olcay Seygan9ad0476dc44e
diff --git a/CHANGELOG.md b/CHANGELOG.md
index bfdec52d9..d640e38dd 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -455,9 +455,8 @@ found and fixed — EA's own, not port damage.**
- 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. The stray pixels along the right-hand edges of the pieces are gone: a one-pixel light line down the side of the middle piece, and a lit speck sitting in the battlefield next to the bottom corner of the Chinese radar. Both were the same thing. The bar's artwork was being rescaled as it went to the graphics card, which left the last column of each picture holding a mirrored copy of it, and the last column of pixels on screen drew from there.
- The rest of the interface is drawn at the command bar's size, not the screen's width. The queue strip, the superweapon countdowns, the generals' powers bar down the right edge and the rank screen were each measured against how wide your monitor is, and the bar they sit beside is measured against the smaller of the two dimensions - so on a 16:9 screen a queue picture came out a third bigger than the build button it is a picture of, and the power slots were oblong where they were drawn square. One size for all of it now, and it is the bar's own.
- The writing on a build button keeps its size against the button. The hotkey letter, the price, the build time and the queue count were sized off how wide your monitor is while the bar they sit on is sized off the smaller of its width and its height, so the wider the screen the further the lettering grew away from the cameo underneath it. One size for both now, and it is the bar's.
-- Every key the game answers to is in the options screen, and you can move any of them. The keyboard screen has been in the game since 2003 - the code for it, anyway; the layout it needed was never shipped in any data file, which is why the button that opens it was authored hidden and parked off the right edge, and why its Assign button had an empty body with a comment where the work should be. It is built now: every command in one list with the key it answers to beside it, click a row and press the key you want. A key can only mean one thing, so whatever was on it gives it up. Your changes go in `Keybinds.ini` next to `Options.ini` and hold only what you moved, so a patch that adds commands does not wipe them - and none of it is in the multiplayer checksum, so two players in one match can hold completely different keyboards. It opens over a running match and closes back onto the options screen you opened it from: it used to be filed with the menus the shell keeps, so opening it mid-match put the skirmish lobby back on screen and cancel left the lobby, the pause menu and the options panel stacked on top of the battlefield. Its button on the options screen wears the game's own lettering instead of the one face in that layout that was still Times New Roman.
- Minimising the command bar sends all three panels down, and they slide back up when you bring them back. The old minimise dropped the bar a tenth of the screen and left a strip of metal, a readable money box and the top of the radar dish lying along the bottom edge, which is neither the bar nor out of the way. The radar and the middle go off the screen entirely; the selection panel stops with the row its minimise tab is in standing on the bottom corner, so what you click to bring the bar back is that tab with its own artwork behind it, not a button floating over the battlefield.
-- Everything on the command bar that each faction places for itself lands where that faction's artwork paints it. The bar's own arithmetic was overwriting those positions with the ones it had used a moment earlier, so every panel wore the generic layout's vertical placement instead of its own: the minimise button drew a second tab below the painted one, arrow and all, and the GLA money sat high enough in its box to touch the frame. One arrow now, one tab, and the number in the middle of its readout - and the same correction reaches the worker, beacon, chat and options buttons down the side of the grid.
+- Everything on the command bar that each faction places for itself lands where that faction's artwork paints it. The bar's own arithmetic was overwriting those positions with the ones it had used a moment earlier, so every panel wore the generic layout's vertical placement instead of its own: the minimise button drew a second tab below the painted one, arrow and all, and the GLA money sat high enough in its box to touch the frame. One arrow now, one tab, and the number in the middle of its readout - and the same correction reaches the worker, beacon, chat and options buttons down the side of the grid. The American power bar sits in its rail as well: it was drawing on the ledge above the rail, which put the left half of the bar on the battlefield rather than on the bar, and left the rail it reads in standing empty.
- Two stray letters, an "S" and an "M", no longer appear over the battlefield beside the selection panel the first time you minimise the bar and bring it back. They are the labels on the two unused minimise buttons the 2003 layout ships hidden; minimising hid them a second time and un-hid them on the way back.
- The markings on a build button - the shortcut letters, the price, the build time, the queue count - are set bold. At seven points against a busy cameo the light weight read as part of the picture.
- Menu panels slide in at the same speed whatever your monitor is. They travel the width of the
diff --git a/GeneralsMD/Code/GameEngine/Include/GameClient/ControlBar.h b/GeneralsMD/Code/GameEngine/Include/GameClient/ControlBar.h
index b235e8295..c7203a9e3 100644
--- a/GeneralsMD/Code/GameEngine/Include/GameClient/ControlBar.h
+++ b/GeneralsMD/Code/GameEngine/Include/GameClient/ControlBar.h
@@ -1317,6 +1317,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 powerShiftY; ///< design units the power bar moves to sit in this art's rail
Int gridShiftX; ///< design units the command grid moves to centre in this art's field
Int artW, artH; ///< texels of painting in the targa; the rest is power-of-two padding
IRegion2D minTab; ///< the minimise tab this art paints, in design units, bezel and all;
diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/ControlBar/ControlBar.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/ControlBar/ControlBar.cpp
index 8fb4fa6f2..f9c704649 100644
--- a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/ControlBar/ControlBar.cpp
+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/ControlBar/ControlBar.cpp
@@ -1563,7 +1563,7 @@ static const ControlBarPlateSet thePlateSets[] =
{
{ "America",
{
- { "RebornBarAmericaLeft.tga", { { 0, 412 }, { 183, 599 } }, 0, 0, 293, 301 },
+ { "RebornBarAmericaLeft.tga", { { 0, 412 }, { 183, 599 } }, 0, 0, 0, 293, 301 },
/* This painting is 170 design units tall for a 180-unit slot, and it is the plate's own
composition rather than a straight cut of the shipped bar: its grid field lines up with
the command buttons (494-589) exactly where it stands, and its money box does not line
@@ -1573,30 +1573,43 @@ static const ControlBarPlateSet thePlateSets[] =
447.5. Nine. (It was ten while the readout was landing at ControlBar.wnd's 446.5
instead; see the slide note in layoutPanels.)
+ The power bar moves for the same reason and is the same kind of measurement. This art
+ paints the rail in two halves - a dark groove at texels 73 to 80 and the silver tube
+ that reads as the gauge at 81 to 85, design 479.8 to 482.3 - where
+ ControlBarScheme.ini puts America's 6-unit power window at 470 to 476, on the pale
+ ledge above the whole assembly. At 1280x720 that left the bar's left half on the
+ terrain, over the plate's sloping top edge. Ten sits the bar on the tube, which is
+ the part of the rail that looks like a slot to read a bar in, with the tube's own top
+ edge showing above it; five only got it as far as the dark groove and left the tube
+ standing empty underneath, and eight covered the tube to its last texel. Twelve is
+ the ceiling - past that the bar is off the rail and on the button field. China and
+ GLA stay at 0 - their windows already cover their own rails, top highlight to bottom
+ band.
+
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 } }, 9, 6, 706, 271 },
- { "RebornBarAmericaRight.tga", { { 610, 433 }, { 800, 599 } }, 0, 0, 304, 268,
+ { "RebornBarAmericaCenter.tga", { { 180, 429 }, { 623, 599 } }, 9, 10, 6, 706, 271 },
+ { "RebornBarAmericaRight.tga", { { 610, 433 }, { 800, 599 } }, 0, 0, 0, 304, 268,
{ { 648, 434 }, { 717, 460 } } },
}
},
{ "China",
{
- { "RebornBarChinaLeft.tga", { { 1, 417 }, { 196, 598 } }, 0, 0, 315, 295 },
- { "RebornBarChinaCenter.tga", { { 176, 433 }, { 617, 597 } }, 0, 0, 718, 269 },
- { "RebornBarChinaRight.tga", { { 611, 424 }, { 798, 598 } }, 0, 0, 303, 284,
+ { "RebornBarChinaLeft.tga", { { 1, 417 }, { 196, 598 } }, 0, 0, 0, 315, 295 },
+ { "RebornBarChinaCenter.tga", { { 176, 433 }, { 617, 597 } }, 0, 0, 0, 718, 269 },
+ { "RebornBarChinaRight.tga", { { 611, 424 }, { 798, 598 } }, 0, 0, 0, 303, 284,
{ { 639, 430 }, { 686, 463 } } },
}
},
{ "GLA",
{
- { "RebornBarGLALeft.tga", { { 0, 416 }, { 215, 599 } }, 0, 0, 345, 295 },
+ { "RebornBarGLALeft.tga", { { 0, 416 }, { 215, 599 } }, 0, 0, 0, 345, 295 },
/* No shift: this plate paints its box at design 443.2 to 459.3, middle 451.3, and
ControlBarScheme.ini already puts GLA's readout at 443 to 462, middle 452.5. */
- { "RebornBarGLACenter.tga", { { 168, 437 }, { 617, 599 } }, 0, 0, 720, 261 },
- { "RebornBarGLARight.tga", { { 612, 423 }, { 799, 599 } }, 0, 0, 300, 284,
+ { "RebornBarGLACenter.tga", { { 168, 437 }, { 617, 599 } }, 0, 0, 0, 720, 261 },
+ { "RebornBarGLARight.tga", { { 612, 423 }, { 799, 599 } }, 0, 0, 0, 300, 284,
{ { 631, 428 }, { 705, 465 } } },
}
},
@@ -1693,6 +1706,8 @@ void ControlBar::placeInPanel( GameWindow *win, Int panel,
newX += shiftX;
if( plate && strcmp( shortName, "MoneyDisplay" ) == 0 )
newY += REAL_TO_INT_FLOOR( plate->readoutShiftY * s );
+ if( plate && strcmp( shortName, "PowerWindow" ) == 0 )
+ newY += REAL_TO_INT_FLOOR( plate->powerShiftY * s );
// the grid shift starts at CenterBackground and is inherited by everything under it
Int childShiftX = shiftX;
diff --git a/GeneralsMD/Code/Tests/test_gameengine.cpp b/GeneralsMD/Code/Tests/test_gameengine.cpp
index 4c7129200..ee1e8f219 100644
--- a/GeneralsMD/Code/Tests/test_gameengine.cpp
+++ b/GeneralsMD/Code/Tests/test_gameengine.cpp
@@ -8110,15 +8110,23 @@ TEST(the_grid_and_the_readout_follow_the_plate_that_paints_them)
the 19-unit readout ControlBarScheme.ini places at 438 to 457; 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 - GLA's box middle is 451.3 against a readout the scheme puts at 443 to 462. */
- struct Expect { const char *side; Int readout; Int grid; };
+ nothing - GLA's box middle is 451.3 against a readout the scheme puts at 443 to 462.
+
+ The power bar is the third of them and the same measurement: America paints a dark groove at
+ 474.8 to 479.2 and under it the silver tube that reads as the gauge, 479.8 to 482.3, against
+ the 6-unit power window ControlBarScheme.ini places at 470 to 476 - which is the pale ledge
+ above both, and at 1280x720 put the bar's left half on the terrain over the plate's sloping
+ top edge. Ten lands it on the tube. China's window covers its own rail from 469 and
+ GLA's from 470, so those two shift nothing here either. */
+ struct Expect { const char *side; Int readout; Int power; Int grid; };
static const Expect expected[] =
{
- { "America", 9, 6 }, { "China", 0, 0 }, { "GLA", 0, 0 }, { NULL, 0, 0 }
+ { "America", 9, 10, 6 }, { "China", 0, 0, 0 }, { "GLA", 0, 0, 0 }, { NULL, 0, 0, 0 }
};
- // what ControlBarScheme.ini gives the readout and the .wnd gives the button block
+ // what ControlBarScheme.ini gives the readout and the power bar, and the .wnd the button block
const Int schemeTop = 438, schemeBottom = 457;
+ const Int powerTop = 469, powerBottom = 476;
const Int gridLeft = 223, gridRight = 603;
for( const Expect *e = expected; e->side; e++ )
@@ -8126,15 +8134,30 @@ TEST(the_grid_and_the_readout_follow_the_plate_that_paints_them)
const ControlBarPlate *plate = ControlBarPlateForSide( AsciiString( e->side ), ControlBar::CB_PANEL_CENTER );
CHECK( plate != NULL );
CHECK_EQ( plate->readoutShiftY, e->readout );
+ CHECK_EQ( plate->powerShiftY, e->power );
CHECK_EQ( plate->gridShiftX, e->grid );
- // 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
+ // wherever they end up, all three have to land on the plate rather than off an edge of it -
+ // a shift big enough to hang any of them 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( powerTop + plate->powerShiftY >= plate->design.lo.y );
+ CHECK( powerBottom + plate->powerShiftY <= plate->design.hi.y );
CHECK( gridLeft + plate->gridShiftX >= plate->design.lo.x );
CHECK( gridRight + plate->gridShiftX <= plate->design.hi.x );
}
+
+ /* The shift is what puts the bar on the tube: America's window without it ends at 476, above
+ the 479.8 the tube starts at, so the whole bar sat on the pale ledge with the tube standing
+ empty below it. With the shift the window starts no lower than the tube's top edge and
+ reaches past its bottom, which is the ceiling as well as the floor - one unit further and
+ the bar starts below the rail and reads as sitting on the button field. */
+ const ControlBarPlate *am = ControlBarPlateForSide( AsciiString( "America" ), ControlBar::CB_PANEL_CENTER );
+ CHECK( am != NULL );
+ const Int tubeTop = 480, tubeBottom = 482; // texels 81..85 of the targa, in design units
+ CHECK( 476 < tubeTop ); // unshifted: entirely above the tube
+ CHECK( 470 + am->powerShiftY <= tubeTop );
+ CHECK( 476 + am->powerShiftY >= tubeBottom );
}
TEST(the_minimised_panel_stops_on_the_tab_its_plate_paints)