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): fit every bar panel to its windows, stars in the corner
Olcay Seygan51ae35c7452d
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 41b6dc535..585c49770 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -497,8 +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.+- Every panel of the bar is only as big as what it holds now. The left one fits round the radar's bezel, the right one round the portrait and the experience bar, the middle one round the command grid with the power bar over it, and above that a small plaque carries the money and nothing else. Everything the old painting filled round them is 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 and Chat, lit gold under the pointer and pressed in when pushed. The general's promotions and the minimise arrow are two small caps in the right panel's top right corner, the promotions marked with three stars, which glow 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/Window/Html/ControlBar.html b/GeneralsMD/Code/Data/Window/Html/ControlBar.htmlindex a3f8a38d8..a29b43546 100644--- a/GeneralsMD/Code/Data/Window/Html/ControlBar.html+++ b/GeneralsMD/Code/Data/Window/Html/ControlBar.html@@ -16,9 +16,12 @@{{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- {{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+ {{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+ {{right.x}} .y .w .h the box round the portrait and the experience bar. The promotion and+ minimise 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"and {{Name.state}} any of "disabled", "hilite", "pushed", for LeftHUD (theradar), RightHUD (the portrait's box), CameoWindow (the portrait),@@ -50,10 +53,15 @@.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; }+ /* every panel hugs what it holds, and what the old plates covered round them is battlefield and+ takes 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 */+ .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;@@ -65,7 +73,7 @@.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: -2px 0 0 -8px; padding: 0 6px; border: 1px solid #0c1114; border-bottom-color: #6f7782; background-color: #05080a; }+ .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 */@@ -78,6 +86,7 @@.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 under-attack light: a tab on the left panel's top left edge, red while the bar blinks it */@@ -89,13 +98,13 @@<body><div class="{{side}}">- <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="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 {{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 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"><div class="lip"></div>@@ -121,7 +130,7 @@<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 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>diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/InGameUI.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/InGameUI.cppindex 5e7d3e86c..13e388fc9 100644--- a/GeneralsMD/Code/GameEngine/Source/GameClient/InGameUI.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/InGameUI.cpp@@ -10100,14 +10100,28 @@ static const char *const CONTROL_BAR_CUSTOM[] ="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. */+/** 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. */+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", "ButtonOptions", "ButtonIdleWorker", "ButtonPlaceBeacon",- "PopupCommunicator", NULL+ "CommandWindow", "ObserverPlayerListWindow", "PowerWindow", "ButtonOptions", "ButtonIdleWorker",+ "ButtonPlaceBeacon", "PopupCommunicator", NULL};-static const char *const CONTROL_BAR_PURSE[] = { "MoneyDisplay", "PowerWindow", 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. */+enum+{+ CORNER_BUTTON_WIDTH = 32,+ CORNER_BUTTON_HEIGHT = 14,+ CORNER_BUTTON_GAP = 2,+ CORNER_BUTTON_RISE = 16 ///< how far above the portrait's box the buttons' top edge sits+};+static const char *const CORNER_BUTTONS[] = { "ButtonLarge", "ButtonGeneral" };static void drawNothing( GameWindow *window, WinInstanceData *instData ){@@ -10216,6 +10230,42 @@ Bool InGameUI::drawControlBarPage( const IRegion2D *panels, const Bool *shown, Ifor( Int panel = 0; panel < panelCount; panel++ )putPageRect( values, "panel" + std::to_string( panel ), panels[ panel ], shown[ panel ] );+ // every panel hugs what it holds, so the rest of the old plates is battlefield again+ IRegion2D 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 );+ const Bool rightFound = controlBarUnion( CONTROL_BAR_RIGHT, box );+ putPageRect( values, "right", box, rightFound && panelCount > 2 && shown[ 2 ] );++ // the promotion and minimise buttons go to the right panel's top right corner; a bar with no+ // portrait showing leaves them where the bar put them, so minimise stays in reach+ if( rightFound )+ {+ const Real scale = ControlBarUniformScale();+ const Int width = REAL_TO_INT( CORNER_BUTTON_WIDTH * scale );+ const Int height = REAL_TO_INT( CORNER_BUTTON_HEIGHT * scale );+ Int x = box.hi.x;+ for( Int each = 0; each < (Int)ARRAY_SIZE( CORNER_BUTTONS ); each++ )+ {+ GameWindow *button = controlBarWindow( CORNER_BUTTONS[ each ] );+ if( button == NULL )+ continue;++ x -= width;+ Int parentX = 0, parentY = 0;+ if( button->winGetParent() )+ button->winGetParent()->winGetScreenPosition( &parentX, &parentY );+ button->winSetPosition( x - parentX, box.lo.y - REAL_TO_INT( CORNER_BUTTON_RISE * scale ) - parentY );+ button->winSetSize( width, height );+ x -= REAL_TO_INT( CORNER_BUTTON_GAP * scale );+ }+ }+for( Int each = 0; each < (Int)ARRAY_SIZE( CONTROL_BAR_WINDOWS ); each++ ){const std::string name = CONTROL_BAR_WINDOWS[ each ];@@ -10225,15 +10275,6 @@ Bool InGameUI::drawControlBarPage( const IRegion2D *panels, const Bool *shown, Ivalues[ 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 ] );