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): general's powers in a steel tray that grows left
Olcay Seygan6bcddc6ecee0
diff --git a/GeneralsMD/Code/Data/Window/Html/ControlBar.html b/GeneralsMD/Code/Data/Window/Html/ControlBar.htmlindex 71e1449c5..af3d4f0c0 100644--- a/GeneralsMD/Code/Data/Window/Html/ControlBar.html+++ b/GeneralsMD/Code/Data/Window/Html/ControlBar.html@@ -31,7 +31,9 @@{{x}} inside the 58 wide key so the row is centred on itdata-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 .h- data-each="skillcells" the grid's nine empty places behind the general's powers, each {{cell.x}} .y .w .h+ {{skilltray.x}} ... the general's powers' tray, a panel as {{right.x}} is, only as big as the+ powers shown; data-each="skillcells" a cell behind each power, each+ {{cell.x}} .y .w .h{{signals.x}} ... the column of smoke signal buttons against the left panel;data-click="signal:attack", "signal:defend" or "signal:look" sends oneto the middle of the view; {{signals.shown}} is "hidden" where the keys@@ -292,8 +294,10 @@.rungs .seg { margin-top: 1px; background-color: #15130c; }.rungs .lit .seg { background: linear-gradient(to right, #8a6a14, #f6d860, #b08a24); }- /* the grid's empty places stand behind the powers */- .skillcell { margin: 1px 0 0 1px; }+ /* the general's powers stand in a tray of the panels' steel against the screen's right edge, only+ as big as the powers shown, a dark cell behind each; its bottom edge is shaded, since it stands+ over the battlefield rather than on the screen's edge */+ .bezel .base { position: absolute; height: 1px; background-color: #0c1114; }/* the smoke signals: a step on the radar's bezel's right, dark down its own right, and a jointover the bezel's dark right line so the two read as one piece. Three keys in it: a crosshair to@@ -388,7 +392,14 @@<div class="key signal look" data-click="signal:look" style="top: 48px; margin-top: {{signal2.drop}}px"><div class="icon"></div></div></div>- <div class="piece skillcell well" data-each="skillcells" style="left: {{cell.x}}px; top: {{cell.y}}px; width: {{cell.w}}px; height: {{cell.h}}px"></div>+ <div class="piece frame bezel solid {{skilltray.shown}}" style="left: {{skilltray.x}}px; top: {{skilltray.y}}px; width: {{skilltray.w}}px; height: {{skilltray.h}}px; border-width: {{skilltray.bt}}px {{skilltray.br}}px {{skilltray.bb}}px {{skilltray.bl}}px">+ <div class="steel" style="left: -{{skilltray.bl}}px; right: -{{skilltray.br}}px; top: -{{skilltray.bt}}px; bottom: -{{skilltray.bb}}px"></div>+ <div class="shine" style="left: -{{skilltray.bl}}px; right: -{{skilltray.br}}px; top: -{{skilltray.bt}}px"></div>+ <div class="lit" style="left: -{{skilltray.bl}}px; top: -{{skilltray.bt}}px; bottom: -{{skilltray.bb}}px"></div>+ <div class="base" style="left: -{{skilltray.bl}}px; right: -{{skilltray.br}}px; bottom: -{{skilltray.bb}}px"></div>+ <div class="sunk grid" style="width: {{skilltray.w}}px; height: {{skilltray.h}}px"></div>+ </div>+ <div class="piece commandcell" data-each="skillcells" 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 button menu {{ButtonOptions.state}}" data-click="press:ButtonOptions"><div class="bar" style="top: 4px"></div>diff --git a/GeneralsMD/Code/GameEngine/Include/GameClient/ControlBar.h b/GeneralsMD/Code/GameEngine/Include/GameClient/ControlBar.hindex 929050434..7d2776954 100644--- a/GeneralsMD/Code/GameEngine/Include/GameClient/ControlBar.h+++ b/GeneralsMD/Code/GameEngine/Include/GameClient/ControlBar.h@@ -993,12 +993,13 @@ public:* solid panel. */void setPageSolids( const std::vector< IRegion2D > *solids, const std::vector< IRegion2D > *holes = NULL );- /** The HUD page's place for the general's powers: the bar laid out as rows of- * SPECIAL_POWER_SHORTCUT_COLS filling `area`'s width, the first row at the top, standing on- * `area`'s bottom edge so more rows grow upward; its top is not read. NULL hides it. Screen- * pixels. Asked every frame the page draws, so it holds against the bar's own layout. `cell`,- * when given, is set to one cell's size, 0 by 0 while there is no bar to lay out. */- void placeSpecialPowerShortcutGrid( const IRegion2D *area, ICoord2D *cell = NULL );+ /** The HUD page's place for the general's powers: the first in `corner`, the bottom right of the+ * grid, each `cell` big with `gap` between them, a row of SPECIAL_POWER_SHORTCUT_COLS running+ * left from it and the next row over it, the order the row keys count in. The slots' own tray+ * art is not drawn; the page draws their cells. NULL hides the bar. Screen pixels. Asked every+ * frame the page draws, so it holds against the bar's own layout. Returns how many powers are+ * shown, each in its place. */+ Int placeSpecialPowerShortcutGrid( const ICoord2D *corner, const ICoord2D &cell, Int gap );/// the general's stars are asking to be spent, so the button blinks; see getStarImageBool isGeneralStarFlashing( void ) const { return m_genStarFlash; }@@ -1329,7 +1330,6 @@ protected:AsciiString m_watchedSide; ///< the side the bar is wearing while watching, so a selection change only lays it out again when it really changes sidestd::vector< IRegion2D > m_pageSolids; ///< what the CSS page drew solid, in screen pixels; see setPageSolidsstd::vector< IRegion2D > m_pageHoles; ///< the page's own buttons, which let their clicks through- ICoord2D m_shippedShortcutSlot; ///< the powers bar's slot as its layout shipped it, before the page's grid resized itBool 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 nobodydiff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/ControlBar/ControlBar.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/ControlBar/ControlBar.cppindex e2f515292..23a7283bf 100644--- a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/ControlBar/ControlBar.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/ControlBar/ControlBar.cpp@@ -1385,7 +1385,6 @@ ControlBar::ControlBar( void )m_remainingRadarAttackGlowFrames = 0;m_radarAttackGlowWindow = NULL;m_pageSolidsActive = FALSE;- m_shippedShortcutSlot.x = m_shippedShortcutSlot.y = 0;#if defined( _INTERNAL ) || defined( _DEBUG )m_lastFrameMarkedDirty = 0;@@ -6042,7 +6041,6 @@ void ControlBar::initSpecialPowershortcutBar( Player *player)m_specialPowerShortcutButtonParents[i] = NULL;m_specialPowerShortcutButtons[i] = NULL;}- m_shippedShortcutSlot.x = m_shippedShortcutSlot.y = 0; // a new layout, measured afreshif(m_specialPowerLayout){@@ -6199,57 +6197,48 @@ void ControlBar::arrangeSpecialPowerShortcutGrid( void )}//--------------------------------------------------------------------------------------------------void ControlBar::placeSpecialPowerShortcutGrid( const IRegion2D *area, ICoord2D *cell )+/** The page draws the cell behind each power, so the slot's own tray picture, in the side's art,+ * is not drawn under it. */+static void drawNoTray( GameWindow *window, WinInstanceData *instData )+{+}++Int ControlBar::placeSpecialPowerShortcutGrid( const ICoord2D *corner, const ICoord2D &cell, Int gap ){- if( cell )- cell->x = cell->y = 0;if( m_specialPowerShortcutParent == NULL || m_specialPowerShortcutButtonParents[ 0 ] == NULL )- return;+ return 0;- // the cell keeps the tray's own proportions, read off the first slot the layout shipped - once,- // since the grid below resizes that slot every frame- if( m_shippedShortcutSlot.x <= 0 )- m_specialPowerShortcutButtonParents[ 0 ]->winGetSize( &m_shippedShortcutSlot.x, &m_shippedShortcutSlot.y );- const Int cellWidth = area ? ( area->hi.x - area->lo.x ) / SPECIAL_POWER_SHORTCUT_COLS : 0;- if( m_shippedShortcutSlot.x <= 0 || cellWidth <= 0 )- {- if( !m_specialPowerShortcutParent->winIsHidden() )- m_specialPowerShortcutParent->winHide( TRUE );- return;- }- const Int cellHeight = cellWidth * m_shippedShortcutSlot.y / m_shippedShortcutSlot.x;- if( cell )- {- cell->x = cellWidth;- cell->y = cellHeight;- }- if( m_currentlyUsedSpecialPowersButtons < 1 )+ if( corner == NULL || m_currentlyUsedSpecialPowersButtons < 1 ){if( !m_specialPowerShortcutParent->winIsHidden() )m_specialPowerShortcutParent->winHide( TRUE );- return;+ return 0;}- ICoord2D cameoSize, cameoOffset;- if( trayLayoutFromSlot( cellWidth, cellHeight, NULL, &cameoSize, &cameoOffset, NULL ) == FALSE )- return;-- // the bar covers every cell, or a cell off its edge draws and never takes a click. It is as tall- // as SPECIAL_POWER_SHORTCUT_COLS rows at least, so the first power takes the grid's top left place- // with the page's empty ones under it; a longer list grows upward. Its position is its own- // parent's, and the layout's root is not the screen// the powers showing, not the slots the side has: m_currentlyUsedSpecialPowersButtons is eleven- // for a general with one power ready, and four rows of it stood the grid a row too high- const Int filled = ( countVisibleSpecialPowerShortcuts() + SPECIAL_POWER_SHORTCUT_COLS - 1 ) / SPECIAL_POWER_SHORTCUT_COLS;- const Int rows = MAX( filled, (Int)SPECIAL_POWER_SHORTCUT_COLS );+ // for a general with one power ready+ const Int shown = countVisibleSpecialPowerShortcuts();+ if( shown < 1 )+ return 0;++ // the bar covers every cell, or a cell off its edge draws and never takes a click, and it is only+ // as big as the powers shown, so the battlefield round them takes its own clicks. Its position is+ // its own parent's, and the layout's root is not the screen+ const Int columns = MIN( shown, (Int)SPECIAL_POWER_SHORTCUT_COLS );+ const Int rows = ( shown + SPECIAL_POWER_SHORTCUT_COLS - 1 ) / SPECIAL_POWER_SHORTCUT_COLS;+ const Int width = columns * cell.x + ( columns - 1 ) * gap;+ const Int height = rows * cell.y + ( rows - 1 ) * gap;Int parentX = 0, parentY = 0;if( m_specialPowerShortcutParent->winGetParent() )m_specialPowerShortcutParent->winGetParent()->winGetScreenPosition( &parentX, &parentY );- m_specialPowerShortcutParent->winSetPosition( area->lo.x - parentX, area->hi.y - cellHeight * rows - parentY );- m_specialPowerShortcutParent->winSetSize( cellWidth * SPECIAL_POWER_SHORTCUT_COLS, cellHeight * rows );+ m_specialPowerShortcutParent->winSetPosition( corner->x - width - parentX, corner->y - height - parentY );+ m_specialPowerShortcutParent->winSetSize( width, height );+ m_specialPowerShortcutParent->winSetDrawFunc( drawNoTray );if( m_specialPowerShortcutParent->winIsHidden() )m_specialPowerShortcutParent->winHide( FALSE );+ // the first power in the corner, the row running left from it and the next row over it: the+ // order the row keys count in. Each cameo fills its cellfor( Int i = 0; i < MAX_SPECIAL_POWER_SHORTCUTS; i++ ){GameWindow *slot = m_specialPowerShortcutButtonParents[ i ];@@ -6257,11 +6246,15 @@ void ControlBar::placeSpecialPowerShortcutGrid( const IRegion2D *area, ICoord2Dif( slot == NULL || button == NULL )continue;- slot->winSetPosition( ( i % SPECIAL_POWER_SHORTCUT_COLS ) * cellWidth, ( i / SPECIAL_POWER_SHORTCUT_COLS ) * cellHeight );- slot->winSetSize( cellWidth, cellHeight );- button->winSetSize( cameoSize.x, cameoSize.y );- button->winSetPosition( cameoOffset.x, cameoOffset.y );+ const Int column = i % SPECIAL_POWER_SHORTCUT_COLS;+ const Int row = i / SPECIAL_POWER_SHORTCUT_COLS;+ slot->winSetPosition( width - ( column + 1 ) * cell.x - column * gap, height - ( row + 1 ) * cell.y - row * gap );+ slot->winSetSize( cell.x, cell.y );+ slot->winSetDrawFunc( drawNoTray );+ button->winSetSize( cell.x, cell.y );+ button->winSetPosition( 0, 0 );}+ return shown;}//-------------------------------------------------------------------------------------------------diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/InGameUI.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/InGameUI.cppindex afcb40b92..d33459676 100644--- a/GeneralsMD/Code/GameEngine/Source/GameClient/InGameUI.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/InGameUI.cpp@@ -10365,13 +10365,12 @@ enum{STARS_TAB_WIDTH = 66, ///< the rank's stars, a key in a tab on the right panel's border, which is the promotion buttonSTARS_TAB_HEIGHT = 22, ///< the key 17 tall with its rim, three pixels down- SKILL_GRID_WIDTH = 150, ///< the general's powers, three to a row, against the screen's right edge- SKILL_GRID_GAP = 30, ///< between them and the stars' tab+ SKILL_GRID_GAP = 12, ///< between the general's powers' tray and the stars' tab under it+ SKILL_TRAY_BORDER = 6, ///< the tray's steel round its cells+ SKILL_CELL_GAP = 2, ///< the steel between two cellsSIGNAL_BUTTON_SIZE = 24, ///< each smoke signal button's height, a row of the columnSIGNAL_BUTTON_WIDTH = 40, ///< and its width, room for its pictureSIGNAL_BUTTONS = 3, ///< attack, defend, look- SKILL_GRID_ROWS = 3, ///< the empty places drawn behind the powers- SKILL_GRID_COLUMNS = 3,ALERT_TAB_WIDTH = 54, ///< the under-attack light, a lamp on the radar panel's borderWORKER_TAB_WIDTH = 39, ///< the idle worker's step, against the command grid panel's border, as wide as the signals' columnWORKER_STEP_HEIGHT = 30, ///< and its height, its key's bottom GRID_BOTTOM_GAP over the screen's bottom edge@@ -10813,31 +10812,39 @@ Bool InGameUI::drawControlBarPage( const IRegion2D *panels, const Bool *shown, IportraitCells.push_back( entry );}- // the general's powers ready to fire, three to a row over the right panel- IRegion2D powers;- powers.hi.x = TheDisplay->getWidth();- powers.lo.x = powers.hi.x - REAL_TO_INT( SKILL_GRID_WIDTH * scale );- powers.hi.y = starsTab.lo.y - REAL_TO_INT( SKILL_GRID_GAP * scale );- powers.lo.y = powers.hi.y;+ // the general's powers ready to fire over the right panel, the first in the corner against the+ // screen's right edge, the row growing left as they come and wrapping upward past three, each a+ // command button's size. They sit in a tray of the panels' steel only as big as they are, and each+ // has a dark cell behind it the way the command grid's buttons do+ const Int trayBorder = REAL_TO_INT( SKILL_TRAY_BORDER * scale );+ ICoord2D corner;+ corner.x = TheDisplay->getWidth() - trayBorder;+ corner.y = starsTab.lo.y - REAL_TO_INT( SKILL_GRID_GAP * scale ) - trayBorder;+ const IRegion2D button = commandButtonRect( 1 );ICoord2D cell;- TheControlBar->placeSpecialPowerShortcutGrid( rightFound ? &powers : NULL, &cell );+ cell.x = button.hi.x - button.lo.x;+ cell.y = button.hi.y - button.lo.y;+ const Int cellGap = REAL_TO_INT( SKILL_CELL_GAP * scale );+ const Int powersShown = TheControlBar->placeSpecialPowerShortcutGrid( rightFound && rightShown ? &corner : NULL, cell, cellGap );- // the grid's empty places, three by three, drawn behind the powers the way the command grid's- // well stands behind its buttonsstd::vector< HtmlValues > &places = lists[ "skillcells" ];- for( Int row = 0; row < SKILL_GRID_ROWS && cell.x > 0; row++ )- {- for( Int column = 0; column < SKILL_GRID_COLUMNS; column++ )- {- IRegion2D place;- place.lo.x = powers.lo.x + column * cell.x;- place.lo.y = powers.hi.y - ( SKILL_GRID_ROWS - row ) * cell.y;- place.hi.x = place.lo.x + cell.x;- place.hi.y = place.lo.y + cell.y;- HtmlValues entry;- putPageRect( entry, "cell", place, TRUE );- places.push_back( entry );- }+ IRegion2D powers;+ powers.lo = corner;+ powers.hi = corner;+ for( Int slot = 0; slot < powersShown; slot++ )+ {+ const Int column = slot % SPECIAL_POWER_SHORTCUT_COLS;+ const Int row = slot / SPECIAL_POWER_SHORTCUT_COLS;+ IRegion2D place;+ place.hi.x = corner.x - column * ( cell.x + cellGap );+ place.hi.y = corner.y - row * ( cell.y + cellGap );+ place.lo.x = place.hi.x - cell.x;+ place.lo.y = place.hi.y - cell.y;+ powers.lo.x = min( powers.lo.x, place.lo.x );+ powers.lo.y = min( powers.lo.y, place.lo.y );+ HtmlValues entry;+ putPageRect( entry, "cell", place, TRUE );+ places.push_back( entry );}// the promotion button is the stars' tab: its window moves under the tab and takes the click that@@ -10846,6 +10853,12 @@ Bool InGameUI::drawControlBarPage( const IRegion2D *panels, const Bool *shown, Iif( rightFound && promotion ){Int parentX = 0, parentY = 0;+ IRegion2D tray = powers;+ tray.lo.x -= trayBorder;+ tray.lo.y -= trayBorder;+ tray.hi.x = TheDisplay->getWidth();+ tray.hi.y += trayBorder;+ putFrame( values, "skilltray", powers, tray, powersShown > 0 );if( promotion->winGetParent() )promotion->winGetParent()->winGetScreenPosition( &parentX, &parentY );promotion->winSetPosition( starsTab.lo.x - parentX, starsTab.lo.y - parentY );