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): rank stars on a key, the portrait grid in steel
Olcay Seygan525bd21da0e3
diff --git a/GeneralsMD/Code/Data/Window/Html/ControlBar.html b/GeneralsMD/Code/Data/Window/Html/ControlBar.htmlindex 152294bde..e97aaea0b 100644--- a/GeneralsMD/Code/Data/Window/Html/ControlBar.html+++ b/GeneralsMD/Code/Data/Window/Html/ControlBar.html@@ -27,7 +27,9 @@ten rungs from the bottom up, each {{lit}} "lit" up to the way from thisrank to the next, at {{y}} inside the lip, {{h}} tall, {{segh}} withoutits black line- data-each="rankstars" a star for every rank there is, {{lit}} "lit" up to the one reached+ data-each="rankstars" a star for every rank there is, {{lit}} "lit" up to the one reached, at+ {{x}} inside the 58 wide key so the row is centred on it+ data-each="portraitcells" the production queue's nine places over the portrait's, each {{cell.x}} .y .w .hdata-each="commandcells" the fourteen command buttons' places, shown or not, each {{cell.x}} .y .w .hdata-each="skillcells" the grid's nine empty places behind the general's powers, each {{cell.x}} .y .w .h{{signals.x}} ... the column of smoke signal buttons against the left panel;@@ -253,17 +255,20 @@.alert.disabled .led { border-color: #ff9a80; background: linear-gradient(to bottom, #ff6a50, #d01a08); }.alert.disabled .glint { background-color: #ffe4dc; }- /* the rank: a star for every rank there is in a tab on the right panel's bezel, gold up to the one- reached and sunk dark past it. The tab is the promotion button: under the pointer its stars- brighten, and while a promotion waits to be spent the tab blinks gold */- .rank .stars { position: absolute; left: 0; right: 0; top: 1px; line-height: 12px; font-size: 11px; text-align: center; }- .rank .star { color: #2a2f35; }- .rank .star.lit { color: #f2cf4a; }- .rank.hilite .star.lit { color: #fff0a0; }- .rank.hilite .star { color: #4b535e; }- .rank.ready.lit { background: linear-gradient(to bottom, #f6e08a, #a4832a); border-top-color: #fff4b8; }- .rank.ready.lit .star { color: #5a4410; }- .rank.ready.lit .star.lit { color: #ffffff; }+ /* the rank: the promotion button, a key like the idle worker's in a tab on the right panel's+ bezel, a star on it for every rank there is, gold up to the one reached and dark past it. The+ tab is 66 by 22 and the key 60 by 17 with its rim, three pixels in. Under the pointer it comes+ up as lit steel with a gold rim, and while a promotion waits to be spent it blinks gold */+ .rank .key { left: 3px; top: 3px; width: 58px; height: 15px; }+ .rank.hilite .key { background: linear-gradient(to bottom, #b3bbc4, #5a626c); border-color: #e8d27a; }+ .china .rank.hilite .key { background: linear-gradient(to bottom, #d58a70, #7a3120); }+ .gla .rank.hilite .key { background: linear-gradient(to bottom, #cabe86, #766a3a); }+ .rank.ready.lit .key { background: linear-gradient(to bottom, #f6e08a, #a4832a); border-color: #fff4b8; }+ .rank .star { position: absolute; top: 2px; width: 10px; height: 10px; background-size: 100% 100%;+ background-repeat: no-repeat; background-image: url(Icons/RankStarDark.svg); }+ .rank .star.lit { background-image: url(Icons/RankStar.svg); }+ .rank.disabled .key .veil { display: block; position: absolute; left: 0; top: 0; width: 58px; height: 15px;+ background-color: rgba(4, 8, 10, 0.65); }/* the experience bar: rungs up the right panel's groove, lit gold from the bottom up to the wayfrom this rank to the next, a black line over each */@@ -348,14 +353,15 @@<div class="steel" style="left: -{{right.bl}}px; right: -{{right.br}}px; top: -{{right.bt}}px; bottom: -{{right.bb}}px"></div><div class="shine" style="left: -{{right.bl}}px; right: -{{right.br}}px; top: -{{right.bt}}px"></div><div class="lit" style="left: -{{right.bl}}px; top: -{{right.bt}}px; bottom: -{{right.bb}}px"></div>- <div class="sunk" style="width: {{right.w}}px; height: {{right.h}}px"></div>+ <div class="sunk grid" style="width: {{right.w}}px; height: {{right.h}}px"></div></div>+ <div class="piece commandcell" data-each="portraitcells" style="left: {{cell.x}}px; top: {{cell.y}}px; width: {{cell.w}}px; height: {{cell.h}}px"><div class="bevel"></div></div><div class="piece groove solid stack {{expframe.shown}}" style="left: {{expframe.x}}px; top: {{expframe.y}}px; width: {{expframe.w}}px; height: {{expframe.h}}px"><div class="rungs" style="width: {{expframe.innerw}}px"><div class="rung {{lit}}" data-each="expcells" style="top: {{y}}px; height: {{h}}px; width: {{expframe.innerw}}px"><div class="seg" style="width: {{expframe.innerw}}px; height: {{segh}}px"></div></div></div><div class="lip"></div></div><div class="piece tab rank {{starstab.shown}} {{promotion}} {{blink}} {{ButtonGeneral.state}}" style="left: {{starstab.x}}px; top: {{starstab.y}}px; width: {{starstab.w}}px; height: {{starstab.h}}px">- <div class="stars"><span class="star {{lit}}" data-each="rankstars">★</span></div>+ <div class="key"><div class="star {{lit}}" data-each="rankstars" style="left: {{x}}px"></div><div class="veil"></div></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>diff --git a/GeneralsMD/Code/Data/Window/Html/Icons/RankStar.svg b/GeneralsMD/Code/Data/Window/Html/Icons/RankStar.svgnew file mode 100644index 000000000..4b0a3b508--- /dev/null+++ b/GeneralsMD/Code/Data/Window/Html/Icons/RankStar.svg@@ -0,0 +1,3 @@+<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24">+ <path d="M12.0 1.8 14.6 9.2 22.5 9.4 16.2 14.2 18.5 21.7 12.0 17.2 5.5 21.7 7.8 14.2 1.5 9.4 9.4 9.2Z" fill="#f2cf4a"/>+</svg>diff --git a/GeneralsMD/Code/Data/Window/Html/Icons/RankStarDark.svg b/GeneralsMD/Code/Data/Window/Html/Icons/RankStarDark.svgnew file mode 100644index 000000000..8a9998cf4--- /dev/null+++ b/GeneralsMD/Code/Data/Window/Html/Icons/RankStarDark.svg@@ -0,0 +1,3 @@+<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24">+ <path d="M12.0 1.8 14.6 9.2 22.5 9.4 16.2 14.2 18.5 21.7 12.0 17.2 5.5 21.7 7.8 14.2 1.5 9.4 9.4 9.2Z" fill="#3a4048"/>+</svg>diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/InGameUI.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/InGameUI.cppindex d7e7cb819..9717487cb 100644--- a/GeneralsMD/Code/GameEngine/Source/GameClient/InGameUI.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/InGameUI.cpp@@ -10179,7 +10179,8 @@ static const char *const CONTROL_BAR_WINDOWS[] =* clicks; only their pictures are the page's. */static const char *const CONTROL_BAR_CUSTOM[] ={- "ButtonGeneral", "ButtonLarge", "ButtonPlaceBeacon", "WinUAttack", "PowerWindow", "GeneralsExp", "ExpBarForeground"+ "ButtonGeneral", "ButtonLarge", "ButtonPlaceBeacon", "WinUAttack", "PowerWindow", "GeneralsExp", "ExpBarForeground", "RightHUD",+ "WinUnitSelected"};/** How far along its scale a power figure reaches, 0 to 1: the power bar's own logarithmic scale,@@ -10288,10 +10289,16 @@ static void putExperienceBar( HtmlValues &values, std::vector< HtmlValues > &celcells.push_back( entry );}- for( Int rank = 1; rank <= TheRankInfoStore->getRankLevelCount(); rank++ )+ // the stars stand at pixel places centred on the key: centred as a line of text, the page measured+ // the star glyph wider than it drew it and the row sat to the left+ enum { RANK_KEY_WIDTH = 58, STAR_PITCH = 11, STAR_SIZE = 10 };+ const Int rankCount = TheRankInfoStore->getRankLevelCount();+ const Int firstStar = ( RANK_KEY_WIDTH - ( rankCount * STAR_PITCH - ( STAR_PITCH - STAR_SIZE ) ) ) / 2;+ for( Int rank = 1; rank <= rankCount; rank++ ){HtmlValues entry;entry[ "lit" ] = rank <= player->getRankLevel() ? "lit" : "";+ entry[ "x" ] = std::to_string( firstStar + ( rank - 1 ) * STAR_PITCH );stars.push_back( entry );}}@@ -10351,11 +10358,13 @@ static const char *const CONTROL_BAR_RIGHT[] = { "RightHUD", "GeneralsExp", "Expstatic const char *const CONTROL_BAR_CENTRE[] = { "ObserverPlayerListWindow", "ButtonPlaceBeacon", NULL };static const char *const CONTROL_BAR_EXPERIENCE[] = { "GeneralsExp", "ExpBarForeground", NULL };static const Int COMMAND_BUTTONS = 14; ///< ButtonCommand01 to 14, the grid a player sees+static const Int QUEUE_BUTTONS = 9; ///< ButtonQueue01 to 09, the production queue's three by three over the portrait's place/** The pieces standing round the panels, 800x600 pixels. */enum{- STARS_TAB_WIDTH = 62, ///< the rank's stars, a tab on the right panel's border, which is the promotion button+ STARS_TAB_WIDTH = 66, ///< the rank's stars, a key in a tab on the right panel's border, which is the promotion button+ STARS_TAB_HEIGHT = 22, ///< the key 17 tall with its rim, three pixels downSKILL_GRID_WIDTH = 150, ///< the general's powers, three to a row, against the screen's right edgeSKILL_GRID_GAP = 30, ///< between them and the stars' tabSIGNAL_BUTTON_SIZE = 24, ///< each smoke signal button's height, a row of the column@@ -10508,13 +10517,13 @@ static void putFrame( HtmlValues &values, const std::string &name, const IRegionvalues[ name + ".shown" ] = shown ? "shown" : "hidden";}-/** A tab of `width` 800x600 pixels standing on `box`'s top edge, from its left or its right. */-static IRegion2D tabOn( const IRegion2D &box, Int width, Bool fromRight )+/** A tab of `width` by `height` 800x600 pixels standing on `box`'s top edge, from its left or its right. */+static IRegion2D tabOn( const IRegion2D &box, Int width, Int height, Bool fromRight ){const Real scale = ControlBarUniformScale();IRegion2D tab;tab.hi.y = box.lo.y;- tab.lo.y = tab.hi.y - REAL_TO_INT( PANEL_TAB_HEIGHT * scale );+ tab.lo.y = tab.hi.y - REAL_TO_INT( height * scale );tab.lo.x = fromRight ? box.hi.x - REAL_TO_INT( width * scale ) : box.lo.x;tab.hi.x = fromRight ? box.hi.x : box.lo.x + REAL_TO_INT( width * scale );return tab;@@ -10529,21 +10538,27 @@ static IRegion2D tabOn( const IRegion2D &box, Int width, Bool fromRight )* line of text and set down on the block under it, so its block is no taller than the figure.* Written as centre, powerframe and moneyblock. *///--------------------------------------------------------------------------------------------------/** ButtonCommandNN's screen rectangle, `button` 1 to COMMAND_BUTTONS, shown or not. */-static IRegion2D commandButtonRect( Int button )+/** The screen rectangle of the bar's window `prefix` followed by `number` in two digits, shown or not. */+static IRegion2D numberedWindowRect( const char *prefix, Int number ){char name[ 32 ];- snprintf( name, sizeof( name ), "ButtonCommand%02d", button );- GameWindow *command = controlBarWindow( name );+ snprintf( name, sizeof( name ), "%s%02d", prefix, number );+ GameWindow *window = controlBarWindow( name );IRegion2D place;Int width = 0, height = 0;- command->winGetScreenPosition( &place.lo.x, &place.lo.y );- command->winGetSize( &width, &height );+ window->winGetScreenPosition( &place.lo.x, &place.lo.y );+ window->winGetSize( &width, &height );place.hi.x = place.lo.x + width;place.hi.y = place.lo.y + height;return place;}+/** ButtonCommandNN's screen rectangle, `button` 1 to COMMAND_BUTTONS, shown or not. */+static IRegion2D commandButtonRect( Int button )+{+ return numberedWindowRect( "ButtonCommand", button );+}+/** The box round the fourteen command buttons, shown or not. */static IRegion2D commandButtonsBox( void ){@@ -10730,7 +10745,7 @@ Bool InGameUI::drawControlBarPage( const IRegion2D *panels, const Bool *shown, Iconst Bool leftFound = controlBarUnion( CONTROL_BAR_LEFT, content );const IRegion2D leftBox = framed( content, border, TRUE, FALSE );putFrame( values, "left", content, leftBox, leftFound && leftShown );- putPageRect( values, "alerttab", tabOn( leftBox, ALERT_TAB_WIDTH, FALSE ), leftFound && leftShown );+ putPageRect( values, "alerttab", tabOn( leftBox, ALERT_TAB_WIDTH, PANEL_TAB_HEIGHT, FALSE ), leftFound && leftShown );// the three smoke signal buttons, a column standing on the screen's bottom edge against the left// panel's border; not there at all where the keys would do nothing either, a game with no allies@@ -10782,9 +10797,19 @@ Bool InGameUI::drawControlBarPage( const IRegion2D *panels, const Bool *shown, Iconst Bool experienceFound = controlBarUnion( CONTROL_BAR_EXPERIENCE, experience );putPageRect( values, "expframe", experience, experienceFound && rightFound && rightShown );putExperienceBar( values, lists[ "expcells" ], lists[ "rankstars" ] );- const IRegion2D starsTab = tabOn( rightBox, STARS_TAB_WIDTH, TRUE );+ const IRegion2D starsTab = tabOn( rightBox, STARS_TAB_WIDTH, STARS_TAB_HEIGHT, TRUE );putPageRect( values, "starstab", starsTab, rightFound && rightShown );+ // the portrait's well is steel with a dark cell for each of the production queue's nine places,+ // the grid the side's RightHUD picture used to draw in the side's own colour, blue for America+ std::vector< HtmlValues > &portraitCells = lists[ "portraitcells" ];+ for( Int button = 1; button <= QUEUE_BUTTONS && rightFound && rightShown; button++ )+ {+ HtmlValues entry;+ putPageRect( entry, "cell", numberedWindowRect( "ButtonQueue", button ), TRUE );+ portraitCells.push_back( entry );+ }+// the general's powers ready to fire, three to a row over the right panelIRegion2D powers;powers.hi.x = TheDisplay->getWidth();