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): the bar's own buttons, a tighter centre and page clicks
Olcay Seygan7c94a39b3306
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex efd79a5c1..41b6dc535 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -497,6 +497,8 @@ found and fixed — EA's own, not port damage.**- Both are an ordinary web page with a stylesheet, in the game's Window folder. Change the colours, the sizes or the order there and the next match you watch draws it that way, and the page opens in a browser too.- A minimised command bar stays minimised. Changing seats, or clicking another player's unit while watching, put the whole bar back up over the battlefield you had just cleared. A new match still opens with the bar up.- The command bar's frame is drawn new, in the same steel as the boards: three dark panels under a steel rail, the radar and the portrait each set in a bezel with a rivet at every corner, the command buttons in a shallow well, the money on a plaque and the power bar in a groove. Grey for America, red for China, sand for GLA. It slides and minimises with the bar, and like the boards it is a page in the Window folder; take the page away and the old painted bar comes back.+- The middle of the bar is only as big as its buttons now: one panel round the command grid and its side buttons, and a narrower one above it round the money and the power bar. The corners the old painting filled either side of the money are battlefield again, and a click there lands on the battlefield.+- The bar's own buttons are drawn to match, steel caps with their names on them, Menu, Worker, Beacon, Chat and Promotions, lit gold under the pointer and pressed in when pushed. Promotions glows gold on the half second while you have one to spend. The under-attack light is a tab on the top left corner of the radar's panel that blinks red, written UNDER ATTACK.## Placing buildingsdiff --git a/GeneralsMD/Code/Data/Patch.str b/GeneralsMD/Code/Data/Patch.strindex 51b444bba..291f95de8 100644--- a/GeneralsMD/Code/Data/Patch.str+++ b/GeneralsMD/Code/Data/Patch.str@@ -1103,6 +1103,32 @@ GUI:HudSuperweaponReady"ready to fire"END+// 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++GUI:BarBeacon+"Beacon"+END++GUI:BarChat+"Chat"+END++GUI:BarGeneral+"Promotions"+END++// the box in the corner of the radar that lights while your forces are under attack+GUI:BarUnderAttack+"UNDER ATTACK"+END+// the scoreboard on TabGUI:ScoreboardAllies"YOUR SIDE"diff --git a/GeneralsMD/Code/Data/Turkish/Generals.str b/GeneralsMD/Code/Data/Turkish/Generals.strindex c08876545..2b632e7b7 100644--- a/GeneralsMD/Code/Data/Turkish/Generals.str+++ b/GeneralsMD/Code/Data/Turkish/Generals.str@@ -15629,6 +15629,30 @@ GUI:HudSuperweaponReady"ateşe hazır"END+GUI:BarMenu+"Menü"+END++GUI:BarIdleWorker+"İşçi"+END++GUI:BarBeacon+"İşaret"+END++GUI:BarChat+"Sohbet"+END++GUI:BarGeneral+"Terfiler"+END++GUI:BarUnderAttack+"SALDIRI ALTINDA"+END+GUI:ScoreboardAllies"TAKIMIN"ENDdiff --git a/GeneralsMD/Code/Data/Window/Html/ControlBar.html b/GeneralsMD/Code/Data/Window/Html/ControlBar.htmlindex 979f84ada..a3f8a38d8 100644--- a/GeneralsMD/Code/Data/Window/Html/ControlBar.html+++ b/GeneralsMD/Code/Data/Window/Html/ControlBar.html@@ -1,20 +1,31 @@<!DOCTYPE html><!--- The command bar's frame, drawn where its three plates used to be. The buttons, the radar, the- money, the power bar and the portrait are still the bar's own windows and paint over this page;- the page draws the steel round and under them. Same materials as Window/Html/Spectator.html,- whose header says what the renderer draws and what it does not.+ The command bar's frame, drawn where its three plates used to be, and the bar's own buttons. The+ command 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.++ Everything with class "solid" catches clicks; the rest of the screen is battlefield, whatever the+ old plates covered.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+ {{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- {{Name.x}} .y .w .h the rectangle of the bar's window Name, and {{Name.shown}} "shown" or- "hidden", for LeftHUD (the radar), RightHUD (the portrait's box),- CameoWindow (the portrait), CommandWindow, MoneyDisplay, PowerWindow,- GeneralsExp, ButtonGeneral, ButtonLarge, ButtonOptions, ButtonIdleWorker,- ButtonPlaceBeacon, PopupCommunicator and WinUAttack+ {{centre.x}} .y .w .h the box round the command grid and the four buttons beside it, so the+ centre panel is only as big as its buttons; {{centre.shown}} as above+ {{purse.x}} .y .w .h the box round the money and the power bar, above it+ {{Name.x}} .y .w .h the rectangle of the bar's window Name, {{Name.shown}} "shown" or "hidden"+ and {{Name.state}} any of "disabled", "hilite", "pushed", for LeftHUD (the+ radar), RightHUD (the portrait's box), CameoWindow (the portrait),+ CommandWindow, MoneyDisplay, PowerWindow, GeneralsExp, ButtonGeneral,+ ButtonLarge (minimise), ButtonOptions, ButtonIdleWorker, ButtonPlaceBeacon,+ PopupCommunicator and WinUAttack (the under-attack light: "disabled" while+ it is lit, which is how the bar blinks it)All in the page's pixels, a pixel of an 800x600 screen. Without this page the plates draw.Edit the copy under Run/Window/Html and the next match reads it.@@ -25,7 +36,7 @@<title>Command bar</title><style>html, body { margin: 0; padding: 0; }- body { background-color: #3b4a36; }+ body { background-color: #3b4a36; font-size: 8px; color: #dfe5ea; }.hidden { display: none; }.piece { position: absolute; }@@ -39,6 +50,11 @@.gla .panel { background-color: rgba(21, 18, 8, 0.94); border-top-color: #cbbf82; border-left-color: #a99d62; }.gla .rail { background: linear-gradient(to bottom, #8f8249, #48401e); }+ /* the centre hugs the command grid and its side buttons, and the purse above it the money and the+ power bar: what the old plate covered round them is battlefield, and takes clicks as one */+ .centre { margin: -10px 0 0 -6px; padding: 10px 6px 0 6px; }+ .purse { margin: -10px 0 0 -8px; padding: 10px 8px 6px 8px; }+/* 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;border-bottom-color: #8a949f; border-right-color: #6f7782; }@@ -47,25 +63,40 @@.gla .bezel { border-color: #625a31; border-top-color: #302b15; border-left-color: #302b15; border-bottom-color: #a99d62; border-right-color: #867a45; }.rivet { position: absolute; width: 3px; height: 3px; background-color: #aab4bf; border-bottom: 1px solid #0c1114; }- /* the command grid sits in a shallow well */.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); }-- /* the money's plaque and the power bar's groove */- .plaque { margin: -2px 0 0 -8px; padding: 0 6px; border: 1px solid #0c1114; border-top-color: #000000; border-bottom-color: #6f7782;- background-color: #05080a; }+ .plaque { margin: -2px 0 0 -8px; padding: 0 6px; 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 */+ .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.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.promotion.ready.lit { background: linear-gradient(to bottom, #f6e08a, #a4832a); color: #1a1406; border-color: #fff4b8; }++ /* 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; }+ .alert.disabled { color: #ffffff; background: linear-gradient(to bottom, #ff6a50, #b0200f); border-color: #ffb0a0; }</style></head><body><div class="{{side}}">- <!-- the three plates -->- <div class="piece panel {{panel0.shown}}" style="left: {{panel0.x}}px; top: {{panel0.y}}px; width: {{panel0.w}}px; height: {{panel0.h}}px"><div class="rail"></div></div>- <div class="piece panel {{panel1.shown}}" style="left: {{panel1.x}}px; top: {{panel1.y}}px; width: {{panel1.w}}px; height: {{panel1.h}}px"><div class="rail"></div></div>- <div class="piece panel {{panel2.shown}}" style="left: {{panel2.x}}px; top: {{panel2.y}}px; width: {{panel2.w}}px; height: {{panel2.h}}px"><div class="rail"></div></div>+ <div class="piece panel solid {{panel0.shown}}" style="left: {{panel0.x}}px; top: {{panel0.y}}px; width: {{panel0.w}}px; height: {{panel0.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 {{panel2.shown}}" style="left: {{panel2.x}}px; top: {{panel2.y}}px; width: {{panel2.w}}px; height: {{panel2.h}}px"><div class="rail"></div></div>- <!-- the radar, set in a bezel with a rivet at each corner --><div class="piece bezel {{LeftHUD.shown}}" style="left: {{LeftHUD.x}}px; top: {{LeftHUD.y}}px; width: {{LeftHUD.w}}px; height: {{LeftHUD.h}}px"><div class="lip"></div><div class="rivet" style="left: -4px; top: -4px"></div>@@ -73,8 +104,6 @@<div class="rivet" style="left: -4px; bottom: -4px"></div><div class="rivet" style="right: -4px; bottom: -4px"></div></div>-- <!-- the portrait's box, the same bezel --><div class="piece bezel {{RightHUD.shown}}" style="left: {{RightHUD.x}}px; top: {{RightHUD.y}}px; width: {{RightHUD.w}}px; height: {{RightHUD.h}}px"><div class="lip"></div><div class="rivet" style="left: -4px; top: -4px"></div>@@ -88,6 +117,13 @@<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">{{text:GUI:BarGeneral}}</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></body></html>diff --git a/GeneralsMD/Code/GameEngine/Include/GameClient/ControlBar.h b/GeneralsMD/Code/GameEngine/Include/GameClient/ControlBar.hindex 67efedbcd..17446cda9 100644--- a/GeneralsMD/Code/GameEngine/Include/GameClient/ControlBar.h+++ b/GeneralsMD/Code/GameEngine/Include/GameClient/ControlBar.h@@ -987,6 +987,13 @@ public:* went nowhere. GameWindow::winPointInChild asks, so clicking and unit picking agree. */Bool letsClickThrough( GameWindow *window, Int x, Int y );+ /** The screen rectangles the bar's CSS page drew solid, which take the place of the plates in+ * letsClickThrough while the page is drawing; NULL when it is not, and the plates decide again. */+ void setPageSolids( const std::vector< IRegion2D > *solids );++ /// the general's stars are asking to be spent, so the button blinks; see getStarImage+ Bool isGeneralStarFlashing( void ) const { return m_genStarFlash; }+/// the same journey as a fraction, 0 home and 1 gone. Needs no display, which is why the test/// for the rebuild ordering asks this one; see clearPanelSlideReal getPanelSlideFraction( Int panel ) const@@ -1311,6 +1318,8 @@ protected:Bool m_isObserverCommandBar; ///< If this is true, the command bar behaves greatly differntPlayer *m_observerLookAtPlayer; ///< The current player we're looking at, Null if we're not looking at anyone.AsciiString m_watchedSide; ///< the side the bar is wearing while watching, so a selection change only lays it out again when it really changes side+ std::vector< IRegion2D > m_pageSolids; ///< what the CSS page drew solid, in screen pixels; see setPageSolids+ Bool m_pageSolidsActive; ///< the page is drawing, so m_pageSolids decides clicks and not the platesPlayer *m_watchedSelection; ///< the player the selection last named while watching, NULL for nobodyWindowLayout *m_buildToolTipLayout; ///< The window that will slide on/display tooltipsdiff --git a/GeneralsMD/Code/GameEngine/Include/GameClient/HtmlOverlay.h b/GeneralsMD/Code/GameEngine/Include/GameClient/HtmlOverlay.hindex acc8041e9..7901336a4 100644--- a/GeneralsMD/Code/GameEngine/Include/GameClient/HtmlOverlay.h+++ b/GeneralsMD/Code/GameEngine/Include/GameClient/HtmlOverlay.h@@ -41,6 +41,7 @@#include "Common/AsciiString.h"#include <string>+#include <vector>class HtmlOverlayContainer;@@ -66,6 +67,9 @@ public:/** The bottom edge in screen pixels of the first element the CSS selector finds, 0 for none. */Int bottomOf( const char *selector );+ /** The screen rectangle of every element the CSS selector finds, empty ones left out. */+ void rectsOf( const char *selector, std::vector< IRegion2D > &rects );+private:HtmlOverlayContainer *m_container;};diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/ControlBar/ControlBar.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/ControlBar/ControlBar.cppindex a78d6baaa..f913fce25 100644--- a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/ControlBar/ControlBar.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/ControlBar/ControlBar.cpp@@ -1384,6 +1384,7 @@ ControlBar::ControlBar( void )m_radarAttackGlowOn = FALSE;m_remainingRadarAttackGlowFrames = 0;m_radarAttackGlowWindow = NULL;+ m_pageSolidsActive = FALSE;#if defined( _INTERNAL ) || defined( _DEBUG )m_lastFrameMarkedDirty = 0;@@ -1910,6 +1911,16 @@ static const std::vector<UnsignedByte> &plateMask( const ControlBarPlate *platereturn mask;}+//-------------------------------------------------------------------------------------------------+void ControlBar::setPageSolids( const std::vector< IRegion2D > *solids )+{+ m_pageSolidsActive = solids != NULL;+ if( solids )+ m_pageSolids = *solids;+ else+ m_pageSolids.clear();+}+//-------------------------------------------------------------------------------------------------Bool ControlBar::letsClickThrough( GameWindow *window, Int x, Int y ){@@ -1923,6 +1934,20 @@ Bool ControlBar::letsClickThrough( GameWindow *window, Int x, Int y )if( shortName[ 0 ] != 0 && strcmp( shortName, "CenterBackground" ) != 0 )return FALSE;+ // the CSS page is what is drawn, so what it drew solid is what is solid. Asked before the+ // children, because a see-through child the page does not draw - the observer's info window+ // spans the whole centre - would otherwise keep a click on bare battlefield+ if( m_pageSolidsActive )+ {+ for( size_t solid = 0; solid < m_pageSolids.size(); solid++ )+ {+ const IRegion2D &rect = m_pageSolids[ solid ];+ if( x >= rect.lo.x && y >= rect.lo.y && x < rect.hi.x && y < rect.hi.y )+ return FALSE;+ }+ return TRUE;+ }+// a command button or anything else inside the pane is its own window and keeps its clickif( window->winPointInChild( x, y, TRUE ) != window )return FALSE;diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/HtmlOverlay.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/HtmlOverlay.cppindex f01769f96..e2ad4abbd 100644--- a/GeneralsMD/Code/GameEngine/Source/GameClient/HtmlOverlay.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/HtmlOverlay.cpp@@ -92,6 +92,7 @@ public:Bool hover( const ICoord2D &mouse );std::string click( const ICoord2D &mouse );Int bottomOf( const char *selector );+ void rectsOf( const char *selector, std::vector< IRegion2D > &rects );litehtml::uint_ptr create_font( const litehtml::font_description &description, const litehtml::document *document,litehtml::font_metrics *metrics ) override;@@ -254,6 +255,29 @@ Int HtmlOverlayContainer::bottomOf( const char *selector )return screen( placement.y + placement.height );}+//-------------------------------------------------------------------------------------------------+void HtmlOverlayContainer::rectsOf( const char *selector, std::vector< IRegion2D > &rects )+{+ rects.clear();+ if( !m_document )+ return;++ const litehtml::elements_list elements = m_document->root()->select_all( selector );+ for( litehtml::elements_list::const_iterator element = elements.begin(); element != elements.end(); ++element )+ {+ const litehtml::position placement = ( *element )->get_placement();+ if( placement.width <= 0 || placement.height <= 0 )+ continue;++ IRegion2D rect;+ rect.lo.x = screen( placement.x );+ rect.lo.y = screen( placement.y );+ rect.hi.x = screen( placement.x + placement.width );+ rect.hi.y = screen( placement.y + placement.height );+ rects.push_back( rect );+ }+}+//-------------------------------------------------------------------------------------------------bool HtmlOverlayContainer::on_element_click( const litehtml::element::ptr &element ){@@ -557,3 +581,4 @@ void HtmlOverlay::draw( void ) { m_container->draw(); }Bool HtmlOverlay::hover( const ICoord2D &mouse ) { return m_container->hover( mouse ); }std::string HtmlOverlay::click( const ICoord2D &mouse ) { return m_container->click( mouse ); }Int HtmlOverlay::bottomOf( const char *selector ) { return m_container->bottomOf( selector ); }+void HtmlOverlay::rectsOf( const char *selector, std::vector< IRegion2D > &rects ) { m_container->rectsOf( selector, rects ); }diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/InGameUI.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/InGameUI.cppindex 16a00c4ee..5e7d3e86c 100644--- a/GeneralsMD/Code/GameEngine/Source/GameClient/InGameUI.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/InGameUI.cpp@@ -10092,6 +10092,84 @@ 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. */+static const char *const CONTROL_BAR_CUSTOM[] =+{+ "ButtonGeneral", "ButtonLarge", "ButtonOptions", "ButtonIdleWorker", "ButtonPlaceBeacon", "PopupCommunicator",+ "WinUAttack"+};++/** The windows the centre panel is drawn round, so it is only as big as its buttons, and the ones+ * the purse above it is drawn round. NULL ends each list. */+static const char *const CONTROL_BAR_CENTRE[] =+{+ "CommandWindow", "ObserverPlayerListWindow", "ButtonOptions", "ButtonIdleWorker", "ButtonPlaceBeacon",+ "PopupCommunicator", NULL+};+static const char *const CONTROL_BAR_PURSE[] = { "MoneyDisplay", "PowerWindow", NULL };++static void drawNothing( GameWindow *window, WinInstanceData *instData )+{+}++static GameWindow *controlBarWindow( const std::string &name )+{+ return TheWindowManager->winGetWindowFromId( NULL, NAMEKEY( ( "ControlBar.wnd:" + name ).c_str() ) );+}++/** A window's screen rectangle, and FALSE when it is missing or hidden. */+static Bool controlBarWindowRect( GameWindow *window, IRegion2D &rect )+{+ rect.lo.x = rect.lo.y = rect.hi.x = rect.hi.y = 0;+ if( window == NULL || window->winIsHidden() )+ return FALSE;++ Int width = 0, height = 0;+ window->winGetScreenPosition( &rect.lo.x, &rect.lo.y );+ window->winGetSize( &width, &height );+ rect.hi.x = rect.lo.x + width;+ rect.hi.y = rect.lo.y + height;+ return TRUE;+}++/** "disabled", "hilite" and "pushed" as they apply, for a page to draw a button's state by. */+static std::string controlBarWindowState( GameWindow *window )+{+ std::string state;+ if( window == NULL )+ return state;+ if( !BitTest( window->winGetStatus(), WIN_STATUS_ENABLED ) )+ state += " disabled";+ const UnsignedInt flags = window->winGetInstanceData()->getState();+ if( BitTest( flags, WIN_STATE_HILITED ) )+ state += " hilite";+ if( BitTest( flags, WIN_STATE_SELECTED ) )+ state += " pushed";+ return state;+}++/** The box round every shown window of a NULL-ended list, and FALSE when none of them is shown. */+static Bool controlBarUnion( const char *const *names, IRegion2D &box )+{+ Bool found = FALSE;+ box.lo.x = box.lo.y = box.hi.x = box.hi.y = 0;+ for( ; *names; names++ )+ {+ IRegion2D rect;+ if( !controlBarWindowRect( controlBarWindow( *names ), rect ) )+ continue;+ if( !found )+ box = rect;+ box.lo.x = min( box.lo.x, rect.lo.x );+ box.lo.y = min( box.lo.y, rect.lo.y );+ box.hi.x = max( box.hi.x, rect.hi.x );+ box.hi.y = max( box.hi.y, rect.hi.y );+ found = TRUE;+ }+ return found;+}+/** `name`.x, .y, .w and .h in the page's pixels, and `name`.shown "shown" or "hidden". */static void putPageRect( HtmlValues &values, const std::string &name, const IRegion2D &rect, Bool shown ){@@ -10113,7 +10191,10 @@ static void putPageRect( HtmlValues &values, const std::string &name, const IRegBool InGameUI::drawControlBarPage( const IRegion2D *panels, const Bool *shown, Int panelCount ){if( TheGameLogic == NULL || !TheGameLogic->isInGame() || TheGameLogic->isInShellGame() )+ {+ TheControlBar->setPageSolids( NULL );return FALSE;+ }if( !m_controlBarPageLoaded ){@@ -10121,34 +10202,51 @@ Bool InGameUI::drawControlBarPage( const IRegion2D *panels, const Bool *shown, IreadHtmlPage( CONTROL_BAR_PAGE, m_controlBarPage );}if( m_controlBarPage.empty() )+ {+ TheControlBar->setPageSolids( NULL );return FALSE;+ }if( m_controlBarOverlay == NULL )m_controlBarOverlay = new HtmlOverlay( m_superweaponNormalFont );HtmlValues values;values[ "side" ] = spectatorSide();+ values[ "promotion" ] = TheControlBar->isGeneralStarFlashing() ? "ready" : "";+ 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 ] );for( Int each = 0; each < (Int)ARRAY_SIZE( CONTROL_BAR_WINDOWS ); each++ ){const std::string name = CONTROL_BAR_WINDOWS[ each ];- GameWindow *window = TheWindowManager->winGetWindowFromId( NULL, NAMEKEY( ( "ControlBar.wnd:" + name ).c_str() ) );+ GameWindow *window = controlBarWindow( name );IRegion2D rect;- rect.lo.x = rect.lo.y = rect.hi.x = rect.hi.y = 0;+ putPageRect( values, name, rect, controlBarWindowRect( window, rect ) );+ values[ name + ".state" ] = controlBarWindowState( window );+ }++ // the centre panel hugs its buttons and the purse its money, so the rest of the old plate is+ // battlefield again+ const Bool centreShown = panelCount > 1 && shown[ 1 ];+ IRegion2D box;+ 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 );++ for( Int each = 0; each < (Int)ARRAY_SIZE( CONTROL_BAR_CUSTOM ); each++ )+ {+ GameWindow *window = controlBarWindow( CONTROL_BAR_CUSTOM[ each ] );if( window )- {- Int width = 0, height = 0;- window->winGetScreenPosition( &rect.lo.x, &rect.lo.y );- window->winGetSize( &width, &height );- rect.hi.x = rect.lo.x + width;- rect.hi.y = rect.lo.y + height;- }- putPageRect( values, name, rect, window != NULL && !window->winIsHidden() );+ window->winSetDrawFunc( drawNothing );}m_controlBarOverlay->setPage( HtmlTemplate_expand( m_controlBarPage, values, HtmlLists(), lookupGameText ) );m_controlBarOverlay->draw();++ std::vector< IRegion2D > solids;+ m_controlBarOverlay->rectsOf( ".solid", solids );+ TheControlBar->setPageSolids( &solids );return TRUE;}