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.
C++ cmakecnccommand-and-conquercppdirectx11game-enginegame-preservationgeneralsrtssage-enginex64zero-hour
fix(gameclient): stop the re-layout throwing away the scheme's positions
Olcay Seygan54933d66b57f
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 8cfb7440d..996f834bc 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -449,7 +449,8 @@ found and fixed — EA's own, not port damage.**- 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. That tab sits where the painting puts it now: every faction's panel paints its own minimise tab, arrow and all, and none of them paints it where the 2003 layout put the button, so the button was drawing a second tab beside the painted one - two arrows, up to nineteen pixels apart. The painted tab is the one you see: the button stopped drawing a tab of its own over it, having no artwork the right shape for the space, and is now just the place you click. Minimised it draws again, because then the arrow has to point the other way.+- 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.- 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 thediff --git a/GeneralsMD/Code/GameEngine/Include/GameClient/ControlBar.h b/GeneralsMD/Code/GameEngine/Include/GameClient/ControlBar.hindex bed73a36d..b235e8295 100644--- a/GeneralsMD/Code/GameEngine/Include/GameClient/ControlBar.h+++ b/GeneralsMD/Code/GameEngine/Include/GameClient/ControlBar.h@@ -1319,7 +1319,8 @@ struct ControlBarPlateInt readoutShiftY; ///< design units the money readout moves to sit in this art's boxInt gridShiftX; ///< design units the command grid moves to centre in this art's fieldInt 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; ButtonLarge takes it+ IRegion2D minTab; ///< the minimise tab this art paints, in design units, bezel and all;+ ///< a minimised panel stops with this row standing on the bottom edge};/** The plate 'panel' wears while the bar is dressed in 'side'. A general's scheme names a sidediff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/ControlBar/ControlBar.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/ControlBar/ControlBar.cppindex 3c511e5d9..8fb4fa6f2 100644--- a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/ControlBar/ControlBar.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/ControlBar/ControlBar.cpp@@ -1568,14 +1568,16 @@ static const ControlBarPlateSet thePlateSets[] =composition rather than a straight cut of the shipped bar: its grid field lines up withthe command buttons (494-589) exactly where it stands, and its money box does not lineup 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.+ belongs, and the readout moves down into the box - the box's dark interior measures+ 448.5 to 465.4, middle 456.6, where ControlBarScheme.ini puts the readout's middle at+ 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 grid moves the same way and for the same reason. The painting's striped fieldruns 224.6 to 614.2, and the fourteen command buttons are 223 to 603: the firstcolumn overhangs the left bezel by a unit and a half while eleven units stand emptyon the right. Six to the right centres the block in the field. */- { "RebornBarAmericaCenter.tga", { { 180, 429 }, { 623, 599 } }, 10, 6, 706, 271 },+ { "RebornBarAmericaCenter.tga", { { 180, 429 }, { 623, 599 } }, 9, 6, 706, 271 },{ "RebornBarAmericaRight.tga", { { 610, 433 }, { 800, 599 } }, 0, 0, 304, 268,{ { 648, 434 }, { 717, 460 } } },}@@ -1591,6 +1593,8 @@ static const ControlBarPlateSet thePlateSets[] ={ "GLA",{{ "RebornBarGLALeft.tga", { { 0, 416 }, { 215, 599 } }, 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,{ { 631, 428 }, { 705, 465 } } },@@ -1690,19 +1694,6 @@ void ControlBar::placeInPanel( GameWindow *win, Int panel,if( plate && strcmp( shortName, "MoneyDisplay" ) == 0 )newY += REAL_TO_INT_FLOOR( plate->readoutShiftY * s );- //- // The minimise button is not where the .wnd says either: every plate paints its own tab for it,- // and the button takes that rectangle rather than the authored one. Otherwise it draws its own- // tab beside the painted one and you get two arrows.- //- if( plate && plate->minTab.width() > 0 && strcmp( shortName, "ButtonLarge" ) == 0 )- {- newX = REAL_TO_INT_FLOOR( originX + plate->minTab.lo.x * s );- newY = REAL_TO_INT_FLOOR( dispH - ( CONTROL_BAR_DESIGN_H - plate->minTab.lo.y ) * s );- newW = REAL_TO_INT_CEIL( plate->minTab.width() * s );- newH = REAL_TO_INT_CEIL( plate->minTab.height() * s );- }-// the grid shift starts at CenterBackground and is inherited by everything under itInt childShiftX = shiftX;if( strcmp( shortName, "CenterBackground" ) == 0 )@@ -1929,16 +1920,50 @@ void ControlBar::layoutPanels( void )// taken off first and put back at the end, and a bar that was minimised when the side changed// is minimised again without the trip down.//+ // Taken off by moving each panel back up by however far it had travelled, not by calling+ // applyPanelSlide - that puts every window back where this function last put it, and+ // ControlBarScheme::init writes the money readout, the two tabs and the toolbar column their+ // own positions immediately before calling us. Restoring the cached y threw every one of+ // those away, so the bar wore ControlBarScheme.ini's x and size with ControlBar.wnd's y: the+ // GLA money sat six units high in its box, and the minimise button drew its tab eleven units+ // below the one its plate paints, which is where the two arrows came from.+ //Bool wasAway[ CB_PANEL_COUNT ];+ Int slideOff[ CB_PANEL_COUNT ];Int q;for( q = 0; q < CB_PANEL_COUNT; q++ ){wasAway[ q ] = ( m_panelSlideTo[ q ] > 0.0f );+ slideOff[ q ] = getPanelSlideOffset( q );+ }++ for( GameWindow *slid = parent->winGetChild(); slid; slid = slid->winGetNext() )+ {+ ControlBarPanelPlacementMap::iterator it = theControlBarPlacement.find( slid );+ if( it == theControlBarPlacement.end() || it->second.known == FALSE )+ continue;+ ControlBarPanelPlacement &place = it->second;+ if( place.panel < 0 || place.panel >= CB_PANEL_COUNT )+ continue;+ if( place.weHid )+ {+ slid->winHide( FALSE );+ place.weHid = FALSE;+ }+ if( slideOff[ place.panel ] != 0 )+ {+ ICoord2D pos;+ slid->winGetPosition( &pos.x, &pos.y );+ slid->winSetPosition( pos.x, pos.y - slideOff[ place.panel ] );+ }+ }++ for( q = 0; q < CB_PANEL_COUNT; q++ )+ {m_panelSlide[ q ] = 0.0f;m_panelSlideTo[ q ] = 0.0f;m_panelHidden[ q ] = FALSE;}- applyPanelSlide();const Real dispW = (Real)TheDisplay->getWidth();const Real dispH = (Real)TheDisplay->getHeight();@@ -5215,28 +5240,6 @@ void ControlBar::setUpDownImages( void )return;}- //- // A plate that paints its own minimise tab is the picture. The button sits exactly on that tab- // now (see placeInPanel), so drawing the down arrow's art there lays a second copy of the tab- // over the painted one, stretched to a rectangle the art was not drawn for - a wide arrow on a- // slab covering the painted bezel. Leave the button as the place you click and let the painting- // be what you see. It costs the hover and pushed states, which nothing else paints.- //- // Only in this stage. Minimised, the painted arrow points the wrong way - the tab is then the- // only piece of the bar on screen and it has to say "up" - so the up art is drawn there as it- // always was.- //- const ControlBarPlate *minTabPlate = m_controlBarSchemeManager- ? ControlBarPlateForSide( m_controlBarSchemeManager->getCurrentSide(), CB_PANEL_RIGHT )- : NULL;- if( minTabPlate && minTabPlate->minTab.width() > 0 )- {- GadgetButtonSetEnabledImage( win, NULL );- GadgetButtonSetHiliteImage( win, NULL );- GadgetButtonSetHiliteSelectedImage( win, NULL );- return;- }-GadgetButtonSetEnabledImage(win, m_toggleButtonDownOn);GadgetButtonSetHiliteImage(win, m_toggleButtonDownIn);GadgetButtonSetHiliteSelectedImage(win, m_toggleButtonDownPushed);diff --git a/GeneralsMD/Code/Tests/test_gameengine.cpp b/GeneralsMD/Code/Tests/test_gameengine.cppindex 302457f5b..b58b82b25 100644--- a/GeneralsMD/Code/Tests/test_gameengine.cpp+++ b/GeneralsMD/Code/Tests/test_gameengine.cpp@@ -8083,14 +8083,15 @@ 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 andthe grid field are where the plate draws them and not where ControlBarScheme.ini and the .wndput 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. */+ targa: the box's dark interior runs 448.5 to 465.4, middle 456.6, nine below the middle of+ 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; };static const Expect expected[] ={- { "America", 10, 6 }, { "China", 0, 0 }, { "GLA", 0, 0 }, { NULL, 0, 0 }+ { "America", 9, 6 }, { "China", 0, 0 }, { "GLA", 0, 0 }, { NULL, 0, 0 }};// what ControlBarScheme.ini gives the readout and the .wnd gives the button block@@ -8113,13 +8114,13 @@ TEST(the_grid_and_the_readout_follow_the_plate_that_paints_them)}}-TEST(the_minimise_button_sits_on_the_tab_its_plate_paints)+TEST(the_minimised_panel_stops_on_the_tab_its_plate_paints){- /* Each right-hand plate paints its own minimise tab, green arrow and all, and none of them- paints it where ControlBar.wnd puts ButtonLarge - 666,445 to 714,473. Left on the authored- rectangle the button drew a second tab beside the painted one, which at 1920x1080 was up to- nineteen pixels of doubled metal and two arrows. The rectangles below were measured off the- three targas; placeInPanel hands them to ButtonLarge instead of the authored one. */+ /* Each right-hand plate paints its own minimise tab, bezel and arrow, and none of them paints it+ where ControlBar.wnd puts ButtonLarge - 666,445 to 714,473. The button itself lands on the+ painting from ControlBarScheme.ini's MinMaxUL/LR, which is EA's own per-side rectangle; what+ the plate carries is the tab as painted, bezel included, because that is where the minimised+ selection panel has to stop. The rectangles were measured off the three targas. */static const char *const sides[] = { "America", "China", "GLA", NULL };// what the .wnd says, which is the thing every one of these has to disagree with@@ -8131,7 +8132,7 @@ TEST(the_minimise_button_sits_on_the_tab_its_plate_paints)const ControlBarPlate *plate = ControlBarPlateForSide( AsciiString( *s ), ControlBar::CB_PANEL_RIGHT );CHECK( plate != NULL );- // a tab at all - a zeroed rectangle means the button went back to the authored place+ // a tab at all - a zeroed rectangle means the panel drops out of sight entirelyCHECK( plate->minTab.width() > 0 );CHECK( plate->minTab.height() > 0 );@@ -8141,8 +8142,8 @@ TEST(the_minimise_button_sits_on_the_tab_its_plate_paints)CHECK( plate->minTab.lo.y >= plate->design.lo.y );CHECK( plate->minTab.hi.y <= plate->design.hi.y );- // and it has to be a tab-sized thing: the arrow art is stretched into it, so a fat-fingered- // number that makes the button half the panel is the failure worth catching+ // and it has to be a tab-sized thing: a fat-fingered number that leaves half the panel on+ // screen, or nothing of it, is the failure worth catchingCHECK( plate->minTab.width() >= wndWidth / 2 );CHECK( plate->minTab.width() <= wndWidth * 2 );CHECK( plate->minTab.height() >= wndHeight / 2 );