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(gameengine): superweapon strip in owner colours, readouts on plates inside the cell
Olcay Seyganf722b2ca11c1
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex f84cce5b8..380e63c21 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -598,8 +598,10 @@ A third pass went through the generals' powers, promotions and unit abilities.- Workers and supply trucks walk to a pile up to 1400 feet away, the reach the computer opponent always had. Yours gave up at 700: when the pile beside your base ran dry they went home and stood there, with the next pile in plain sight.- Every countdown reads real seconds and answers the game speed. That means the speed the match is really running at, measured over the last second, and not the one it was set to: a barracks that says 10s in a match holding 30 frames a second says 30s once a crowded fight drags it down to 10, because that is how long you will wait for it. Build buttons, the production queue, buildings going up, the bars over your units and the bomb timers all read it.- The clock and frame-rate readout is drawn on top of everything.-- The superweapon countdowns are pictures now, not a list of names: the same strip treatment, in the top right corner, under that readout. Each one wears its own seconds and a sweeping clock, the next to land sits at the right hand end, and if you are watching more than eighteen of them the rest become a count.+- The superweapon countdowns are pictures now, not a list of names: the same strip treatment, in the top right corner, under that readout. Each one wears its own seconds and a sweeping clock, the next to land sits at the right hand end, and a seventh starts a second row under the first.- The superweapon countdowns are back in the top right corner while you play. They left when the row of players across the top arrived, and stayed gone when that row did, so a player had to hold Tab to see when the enemy's nuke would land. Watching a match or a replay, they stay on the Tab scoreboard and off the battlefield.+- Those countdowns stand in the command bar's steel. They were still sitting in the old bar's tray art, each in a flat box of its owner's colour. Now they share one steel tray with the production queue's thin rim, and the frame round each picture is the colour of the player whose weapon it is, one solid band with the tray's steel between two of them. A charged one breathes every 2.4 seconds, slowing at both ends: its frame swells toward white while a wash of its owner's colour rises over the picture, and both sink back. Every superweapon has a cell of its own, six to a row, where anything past eighteen used to fold into a count. The tray is cut to each row: a last row of two stands in steel two cells wide, against the edge of the screen. The tray grows with HUD Size, and at every step the steel between two pictures is one width along a row and down the rows. With the corner box switched off it sits in the corner itself.+- The small figures on a button or a picture stand on a solid plate inside the frame: the key, the price, the seconds, the power and the count on every command button, the countdown and the "x5" on a queue picture, the seconds on a superweapon. They used to sit flush in the corner on a see-through plate, so the steel frame was drawn over the first digit's left edge and a pale picture showed through the number. A figure too long for its button, a four-digit price at the smallest HUD Size, is set a size smaller until it fits. A countdown is never the one that shrinks: a "103s" too wide for its picture is written "103" at the size of the "79s" beside it.- Every button's corner markings - the hotkey, the price, the time, the number queued - sit flush in the corners instead of floating a few pixels inside them, and are set a size smaller than the button's own text: four labels at full size were eating the picture they were meant to annotate.- The messages that ran down the top left corner, out of money or a structure under attack, are lines of a feed standing on the radar now, the way Dota's kill feed stands on its minimap. Each line sits on a black band that thins out over the battlefield. A line about a player opens on his general's flag with his name in his colour; the rest open on a gold mark. A smoke signal or a beacon goes in, and so does a player beaten or gone, for a player and a watcher alike. Six lines at most, ten seconds each, the newest at the bottom, and the feed steps up over the production queue's row whenever that is out. Missed something? Press Enter: while the chat is open the last twelve lines come back, however old they are, and the chat moves up to stand clear of them. A line with no player opens on a steel plate the size of a flag with a gold exclamation mark lying across it, so every line's words start in the same column.- A superweapon's wait is written in plain seconds - 200, not 3:20 - so it compares with every other countdown on the screen at a glance. Once it is charged the number goes away entirely and the picture itself breathes in your colour, which is the one thing you want to catch out of the corner of your eye.diff --git a/GeneralsMD/Code/Data/Window/Html/ControlBar.html b/GeneralsMD/Code/Data/Window/Html/ControlBar.htmlindex a17d3bdbd..8c1491c74 100644--- a/GeneralsMD/Code/Data/Window/Html/ControlBar.html+++ b/GeneralsMD/Code/Data/Window/Html/ControlBar.html@@ -47,7 +47,7 @@{{attackkey.x}} ... the attack, hold position and move places, where the page's own keys{{holdkey.x}} ... stand, data-click="order:attack", "order:hold" and "order:move", for a{{movekey.x}} ... selection that attack moves; no command set has a button for any of- them. .key is the key bound to that place, "A", "C" and "V" as shipped+ them. The game letters each with the key bound to its placedata-each="portraitcells" the portrait bar's cells, the portrait's first and then only what itholds, each {{cell.x}} .y .w .h{{skilltray.x}} ... the general's powers' tray, a panel as {{centre.x}} is, only as big as the@@ -276,9 +276,8 @@.order .glow { position: absolute; left: 0; top: 0; right: 0; bottom: 0; background-size: 100% 100%; background-repeat: no-repeat; }.order:hover .glow { background-image: url(Cameo_hilited); }.held .order:hover .glow { background-image: url(Cameo_push); }- /* the key in the top left corner, the way the command buttons wear theirs */- .order .keyname { position: absolute; left: 0; top: 0; padding: 0 1px; line-height: 7px; font-size: 7px;- background-color: rgba(0, 0, 0, 0.6); color: #ffffff; }+ /* the key in each one's top left corner is the game's, lettered the way the command buttons'+ are (InGameUI::drawCellGridFront) *//* the under-attack light: a red lamp in a tab on the radar's bezel, dark until the bar blinks it.The tab is 66 by 14 and the lamp a bar 54 by 10 with its rim */@@ -399,9 +398,9 @@</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" style="left: -{{ring}}px; top: -{{ring}}px; right: -{{ring}}px; bottom: -{{ring}}px; border-width: {{ring}}px"></div><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" style="left: -{{ring}}px; top: -{{ring}}px; right: -{{ring}}px; bottom: -{{ring}}px; border-width: {{ring}}px"></div><div class="bevel"></div></div>- <div class="piece order attack {{attackkey.shown}}" data-click="order:attack" style="left: {{attackkey.x}}px; top: {{attackkey.y}}px; width: {{attackkey.w}}px; height: {{attackkey.h}}px"><div class="glow"></div><div class="keyname">{{attackkey.key}}</div></div>- <div class="piece order hold {{holdkey.shown}}" data-click="order:hold" style="left: {{holdkey.x}}px; top: {{holdkey.y}}px; width: {{holdkey.w}}px; height: {{holdkey.h}}px"><div class="glow"></div><div class="keyname">{{holdkey.key}}</div></div>- <div class="piece order move {{movekey.shown}}" data-click="order:move" style="left: {{movekey.x}}px; top: {{movekey.y}}px; width: {{movekey.w}}px; height: {{movekey.h}}px"><div class="glow"></div><div class="keyname">{{movekey.key}}</div></div>+ <div class="piece order attack {{attackkey.shown}}" data-click="order:attack" style="left: {{attackkey.x}}px; top: {{attackkey.y}}px; width: {{attackkey.w}}px; height: {{attackkey.h}}px"><div class="glow"></div></div>+ <div class="piece order hold {{holdkey.shown}}" data-click="order:hold" style="left: {{holdkey.x}}px; top: {{holdkey.y}}px; width: {{holdkey.w}}px; height: {{holdkey.h}}px"><div class="glow"></div></div>+ <div class="piece order move {{movekey.shown}}" data-click="order:move" style="left: {{movekey.x}}px; top: {{movekey.y}}px; width: {{movekey.w}}px; height: {{movekey.h}}px"><div class="glow"></div></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>diff --git a/GeneralsMD/Code/Data/Window/Html/Queue.html b/GeneralsMD/Code/Data/Window/Html/Queue.htmlindex a1048079d..dda5ccf8a 100644--- a/GeneralsMD/Code/Data/Window/Html/Queue.html+++ b/GeneralsMD/Code/Data/Window/Html/Queue.html@@ -10,13 +10,31 @@{{layer}} "back" under the cameos, "front" over them: the cells' frames again, sothe steel lies over each picture's edge{{side}} "america", "china" or "gla"- {{tray.x}} .y .w .h the tray, a panel as ControlBar.html's {{right.x}} is: .x and .y the- border's outer corner, .w and .h the cells it holds, .bt .br .bb .bl its- border's four widths+ data-each="trays" the tray, a panel as ControlBar.html's {{right.x}} is: {{tray.x}} and .y+ the border's outer corner, .w and .h the cells it holds, .bt .br .bb .bl+ its border's four widths. The queue has onedata-each="cells" a cell behind each cameo and the "+N", each {{cell.x}} .y .w .h, thecameo's own rectangle, and {{ring}} the steel round it+ {{line}} how thick the tray's light and dark lines are, 1+ {{well}} how deep the well round its cells is, 2All in the page's pixels, a pixel of an 800x600 screen. Without this page the strip draws itscolumn of the power bar's trays.++ The superweapon countdowns in the screen's top right corner stand in the same tray turned round+ (InGameUI::drawSuperweaponStrip). That page is laid out in the screen's own pixels, every length+ above already multiplied out by the game: rows of cells under each other and a tray stepped round+ them have too many edges that must meet for each to be rounded onto the screen by itself. It adds:+ {{mirrored}} "mirrored": the tray is against the screen's right edge, so the dark line+ goes down its left+ data-each="owned" a box under each superweapon's cameo, {{cell.x}} .y .w .h, in+ {{cell.color}}, the colour of the player whose weapon it is, lifted+ toward white and back while the weapon is charged. The game draws the+ cameo inside the box, the same distance in from every side, so what shows+ of the box is the cell's frame. The queue has no owned box, and this+ strip no `cells`+ {{tray.step}} "step" on a second tray: a last row shorter than the six over it hangs+ under them only as wide as its own cells, against the same edge, its+ top where the rows over it end, so the two read as one stepped plate--><html><head>@@ -29,15 +47,16 @@.front .under, .back .over { display: none; }/* the tray: a steel plate lit from above, a light line along its top, dark down its right, which- faces the battlefield, and along its bottom, which stands over it; the cells in a two pixel- well. The border's widths are written into each piece, since the page cannot add a width to a- width */+ faces the battlefield, and along its bottom, which stands over it; the cells in a well. The+ border's widths are written into each piece, since the page cannot add a width to a width */.tray { border-style: solid; border-color: transparent; }.tray .steel { position: absolute; background: linear-gradient(to bottom, #9aa3ad, #5a626c 30%, #353c45); }- .tray .shine { position: absolute; height: 1px; background-color: #dde4ea; }- .tray .shade { position: absolute; width: 1px; background-color: #0c1114; }- .tray .base { position: absolute; height: 1px; background-color: #0c1114; }- .tray .sunk { position: absolute; left: -2px; top: -2px; border: 2px solid #06090b;+ .tray .shine { position: absolute; height: {{line}}px; background-color: #dde4ea; }+ .tray .shade { position: absolute; width: {{line}}px; background-color: #0c1114; }+ .tray .base { position: absolute; height: {{line}}px; background-color: #0c1114; }+ .tray .lefthand, .mirrored .tray .righthand { display: none; }+ .mirrored .tray .lefthand { display: block; }+ .tray .sunk { position: absolute; left: -{{well}}px; top: -{{well}}px; border: {{well}}px solid #06090b;border-bottom-color: #b4bec8; border-right-color: #b4bec8; background-color: #3a414a; }.china .tray .steel { background: linear-gradient(to bottom, #c06a52, #7a3120 30%, #3f160f); }.china .tray .shine { background-color: #f0b8a4; }@@ -45,6 +64,12 @@.gla .tray .steel { background: linear-gradient(to bottom, #b8ab6e, #766a3a 30%, #3c3519); }.gla .tray .shine { background-color: #ebe2b4; }.gla .tray .sunk { border-bottom-color: #cbbf82; border-right-color: #cbbf82; background-color: #423a1c; }+ /* a step: a shorter row hung under the tray over it as one plate. It has no top of its own, so+ no light line, and its well's top edge is the well's steel, the gap between two rows */+ .tray.step .shine { display: none; }+ .tray.step .sunk { border-top-color: #3a414a; }+ .china .tray.step .sunk { border-top-color: #45190f; }+ .gla .tray.step .sunk { border-top-color: #423a1c; }/* a cell as the command grid's: a dark hole the cameo's size, a ring of the well's steel {{ring}}wide round it and a bevel on its edge */@@ -60,14 +85,16 @@</style></head><body>-<div class="{{layer}} {{side}}">- <div class="piece tray under" style="left: {{tray.x}}px; top: {{tray.y}}px; width: {{tray.w}}px; height: {{tray.h}}px; border-width: {{tray.bt}}px {{tray.br}}px {{tray.bb}}px {{tray.bl}}px">+<div class="{{layer}} {{side}} {{mirrored}}">+ <div class="piece tray under {{tray.step}}" data-each="trays" style="left: {{tray.x}}px; top: {{tray.y}}px; width: {{tray.w}}px; height: {{tray.h}}px; border-width: {{tray.bt}}px {{tray.br}}px {{tray.bb}}px {{tray.bl}}px"><div class="steel" style="left: -{{tray.bl}}px; right: -{{tray.br}}px; top: -{{tray.bt}}px; bottom: -{{tray.bb}}px"></div><div class="shine" style="left: -{{tray.bl}}px; right: -{{tray.br}}px; top: -{{tray.bt}}px"></div>- <div class="shade" style="right: -{{tray.br}}px; top: -{{tray.bt}}px; bottom: -{{tray.bb}}px"></div>+ <div class="shade righthand" style="right: -{{tray.br}}px; top: -{{tray.bt}}px; bottom: -{{tray.bb}}px"></div>+ <div class="shade lefthand" style="left: -{{tray.bl}}px; top: -{{tray.bt}}px; bottom: -{{tray.bb}}px"></div><div class="base" style="left: -{{tray.bl}}px; right: -{{tray.br}}px; bottom: -{{tray.bb}}px"></div><div class="sunk" style="width: {{tray.w}}px; height: {{tray.h}}px"></div></div>+ <div class="piece under" data-each="owned" style="left: {{cell.x}}px; top: {{cell.y}}px; width: {{cell.w}}px; height: {{cell.h}}px; background-color: {{cell.color}}"></div><div class="piece cell under" data-each="cells" style="left: {{cell.x}}px; top: {{cell.y}}px; width: {{cell.w}}px; height: {{cell.h}}px"><div class="edge" style="left: -{{ring}}px; top: -{{ring}}px; right: -{{ring}}px; bottom: -{{ring}}px; border-width: {{ring}}px"></div><div class="bevel"></div></div><div class="piece cell over" data-each="cells" style="left: {{cell.x}}px; top: {{cell.y}}px; width: {{cell.w}}px; height: {{cell.h}}px"><div class="edge" style="left: -{{ring}}px; top: -{{ring}}px; right: -{{ring}}px; bottom: -{{ring}}px; border-width: {{ring}}px"></div><div class="bevel"></div></div></div>diff --git a/GeneralsMD/Code/Data/Window/Html/Scoreboard.html b/GeneralsMD/Code/Data/Window/Html/Scoreboard.htmlindex 3ee84374d..2110e747c 100644--- a/GeneralsMD/Code/Data/Window/Html/Scoreboard.html+++ b/GeneralsMD/Code/Data/Window/Html/Scoreboard.html@@ -129,7 +129,8 @@.seatrow.full.watching { height: 44px; }.watching .arms { left: 244px; }.jobs .more { left: 180px; }- .arm .count { position: absolute; left: 1px; top: 10px; line-height: 8px; font-size: 7px; font-weight: bold; color: #f1f4f6; }+ .arm .count { position: absolute; left: 1px; top: 11px; padding: 0 1px; line-height: 8px; font-size: 7px; font-weight: bold;+ background-color: #020405; color: #f1f4f6; }</style></head><body>diff --git a/GeneralsMD/Code/Data/Window/Html/Spectator.html b/GeneralsMD/Code/Data/Window/Html/Spectator.htmlindex a49c589ef..75f224cda 100644--- a/GeneralsMD/Code/Data/Window/Html/Spectator.html+++ b/GeneralsMD/Code/Data/Window/Html/Spectator.html@@ -139,7 +139,8 @@.army .cell img { position: absolute; left: 1px; top: 1px; width: 17px; height: 15px; }.army .cell.head { clear: left; width: 30px; height: 18px; margin-right: 1px; }.army .cell.head img { left: 0; top: 0; width: 30px; height: 18px; }- .count { position: absolute; right: 2px; bottom: 0; font-size: 8px; font-weight: bold; color: #ffffff; }+ .count { position: absolute; right: 2px; bottom: 1px; padding: 0 1px; line-height: 8px; font-size: 8px; font-weight: bold;+ background-color: #020405; color: #ffffff; }/* ---- the replay strip, on the screen's bottom edge where the command grid stands in a match ----ControlBar.html's own bezel: a steel plate lit from above, a light line along its top and downdiff --git a/GeneralsMD/Code/GameEngine/Include/GameClient/HtmlOverlay.h b/GeneralsMD/Code/GameEngine/Include/GameClient/HtmlOverlay.hindex 1794d4104..cf2f7bef5 100644--- a/GeneralsMD/Code/GameEngine/Include/GameClient/HtmlOverlay.h+++ b/GeneralsMD/Code/GameEngine/Include/GameClient/HtmlOverlay.h@@ -60,6 +60,12 @@ public:/** Lay the page out at ControlBarHudScale(), the bottom HUD's, rather than the uniform scale. */void setHud( Bool hud );+ /** Lay the page out with a page pixel one pixel of the screen. At any other scale a page pixel is+ * a whole number of screen pixels only by luck, and a row of equal cells comes out with its gaps+ * two pixels here and three there; a page whose every length the game has already turned into+ * screen pixels has nothing left to round. */+ void setScreenPixels( Bool screenPixels );+/** Fade everything the page draws, text, fills and images, 0 to 255; 255 until it is set. */void setAlpha( Int alpha );diff --git a/GeneralsMD/Code/GameEngine/Include/GameClient/InGameUI.h b/GeneralsMD/Code/GameEngine/Include/GameClient/InGameUI.hindex 5c5cd40c6..416a844c5 100644--- a/GeneralsMD/Code/GameEngine/Include/GameClient/InGameUI.h+++ b/GeneralsMD/Code/GameEngine/Include/GameClient/InGameUI.h@@ -1113,7 +1113,7 @@ public: // ********************************************************************// whatever timers are live, so nothing here outlives the draw that filled it in.//enum { SUPERWEAPON_STRIP_COLS = 6 }; ///< cameos in one row, the soonest at the right hand end- enum { SUPERWEAPON_STRIP_ROWS = 3 }; ///< rows of them, and the rest become a "+N"+ enum { SUPERWEAPON_STRIP_ROWS = 7 }; ///< rows the strip can grow to, as many as fit the top half of the screen; past 42 the latest to land have no cellenum { SUPERWEAPON_STRIP_MAX = SUPERWEAPON_STRIP_COLS * SUPERWEAPON_STRIP_ROWS };enum { SKILL_STRIP_COLS = 6 }; ///< bought promotions in one row, under the countdowns@@ -1500,7 +1500,9 @@ protected:const Image *productionStripTray( void ); ///< the bar's tray, mirrored, kept until the bar changes sidevoid stripTrayMetrics( ICoord2D *tray, ICoord2D *cameo, ICoord2D *hole, Int *step ); ///< that tray's size, its cameo hole, and the column stepvoid drawStripSeconds( Int which, Int x, Int y, Int w, Int h, Int seconds ); ///< countdown written inside a cameo- void drawStripQuantity( Int which, Int x, Int y, Int w, Int quantity ); ///< the "xN" in a cameo's top right corner+ void drawStripQuantity( Int which, Int x, Int y, Int w, Int h, Int quantity ); ///< the "xN" in a cameo's top right corner+ ///< one of the strips' own strings set to 'text', a point smaller at a time until a readout on 'cell' holds it+ DisplayString *fitStripString( DisplayString *&string, const UnicodeString &text, Int points, const IRegion2D &cell );void addSuperweaponIcon( const Image *image, Int seconds, Int percent, Bool ready, Color color );void drawSuperweaponStrip( void ); ///< those icons, top right, soonest at the right hand endvoid drawSkillStrip( void ); ///< the watched player's bought promotions, under those@@ -1546,6 +1548,11 @@ protected:HtmlOverlay * m_promotionFrontOverlay; ///< the grid's frames, drawn over the promotionsHtmlOverlay * 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+ enum { ORDER_KEYS = 3 }; ///< the page's attack, hold position and move keys+ IRegion2D m_orderKeyCell[ ORDER_KEYS ]; ///< where the page last put each, screen pixels+ Bool m_orderKeysShown;+ DisplayString * m_orderKeyString[ ORDER_KEYS ]; ///< each one's letter, on the command buttons' plate+ Int m_orderKeyPoints; ///< the size those were last lettered at: HUD Size changes in a matchBool m_promotionPageLoaded;std::string m_promotionPage;Int m_promotionShownMs; ///< how far the promotion screen has come up, -1 before its first picture@@ -1665,6 +1672,7 @@ protected:Int m_productionStripStep; ///< from one themed cameo to the next, acrossHtmlOverlay * m_queueOverlay; ///< Window/Html/Queue.html under the cameosHtmlOverlay * m_queueFrontOverlay; ///< and its frames over them+ HtmlOverlay * m_superweaponOverlay; ///< the same page under the superweapon strip's cameos, top rightBool m_queuePageLoaded;std::string m_queuePage;@@ -1687,7 +1695,6 @@ protected:enum{STRIP_OVERFLOW_PRODUCTION = 0, ///< the "+N" closing the production column- STRIP_OVERFLOW_SUPERWEAPON, ///< and the superweapon strip'sSTRIP_OVERFLOW_STRINGS};@@ -1703,7 +1710,6 @@ protected://SuperweaponIconSlot m_superweaponIcons[ SUPERWEAPON_STRIP_MAX ];Int m_superweaponIconCount; ///< icons drawn- Int m_superweaponIconTotal; ///< timers live, drawn or not; the difference is the "+N"Coord2D m_superweaponPosition;Real m_superweaponFlashDuration;@@ -1840,4 +1846,27 @@ protected:// the singletonextern InGameUI *TheInGameUI;+//+// A readout on a cell of the HUD: a countdown, a key, a price, a power figure, a count. Every one+// of them stands on a solid plate in a corner of the cell's inner rectangle, which is the cell less+// the frame the page draws over its edge, so no plate lies under a border and no digit is cut by+// one. The strips in InGameUI.cpp and the command buttons' badges in W3DPushButton.cpp both draw+// through these.+//+enum HudReadoutCorner+{+ HUD_READOUT_TOP_LEFT,+ HUD_READOUT_TOP_RIGHT,+ HUD_READOUT_BOTTOM_LEFT,+ HUD_READOUT_BOTTOM_RIGHT,+ HUD_READOUT_CENTRE+};++/** Whether `text` as drawn is no wider than a readout on `cell` may be: the inner rectangle less the+ * plate's own margins. Text that does not fit is set a point smaller until it does. */+extern Bool HudReadout_fits( DisplayString *text, const IRegion2D &cell );++/** The plate in `corner` of `cell`'s inner rectangle and `text` on it. */+extern void HudReadout_draw( DisplayString *text, const IRegion2D &cell, HudReadoutCorner corner, Color textColor );+#endif // _IN_GAME_UI_H_diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/HtmlOverlay.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/HtmlOverlay.cppindex f41b9a50b..a62c0318d 100644--- a/GeneralsMD/Code/GameEngine/Source/GameClient/HtmlOverlay.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/HtmlOverlay.cpp@@ -202,6 +202,7 @@ private:Int m_alpha; ///< the whole page's, OPAQUE_ALPHA unless it is fadingpublic:Bool m_hud; ///< laid out at ControlBarHudScale(), the bottom HUD's own+ Bool m_screenPixels; ///< laid out in the screen's own pixels, over either scale};//-------------------------------------------------------------------------------------------------@@ -213,7 +214,8 @@ HtmlOverlayContainer::HtmlOverlayContainer( const AsciiString &defaultFont ) :m_screenHeight( 0 ),m_stamp( 0 ),m_alpha( OPAQUE_ALPHA ),- m_hud( FALSE )+ m_hud( FALSE ),+ m_screenPixels( FALSE ){}@@ -234,7 +236,7 @@ void HtmlOverlayContainer::setPage( const std::string &html ){const Int width = TheDisplay->getWidth();const Int height = TheDisplay->getHeight();- const Real scale = m_hud ? ControlBarHudScale() : ControlBarUniformScale();+ const Real scale = m_screenPixels ? 1.0f : m_hud ? ControlBarHudScale() : ControlBarUniformScale();if( m_document && html == m_page && width == m_screenWidth && height == m_screenHeight && scale == m_scale )return;@@ -695,34 +697,47 @@ void HtmlOverlayContainer::draw_borders( litehtml::uint_ptr hdc, const litehtml:if( root )return;+ //+ // A side is as many whole screen pixels thick as its width comes to, one at least, measured in+ // from the box's own edge, and never short of where its inner edge rounds to by itself. With+ // both edges rounded apart and nothing else, at a scale that is not a whole number a one pixel+ // border was one screen pixel on one side of a cell and two on the other. Cut to its width and+ // nothing else, it stopped a pixel short of what stands inside it: a cell's ring left the command+ // button's own coloured outline showing down one side of a whole column at HUD Size 115%.+ //+ const Int left = screen( place.x );+ const Int top = screen( place.y );+ const Int right = screen( place.x + place.width );+ const Int bottom = screen( place.y + place.height );+ const litehtml::border *sides[] = { &borders.top, &borders.bottom, &borders.left, &borders.right };+ const Int inner[] =+ {+ screen( place.y + borders.top.width ) - top,+ bottom - screen( place.y + place.height - borders.bottom.width ),+ screen( place.x + borders.left.width ) - left,+ right - screen( place.x + place.width - borders.right.width )+ };+ Int thick[ ARRAY_SIZE( sides ) ];+ for( size_t side = 0; side < ARRAY_SIZE( sides ); side++ )+ thick[ side ] = drawnWidth( *sides[ side ] ) > 0 ? std::max( inner[ side ], std::max( 1, screen( sides[ side ]->width ) ) ) : 0;+// the top and bottom own the corners and the sides stand between them: drawn full height, a// groove's dark left edge ran on down past its lit bottom and stuck out of the bevel in black- const litehtml::pixel_t topWidth = drawnWidth( borders.top );- const litehtml::pixel_t bottomWidth = drawnWidth( borders.bottom );- const litehtml::border *sides[] = { &borders.top, &borders.bottom, &borders.left, &borders.right };+ const Int sideTop = top + thick[ 0 ];+ const Int sideHeight = bottom - top - thick[ 0 ] - thick[ 1 ];+ const IRegion2D edges[] =+ {+ { { left, top }, { right, top + thick[ 0 ] } },+ { { left, bottom - thick[ 1 ] }, { right, bottom } },+ { { left, sideTop }, { left + thick[ 2 ], sideTop + sideHeight } },+ { { right - thick[ 3 ], sideTop }, { right, sideTop + sideHeight } }+ };for( size_t side = 0; side < ARRAY_SIZE( sides ); side++ ){- const litehtml::border &border = *sides[ side ];- if( drawnWidth( border ) <= 0 )- continue;-- litehtml::position edge = place;- if( sides[ side ] == &borders.top )- edge.height = border.width;- else if( sides[ side ] == &borders.bottom )- {- edge.y = place.y + place.height - border.width;- edge.height = border.width;- }- else- {- edge.y = place.y + topWidth;- edge.height = place.height - topWidth - bottomWidth;- edge.width = border.width;- if( sides[ side ] == &borders.right )- edge.x = place.x + place.width - border.width;- }- fillBox( edge, border.color );+ const IRegion2D &edge = edges[ side ];+ if( sides[ side ]->color.alpha > 0 && edge.hi.x > edge.lo.x && edge.hi.y > edge.lo.y )+ TheDisplay->drawFillRect( edge.lo.x, edge.lo.y, edge.hi.x - edge.lo.x, edge.hi.y - edge.lo.y,+ tint( sides[ side ]->color ) );}}@@ -798,6 +813,7 @@ HtmlOverlay::~HtmlOverlay( void )void HtmlOverlay::setPage( const std::string &html ) { m_container->setPage( html ); }void HtmlOverlay::draw( void ) { m_container->draw(); }void HtmlOverlay::setHud( Bool hud ) { m_container->m_hud = hud; }+void HtmlOverlay::setScreenPixels( Bool screenPixels ) { m_container->m_screenPixels = screenPixels; }void HtmlOverlay::setAlpha( Int alpha ) { m_container->setAlpha( alpha ); }Bool HtmlOverlay::hover( const ICoord2D &mouse ) { return m_container->hover( mouse ); }std::string HtmlOverlay::click( const ICoord2D &mouse ) { return m_container->click( mouse ); }diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/InGameUI.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/InGameUI.cppindex 09bebc1cf..f6426c7ca 100644--- a/GeneralsMD/Code/GameEngine/Source/GameClient/InGameUI.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/InGameUI.cpp@@ -191,7 +191,8 @@ static Int stripPixels( Int nominal )/** A countdown written inside a cameo, always in bare seconds with the unit on it: "45s", "200s".* A tank takes seconds and a superweapon charges for minutes, and both are read against every* other countdown on the screen, all of which are in seconds - m:ss was a number you had to- * convert first. The trailing s is what stops a lone "45" reading as a count of something. */+ * convert first. The trailing s is what stops a lone "45" reading as a count of something; a+ * number too wide for its cameo with the s on goes without it, see drawStripSeconds. *///-------------------------------------------------------------------------------------------------static void formatStripSeconds( UnicodeString *text, Int seconds ){@@ -1211,6 +1212,7 @@ InGameUI::InGameUI()m_productionStripStep = 0;m_queueOverlay = NULL;m_queueFrontOverlay = NULL;+ m_superweaponOverlay = NULL;m_queuePageLoaded = FALSE;m_productionStripTray = NULL;m_productionStripTraySource = NULL;@@ -1235,6 +1237,10 @@ InGameUI::InGameUI()m_promotionFrontOverlay = NULL;for( Int grid = 0; grid < CELL_GRID_COUNT; grid++ )m_cellFrontOverlay[ grid ] = NULL;+ m_orderKeysShown = FALSE;+ m_orderKeyPoints = 0;+ for( Int orderKey = 0; orderKey < ORDER_KEYS; orderKey++ )+ m_orderKeyString[ orderKey ] = NULL;m_promotionPageLoaded = FALSE;m_promotionShownMs = 0;m_promotionDrawnAt = 0;@@ -1254,7 +1260,6 @@ InGameUI::InGameUI()for( Int stripQuantity = 0; stripQuantity < STRIP_QUANTITY_STRINGS; stripQuantity++ )m_stripQuantityString[ stripQuantity ] = NULL;m_superweaponIconCount = 0;- m_superweaponIconTotal = 0;m_superweaponPosition.x = 0.7f;m_superweaponPosition.y = 0.7f;@@ -1392,6 +1397,8 @@ InGameUI::~InGameUI()m_queueOverlay = NULL;delete m_queueFrontOverlay;m_queueFrontOverlay = NULL;+ delete m_superweaponOverlay;+ m_superweaponOverlay = NULL;delete m_tooltipOverlay;m_tooltipOverlay = NULL;}@@ -7866,7 +7873,6 @@ void InGameUI::postDraw( void )// laid out at the end of it, soonest first.//m_superweaponIconCount = 0;- m_superweaponIconTotal = 0;m_spectatorSuperweapons.clear();for (Int i=0; i<MAX_PLAYER_COUNT; ++i)@@ -10231,35 +10237,127 @@ Bool InGameUI::stripSlotGoesBefore( Bool leads, Int remaining,//-------------------------------------------------------------------------------------------------void InGameUI::drawStripSeconds( Int which, Int x, Int y, Int w, Int h, Int seconds ){- // its own string, kept between frames - see m_stripSecondsString- DisplayString *&secondsString = m_stripSecondsString[ which ];+ const IRegion2D cell = { { x, y }, { x + w, y + h } };- if( secondsString == NULL )+ UnicodeString text, number;+ formatStripSeconds( &text, seconds );+ number.format( L"%d", seconds > 0 ? seconds : 0 );++ //+ // Its own string, kept between frames - see m_stripSecondsString. Every countdown in a strip is+ // lettered at one size: a "103s" too wide for its cameo drops the unit and stays that size, where+ // set a point smaller it stood thin beside a bold "79s" in the next cell. A string already+ // holding the bare number was measured when the number last changed and is not measured again,+ // which would letter it twice a frame.+ //+ DisplayString *&string = m_stripSecondsString[ which ];+ if( string == NULL )+ string = TheDisplayStringManager->newDisplayString();+ const Bool unitDropped = string->getText().compare( number ) == 0;+ if( !unitDropped && ( string->getFont() == NULL || string->getText().compare( text ) != 0 ) ){- secondsString = TheDisplayStringManager->newDisplayString();- secondsString->setFont( TheFontLibrary->getFont( m_superweaponNormalFont,- TheGlobalLanguageData->adjustFontSize( PRODUCTION_STRIP_SECS ),- TRUE ) );+ string->setFont( TheFontLibrary->getFont( m_superweaponNormalFont, TheGlobalLanguageData->adjustFontSize( PRODUCTION_STRIP_SECS ), TRUE ) );+ string->setText( text );}+ if( unitDropped || !HudReadout_fits( string, cell ) )+ fitStripString( string, number, PRODUCTION_STRIP_SECS, cell );+ HudReadout_draw( string, cell, HUD_READOUT_BOTTOM_LEFT, GameMakeColor( 245, 245, 245, 255 ) );+}- UnicodeString text;- formatStripSeconds( &text, seconds );- secondsString->setText( text );+//-------------------------------------------------------------------------------------------------+/** A frame the page draws over a cell's edge, in screen pixels: one page pixel, as thick as+ * HtmlOverlay's draw_borders makes it at the HUD's scale. */+//-------------------------------------------------------------------------------------------------+static Int hudReadoutFrame( void )+{+ const Int frame = REAL_TO_INT_FLOOR( ControlBarHudScale() + 0.5f );+ return frame > 1 ? frame : 1;+}+enum+{+ HUD_READOUT_PAD = 2, ///< the plate's margin each side of its text, screen pixels+ HUD_READOUT_POINTS_LEAST = 6 ///< text that still does not fit at this size stays this size+};++//-------------------------------------------------------------------------------------------------+/** How wide a readout's text may be on `cell`: the cell less its frame and the plate's margins. */+static Int readoutRoom( const IRegion2D &cell )+{+ return cell.hi.x - cell.lo.x - 2 * hudReadoutFrame() - 2 * HUD_READOUT_PAD;+}++//-------------------------------------------------------------------------------------------------+/** Measured the way the plate is: by the string's drawn size. getWidth() adds up the letters'+ * advances, which leaves out the last letter's overhang, so a "103s" that fitted by that sum had a+ * plate one pixel wider than its room and stood on the first column of the frame. */+Bool HudReadout_fits( DisplayString *text, const IRegion2D &cell )+{+ Int textWidth = 0;+ text->getSize( &textWidth, NULL );+ return textWidth <= readoutRoom( cell );+}++//-------------------------------------------------------------------------------------------------+void HudReadout_draw( DisplayString *text, const IRegion2D &cell, HudReadoutCorner corner, Color textColor )+{Int textWidth = 0, textHeight = 0;- secondsString->getSize( &textWidth, &textHeight );+ text->getSize( &textWidth, &textHeight );+ if( textWidth <= 0 || textHeight <= 0 )+ return;++ // text still too wide at the smallest size loses its end to the plate's edge: the plate is never+ // wider than the cell inside its frame+ const Int frame = hudReadoutFrame();+ const Int plateWidth = min( textWidth, readoutRoom( cell ) ) + 2 * HUD_READOUT_PAD;+ const Bool atLeft = corner == HUD_READOUT_TOP_LEFT || corner == HUD_READOUT_BOTTOM_LEFT;+ const Bool atTop = corner == HUD_READOUT_TOP_LEFT || corner == HUD_READOUT_TOP_RIGHT;++ Int left = atLeft ? cell.lo.x + frame : cell.hi.x - frame - plateWidth;+ Int top = atTop ? cell.lo.y + frame : cell.hi.y - frame - textHeight;+ if( corner == HUD_READOUT_CENTRE )+ {+ left = ( cell.lo.x + cell.hi.x - plateWidth ) / 2;+ top = ( cell.lo.y + cell.hi.y - textHeight ) / 2;+ }++ // solid, the colour of a cell's own hole: the text is read against the plate at every HUD Size,+ // whatever picture is under it+ TheDisplay->drawFillRect( left, top, plateWidth, textHeight, GameMakeColor( 2, 4, 5, 255 ) );+ IRegion2D plate = { { left, top }, { left + plateWidth, top + textHeight } };+ text->setClipRegion( &plate );+ text->draw( left + HUD_READOUT_PAD, top, textColor, GameMakeColor( 0, 0, 0, 255 ) );+}++//-------------------------------------------------------------------------------------------------+/** A readout's own string holding `text`, made the first time, in `fontName` bold at `points` or as+ * many points under it as it takes to fit a readout on `cell`. The font is only set when the text+ * changes or the text no longer fits, so a string whose value stands still keeps its font surface. */+//-------------------------------------------------------------------------------------------------+static DisplayString *fitReadoutString( DisplayString *&string, const UnicodeString &text,+ const AsciiString &fontName, Int points, const IRegion2D &cell )+{+ if( string == NULL )+ string = TheDisplayStringManager->newDisplayString();- const Int textX = x + 1;- const Int textY = y + h - textHeight - 1;+ if( string->getFont() == NULL || string->getText().compare( text ) != 0 )+ {+ string->setFont( TheFontLibrary->getFont( fontName, points, TRUE ) );+ string->setText( text );+ }- // a plate under it: down in the corner the number sits on whatever the picture happens to be- // there, and a pale cameo swallowed the drop shadow along with the digits- if( textWidth > 0 && textHeight > 0 )- TheDisplay->drawFillRect( textX - 1, textY, textWidth + 2, textHeight,- GameMakeColor( 0, 0, 0, 160 ) );+ while( !HudReadout_fits( string, cell ) && string->getFont()->pointSize > HUD_READOUT_POINTS_LEAST )+ string->setFont( TheFontLibrary->getFont( fontName, string->getFont()->pointSize - 1, TRUE ) );- secondsString->draw( textX, textY, GameMakeColor( 245, 245, 245, 255 ),- GameMakeColor( 0, 0, 0, 255 ) );+ return string;+}++//-------------------------------------------------------------------------------------------------+/** One of the strips' own strings, in the strips' font. */+//-------------------------------------------------------------------------------------------------+DisplayString *InGameUI::fitStripString( DisplayString *&string, const UnicodeString &text, Int points, const IRegion2D &cell )+{+ return fitReadoutString( string, text, m_superweaponNormalFont, TheGlobalLanguageData->adjustFontSize( points ), cell );}//-------------------------------------------------------------------------------------------------@@ -10268,38 +10366,24 @@ void InGameUI::drawStripSeconds( Int which, Int x, Int y, Int w, Int h, Int seco* Kept per cameo for the reason the countdowns are: a DisplayString rebuilds a font surface every* time its text changes, and this one changes only when the run does. *///--------------------------------------------------------------------------------------------------void InGameUI::drawStripQuantity( Int which, Int x, Int y, Int w, Int quantity )+void InGameUI::drawStripQuantity( Int which, Int x, Int y, Int w, Int h, Int quantity ){- DisplayString *&quantityString = m_stripQuantityString[ which ];-- if( quantityString == NULL )- {- quantityString = TheDisplayStringManager->newDisplayString();- quantityString->setFont( TheFontLibrary->getFont( m_superweaponNormalFont,- TheGlobalLanguageData->adjustFontSize( PRODUCTION_STRIP_SECS ),- TRUE ) );- }+ const IRegion2D cell = { { x, y }, { x + w, y + h } };UnicodeString text;text.format( L"x%d", quantity );- quantityString->setText( text );-- Int textWidth = 0, textHeight = 0;- quantityString->getSize( &textWidth, &textHeight );- quantityString->draw( x + w - textWidth - 1, y + 1,- GameMakeColor( 255, 255, 255, 255 ),- GameMakeColor( 0, 0, 0, 255 ) );+ DisplayString *quantityString = fitStripString( m_stripQuantityString[ which ], text, PRODUCTION_STRIP_SECS, cell );+ HudReadout_draw( quantityString, cell, HUD_READOUT_TOP_RIGHT, GameMakeColor( 255, 255, 255, 255 ) );}//-------------------------------------------------------------------------------------------------/** Keep one superweapon timer for the strip, in a list sorted by how long it still has to wait -- * soonest first. Everything live is counted; only the ones that will be drawn get a slot. */+ * soonest first. The strip has a cell for SUPERWEAPON_STRIP_MAX of them; past that the soonest+ * keep theirs and the latest to land have none. *///-------------------------------------------------------------------------------------------------void InGameUI::addSuperweaponIcon( const Image *image, Int seconds, Int percent, Bool ready, Color color ){- m_superweaponIconTotal++;-// walk back over the ones that come ready later than this and drop it in front of them; ties// keep the order they were met in, so a pair of identical silos stays put frame to frameInt at = m_superweaponIconCount;@@ -10307,7 +10391,7 @@ void InGameUI::addSuperweaponIcon( const Image *image, Int seconds, Int percent,at--;if( at >= SUPERWEAPON_STRIP_MAX )- return; // everything already kept is sooner: counted into the "+N", not drawn+ return; // every cell is taken by one that lands soonerif( m_superweaponIconCount < SUPERWEAPON_STRIP_MAX )m_superweaponIconCount++;@@ -10323,223 +10407,6 @@ void InGameUI::addSuperweaponIcon( const Image *image, Int seconds, Int percent,slot->color = color;}-//--------------------------------------------------------------------------------------------------/** The superweapon strip: the cameos gathered this frame, top right, under the clock plate.- *- * Rows fill from the right, because the right hand end is where the strip is anchored and the- * one countdown that matters is the next one to land - it is always in the same place, however- * many are behind it. Three rows of six, and whatever is left over closes the last row as a- * "+N", the same way the production strip's rows do. */-//--------------------------------------------------------------------------------------------------void InGameUI::drawSuperweaponStrip( void )-{- // a player gets the strip, top right; an observer or a replay does not - the spectator page- // and the Tab scoreboard carry the countdowns for them- if( m_superweaponIconCount < 1 || m_spectatorPageShown || localPlayerWatching() ||- ( TheRecorder && TheRecorder->getMode() == RECORDERMODETYPE_PLAYBACK ) )- return;-- if( TheGameLogic == NULL || !TheGameLogic->isInGame() || TheGameLogic->isInShellGame() )- return;-- //- // The same tray the production strip stands its cameos in, and the same measurements off the- // general's power bar - but this strip is not mirrored. It is anchored to the right hand edge- // and grows leftwards, which is the direction that bar itself grows, so the artwork sits the- // way it was drawn: the heavy rail leads the row at the right hand end.- //- ICoord2D traySize, cameoSize, trayHole;- Int trayStep = 0;- stripTrayMetrics( &traySize, &cameoSize, &trayHole, &trayStep );-- // the HUD Size option grows this strip with the bar: the player's step on top of the bar's own- const Real hudStep = ControlBarHudScale() / ControlBarHudScaleFor( TheDisplay->getWidth(), TheDisplay->getHeight() );- traySize.x = REAL_TO_INT_CEIL( traySize.x * hudStep );- traySize.y = REAL_TO_INT_CEIL( traySize.y * hudStep );- cameoSize.x = REAL_TO_INT_CEIL( cameoSize.x * hudStep );- cameoSize.y = REAL_TO_INT_CEIL( cameoSize.y * hudStep );- trayHole.x = REAL_TO_INT_CEIL( trayHole.x * hudStep );- trayHole.y = REAL_TO_INT_CEIL( trayHole.y * hudStep );- trayStep = REAL_TO_INT_CEIL( trayStep * hudStep );-- const Int trayW = traySize.x;- const Int trayH = traySize.y;- const Int cameoW = cameoSize.x;- const Int cameoH = cameoSize.y;- const Image *tray = TheControlBar ? TheControlBar->getSpecialPowerTrayImage() : NULL;-- const Int gap = REAL_TO_INT_CEIL( stripPixels( PRODUCTION_STRIP_GAP ) * hudStep );- const Int more = REAL_TO_INT_CEIL( stripPixels( PRODUCTION_STRIP_MORE ) * hudStep );- const Int plate = stripPixels( 3 );-- //- // The corner readout owns the top right - the clock plate, or with the bar's page up the network- // box, which is a page of its own - so the strip starts under whichever is up. A countdown- // drawn behind the readout is one nobody can read.- //- Int cornerBottom = m_hudOverlayBottom;- if( m_controlBarPageShown && m_netOverlay != NULL )- {- const Int netBottom = m_netOverlay->bottomOf( "#net" );- if( netBottom > cornerBottom )- cornerBottom = netBottom;- }- const Int top = cornerBottom + plate;-- //- // one pulse for the whole strip rather than one per icon, so every charged superweapon breathes- // together instead of each on its own clock. SuperweaponCountdownFlashDuration is half a cycle- // (dark to bright), so the INI knob still says how fast the strip blinks.- //- Real pulse = 1.0f;- if( m_superweaponFlashDuration >= 1.0f )- {- const Real period = 2.0f * m_superweaponFlashDuration;- const Real phase = (Real)( TheGameLogic->getFrame() % (UnsignedInt)period ) / period;- pulse = 0.5f - 0.5f * (Real)cos( 2.0 * PI * phase );- }-- // flush against the right hand edge: the tray's heavy rail is the edge of the strip, and an inset- // leaves it hanging in the middle of nothing. The production rows keep their inset because their- // rail faces the other way, into the screen- const Int right = TheDisplay->getWidth();- const Int hidden = m_superweaponIconTotal - m_superweaponIconCount;-- // drawn as a batch, for the reason drawProductionStrip() gives - see Display::beginBatch2D- TheDisplay->beginBatch2D();-- for( Int row = 0; row < SUPERWEAPON_STRIP_ROWS; row++ )- {- const Int first = row * SUPERWEAPON_STRIP_COLS;- if( first >= m_superweaponIconCount )- break;-- Int inRow = m_superweaponIconCount - first;- if( inRow > SUPERWEAPON_STRIP_COLS )- inRow = SUPERWEAPON_STRIP_COLS;-- const Bool lastRow = ( first + inRow >= m_superweaponIconCount );- Int rowWidth = ( inRow - 1 ) * trayStep + trayW;- if( hidden > 0 && lastRow )- rowWidth += gap + more;-- const Int trayY = top + row * trayH;- const Int y = trayY + trayHole.y;-- //- // The trays go down first, all of them, and from the far end back, so the rightmost - the- // countdown that lands next - is the one drawn last.- //- for( Int back = inRow - 1; back >= 0; back-- )- {- const Int backX = right - trayW - back * trayStep;- if( tray )- TheDisplay->drawImage( tray, backX, trayY, backX + trayW, trayY + trayH );- else- TheDisplay->drawFillRect( backX, trayY, trayW, trayH, GameMakeColor( 0, 0, 0, 130 ) );- }-- //- // The row goes down a piece at a time - every picture, then every sweep, then every border -- // rather than an icon at a time, for the reason drawProductionStripRow() gives: pieces that- // want the same thing of the renderer are one draw call when they follow each other and one- // draw call each when they do not. The icons do not overlap, so nothing changes on screen.- //- for( Int cameoSlot = 0; cameoSlot < inRow; cameoSlot++ )- {- const SuperweaponIconSlot *slot = &m_superweaponIcons[ first + cameoSlot ];- const Int x = right - trayW + trayHole.x - cameoSlot * trayStep;-- if( slot->image )- TheDisplay->drawImage( slot->image, x, y, x + cameoW, y + cameoH );- }-- //- // the same sweep the production cameos wear, and the same way round as the command bar's own- // clock: the scrim covers what is still to be charged and is swept off as the charge runs- //- for( Int clockSlot = 0; clockSlot < inRow; clockSlot++ )- {- const SuperweaponIconSlot *slot = &m_superweaponIcons[ first + clockSlot ];- const Int x = right - trayW + trayHole.x - clockSlot * trayStep;-- if( !slot->ready )- TheDisplay->drawRemainingRectClock( x, y, cameoW, cameoH, slot->percent,- GameMakeColor( 0, 0, 0, 130 ) );- else- {- //- // Charged: no number at all - zero seconds is not information - and the cameo itself- // breathes in the owning player's colour instead. A ready superweapon is the one- // thing on this strip that wants to be noticed rather than looked up, and a- // translucent wash over the picture says whose it is in the same stroke.- //- UnsignedByte r, g, b, a;- GameGetColorComponents( slot->color, &r, &g, &b, &a );- const UnsignedByte washAlpha = (UnsignedByte)( 30.0f + 90.0f * pulse );- TheDisplay->drawFillRect( x, y, cameoW, cameoH, GameMakeColor( r, g, b, washAlpha ) );- }- }-- //- // bare seconds, however many there are: this strip is read against the other countdowns on- // the screen, and m:ss is a number you have to convert first- //- for( Int secondsSlot = 0; secondsSlot < inRow; secondsSlot++ )- {- const SuperweaponIconSlot *slot = &m_superweaponIcons[ first + secondsSlot ];- const Int x = right - trayW + trayHole.x - secondsSlot * trayStep;-- if( !slot->ready )- drawStripSeconds( PRODUCTION_STRIP_ROW_MAX + first + secondsSlot,- x, y, cameoW, cameoH, slot->seconds );- }-- // the border is whose weapon it is - the colour the timer was registered with- for( Int borderSlot = 0; borderSlot < inRow; borderSlot++ )- {- const SuperweaponIconSlot *slot = &m_superweaponIcons[ first + borderSlot ];- const Int x = right - trayW + trayHole.x - borderSlot * trayStep;-- UnsignedByte r, g, b, a;- GameGetColorComponents( slot->color, &r, &g, &b, &a );- TheDisplay->drawOpenRect( x, y, cameoW, cameoH, 2.0f, GameMakeColor( r, g, b, 255 ) );- }-- //- // whatever did not fit closes the last row as a "+N", on the left hand end: the strip is- // read from the right, so the overflow sits at the far end of it- //- if( hidden > 0 && lastRow )- {- // this strip's own "+N", kept apart from the production rows' - see m_stripSecondsString- DisplayString *&overflow = m_productionStripOverflow[ STRIP_OVERFLOW_SUPERWEAPON ];-- if( overflow == NULL )- {- overflow = TheDisplayStringManager->newDisplayString();- overflow->setFont( TheFontLibrary->getFont( m_superweaponNormalFont,- TheGlobalLanguageData->adjustFontSize( HUD_OVERLAY_POINT_SIZE ),- TRUE ) );- }-- UnicodeString text;- text.format( L"+%d", hidden );- overflow->setText( text );-- Int textWidth = 0, textHeight = 0;- overflow->getSize( &textWidth, &textHeight );-- overflow->draw( right - rowWidth + ( more - textWidth ) / 2,- y + ( cameoH - textHeight ) / 2,- GameMakeColor( 235, 235, 235, 255 ),- GameMakeColor( 0, 0, 0, 255 ) );- }- }-- TheDisplay->endBatch2D();-}-//-------------------------------------------------------------------------------------------------/** One bought promotion, and the cameo the promotion screen buys it from. */struct BoughtSkill@@ -11353,7 +11220,9 @@ enumSKILL_GRID_GAP = 12, ///< between the general's powers' tray and what it stands onSKILL_TRAY_BORDER = 6, ///< the tray's steel round its cellsQUEUE_TRAY_BORDER = 3, ///< the production queue's tray's, thinner, since the row runs over the battlefield- SKILL_CELL_GAP = 2 ///< the steel between two cells of the powers and the production queue+ SKILL_CELL_GAP = 2, ///< the steel between two cells of the powers and the production queue+ QUEUE_TRAY_LINE = 1, ///< the light and dark lines along that tray's edges+ QUEUE_TRAY_WELL = SKILL_CELL_GAP ///< the well round its cells: a row stepped under another starts in it};/** A grid cell's size on screen. */@@ -11476,11 +11345,12 @@ static IRegion2D framed( const IRegion2D &content, Int border, Bool againstLeft,}/** A panel for the page: `name`.x and .y the border's outer corner, .w and .h the container, and- * .bt .br .bb .bl the border's four widths, all in the page's pixels, every edge rounded once so- * the container fits what it holds exactly; `name`.shown as putPageRect writes it. */-static void putFrame( HtmlValues &values, const std::string &name, const IRegion2D &content, const IRegion2D &box, Bool shown )+ * .bt .br .bb .bl the border's four widths, all in the page's pixels, `scale` screen pixels to one,+ * every edge rounded once so the container fits what it holds exactly; `name`.shown as putPageRect+ * writes it. */+static void putFrame( HtmlValues &values, const std::string &name, const IRegion2D &content, const IRegion2D &box, Bool shown,+ Real scale = ControlBarHudScale() ){- const Real scale = ControlBarHudScale();struct Edge { static Int page( Int screen, Real scale ) { return REAL_TO_INT_FLOOR( screen / scale + 0.5f ); } };const Int left = Edge::page( box.lo.x, scale ), top = Edge::page( box.lo.y, scale );const Int innerLeft = Edge::page( content.lo.x, scale ), innerTop = Edge::page( content.lo.y, scale );@@ -11755,6 +11625,32 @@ void InGameUI::drawCellGridFront( Int grid )overlay->setHud( TRUE );}+ //+ // The page's attack, hold position and move keys wear their letter the way the command buttons+ // beside them do: the buttons' font and size, on the readouts' plate. The page wrote it itself+ // once, in a box with no width of its own, which this layout engine gives no background: the+ // letter stood bare on the picture in a lighter face than its neighbours'.+ //+ if( grid == CELL_GRID_COMMAND && m_orderKeysShown )+ {+ static const Int ORDER_KEY_PLACES[ ORDER_KEYS ] = { COMMAND_PLACE_ATTACK, COMMAND_PLACE_HOLD, COMMAND_PLACE_MOVE };+ enum { ORDER_KEY_POINTS = 7 }; // W3DPushButton.cpp's BADGE_DESIGN_POINTS, the buttons' corner markings+ const AsciiString fontName = numberedWindow( "ButtonCommand", 1 )->winGetFont()->nameString;+ const Int points = max( (Int)HUD_READOUT_POINTS_LEAST, (Int)REAL_TO_INT_FLOOR( ORDER_KEY_POINTS * ControlBarHudScale() ) );+ for( Int key = 0; key < ORDER_KEYS; key++ )+ {+ // a letter never changes by itself, so a new HUD Size is what letters it again+ if( points != m_orderKeyPoints && m_orderKeyString[ key ] != NULL )+ m_orderKeyString[ key ]->setText( UnicodeString::TheEmptyString );++ UnicodeString letter;+ letter.translate( AsciiString( commandSlotKey( ORDER_KEY_PLACES[ key ] ).c_str() ) );+ HudReadout_draw( fitReadoutString( m_orderKeyString[ key ], letter, fontName, points, m_orderKeyCell[ key ] ),+ m_orderKeyCell[ key ], HUD_READOUT_TOP_LEFT, GameMakeColor( 255, 255, 255, 255 ) );+ }+ m_orderKeyPoints = points;+ }+HtmlValues values;HtmlLists lists;values[ "layer" ] = "front";@@ -11956,9 +11852,11 @@ Bool InGameUI::drawControlBarPage( const IRegion2D *panels, const Bool *shown, IputPageRect( values, "attackkey", place[ COMMAND_PLACE_ATTACK ], centreShown && fights, scale );putPageRect( values, "holdkey", place[ COMMAND_PLACE_HOLD ], centreShown && fights, scale );putPageRect( values, "movekey", place[ COMMAND_PLACE_MOVE ], centreShown && fights, scale );- values[ "attackkey.key" ] = commandSlotKey( COMMAND_PLACE_ATTACK );- values[ "holdkey.key" ] = commandSlotKey( COMMAND_PLACE_HOLD );- values[ "movekey.key" ] = commandSlotKey( COMMAND_PLACE_MOVE );+ // their letters are drawCellGridFront's, on the command buttons' own plate+ m_orderKeysShown = centreShown && fights;+ m_orderKeyCell[ 0 ] = place[ COMMAND_PLACE_ATTACK ];+ m_orderKeyCell[ 1 ] = place[ COMMAND_PLACE_HOLD ];+ m_orderKeyCell[ 2 ] = place[ COMMAND_PLACE_MOVE ];// the portrait bar on the screen's bottom edge right of the command panel: the portrait, then a// single unit's upgrades or a multi-selection's types, the owner's rule, and only as long as what@@ -12934,7 +12832,7 @@ void InGameUI::drawProductionStripColumn( Int left, Int bottomY )const StripSlotDraw *draw = &slots[ quantitySlot ];if( draw->quantity > 1 )drawStripQuantity( quantitySlot,- draw->x, draw->y, cameoW, draw->quantity );+ draw->x, draw->y, cameoW, cameoH, draw->quantity );}// and the borders round them; the themed row's frames are Queue.html's@@ -12968,31 +12866,17 @@ void InGameUI::drawProductionStripColumn( Int left, Int bottomY )//if( hidden > 0 ){- // the column's own "+N" - see m_stripSecondsString- DisplayString *&overflow = m_productionStripOverflow[ STRIP_OVERFLOW_PRODUCTION ];-- if( overflow == NULL )- {- overflow = TheDisplayStringManager->newDisplayString();- overflow->setFont( TheFontLibrary->getFont( m_superweaponNormalFont,- TheGlobalLanguageData->adjustFontSize( HUD_OVERLAY_POINT_SIZE ),- TRUE ) );- }+ const Int moreX = x + count * cellStepX;+ const Int moreY = bottomY - count * cellStepY;+ const IRegion2D cell = { { moreX, moreY }, { moreX + cameoW, moreY + cameoH } };UnicodeString text;text.format( L"+%d", hidden );- overflow->setText( text );-- Int textWidth = 0, textHeight = 0;- overflow->getSize( &textWidth, &textHeight );-- const Int moreX = x + count * cellStepX;- const Int moreY = bottomY - count * cellStepY;- overflow->draw( moreX + ( cameoW - textWidth ) / 2,- moreY + ( cameoH - textHeight ) / 2,- GameMakeColor( 235, 235, 235, 255 ),- GameMakeColor( 0, 0, 0, 255 ) );+ // the column's own "+N" - see m_stripSecondsString+ DisplayString *overflow = fitStripString( m_productionStripOverflow[ STRIP_OVERFLOW_PRODUCTION ], text,+ HUD_OVERLAY_POINT_SIZE, cell );+ HudReadout_draw( overflow, cell, HUD_READOUT_CENTRE, GameMakeColor( 235, 235, 235, 255 ) );}}@@ -13035,7 +12919,10 @@ void InGameUI::drawQueueTray( void )HtmlValues values;HtmlLists lists;values[ "side" ] = spectatorSide();- putFrame( values, "tray", cellsBox, tray, TRUE );+ values[ "line" ] = std::to_string( QUEUE_TRAY_LINE );+ values[ "well" ] = std::to_string( QUEUE_TRAY_WELL );+ lists[ "trays" ].resize( 1 ); // the page's trays are a list: the superweapon strip has a stepped one+ putFrame( lists[ "trays" ][ 0 ], "tray", cellsBox, tray, TRUE );std::vector< HtmlValues > &cellList = lists[ "cells" ];for( Int each = 0; each < cells; each++ ){@@ -13069,6 +12956,281 @@ void InGameUI::drawQueueTray( void )m_queueFrontOverlay->draw();}+//-------------------------------------------------------------------------------------------------+/** The superweapon strip: the cameos gathered this frame, top right, under the network box.+ *+ * Rows fill from the right, because the right hand end is where the strip is anchored and the+ * one countdown that matters is the next one to land - it is always in the same place, however+ * many are behind it. Six to a row and a row for every six: every superweapon has a cell of its+ * own, and nothing stands for the rest.+ *+ * The frames are the page's, Window/Html/Queue.html with the production queue's tray turned+ * round: the tray against the screen's right edge and under every cameo a box in the colour the+ * timer was registered with, whose weapon it is. The cameo stands in the box the frame's+ * thickness in from each side, so the frame is what is left of the box: one piece, the same on all+ * four sides at any HUD Size, with the tray's steel between two of them. A charged one's frame+ * breathes toward white while the wash over its picture breathes in the owner's colour. */+//-------------------------------------------------------------------------------------------------+static const UnsignedInt SUPERWEAPON_BREATH_MS = 2400; ///< a charged superweapon's breath, out and back in+static const Int SUPERWEAPON_BREATH_STEPS = 12; ///< shades its frame takes on the way: each is a page laid out again+static const Real SUPERWEAPON_BREATH_LIFT = 0.6f; ///< how far toward white the frame goes at the top of it+static const Int SUPERWEAPON_CELL_FRAME = 2; ///< a cell's frame in its owner's colour, page pixels++void InGameUI::drawSuperweaponStrip( void )+{+ // a player gets the strip, top right; an observer or a replay does not - the spectator page+ // and the Tab scoreboard carry the countdowns for them+ if( m_superweaponIconCount < 1 || m_spectatorPageShown || localPlayerWatching() ||+ ( TheRecorder && TheRecorder->getMode() == RECORDERMODETYPE_PLAYBACK ) )+ return;++ if( TheGameLogic == NULL || !TheGameLogic->isInGame() || TheGameLogic->isInShellGame() )+ return;++ // a cameo is one of the general's power bar's, and the HUD Size option grows it with the bar:+ // the player's step on top of the bar's own+ ICoord2D traySize, cameoSize, trayHole;+ Int trayStep = 0;+ stripTrayMetrics( &traySize, &cameoSize, &trayHole, &trayStep );++ //+ // The strip is laid out in the screen's pixels, and its page with it: every length of the steel+ // is turned into a whole number of screen pixels here, once, and everything after is sums of+ // those. Laid out in the page's pixels, each edge was rounded onto the screen by itself, and at+ // HUD Size 130% a two pixel gap is 2.6: three screen pixels between the first two rows and two+ // between the next, the tray's rim a pixel up into the last row, its dark line one pixel wide+ // under a tray of six cells and two under a tray of one.+ //+ const Real scale = ControlBarHudScale();+ struct Whole+ {+ static Int of( Real length, Real scale )+ {+ const Int pixels = REAL_TO_INT_FLOOR( length * scale + 0.5f );+ return pixels > 1 ? pixels : 1;+ }+ };+ const Real hudStep = scale / ControlBarHudScaleFor( TheDisplay->getWidth(), TheDisplay->getHeight() );+ const Int cameoW = Whole::of( cameoSize.x, hudStep );+ const Int cameoH = Whole::of( cameoSize.y, hudStep );++ // the production queue's steel: the gap between two of its cells, which here is the steel between+ // two owners' frames, and its tray's border, which is the well and the line along its outer edge+ const Int gap = Whole::of( SKILL_CELL_GAP, scale );+ const Int line = Whole::of( QUEUE_TRAY_LINE, scale );+ const Int well = Whole::of( QUEUE_TRAY_WELL, scale );+ const Int trayBorder = well + line;++ // a cell is the cameo and its frame round it, and the cameo is drawn that far inside the cell's box+ const Int frame = Whole::of( SUPERWEAPON_CELL_FRAME, scale );+ const Int cellW = cameoW + 2 * frame;+ const Int cellH = cameoH + 2 * frame;++ //+ // The corner readout owns the top right - the clock plate, or with the bar's page up the network+ // box, which is a page of its own - so the strip starts under whichever is up. A countdown+ // drawn behind the readout is one nobody can read. With neither up the tray stands in the+ // corner itself, against the screen's top edge as it is against the right.+ //+ Int cornerBottom = m_hudOverlayBottom;+ if( m_controlBarPageShown && m_netOverlay != NULL && TheGlobalData->m_showNetBox )+ {+ const Int netBottom = m_netOverlay->bottomOf( "#net" );+ if( netBottom > cornerBottom )+ cornerBottom = netBottom;+ }+ const Int top = cornerBottom > 0 ? cornerBottom + stripPixels( 3 ) : 0;++ //+ // one breath for the whole strip rather than one per icon, so every charged superweapon breathes+ // together instead of each on its own clock: nothing to full and back along a cosine, which+ // slows at both ends where a blink would snap. It runs off the wall clock. It is a picture,+ // and the match's frames are not its to read: it breathes the same paused or fast-forwarded.+ //+ const Real breath = (Real)( timeGetTime() % SUPERWEAPON_BREATH_MS ) / SUPERWEAPON_BREATH_MS;+ const Real pulse = 0.5f - 0.5f * (Real)cos( 2.0 * PI * breath );++ //+ // The cells, from the screen's right edge leftwards and a row under a row, six to a row and as+ // many rows as there are cells for. Only the last row can be short, and the tray is only as wide+ // as each row's own cells: the full rows stand in one tray, and a short last row in a second one+ // hung under it as a step, whose top is where the full rows' cells end, so the steel between the+ // two is the gap between any two rows and the first tray's bottom rim runs on only past the step.+ //+ const Int shown = m_superweaponIconCount;+ const Int rows = ( shown + SUPERWEAPON_STRIP_COLS - 1 ) / SUPERWEAPON_STRIP_COLS;+ const Int lastColumns = shown - ( rows - 1 ) * SUPERWEAPON_STRIP_COLS;+ const Int fullRows = lastColumns < SUPERWEAPON_STRIP_COLS ? rows - 1 : rows;+ const Int stepX = cellW + gap;+ const Int stepY = cellH + gap;++ // the cells' box inside the tray's border+ const Int cellsRight = TheDisplay->getWidth() - trayBorder;+ const Int cellsTop = top + trayBorder;+ static const Real SCREEN_PIXELS = 1.0f; ///< the page's scale: a pixel of it is one of the screen's++ HtmlValues values;+ HtmlLists lists;+ values[ "side" ] = spectatorSide();+ values[ "mirrored" ] = "mirrored";+ values[ "layer" ] = "back";+ values[ "line" ] = std::to_string( line );+ values[ "well" ] = std::to_string( well );++ // a tray is its cells and the border round them; its bottom is its last row's cells' bottom and+ // the border, the same sum the cells are placed by+ struct Tray+ {+ static void put( std::vector< HtmlValues > &trays, const IRegion2D &cells, Int top, Int border, const char *step )+ {+ IRegion2D box;+ box.lo.x = cells.lo.x - border;+ box.lo.y = top;+ box.hi.x = cells.hi.x + border;+ box.hi.y = cells.hi.y + border;+ trays.push_back( HtmlValues() );+ putFrame( trays.back(), "tray", cells, box, TRUE, SCREEN_PIXELS );+ trays.back()[ "tray.step" ] = step;+ }+ };+ std::vector< HtmlValues > &trayList = lists[ "trays" ];+ if( fullRows > 0 )+ {+ IRegion2D cells;+ cells.lo.x = cellsRight - ( SUPERWEAPON_STRIP_COLS * stepX - gap );+ cells.lo.y = cellsTop;+ cells.hi.x = cellsRight;+ cells.hi.y = cellsTop + fullRows * stepY - gap;+ Tray::put( trayList, cells, top, trayBorder, "" );+ }+ if( fullRows < rows )+ {+ IRegion2D cells;+ cells.lo.x = cellsRight - ( lastColumns * stepX - gap );+ cells.lo.y = cellsTop + fullRows * stepY;+ cells.hi.x = cellsRight;+ cells.hi.y = cells.lo.y + cellH;++ // a step starts where the rows over it end, so its well's top edge is the gap between two rows+ if( fullRows > 0 )+ Tray::put( trayList, cells, cells.lo.y - well, trayBorder, "step" );+ else+ Tray::put( trayList, cells, top, trayBorder, "" );+ }++ //+ // A charged cell's box is its owner's colour lifted toward white, in whole steps so the page is+ // laid out a dozen times a breath and not every frame.+ //+ const Real lift = SUPERWEAPON_BREATH_LIFT * REAL_TO_INT( pulse * SUPERWEAPON_BREATH_STEPS + 0.5f ) / SUPERWEAPON_BREATH_STEPS;++ IRegion2D place[ SUPERWEAPON_STRIP_MAX ]; ///< where each cameo is drawn: its cell's box less the frame+ std::vector< HtmlValues > &ownedList = lists[ "owned" ];+ for( Int each = 0; each < shown; each++ )+ {+ HtmlValues entry;+ IRegion2D box;+ box.lo.x = cellsRight - ( each % SUPERWEAPON_STRIP_COLS ) * stepX - cellW;+ box.lo.y = cellsTop + ( each / SUPERWEAPON_STRIP_COLS ) * stepY;+ box.hi.x = box.lo.x + cellW;+ box.hi.y = box.lo.y + cellH;+ place[ each ].lo.x = box.lo.x + frame;+ place[ each ].lo.y = box.lo.y + frame;+ place[ each ].hi.x = box.hi.x - frame;+ place[ each ].hi.y = box.hi.y - frame;++ UnsignedByte r, g, b, a;+ GameGetColorComponents( m_superweaponIcons[ each ].color, &r, &g, &b, &a );+ const Real lifted = m_superweaponIcons[ each ].ready ? lift : 0.0f;+ putPageRect( entry, "cell", box, TRUE, SCREEN_PIXELS );+ entry[ "cell.color" ] = cssColor( GameMakeColor( r + REAL_TO_INT( ( 255 - r ) * lifted ),+ g + REAL_TO_INT( ( 255 - g ) * lifted ),+ b + REAL_TO_INT( ( 255 - b ) * lifted ), 255 ) );+ ownedList.push_back( entry );+ }++ if( !m_queuePageLoaded )+ {+ m_queuePageLoaded = TRUE;+ readHtmlPage( QUEUE_PAGE, m_queuePage );+ }+ if( m_superweaponOverlay == NULL )+ {+ m_superweaponOverlay = new HtmlOverlay( m_superweaponNormalFont );+ m_superweaponOverlay->setScreenPixels( TRUE );+ }+ m_superweaponOverlay->setPage( HtmlTemplate_expand( m_queuePage, values, lists, lookupGameText ) );+ m_superweaponOverlay->draw();++ // a cameo has no frame drawn over its edge, so a readout's plate stands in its very corner: the+ // cell handed to the readout is the cameo's and the inset the readout takes off again+ const Int readoutInset = hudReadoutFrame();++ // drawn as a batch, for the reason drawProductionStrip() gives - see Display::beginBatch2D+ TheDisplay->beginBatch2D();++ //+ // The strip goes down a piece at a time - every picture, then every sweep, then every number -+ // rather than an icon at a time, for the reason drawProductionStripRow() gives: pieces that+ // want the same thing of the renderer are one draw call when they follow each other and one+ // draw call each when they do not. The icons do not overlap, so nothing changes on screen.+ //+ for( Int cameoSlot = 0; cameoSlot < shown; cameoSlot++ )+ {+ const SuperweaponIconSlot *slot = &m_superweaponIcons[ cameoSlot ];+ const IRegion2D &cell = place[ cameoSlot ];++ if( slot->image )+ TheDisplay->drawImage( slot->image, cell.lo.x, cell.lo.y, cell.hi.x, cell.hi.y );+ }++ //+ // the same sweep the production cameos wear, and the same way round as the command bar's own+ // clock: the scrim covers what is still to be charged and is swept off as the charge runs+ //+ for( Int clockSlot = 0; clockSlot < shown; clockSlot++ )+ {+ const SuperweaponIconSlot *slot = &m_superweaponIcons[ clockSlot ];+ const IRegion2D &cell = place[ clockSlot ];++ if( !slot->ready )+ TheDisplay->drawRemainingRectClock( cell.lo.x, cell.lo.y, cell.hi.x - cell.lo.x, cell.hi.y - cell.lo.y,+ slot->percent, GameMakeColor( 0, 0, 0, 130 ) );+ else+ {+ //+ // Charged: no number at all - zero seconds is not information - and the cameo itself+ // breathes in the owning player's colour instead. A ready superweapon is the one+ // thing on this strip that wants to be noticed rather than looked up, and a+ // translucent wash over the picture says whose it is in the same stroke.+ //+ UnsignedByte r, g, b, a;+ GameGetColorComponents( slot->color, &r, &g, &b, &a );+ const UnsignedByte washAlpha = (UnsignedByte)( 30.0f + 90.0f * pulse );+ TheDisplay->drawFillRect( cell.lo.x, cell.lo.y, cell.hi.x - cell.lo.x, cell.hi.y - cell.lo.y,+ GameMakeColor( r, g, b, washAlpha ) );+ }+ }++ //+ // bare seconds, however many there are: this strip is read against the other countdowns on+ // the screen, and m:ss is a number you have to convert first+ //+ for( Int secondsSlot = 0; secondsSlot < shown; secondsSlot++ )+ {+ const SuperweaponIconSlot *slot = &m_superweaponIcons[ secondsSlot ];+ const IRegion2D &cell = place[ secondsSlot ];++ if( !slot->ready )+ drawStripSeconds( PRODUCTION_STRIP_ROW_MAX + secondsSlot,+ cell.lo.x - readoutInset, cell.lo.y - readoutInset,+ cell.hi.x - cell.lo.x + 2 * readoutInset, cell.hi.y - cell.lo.y + 2 * readoutInset,+ slot->seconds );+ }++ TheDisplay->endBatch2D();+}+#ifdef DEBUG_LOGGINGextern Real TheStripGatherMS;extern Real TheStripDrawMS;diff --git a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/GUI/Gadget/W3DPushButton.cpp b/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/GUI/Gadget/W3DPushButton.cppindex dc4352084..1c4943cdb 100644--- a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/GUI/Gadget/W3DPushButton.cpp+++ b/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/GUI/Gadget/W3DPushButton.cpp@@ -56,6 +56,7 @@#include "GameClient/GadgetPushButton.h"#include "GameClient/Display.h"#include "GameClient/DisplayStringManager.h"+#include "GameClient/InGameUI.h" // HudReadout_draw, the plate every corner marking stands on#include "W3DDevice/GameClient/W3DGameWindow.h"#include "W3DDevice/GameClient/W3DDisplay.h"#include "W3DDevice/GameClient/W3DGadget.h"@@ -131,6 +132,9 @@ static GameFont *getBadgeFont( GameWindow *window, Real designPoints = BADGE_DES} // end getBadgeFont+static void drawBadge( GameWindow *window, const UnicodeString &text, Real designPoints,+ HudReadoutCorner corner, Color color );+// drawButtonText =============================================================/** Draw button text to the screen *///=============================================================================@@ -169,11 +173,16 @@ static void drawButtonText( GameWindow *window, WinInstanceData *instData )dropColor = window->winGetEnabledTextBorderColor();} // end enabled only- // set our font to that of our parent if not the same - except the shortcut letter, which is a- // corner marking and wears the marking font- GameFont *font = window->winGetFont();+ // the shortcut letter is a corner marking: the marking font, on the markings' plate in the top+ // left corner, which the button's own art could be any colour underif( BitTest( window->winGetStatus(), WIN_STATUS_SHORTCUT_BUTTON ) )- font = getBadgeFont( window );+ {+ drawBadge( window, text->getText(), BADGE_DESIGN_POINTS, HUD_READOUT_TOP_LEFT, textColor );+ return;+ }++ // set our font to that of our parent if not the same+ GameFont *font = window->winGetFont();if( font != NULL && text->getFont() != font )text->setFont( font );@@ -181,25 +190,8 @@ static void drawButtonText( GameWindow *window, WinInstanceData *instData )text->getSize( &width, &height );// where to draw- if( BitTest( window->winGetStatus(), WIN_STATUS_SHORTCUT_BUTTON ) )- {- // Oh god... this is a total hack for shortcut buttons to handle rendering text top left corner...- textPos.x = origin.x + 2;- textPos.y = origin.y + 0;- }- else- {- textPos.x = origin.x + (size.x / 2) - (width / 2);- textPos.y = origin.y + (size.y / 2) - (height / 2);- }-- // Shortcut text sits on top of the button's own art, which can be any colour at all -- // a light unit portrait swallowed the letter. Lay a translucent black plate under it.- if( BitTest( window->winGetStatus(), WIN_STATUS_SHORTCUT_BUTTON ) && width > 0 && height > 0 )- {- TheDisplay->drawFillRect( textPos.x - 2, textPos.y, width + 4, height,- GameMakeColor( 0, 0, 0, 160 ) );- }+ textPos.x = origin.x + (size.x / 2) - (width / 2);+ textPos.y = origin.y + (size.y / 2) - (height / 2);// draw ittext->draw( textPos.x, textPos.y, textColor, dropColor );@@ -250,34 +242,45 @@ static DisplayString *badgeString( const UnicodeString &text, GameFont *font )//=============================================================================static void drawCountBadge( GameWindow *window, Int count ){- ICoord2D origin, size, textPos;- Int width, height;-UnicodeString text;text.format( L"%d", count );- DisplayString *badge = badgeString( text, getBadgeFont( window, COUNT_BADGE_DESIGN_POINTS ) );+ drawBadge( window, text, COUNT_BADGE_DESIGN_POINTS, HUD_READOUT_BOTTOM_RIGHT, GameMakeColor( 255, 255, 255, 255 ) );++} // end drawCountBadge++// drawBadge ==================================================================+/** One corner marking: `text` on its plate in `corner` of the button's inner+ * rectangle, inside the frame the command bar's page draws over the button's+ * edge. Text too wide for the button is set a point smaller until it fits, so+ * a four figure price or a three figure countdown shrinks instead of running+ * out over the frame or into the next button. */+//=============================================================================+static void drawBadge( GameWindow *window, const UnicodeString &text, Real designPoints,+ HudReadoutCorner corner, Color color )+{+ IRegion2D cell;+ ICoord2D size;+ window->winGetScreenPosition( &cell.lo.x, &cell.lo.y );+ window->winGetSize( &size.x, &size.y );+ cell.hi.x = cell.lo.x + size.x;+ cell.hi.y = cell.lo.y + size.y;++ GameFont *font = getBadgeFont( window, designPoints );+ DisplayString *badge = badgeString( text, font );if( badge == NULL )return;- window->winGetScreenPosition( &origin.x, &origin.y );- window->winGetSize( &size.x, &size.y );- badge->getSize( &width, &height );-- // the plate is what the eye reads as the badge, so it is the plate that sits in the corner -- // hanging it a few pixels short left a stripe of button art outside it and the three badges- // looked scattered rather than pinned to the button- const Int plateWidth = width + 4;- textPos.x = origin.x + size.x - plateWidth + 2;- textPos.y = origin.y + size.y - height;-- // a solid plate rather than the shortcut letter's translucent one: this number has to be legible- // over whatever cameo is underneath it without the player stopping to look for it- TheDisplay->drawFillRect( textPos.x - 2, textPos.y, plateWidth, height,- GameMakeColor( 0, 0, 0, 230 ) );- badge->draw( textPos.x, textPos.y, GameMakeColor( 255, 255, 255, 255 ),- GameMakeColor( 0, 0, 0, 255 ) );+ // each size tried is a string badgeString keeps, so a marking that had to shrink is looked up+ // the next frame, not lettered again+ while( font != NULL && font->pointSize > 6 && !HudReadout_fits( badge, cell ) )+ {+ font = TheFontLibrary->getFont( font->nameString, font->pointSize - 1, TRUE );+ badge = badgeString( text, font );+ }-} // end drawCountBadge+ HudReadout_draw( badge, cell, corner, color );++} // end drawBadge// drawSecondsBadge ===========================================================/** Draw a small "12s" label in the button's bottom left corner - how long the@@ -285,27 +288,9 @@ static void drawCountBadge( GameWindow *window, Int count )//=============================================================================static void drawSecondsBadge( GameWindow *window, Int seconds ){- ICoord2D origin, size, textPos;- Int width, height;-UnicodeString text;text.format( L"%ds", seconds );- DisplayString *label = badgeString( text, getBadgeFont( window ) );- if( label == NULL )- return;-- window->winGetScreenPosition( &origin.x, &origin.y );- window->winGetSize( &size.x, &size.y );- label->getSize( &width, &height );-- textPos.x = origin.x + 2;- textPos.y = origin.y + size.y - height;-- // same translucent plate the count badge wears - button art can be any colour- TheDisplay->drawFillRect( textPos.x - 2, textPos.y, width + 4, height,- GameMakeColor( 0, 0, 0, 160 ) );- label->draw( textPos.x, textPos.y, GameMakeColor( 255, 255, 255, 255 ),- GameMakeColor( 0, 0, 0, 255 ) );+ drawBadge( window, text, BADGE_DESIGN_POINTS, HUD_READOUT_BOTTOM_LEFT, GameMakeColor( 255, 255, 255, 255 ) );} // end drawSecondsBadge@@ -316,28 +301,9 @@ static void drawSecondsBadge( GameWindow *window, Int seconds )//=============================================================================static void drawCostBadge( GameWindow *window, Int cost ){- ICoord2D origin, size, textPos;- Int width, height;-UnicodeString text;text.format( L"$%d", cost );- DisplayString *label = badgeString( text, getBadgeFont( window ) );- if( label == NULL )- return;-- window->winGetScreenPosition( &origin.x, &origin.y );- window->winGetSize( &size.x, &size.y );- label->getSize( &width, &height );-- const Int plateWidth = width + 4;- textPos.x = origin.x + size.x - plateWidth + 2;- textPos.y = origin.y;-- // same translucent plate the other two badges wear - button art can be any colour- TheDisplay->drawFillRect( textPos.x - 2, textPos.y, plateWidth, height,- GameMakeColor( 0, 0, 0, 160 ) );- label->draw( textPos.x, textPos.y, GameMakeColor( 235, 210, 120, 255 ),- GameMakeColor( 0, 0, 0, 255 ) );+ drawBadge( window, text, BADGE_DESIGN_POINTS, HUD_READOUT_TOP_RIGHT, GameMakeColor( 235, 210, 120, 255 ) );} // end drawCostBadge@@ -350,33 +316,14 @@ static void drawCostBadge( GameWindow *window, Int cost )//=============================================================================static void drawPowerBadge( GameWindow *window, Int power ){- ICoord2D origin, size, textPos;- Int width, height;-// the game's own sign: a template's EnergyProduction is negative when it consumesconst Int draws = -power;UnicodeString text;text.format( draws > 0 ? L"-%d" : L"+%d", draws > 0 ? draws : -draws );- DisplayString *label = badgeString( text, getBadgeFont( window ) );- if( label == NULL )- return;-- window->winGetScreenPosition( &origin.x, &origin.y );- window->winGetSize( &size.x, &size.y );- label->getSize( &width, &height );-- const Int plateWidth = width + 4;- textPos.x = origin.x + size.x - plateWidth + 2;- textPos.y = origin.y + size.y - height;-- // same translucent plate the other badges wear - button art can be any colour- TheDisplay->drawFillRect( textPos.x - 2, textPos.y, plateWidth, height,- GameMakeColor( 0, 0, 0, 160 ) );- label->draw( textPos.x, textPos.y,- draws > 0 ? GameMakeColor( 255, 170, 90, 255 ) // spends it- : GameMakeColor( 130, 220, 255, 255 ), // supplies it- GameMakeColor( 0, 0, 0, 255 ) );+ drawBadge( window, text, BADGE_DESIGN_POINTS, HUD_READOUT_BOTTOM_RIGHT,+ draws > 0 ? GameMakeColor( 255, 170, 90, 255 ) // spends it+ : GameMakeColor( 130, 220, 255, 255 ) ); // supplies it} // end drawPowerBadgediff --git a/GeneralsMD/Code/Tests/test_gameengine.cpp b/GeneralsMD/Code/Tests/test_gameengine.cppindex 6eaea7298..3a0b11e19 100644--- a/GeneralsMD/Code/Tests/test_gameengine.cpp+++ b/GeneralsMD/Code/Tests/test_gameengine.cpp@@ -10734,7 +10734,7 @@ TEST(a_stacked_tray_does_not_lie_over_the_one_below_it)<= (Int)InGameUI::PRODUCTION_STRIP_TRAY_H );//- // the superweapon strip stands in the same trays, three rows of six of them, and that pile has+ // the superweapon strip stands in rows of six, as many as it is allowed to grow to, and that pile has// to fit under the corner clock plate rather than run off the bottom of the 800x600 it is// written in - at the full tray now, which is the taller pile of the two//