Skip to content

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.

feat(gameclient): command bar grids framed over their buttons

Olcay Seygan4c7461f5fe39
diff --git a/CHANGELOG.md b/CHANGELOG.md
index d3c778c80..3cac0287c 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -502,7 +502,7 @@ found and fixed — EA's own, not port damage.**
- 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. Each panel holds one thing and is exactly its size, the radar, the command grid, the portrait with the experience bar, and wears a steel border outside it. 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.
- Every panel of the bar is only as big as what it holds now, and stands on the bottom of the screen. The radar's border runs out to the screen's left edge, the portrait's to the right edge, and the middle is built up like bricks laid flush: the command grid's panel at the bottom, the power bar standing on its border in a steel frame of its own, a row of forty cells that light up from the left with your production and fill the frame from edge to edge when full, the consumption marked by a white needle, and on top of that a narrower block no taller than the money written on it. 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 lit gold under the pointer and pressed in when pushed. The menu is a small square with three bars in the screen's top left corner. The idle worker button is a key like the smoke signals', a hard hat on it, in a steel step against the middle panel's bottom left corner, where it no longer hides the end of the power bar, and the build buttons sit down level with it, a few pixels over the bottom of the screen. Each of the fourteen build places is its own dark cell with steel running between them, so an empty place reads as a slot waiting for a button. The power bar is sunk into the same steel plate as the build grid, the plate carried on upward as wide as it, and the money's block sits on top of that plate with no seam between them: the build grid, the power and the money read as one piece. The power bar is as long as the build grid on every side, where it used to change length from one faction to the next, and the money sits over the grid's middle. The build grid's panel no longer carries an empty strip down its left side. There is no chat button any more: Enter opens the chat as it always did. The portrait sits in the radar's lit steel too. The experience bar beside it is ten gold rungs in a sunk groove, climbing from the bottom as you earn your way to the next rank, and your rank stands in a steel tab on the portrait's top right corner, a key sunk in it like the idle worker's with one star for every rank there is, gold up to the one you hold. The portrait's grid is steel between dark cells on every side, where America's was drawn in blue lines that matched nothing else on the bar. That key is the promotions button: point at it and it comes up with a gold rim, it blinks bright in your side's own steel while you have a promotion to spend, and a click opens the promotion screen. That screen is rebuilt in the same steel and half its old size: each rank's promotions stand in a grid of build-button cells five wide, like the command grid, an empty place a dark hole, each rank in a steel well of its own with its heading, the wells a plate's thickness apart, the grid's steel laid over the edge of every picture so the picture sits in its cell like a card in a frame, your rank and the points to spend on one line over the experience bar, and Done in the last row's spare place. A gold rim marks what you have bought and a light one what you can buy now. The bar has no minimise arrow any more: it is only as big as what it holds. The radar sits sunk in a bezel of lit steel, bright along the top and shadowed down the right, and the build grid and the money wear the same steel, the figure in a dark window of its own, and the under-attack light is a long red lamp set in a steel tab on its top left corner, dark until you are hit and then blinking. No words on it, so it reads the same in any language.
+- The bar's own buttons are drawn to match, steel caps lit gold under the pointer and pressed in when pushed. The menu is a small square with three bars in the screen's top left corner. The idle worker button is a key like the smoke signals', a hard hat on it, in a steel step against the middle panel's bottom left corner, where it no longer hides the end of the power bar, and the build buttons sit down level with it, a few pixels over the bottom of the screen. Each of the fourteen build places is its own dark cell with steel running between them, so an empty place reads as a slot waiting for a button, and the steel is laid over the edge of every picture the way a frame holds a card, the whole picture showing inside it. The production queue and the general's powers are framed the same way. The power bar is sunk into the same steel plate as the build grid, the plate carried on upward as wide as it, and the money's block sits on top of that plate with no seam between them: the build grid, the power and the money read as one piece. The power bar is as long as the build grid on every side, where it used to change length from one faction to the next, and the money sits over the grid's middle. The build grid's panel no longer carries an empty strip down its left side. There is no chat button any more: Enter opens the chat as it always did. The portrait sits in the radar's lit steel too. The experience bar beside it is ten gold rungs in a sunk groove, climbing from the bottom as you earn your way to the next rank, and your rank stands in a steel tab on the portrait's top right corner, a key sunk in it like the idle worker's with one star for every rank there is, gold up to the one you hold. The portrait's grid is steel between dark cells on every side, where America's was drawn in blue lines that matched nothing else on the bar. That key is the promotions button: point at it and it comes up with a gold rim, it blinks bright in your side's own steel while you have a promotion to spend, and a click opens the promotion screen. That screen is rebuilt in the same steel and half its old size: each rank's promotions stand in a grid of build-button cells five wide, like the command grid, an empty place a dark hole, each rank in a steel well of its own with its heading, the wells a plate's thickness apart, the grid's steel laid over the edge of every picture so the picture sits in its cell like a card in a frame, your rank and the points to spend on one line over the experience bar, and Done in the last row's spare place. A gold rim marks what you have bought and a light one what you can buy now. The bar has no minimise arrow any more: it is only as big as what it holds. The radar sits sunk in a bezel of lit steel, bright along the top and shadowed down the right, and the build grid and the money wear the same steel, the figure in a dark window of its own, and the under-attack light is a long red lamp set in a steel tab on its top left corner, dark until you are hit and then blinking. No words on it, so it reads the same in any language.
- The general's powers you have bought and can fire, the column that climbed the right edge of the screen, stand over the portrait now in a tray of the bar's own steel. The first sits in the corner against the right edge of the screen, and each one you gain takes the place to the left of the last, three to a row before a new row starts above, so the tray is only ever as big as what you hold and an empty one takes no room at all. Each power sits on a dark cell three quarters the size of a build button, where the side's old tray art used to frame it. It is always out; there is no button to fold it away.
- Three buttons sit in a step of the radar's own steel, on its right: the smoke signals Alt+Z, X and C send, placed in the middle of your view for your allies to see. Each is a key sunk into the steel with a sharp white picture on it instead of a word: a crosshair to attack, a shield to defend, an eye to look. Point at one and it comes up out of its well as lit steel with a gold rim, and it sinks in darker while you hold the button down. They rise into place one after another from the bottom of the screen when the match starts. A game with nobody on your side to see the smoke, a skirmish against the computer or a replay, has no signal buttons at all.
- Tooltips wear the bar's steel. Point at a build button and a card opens right above it rather than in a fixed box at the side: the name on a steel header in your side's colour with the price in gold at its end, every "Power Supplied: 5" or "Strong: infantry" line of the description laid out as a label and a bold figure, then the unit's health, damage, attacks a second, damage a second, range and build time in gold, counted with the upgrades you own. Under them every upgrade that touches the unit and what it does to it: a Gattling Tank's card says Chain Guns takes its damage from 15 to 18 and its damage a second from 37 to 46, a Humvee's that TOW adds a 50 damage missile with a range of 317, and an upgrade you already bought turns gold. Point at the upgrade itself and the card lists the units it changes, Composite Armor putting a Crusader from 480 health to 680. At the bottom, "not enough money" or what you still need in a sunk red note at the bottom. Point at something on the battlefield and a small dark box beside the pointer names it, its owner's colour in a stripe down the left edge.
diff --git a/GeneralsMD/Code/Data/Window/Html/ControlBar.html b/GeneralsMD/Code/Data/Window/Html/ControlBar.html
index af3d4f0c0..f404a2731 100644
--- a/GeneralsMD/Code/Data/Window/Html/ControlBar.html
+++ b/GeneralsMD/Code/Data/Window/Html/ControlBar.html
@@ -13,6 +13,9 @@
reaches the page as a click on the battlefield.
The game fills in, every frame (GameClient/HtmlTemplate.h):
+ {{layer}} "back" under the bar's windows; "front" drawn again after one grid's
+ buttons with nothing but {{side}} and data-each="frontcells", that grid's
+ cells, each {{cell.x}} .y .w .h, whose frames then lie over the buttons
{{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
@@ -129,15 +132,21 @@
.gla .bezel .steel { background: linear-gradient(to bottom, #b8ab6e, #766a3a 30%, #3c3519); }
.gla .bezel .shine { background-color: #ebe2b4; }
.gla .bezel .sunk { border-bottom-color: #cbbf82; border-right-color: #cbbf82; }
- /* the command grid: its well is steel, and each of the fourteen places a dark cell exactly its
- button's size, the bevel drawn inside it, so a button covers its cell whole and steel lines run
- between the buttons; an empty place shows as a hole. A pixel round the button showed as a light
- line down one side of every button, the other side rounding under it */
+ /* the command grid: its well is steel, and each of the fourteen places a dark cell with the well's
+ steel laid two pixels over its edge and a bevel inside that; an empty place shows as a hole. The
+ page is drawn a second time as the front, after each grid's buttons, with only the frames and
+ the bevels, so the grid lies over the buttons, which stand in the hole exactly */
+ .front .piece { display: none; }
+ .front .piece.over { display: block; }
.bezel .sunk.grid { background-color: #3a414a; }
.china .bezel .sunk.grid { background-color: #45190f; }
.gla .bezel .sunk.grid { background-color: #423a1c; }
.commandcell { background-color: #020405; }
- .commandcell .bevel { position: absolute; left: 0; top: 0; right: 0; bottom: 0; border: 1px solid #06090b;
+ .commandcell.over { background: none; }
+ .commandcell .edge { position: absolute; left: -1px; top: -1px; right: -1px; bottom: -1px; border: 3px solid #3a414a; }
+ .china .commandcell .edge { border-color: #45190f; }
+ .gla .commandcell .edge { border-color: #423a1c; }
+ .commandcell .bevel { position: absolute; left: 2px; top: 2px; right: 2px; bottom: 2px; border: 1px solid #06090b;
border-bottom-color: #9aa4ae; border-right-color: #9aa4ae; }
.china .commandcell .bevel { border-bottom-color: #d98a72; border-right-color: #d98a72; }
.gla .commandcell .bevel { border-bottom-color: #cbbf82; border-right-color: #cbbf82; }
@@ -326,7 +335,7 @@
</style>
</head>
<body>
-<div class="{{side}} {{watching}} {{held}}">
+<div class="{{layer}} {{side}} {{watching}} {{held}}">
<div class="piece frame bezel solid {{left.shown}}" style="left: {{left.x}}px; top: {{left.y}}px; width: {{left.w}}px; height: {{left.h}}px; border-width: {{left.bt}}px {{left.br}}px {{left.bb}}px {{left.bl}}px">
<div class="steel" style="left: -{{left.bl}}px; right: -{{left.br}}px; top: -{{left.bt}}px; bottom: -{{left.bb}}px"></div>
@@ -342,7 +351,7 @@
<div class="shade" style="right: -{{centre.br}}px; top: -{{centre.bt}}px; bottom: -{{centre.bb}}px"></div>
<div class="sunk grid" style="width: {{centre.w}}px; height: {{centre.h}}px"></div>
</div>
- <div class="piece commandcell" data-each="commandcells" 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 commandcell" data-each="commandcells" style="left: {{cell.x}}px; top: {{cell.y}}px; width: {{cell.w}}px; height: {{cell.h}}px"><div class="edge"></div><div class="bevel"></div></div>
<div class="piece step worker solid {{workertab.shown}} {{ButtonIdleWorker.state}}" style="left: {{workertab.x}}px; top: {{workertab.y}}px; width: {{workertab.w}}px; height: {{workertab.h}}px">
<div class="key" data-click="press:ButtonIdleWorker"><div class="icon"></div><div class="veil"></div></div>
</div>
@@ -374,7 +383,7 @@
<div class="lit" style="left: -{{right.bl}}px; top: -{{right.bt}}px; bottom: -{{right.bb}}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 commandcell" data-each="portraitcells" style="left: {{cell.x}}px; top: {{cell.y}}px; width: {{cell.w}}px; height: {{cell.h}}px"><div class="edge"></div><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>
@@ -399,7 +408,10 @@
<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 commandcell" data-each="skillcells" style="left: {{cell.x}}px; top: {{cell.y}}px; width: {{cell.w}}px; height: {{cell.h}}px"><div class="edge"></div><div class="bevel"></div></div>
+
+ <!-- the front: one grid's frames again, drawn after its buttons -->
+ <div class="piece commandcell over" data-each="frontcells" style="left: {{cell.x}}px; top: {{cell.y}}px; width: {{cell.w}}px; height: {{cell.h}}px"><div class="edge"></div><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.h
index 82922bb82..010cc73c3 100644
--- a/GeneralsMD/Code/GameEngine/Include/GameClient/ControlBar.h
+++ b/GeneralsMD/Code/GameEngine/Include/GameClient/ControlBar.h
@@ -1036,10 +1036,18 @@ public:
/** 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 );
+ * art is not drawn; the page draws their cells, and each power stands `inset` inside its cell
+ * for the page's frame over the edge. 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, Int inset );
+
+ /** Puts one of the bar's windows `inset` pixels inside the rectangle layoutPanels gave it, on every
+ * side, for a frame the page draws over the edge; nought gives it the whole rectangle back. A
+ * rebuild of the layout reads the window as the whole rectangle. */
+ void insetPlacedWindow( GameWindow *window, Int inset );
+ Int getPlacedInset( GameWindow *window ) const; ///< what insetPlacedWindow last put it in by
+ GameWindow *getSpecialPowerShortcutParent( void ) { return m_specialPowerShortcutParent; }
/// the general's stars are asking to be spent, so the button blinks; see getStarImage
Bool isGeneralStarFlashing( void ) const { return m_genStarFlash; }
diff --git a/GeneralsMD/Code/GameEngine/Include/GameClient/InGameUI.h b/GeneralsMD/Code/GameEngine/Include/GameClient/InGameUI.h
index a2606260c..445b2b885 100644
--- a/GeneralsMD/Code/GameEngine/Include/GameClient/InGameUI.h
+++ b/GeneralsMD/Code/GameEngine/Include/GameClient/InGameUI.h
@@ -410,6 +410,10 @@ public: // ********************************************************************
/** The general's promotion screen, Window/Html/Promotion.html, drawn as `parent`'s picture: the
* screen's windows keep their clicks and the promotions' own cameos paint over it. */
void drawPromotionPage( GameWindow *parent, Bool front );
+ /** The command bar's grids of buttons whose cells the page frames in front of the buttons. */
+ enum CellGrid { CELL_GRID_COMMAND, CELL_GRID_QUEUE, CELL_GRID_POWERS, CELL_GRID_COUNT };
+ /** The steel frames over one grid's buttons, from Window/Html/ControlBar.html, drawn after them. */
+ void drawCellGridFront( Int grid );
void drawScoreboard( void ); ///< that scoreboard, over everything
/** Window/Html/Tooltip.html is there to draw with, in a match. */
Bool isTooltipPageReady( void );
@@ -1227,6 +1231,8 @@ protected:
ICoord2D m_tooltipSize; ///< the box as last laid out, in screen pixels, to place the next one by
HtmlOverlay * m_promotionOverlay;
HtmlOverlay * m_promotionFrontOverlay; ///< the grid's frames, drawn over the promotions
+ HtmlOverlay * m_cellFrontOverlay[ CELL_GRID_COUNT ];
+ std::vector< HtmlValues > m_cellFrontCells[ CELL_GRID_COUNT ]; ///< each grid's cells as the bar's page last placed them
Bool m_promotionPageLoaded;
std::string m_promotionPage;
Bool m_signalsWereShown; ///< the smoke signal column was up last frame
diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/ControlBar/ControlBar.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/ControlBar/ControlBar.cpp
index 23a7283bf..4d0a5b7a7 100644
--- a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/ControlBar/ControlBar.cpp
+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/ControlBar/ControlBar.cpp
@@ -1637,6 +1637,7 @@ struct ControlBarPanelPlacement
Real designX, designY, designW, designH;
Int placedX, placedY, placedW, placedH;
Int slideApplied; ///< how far down applyPanelSlide has actually moved this one, in pixels
+ Int inset; ///< how far insetPlacedWindow has put it inside the placed rectangle, in pixels
};
typedef std::map< GameWindow *, ControlBarPanelPlacement > ControlBarPanelPlacementMap;
static ControlBarPanelPlacementMap theControlBarPlacement;
@@ -2021,10 +2022,14 @@ void ControlBar::placeInPanel( GameWindow *win, Int panel,
win->winGetPosition( &rel.x, &rel.y );
win->winGetSize( &size.x, &size.y );
- const Int oldX = oldParentX + rel.x;
- const Int oldY = oldParentY + rel.y;
-
+ // a window insetPlacedWindow put inside its place is read as the whole place, or every rebuild
+ // would take the inset for what it was authored at and shrink it again
ControlBarPanelPlacement &place = theControlBarPlacement[ win ];
+ size.x += 2 * place.inset;
+ size.y += 2 * place.inset;
+ const Int oldX = oldParentX + rel.x - place.inset;
+ const Int oldY = oldParentY + rel.y - place.inset;
+
if( place.known == FALSE || oldX != place.placedX || oldY != place.placedY ||
size.x != place.placedW || size.y != place.placedH )
{
@@ -2092,6 +2097,7 @@ void ControlBar::placeInPanel( GameWindow *win, Int panel,
place.panel = panel;
place.weHid = FALSE;
place.slideApplied = 0;
+ place.inset = 0;
place.placedX = newX;
place.placedY = newY;
place.placedW = newW;
@@ -2140,6 +2146,25 @@ Int ControlBar::getPanelSlideOffset( Int panel ) const
return REAL_TO_INT_FLOOR( m_panelSlide[ panel ] * drop );
}
+//-------------------------------------------------------------------------------------------------
+void ControlBar::insetPlacedWindow( GameWindow *window, Int inset )
+{
+ ControlBarPanelPlacement &place = theControlBarPlacement.find( window )->second;
+ if( place.inset == inset )
+ return;
+
+ // where placeInPanel put it in its parent, which the parent carries with it wherever it goes
+ const ControlBarPanelPlacement &parent = theControlBarPlacement.find( window->winGetParent() )->second;
+ window->winSetPosition( place.placedX - parent.placedX + inset, place.placedY - parent.placedY + inset );
+ window->winSetSize( place.placedW - 2 * inset, place.placedH - 2 * inset );
+ place.inset = inset;
+}
+
+Int ControlBar::getPlacedInset( GameWindow *window ) const
+{
+ return theControlBarPlacement.find( window )->second.inset;
+}
+
//-------------------------------------------------------------------------------------------------
/** Put every window where its panel's slide says it should be.
*
@@ -6203,7 +6228,7 @@ static void drawNoTray( GameWindow *window, WinInstanceData *instData )
{
}
-Int ControlBar::placeSpecialPowerShortcutGrid( const ICoord2D *corner, const ICoord2D &cell, Int gap )
+Int ControlBar::placeSpecialPowerShortcutGrid( const ICoord2D *corner, const ICoord2D &cell, Int gap, Int inset )
{
if( m_specialPowerShortcutParent == NULL || m_specialPowerShortcutButtonParents[ 0 ] == NULL )
return 0;
@@ -6238,7 +6263,7 @@ Int ControlBar::placeSpecialPowerShortcutGrid( const ICoord2D *corner, const ICo
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 cell
+ // order the row keys count in. Each cameo fills its cell but for the inset round it
for( Int i = 0; i < MAX_SPECIAL_POWER_SHORTCUTS; i++ )
{
GameWindow *slot = m_specialPowerShortcutButtonParents[ i ];
@@ -6251,8 +6276,8 @@ Int ControlBar::placeSpecialPowerShortcutGrid( const ICoord2D *corner, const ICo
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 );
+ button->winSetSize( cell.x - 2 * inset, cell.y - 2 * inset );
+ button->winSetPosition( inset, inset );
}
return shown;
}
diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/InGameUI.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/InGameUI.cpp
index cb1301852..8408095be 100644
--- a/GeneralsMD/Code/GameEngine/Source/GameClient/InGameUI.cpp
+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/InGameUI.cpp
@@ -1207,6 +1207,8 @@ InGameUI::InGameUI()
m_controlBarPageLoaded = FALSE;
m_promotionOverlay = NULL;
m_promotionFrontOverlay = NULL;
+ for( Int grid = 0; grid < CELL_GRID_COUNT; grid++ )
+ m_cellFrontOverlay[ grid ] = NULL;
m_promotionPageLoaded = FALSE;
m_controlBarPageShown = FALSE;
m_tooltipOverlay = NULL;
@@ -1340,6 +1342,11 @@ InGameUI::~InGameUI()
m_promotionOverlay = NULL;
delete m_promotionFrontOverlay;
m_promotionFrontOverlay = NULL;
+ for( Int grid = 0; grid < CELL_GRID_COUNT; grid++ )
+ {
+ delete m_cellFrontOverlay[ grid ];
+ m_cellFrontOverlay[ grid ] = NULL;
+ }
delete m_tooltipOverlay;
m_tooltipOverlay = NULL;
}
@@ -10411,6 +10418,7 @@ enum
SKILL_TRAY_BORDER = 6, ///< the tray's steel round its cells
SKILL_CELL_GAP = 2, ///< the steel between two cells
SKILL_CELL_PERCENT = 75, ///< a cell's size against a command button's; the whole size stood too big over the portrait
+ CELL_FRAME = 3, ///< a grid's steel and bevel, drawn in front over a cell's edge; its button fills the hole inside
SIGNAL_BUTTON_SIZE = 24, ///< each smoke signal button's height, a row of the column
SIGNAL_BUTTON_WIDTH = 40, ///< and its width, room for its picture
SIGNAL_BUTTONS = 3, ///< attack, defend, look
@@ -10580,21 +10588,53 @@ static IRegion2D tabOn( const IRegion2D &box, Int width, Int height, Bool fromRi
* 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. */
//-------------------------------------------------------------------------------------------------
-/** 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 )
+static GameWindow *numberedWindow( const char *prefix, Int number )
{
char name[ 32 ];
snprintf( name, sizeof( name ), "%s%02d", prefix, number );
- GameWindow *window = controlBarWindow( name );
+ return controlBarWindow( name );
+}
+
+/** The screen rectangle of the bar's window `prefix` followed by `number` in two digits, shown or
+ * not: its whole place, the frame the page draws over its edge included. */
+static IRegion2D numberedWindowRect( const char *prefix, Int number )
+{
+ GameWindow *window = numberedWindow( prefix, number );
+ const Int inset = TheControlBar->getPlacedInset( window );
IRegion2D place;
Int width = 0, height = 0;
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;
+ place.lo.x -= inset;
+ place.lo.y -= inset;
+ place.hi.x = place.lo.x + width + 2 * inset;
+ place.hi.y = place.lo.y + height + 2 * inset;
return place;
}
+/** How far a grid's cells reach out past their buttons into the gaps between them: half the narrower
+ * of the gaps beside and below button `first`, so a cell's frame stops short of its neighbour's
+ * bevel, and never more than the frame. The frame's depth past that is taken off the buttons, and
+ * the steel between two pictures stays near the gap the layout left. */
+static Int cellReach( const char *prefix, Int first, Int beside, Int below, Int frame )
+{
+ const IRegion2D place = numberedWindowRect( prefix, first );
+ const Int across = numberedWindowRect( prefix, beside ).lo.x - place.hi.x;
+ const Int down = numberedWindowRect( prefix, below ).lo.y - place.hi.y;
+ return min( frame, min( across, down ) / 2 );
+}
+
+/** `place` grown by `reach` screen pixels on every side. */
+static IRegion2D reachedBy( const IRegion2D &place, Int reach )
+{
+ IRegion2D cell = place;
+ cell.lo.x -= reach;
+ cell.lo.y -= reach;
+ cell.hi.x += reach;
+ cell.hi.y += reach;
+ return cell;
+}
+
/** ButtonCommandNN's screen rectangle, `button` 1 to COMMAND_BUTTONS, shown or not. */
static IRegion2D commandButtonRect( Int button )
{
@@ -10627,7 +10667,7 @@ static void lowerControlBarWindow( const char *name, Int shift )
window->winSetPosition( x, y + shift );
}
-static void stackCentre( HtmlValues &values, Bool shown, IRegion2D &centre )
+static void stackCentre( HtmlValues &values, Bool shown, Int reach, IRegion2D &centre )
{
// the command buttons stand as low as the idle worker's key beside them, GRID_BOTTOM_GAP over the
// screen's bottom edge, wherever the side's layout put them; the beacon button goes down with them
@@ -10646,7 +10686,8 @@ static void stackCentre( HtmlValues &values, Bool shown, IRegion2D &centre )
// money and the power bar stood over bare battlefield. The grid's place holds whether it is up,
// and it is the fourteen buttons' place rather than CommandWindow's: the window reaches 34 pixels
// further left, over where the beacon button stands, and left an empty strip in the panel
- IRegion2D buttons = commandButtonsBox();
+ // It is the cells', which reach `reach` past the buttons
+ IRegion2D buttons = reachedBy( commandButtonsBox(), reach );
if( othersFound )
{
buttons.lo.x = min( buttons.lo.x, grid.lo.x );
@@ -10735,6 +10776,52 @@ static void putPageRect( HtmlValues &values, const std::string &name, const IReg
values[ name + ".shown" ] = shown ? "shown" : "hidden";
}
+static void drawCommandGridFront( GameWindow *window, WinInstanceData *instData )
+{
+ TheInGameUI->drawCellGridFront( InGameUI::CELL_GRID_COMMAND );
+}
+
+static void drawQueueGridFront( GameWindow *window, WinInstanceData *instData )
+{
+ TheInGameUI->drawCellGridFront( InGameUI::CELL_GRID_QUEUE );
+}
+
+static void drawPowersGridFront( GameWindow *window, WinInstanceData *instData )
+{
+ TheInGameUI->drawCellGridFront( InGameUI::CELL_GRID_POWERS );
+}
+
+/** A window of no size and no input at the head of `parent`'s children, which draw from the tail,
+ * so `draw` runs after every one of them; made the first time and kept at the head. */
+static void putFrontWindow( GameWindow *parent, GameWinDrawFunc draw )
+{
+ GameWindow *front = parent->winGetChild();
+ while( front && front->winGetDrawFunc() != draw )
+ front = front->winGetNext();
+ if( front == NULL )
+ {
+ front = TheWindowManager->winCreate( parent, WIN_STATUS_NO_INPUT, 0, 0, 0, 0, NULL );
+ front->winSetDrawFunc( draw );
+ }
+ if( parent->winGetChild() != front )
+ front->winBringToTop();
+}
+
+void InGameUI::drawCellGridFront( Int grid )
+{
+ HtmlOverlay *&overlay = m_cellFrontOverlay[ grid ];
+ if( overlay == NULL )
+ overlay = new HtmlOverlay( m_superweaponNormalFont );
+
+ HtmlValues values;
+ HtmlLists lists;
+ values[ "layer" ] = "front";
+ values[ "side" ] = spectatorSide();
+ lists[ "frontcells" ] = m_cellFrontCells[ grid ];
+ overlay->setPage( HtmlTemplate_expand( m_controlBarPage, values, lists, lookupGameText ) );
+ overlay->draw();
+}
+
//-------------------------------------------------------------------------------------------------
/** The command bar's frame, drawn from Window/Html/ControlBar.html in the place of its three plates.
* The buttons, the radar and the portrait are still the bar's own windows and paint over it; the
@@ -10765,6 +10852,7 @@ Bool InGameUI::drawControlBarPage( const IRegion2D *panels, const Bool *shown, I
m_controlBarOverlay = new HtmlOverlay( m_superweaponNormalFont );
HtmlValues values;
+ values[ "layer" ] = "back";
values[ "side" ] = spectatorSide();
// a watcher has no promotions of his own to spend, whatever the bar's flash says
const Bool watching = localPlayerWatching();
@@ -10783,6 +10871,18 @@ Bool InGameUI::drawControlBarPage( const IRegion2D *panels, const Bool *shown, I
// else - the tabs, the buttons, the signals - stands outside the border.
const Real scale = ControlBarUniformScale();
const Int border = REAL_TO_INT( PANEL_BORDER * scale );
+
+ // the command and queue buttons stand inside the frame the page draws over their cells' edges, so
+ // the frame covers no part of the picture; the cells reach into the gaps for as much of it as fits.
+ // The gaps are measured from the whole places, whatever the buttons were last put in by
+ const Int cellFrame = REAL_TO_INT( CELL_FRAME * scale );
+ const Int commandReach = cellReach( "ButtonCommand", 1, 3, 2, cellFrame );
+ const Int queueReach = cellReach( "ButtonQueue", 1, 2, 4, cellFrame );
+ for( Int button = 1; button <= COMMAND_BUTTONS; button++ )
+ TheControlBar->insetPlacedWindow( numberedWindow( "ButtonCommand", button ), cellFrame - commandReach );
+ for( Int button = 1; button <= QUEUE_BUTTONS; button++ )
+ TheControlBar->insetPlacedWindow( numberedWindow( "ButtonQueue", button ), cellFrame - queueReach );
+
const Bool leftShown = panelCount > 0 && shown[ 0 ];
const Bool rightShown = panelCount > 2 && shown[ 2 ];
@@ -10809,7 +10909,7 @@ Bool InGameUI::drawControlBarPage( const IRegion2D *panels, const Bool *shown, I
putSignalRise( values, nowMs - m_signalsRiseStartMs );
IRegion2D centreBox;
- stackCentre( values, panelCount > 1 && shown[ 1 ], centreBox );
+ stackCentre( values, panelCount > 1 && shown[ 1 ], commandReach, centreBox );
// the idle worker's key, a smoke signal's size, in a step against the centre panel's border at its
// bottom left, standing on the screen's bottom edge; on the top edge it stood under the power bar
IRegion2D workerStep;
@@ -10827,7 +10927,7 @@ Bool InGameUI::drawControlBarPage( const IRegion2D *panels, const Bool *shown, I
for( Int button = 1; button <= COMMAND_BUTTONS && panelCount > 1 && shown[ 1 ]; button++ )
{
HtmlValues entry;
- putPageRect( entry, "cell", commandButtonRect( button ), TRUE );
+ putPageRect( entry, "cell", reachedBy( commandButtonRect( button ), commandReach ), TRUE );
commandCells.push_back( entry );
}
@@ -10851,7 +10951,7 @@ Bool InGameUI::drawControlBarPage( const IRegion2D *panels, const Bool *shown, I
for( Int button = 1; button <= QUEUE_BUTTONS && rightFound && rightShown; button++ )
{
HtmlValues entry;
- putPageRect( entry, "cell", numberedWindowRect( "ButtonQueue", button ), TRUE );
+ putPageRect( entry, "cell", reachedBy( numberedWindowRect( "ButtonQueue", button ), queueReach ), TRUE );
portraitCells.push_back( entry );
}
@@ -10868,7 +10968,9 @@ Bool InGameUI::drawControlBarPage( const IRegion2D *panels, const Bool *shown, I
cell.x = ( button.hi.x - button.lo.x ) * SKILL_CELL_PERCENT / 100;
cell.y = ( button.hi.y - button.lo.y ) * SKILL_CELL_PERCENT / 100;
const Int cellGap = REAL_TO_INT( SKILL_CELL_GAP * scale );
- const Int powersShown = TheControlBar->placeSpecialPowerShortcutGrid( rightFound && rightShown ? &corner : NULL, cell, cellGap );
+ const Int powersReach = min( cellFrame, cellGap / 2 );
+ const Int powersShown = TheControlBar->placeSpecialPowerShortcutGrid( rightFound && rightShown ? &corner : NULL, cell, cellGap,
+ cellFrame - powersReach );
std::vector< HtmlValues > &places = lists[ "skillcells" ];
IRegion2D powers;
@@ -10886,7 +10988,7 @@ Bool InGameUI::drawControlBarPage( const IRegion2D *panels, const Bool *shown, I
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 );
+ putPageRect( entry, "cell", reachedBy( place, powersReach ), TRUE );
places.push_back( entry );
}
IRegion2D tray = powers;
@@ -10896,6 +10998,16 @@ Bool InGameUI::drawControlBarPage( const IRegion2D *panels, const Bool *shown, I
tray.hi.y += trayBorder;
putFrame( values, "skilltray", powers, tray, powersShown > 0 );
+ // each grid's frames again in front of its buttons, drawn by a window after them
+ m_cellFrontCells[ CELL_GRID_COMMAND ] = commandCells;
+ m_cellFrontCells[ CELL_GRID_QUEUE ] = portraitCells;
+ m_cellFrontCells[ CELL_GRID_POWERS ] = places;
+ putFrontWindow( controlBarWindow( "CommandWindow" ), drawCommandGridFront );
+ putFrontWindow( controlBarWindow( "ProductionQueueWindow" ), drawQueueGridFront );
+ GameWindow *powersParent = TheControlBar->getSpecialPowerShortcutParent();
+ if( powersParent )
+ putFrontWindow( powersParent, drawPowersGridFront );
+
// the promotion button is the stars' tab: its window moves under the tab and takes the click that
// opens the promotion screen
GameWindow *promotion = controlBarWindow( "ButtonGeneral" );
@@ -11009,7 +11121,6 @@ enum
PROMOTION_MARGIN = 6, ///< the plate round the wells, and between one well and the next
PROMOTION_INSET = 4, ///< a well round its heading and cells
PROMOTION_CELL_GAP = 2,
- PROMOTION_FRAME = 3, ///< the front's frame and bevel over a cell's edge; the promotion fills the hole inside
PROMOTION_TITLE = 14, ///< the rank's name's line, the points beside it
PROMOTION_BAR = 7, ///< the experience bar under it
PROMOTION_BAR_GAP = 3,
@@ -11065,7 +11176,7 @@ static void layoutPromotionScreen( GameWindow *parent, PromotionLayout &layout )
const Int margin = Page::px( PROMOTION_MARGIN, scale );
const Int inset = Page::px( PROMOTION_INSET, scale );
const Int heading = Page::px( PROMOTION_HEADING, scale );
- const Int frame = Page::px( PROMOTION_FRAME, scale );
+ const Int frame = Page::px( CELL_FRAME, scale );
const Int gridWidth = PROMOTION_COLUMNS * cellWidth + ( PROMOTION_COLUMNS - 1 ) * gap;
const Int width = gridWidth + 2 * ( margin + inset );