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
feat(gameclient): menu in the corner, worker tab, money on the steel
Olcay Seygancb38982cd145
diff --git a/GeneralsMD/Code/Data/Patch.str b/GeneralsMD/Code/Data/Patch.strindex fe356f6d8..7f1c1ec29 100644--- a/GeneralsMD/Code/Data/Patch.str+++ b/GeneralsMD/Code/Data/Patch.str@@ -1104,10 +1104,6 @@ GUI:HudSuperweaponReadyEND// the command bar's own buttons, written on them now that the bar is drawn from a page-GUI:BarMenu-"Menu"-END-GUI:BarIdleWorker"Worker"END@@ -1116,10 +1112,6 @@ GUI:BarBeacon"Beacon"END-GUI:BarChat-"Chat"-END-// the box in the corner of the radar that lights while your forces are under attackGUI:BarUnderAttack"UNDER ATTACK"diff --git a/GeneralsMD/Code/Data/Turkish/Generals.str b/GeneralsMD/Code/Data/Turkish/Generals.strindex 47bd78529..a8c51f81a 100644--- a/GeneralsMD/Code/Data/Turkish/Generals.str+++ b/GeneralsMD/Code/Data/Turkish/Generals.str@@ -15629,10 +15629,6 @@ GUI:HudSuperweaponReady"ateşe hazır"END-GUI:BarMenu-"Menü"-END-GUI:BarIdleWorker"İşçi"END@@ -15641,10 +15637,6 @@ GUI:BarBeacon"İşaret"END-GUI:BarChat-"Sohbet"-END-GUI:BarUnderAttack"SALDIRI ALTINDA"ENDdiff --git a/GeneralsMD/Code/Data/Window/Html/ControlBar.html b/GeneralsMD/Code/Data/Window/Html/ControlBar.htmlindex a29b43546..9c650a569 100644--- a/GeneralsMD/Code/Data/Window/Html/ControlBar.html+++ b/GeneralsMD/Code/Data/Window/Html/ControlBar.html@@ -2,24 +2,27 @@<!--The command bar's frame, drawn where its three plates used to be, and the bar's own buttons. Thecommand buttons, the radar, the money, the power bar and the portrait are still the bar's windows- and paint over this page. The menu, worker, beacon, chat, minimise and promotion buttons and the- under-attack light are the page's to draw: their windows take the clicks and draw nothing. Same- materials as Window/Html/Spectator.html, whose header says what the renderer draws and what not.+ and paint over this page. The promotion, minimise and beacon buttons and the under-attack light+ are the page's to draw: their windows take the clicks and draw nothing. The menu and idle worker+ buttons are the page's altogether, pressed through data-click="press:Name"; the chat button is+ gone and Enter still opens the chat. Same materials as Window/Html/Spectator.html, whose header+ says what the renderer draws and what not.- Everything with class "solid" catches clicks; the rest of the screen is battlefield, whatever the- old plates covered.+ Everything with class "solid" catches clicks for the bar; the rest of the screen is battlefield,+ whatever the old plates covered. A data-click="press:Name" button must not be solid: its click+ reaches the page as a click on the battlefield.The game fills in, every frame (GameClient/HtmlTemplate.h):{{side}} "america", "china" or "gla": the side whose bar is on screen{{promotion}} "ready" while the general has a promotion to spend+ {{watching}} "watching" while the local player is an observer or out of the match{{blink}} "lit" for half of every second, for anything that blinks{{panelN.x}} .y .w .h N 0 to 2, left, centre and right: where the plates would have gone,moving with the bar when it slides or minimises; .w and .h are 0 and{{panelN.shown}} is "hidden" when a minimised bar has stood it down{{left.x}} .y .w .h the box round the radar, so the left panel is only as big as its bezel- {{centre.x}} .y .w .h the box round the command grid, the power bar over it and the four buttons- beside it; {{centre.shown}} as above- {{purse.x}} .y .w .h the box round the money, above the centre+ {{centre.x}} .y .w .h the box round the command grid with the money and the power bar over it;+ {{centre.shown}} as above{{right.x}} .y .w .h the box round the portrait and the experience bar. The promotion andminimise buttons are moved to sit over its top right corner{{Name.x}} .y .w .h the rectangle of the bar's window Name, {{Name.shown}} "shown" or "hidden"@@ -55,13 +58,10 @@/* every panel hugs what it holds, and what the old plates covered round them is battlefield andtakes clicks as one: the left the radar's bezel, the right the portrait with the two small- buttons over its top right corner, the centre the command grid under the power bar, and the- purse above it the money and nothing else */+ buttons over its top right corner, the centre the command grid under the money and power bar */.left { margin: -10px 0 0 -8px; padding: 10px 8px 8px 8px; }.right { margin: -22px 0 0 -8px; padding: 22px 8px 8px 8px; }.centre { margin: -10px 0 0 -6px; padding: 10px 6px 6px 6px; }- .purse { margin: -4px 0 0 -6px; padding: 4px 6px 3px 6px; }- .purse .rail { height: 2px; }/* a bezel: a window set into the panel, four pixels of steel round a black lip */.bezel { margin: -5px 0 0 -5px; border: 4px solid #4b535e; border-top-color: #2a3036; border-left-color: #2a3036;@@ -73,22 +73,30 @@.well { margin: -3px 0 0 -3px; border: 2px solid #0c1114; border-bottom-color: #4b535e; border-right-color: #4b535e;background-color: rgba(0, 0, 0, 0.35); }- .plaque { margin: -1px 0 0 -1px; border: 1px solid #0c1114; border-bottom-color: #6f7782; background-color: #05080a; }.groove { margin: -2px 0 0 -2px; border: 1px solid #000000; border-bottom-color: #6f7782; background-color: #020405; }- /* the bar's own buttons: a steel cap with its name on it, pressed in when pushed */+ /* the bar's own buttons: a steel cap, lit gold under the pointer and pressed in when pushed */.button { text-align: center; color: #e8eef2; font-weight: bold;background: linear-gradient(to bottom, #7d8691, #3f4650); border: 1px solid #0c1114;border-top-color: #c3ccd3; border-left-color: #aab4bf; }.china .button { background: linear-gradient(to bottom, #a44734, #4c1b13); border-top-color: #e8a28a; border-left-color: #d98a72; }.gla .button { background: linear-gradient(to bottom, #978a50, #48401e); border-top-color: #ddd29a; border-left-color: #cbbf82; }- .button.hilite { color: #ffffff; border-color: #e8d27a; }+ .button.hilite, .button:hover { color: #ffffff; border-color: #e8d27a; }.button.pushed { background: linear-gradient(to bottom, #2a3036, #4b535e); border-top-color: #0c1114; border-left-color: #0c1114; }.button.disabled { color: #6f7782; }.button .cap { position: absolute; left: 0; right: 0; top: 50%; margin-top: -5px; line-height: 10px; }.button .stars { font-size: 10px; }.button.promotion.ready.lit { background: linear-gradient(to bottom, #f6e08a, #a4832a); color: #1a1406; border-color: #fff4b8; }+ /* the menu: three bars in a square cap in the screen's top left corner */+ .menu { left: 4px; top: 4px; width: 18px; height: 16px; }+ .menu .bar { position: absolute; left: 4px; right: 4px; height: 2px; background-color: #e8eef2; }+ .menu:hover .bar { background-color: #e8d27a; }++ /* the idle worker: a tab over the centre panel's top left corner, outside it */+ .worker { position: absolute; left: 0; top: -15px; width: 44px; height: 14px; border-bottom: 0; }+ .watching .worker { display: none; }+/* the under-attack light: a tab on the left panel's top left edge, red while the bar blinks it */.alert { position: absolute; left: 4px; top: -15px; height: 13px; line-height: 13px; padding: 0 6px; font-size: 7px; font-weight: bold;color: #5a2a24; background-color: rgba(20, 8, 6, 0.9); border: 1px solid #4a1a14; border-bottom: 0; }@@ -96,14 +104,16 @@</style></head><body>-<div class="{{side}}">+<div class="{{side}} {{watching}}"><div class="piece panel solid left {{left.shown}}" style="left: {{left.x}}px; top: {{left.y}}px; width: {{left.w}}px; height: {{left.h}}px"><div class="rail"></div><div class="alert {{WinUAttack.state}}">{{text:GUI:BarUnderAttack}}</div></div>- <div class="piece panel solid purse {{purse.shown}}" style="left: {{purse.x}}px; top: {{purse.y}}px; width: {{purse.w}}px; height: {{purse.h}}px"><div class="rail"></div></div>- <div class="piece panel solid centre {{centre.shown}}" style="left: {{centre.x}}px; top: {{centre.y}}px; width: {{centre.w}}px; height: {{centre.h}}px"><div class="rail"></div></div>+ <div class="piece panel solid centre {{centre.shown}}" style="left: {{centre.x}}px; top: {{centre.y}}px; width: {{centre.w}}px; height: {{centre.h}}px">+ <div class="rail"></div>+ <div class="worker button {{ButtonIdleWorker.state}}" data-click="press:ButtonIdleWorker"><div class="cap">{{text:GUI:BarIdleWorker}}</div></div>+ </div><div class="piece panel solid right {{right.shown}}" style="left: {{right.x}}px; top: {{right.y}}px; width: {{right.w}}px; height: {{right.h}}px"><div class="rail"></div></div><div class="piece bezel {{LeftHUD.shown}}" style="left: {{LeftHUD.x}}px; top: {{LeftHUD.y}}px; width: {{LeftHUD.w}}px; height: {{LeftHUD.h}}px">@@ -122,17 +132,19 @@</div><div class="piece well {{CommandWindow.shown}}" style="left: {{CommandWindow.x}}px; top: {{CommandWindow.y}}px; width: {{CommandWindow.w}}px; height: {{CommandWindow.h}}px"></div>- <div class="piece plaque {{MoneyDisplay.shown}}" style="left: {{MoneyDisplay.x}}px; top: {{MoneyDisplay.y}}px; width: {{MoneyDisplay.w}}px; height: {{MoneyDisplay.h}}px"></div><div class="piece groove {{PowerWindow.shown}}" style="left: {{PowerWindow.x}}px; top: {{PowerWindow.y}}px; width: {{PowerWindow.w}}px; height: {{PowerWindow.h}}px"></div><div class="piece groove {{GeneralsExp.shown}}" style="left: {{GeneralsExp.x}}px; top: {{GeneralsExp.y}}px; width: {{GeneralsExp.w}}px; height: {{GeneralsExp.h}}px"></div>- <div class="piece button {{ButtonOptions.shown}} {{ButtonOptions.state}}" style="left: {{ButtonOptions.x}}px; top: {{ButtonOptions.y}}px; width: {{ButtonOptions.w}}px; height: {{ButtonOptions.h}}px"><div class="cap">{{text:GUI:BarMenu}}</div></div>- <div class="piece button {{ButtonIdleWorker.shown}} {{ButtonIdleWorker.state}}" style="left: {{ButtonIdleWorker.x}}px; top: {{ButtonIdleWorker.y}}px; width: {{ButtonIdleWorker.w}}px; height: {{ButtonIdleWorker.h}}px"><div class="cap">{{text:GUI:BarIdleWorker}}</div></div><div class="piece button {{ButtonPlaceBeacon.shown}} {{ButtonPlaceBeacon.state}}" style="left: {{ButtonPlaceBeacon.x}}px; top: {{ButtonPlaceBeacon.y}}px; width: {{ButtonPlaceBeacon.w}}px; height: {{ButtonPlaceBeacon.h}}px"><div class="cap">{{text:GUI:BarBeacon}}</div></div>- <div class="piece button {{PopupCommunicator.shown}} {{PopupCommunicator.state}}" style="left: {{PopupCommunicator.x}}px; top: {{PopupCommunicator.y}}px; width: {{PopupCommunicator.w}}px; height: {{PopupCommunicator.h}}px"><div class="cap">{{text:GUI:BarChat}}</div></div><div class="piece button promotion {{promotion}} {{blink}} {{ButtonGeneral.shown}} {{ButtonGeneral.state}}" style="left: {{ButtonGeneral.x}}px; top: {{ButtonGeneral.y}}px; width: {{ButtonGeneral.w}}px; height: {{ButtonGeneral.h}}px"><div class="cap stars">★★★</div></div><div class="piece button {{ButtonLarge.shown}} {{ButtonLarge.state}}" style="left: {{ButtonLarge.x}}px; top: {{ButtonLarge.y}}px; width: {{ButtonLarge.w}}px; height: {{ButtonLarge.h}}px"><div class="cap">▼</div></div>+ <div class="piece button menu {{ButtonOptions.state}}" data-click="press:ButtonOptions">+ <div class="bar" style="top: 4px"></div>+ <div class="bar" style="top: 7px"></div>+ <div class="bar" style="top: 10px"></div>+ </div>+</div></body></html>diff --git a/GeneralsMD/Code/Data/Window/Html/Spectator.html b/GeneralsMD/Code/Data/Window/Html/Spectator.htmlindex a49d96c14..0695ab099 100644--- a/GeneralsMD/Code/Data/Window/Html/Spectator.html+++ b/GeneralsMD/Code/Data/Window/Html/Spectator.html@@ -101,7 +101,8 @@.team1 .tint { background-color: #ff7a5c; }/* ---- the left panel ---- */- #hud-top { position: absolute; left: 4px; top: 4px; width: 172px; }+ /* it stands clear of the command bar's menu button in the screen's top left corner */+ #hud-top { position: absolute; left: 26px; top: 4px; width: 172px; }.strips { margin-bottom: 3px; }.strips .plate { padding: 2px 5px; }diff --git a/GeneralsMD/Code/GameEngine/Include/GameClient/InGameUI.h b/GeneralsMD/Code/GameEngine/Include/GameClient/InGameUI.hindex f84505213..0c5b274cc 100644--- a/GeneralsMD/Code/GameEngine/Include/GameClient/InGameUI.h+++ b/GeneralsMD/Code/GameEngine/Include/GameClient/InGameUI.h@@ -404,6 +404,9 @@ public: // ********************************************************************/** The command bar's page, Window/Html/ControlBar.html, under the bar's windows: its panels are* where the plates would have gone, in screen pixels. FALSE when there is no page to draw. */Bool drawControlBarPage( const IRegion2D *panels, const Bool *shown, Int panelCount );+ /** A click that reached the world, on one of that page's own buttons: TRUE when it was one, and+ * when `act` is set the button it names is pressed. */+ Bool handleControlBarPageClick( const ICoord2D *mouse, Bool act );void drawScoreboard( void ); ///< that scoreboard, over everythingvirtual Bool isMessagesOn( void ) { return m_messagesOn; } ///< are the display messages onvoid freeMessageResources( void ); ///< free resources for the ui messages@@ -1204,6 +1207,7 @@ protected:std::string m_scoreboardPage;HtmlOverlay * m_controlBarOverlay;Bool m_controlBarPageLoaded;+ Bool m_controlBarPageShown; ///< drawn this frame, so its buttons can be clickedstd::string m_controlBarPage;//diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/InGameUI.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/InGameUI.cppindex 13e388fc9..9cc974815 100644--- a/GeneralsMD/Code/GameEngine/Source/GameClient/InGameUI.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/InGameUI.cpp@@ -1202,6 +1202,7 @@ InGameUI::InGameUI()m_scoreboardPageLoaded = FALSE;m_controlBarOverlay = NULL;m_controlBarPageLoaded = FALSE;+ m_controlBarPageShown = FALSE;for( Int stripSeconds = 0; stripSeconds < STRIP_SECONDS_STRINGS; stripSeconds++ )m_stripSecondsString[ stripSeconds ] = NULL;for( Int stripQuantity = 0; stripQuantity < STRIP_QUANTITY_STRINGS; stripQuantity++ )@@ -10092,25 +10093,29 @@ static const char *const CONTROL_BAR_WINDOWS[] ="WinUAttack"};-/** The bar's windows the page draws instead of letting them paint themselves: its own buttons and- * the radar's under-attack light. They still take their clicks; only their pictures are the page's. */+/** The bar's windows the page draws instead of letting them paint themselves: the promotion and+ * minimise buttons, the beacon button and the radar's under-attack light. They still take their+ * clicks; only their pictures are the page's. */static const char *const CONTROL_BAR_CUSTOM[] ={- "ButtonGeneral", "ButtonLarge", "ButtonOptions", "ButtonIdleWorker", "ButtonPlaceBeacon", "PopupCommunicator",- "WinUAttack"+ "ButtonGeneral", "ButtonLarge", "ButtonPlaceBeacon", "WinUAttack"};+/** The bar's windows the page stands down altogether. The menu and idle worker buttons are the+ * page's own, pressed through data-click="press:Name" because they sit where the bar's frame takes+ * no clicks; the chat button is gone, and Enter still opens the chat. */+static const char *const CONTROL_BAR_STOOD_DOWN[] = { "ButtonOptions", "ButtonIdleWorker", "PopupCommunicator" };+static const std::string PRESS_ACTION = "press:";+/** The windows each panel is drawn round, so a panel is only as big as what it holds: the left one* the radar, the right one the portrait and the experience bar, the centre the command grid with- * the power bar over it, and the purse above that the money alone. NULL ends each list. */+ * the money and the power bar over it. NULL ends each list. */static const char *const CONTROL_BAR_LEFT[] = { "LeftHUD", NULL };static const char *const CONTROL_BAR_RIGHT[] = { "RightHUD", "GeneralsExp", "ExpBarForeground", NULL };static const char *const CONTROL_BAR_CENTRE[] ={- "CommandWindow", "ObserverPlayerListWindow", "PowerWindow", "ButtonOptions", "ButtonIdleWorker",- "ButtonPlaceBeacon", "PopupCommunicator", NULL+ "CommandWindow", "ObserverPlayerListWindow", "MoneyDisplay", "PowerWindow", "ButtonPlaceBeacon", NULL};-static const char *const CONTROL_BAR_PURSE[] = { "MoneyDisplay", NULL };/** The promotion and minimise buttons, small, side by side in the right panel's top right corner,* the minimise button outermost. 800x600 pixels. */@@ -10204,6 +10209,7 @@ static void putPageRect( HtmlValues &values, const std::string &name, const IReg//-------------------------------------------------------------------------------------------------Bool InGameUI::drawControlBarPage( const IRegion2D *panels, const Bool *shown, Int panelCount ){+ m_controlBarPageShown = FALSE;if( TheGameLogic == NULL || !TheGameLogic->isInGame() || TheGameLogic->isInShellGame() ){TheControlBar->setPageSolids( NULL );@@ -10226,6 +10232,7 @@ Bool InGameUI::drawControlBarPage( const IRegion2D *panels, const Bool *shown, IHtmlValues values;values[ "side" ] = spectatorSide();values[ "promotion" ] = TheControlBar->isGeneralStarFlashing() ? "ready" : "";+ values[ "watching" ] = localPlayerWatching() ? "watching" : "";values[ "blink" ] = TheGameLogic->getFrame() % LOGICFRAMES_PER_SECOND > LOGICFRAMES_PER_SECOND / 2 ? "lit" : "";for( Int panel = 0; panel < panelCount; panel++ )putPageRect( values, "panel" + std::to_string( panel ), panels[ panel ], shown[ panel ] );@@ -10234,11 +10241,8 @@ Bool InGameUI::drawControlBarPage( const IRegion2D *panels, const Bool *shown, IIRegion2D box;const Bool leftFound = controlBarUnion( CONTROL_BAR_LEFT, box );putPageRect( values, "left", box, leftFound && panelCount > 0 && shown[ 0 ] );- const Bool centreShown = panelCount > 1 && shown[ 1 ];const Bool centreFound = controlBarUnion( CONTROL_BAR_CENTRE, box );- putPageRect( values, "centre", box, centreFound && centreShown );- const Bool purseFound = controlBarUnion( CONTROL_BAR_PURSE, box );- putPageRect( values, "purse", box, purseFound && centreShown );+ putPageRect( values, "centre", box, centreFound && panelCount > 1 && shown[ 1 ] );const Bool rightFound = controlBarUnion( CONTROL_BAR_RIGHT, box );putPageRect( values, "right", box, rightFound && panelCount > 2 && shown[ 2 ] );@@ -10281,13 +10285,48 @@ Bool InGameUI::drawControlBarPage( const IRegion2D *panels, const Bool *shown, Iif( window )window->winSetDrawFunc( drawNothing );}+ for( Int each = 0; each < (Int)ARRAY_SIZE( CONTROL_BAR_STOOD_DOWN ); each++ )+ {+ GameWindow *window = controlBarWindow( CONTROL_BAR_STOOD_DOWN[ each ] );+ if( window && !window->winIsHidden() )+ window->winHide( TRUE );+ }m_controlBarOverlay->setPage( HtmlTemplate_expand( m_controlBarPage, values, HtmlLists(), lookupGameText ) );+ m_controlBarOverlay->hover( TheMouse->getMouseStatus()->pos );m_controlBarOverlay->draw();std::vector< IRegion2D > solids;m_controlBarOverlay->rectsOf( ".solid", solids );TheControlBar->setPageSolids( &solids );+ m_controlBarPageShown = TRUE;+ return TRUE;+}++//-------------------------------------------------------------------------------------------------+/** The page's own buttons sit where the bar's frame takes no clicks, so their clicks arrive as clicks+ * on the world and are taken here. data-click="press:Name" presses the bar's window Name, the+ * message a click on it would have sent, even though the window itself is stood down. */+//-------------------------------------------------------------------------------------------------+Bool InGameUI::handleControlBarPageClick( const ICoord2D *mouse, Bool act )+{+ if( !m_controlBarPageShown || m_controlBarOverlay == NULL || !m_controlBarOverlay->hover( *mouse ) )+ return FALSE;++ const std::string action = m_controlBarOverlay->click( *mouse );+ if( action.compare( 0, PRESS_ACTION.size(), PRESS_ACTION ) != 0 )+ return FALSE;+ if( !act )+ return TRUE;++ GameWindow *button = controlBarWindow( action.substr( PRESS_ACTION.size() ) );+ if( button == NULL || !BitTest( button->winGetStatus(), WIN_STATUS_ENABLED ) )+ return TRUE;++ TheWindowManager->winSendSystemMsg( button->winGetOwner(), GBM_SELECTED, (WindowMsgData)button, button->winGetWindowId() );+ AudioEventRTS buttonClick( "GUIClick" );+ if( TheAudio )+ TheAudio->addAudioEvent( &buttonClick );return TRUE;}@@ -10827,7 +10866,10 @@ Bool InGameUI::handleProductionStripClick( const ICoord2D *mouse, Bool cancel )if( mouse == NULL )return FALSE;- // the strip drop-down lies over the world the same way the strip does, so its clicks come here too+ // the command bar's own buttons and the strip drop-down lie over the world the same way the strip+ // does, so their clicks come here too+ if( handleControlBarPageClick( mouse, !cancel ) )+ return TRUE;if( handleSpectatorPageClick( mouse, !cancel ) )return TRUE;