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): promotion screen dims the battlefield and fades in
Olcay Seygand9bf40e62155
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 869f2939c..ac2fa8b35 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -537,7 +537,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, 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 beacon button is gone from the bar too; the smoke signals over the radar are how you point your team at a spot. 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. A watcher has nothing to promote and no longer gets the tab, which used to hang half into the screen's corner. Its button goes with it: a watcher who clicked a unit used to find an empty patch of screen there that still showed the promotions tooltip and opened the promotion screen. 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. It opens straight away; the side's old painted screen no longer fades in over it for the first nine frames. 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 beacon button is gone from the bar too; the smoke signals over the radar are how you point your team at a spot. 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. A watcher has nothing to promote and no longer gets the tab, which used to hang half into the screen's corner. Its button goes with it: a watcher who clicked a unit used to find an empty patch of screen there that still showed the promotions tooltip and opened the promotion screen. 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. It comes up the way the Esc menu does, the battlefield behind it dimmed to 65% black and the screen fading in over an eighth of a second; the side's old painted screen no longer fades in over it for the first nine frames. 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. Press one and the pointer turns to a cross; your next click puts the signal there, on the ground or on the radar, and a right click or Escape takes it back; until now a button dropped its smoke in the middle of your view. Every signal now leaves a mark on the ground in your colour for ten seconds, and the radar ping lasts as long: crossed swords to attack, a shield to defend, an eye to look, each in a ring a few tanks across, fading out over its last two seconds. 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/Promotion.html b/GeneralsMD/Code/Data/Window/Html/Promotion.htmlindex d03331fd0..94875f8e7 100644--- a/GeneralsMD/Code/Data/Window/Html/Promotion.html+++ b/GeneralsMD/Code/Data/Window/Html/Promotion.html@@ -11,6 +11,7 @@{{side}} "america", "china" or "gla"{{held}} "held" while the left mouse button is down{{panel.x}} .y .w .h the screen's plate+ {{screen.x}} .y .w .h the whole screen, dimmed under the back layer as the Esc menu dims itdata-each="wells" a well round each row and its heading, {{well.x}} .y .w .h{{Name.x}} .y .w .h StaticTextTitle, ProgressBarExperience, StaticTextRankPointsAvailable andButtonExit, each with {{Name.shown}} and {{Name.state}} ("disabled",@@ -23,7 +24,8 @@round it in page pixels, and {{state}}"owned" once bought, "ready" while it can be, "locked" while it cannot,"empty" where no promotion stands- All in the page's pixels, a pixel of an 800x600 screen. Without this page the painting draws.+ All in the page's pixels, a pixel of an 800x600 screen. The game fades both layers in as the+ screen comes up. Without this page the painting draws.--><html><head>@@ -34,6 +36,8 @@body { background-color: #3b4a36; font-size: 8px; color: #dfe5ea; }.hidden { display: none; }.piece { position: absolute; }+ /* the battlefield and the bar behind the screen, dimmed as the Esc menu dims them */+ .dim { background-color: rgba(0, 0, 0, 0.65); }/* the plate: steel lit from above, a light line along its top and down its left, dark along itsright and bottom */@@ -105,6 +109,7 @@</head><body><div class="{{layer}} {{side}} {{held}}">+ <div class="piece dim under" style="left: {{screen.x}}px; top: {{screen.y}}px; width: {{screen.w}}px; height: {{screen.h}}px"></div><div class="piece plate under" style="left: {{panel.x}}px; top: {{panel.y}}px; width: {{panel.w}}px; height: {{panel.h}}px"></div><div class="piece well under" data-each="wells" style="left: {{well.x}}px; top: {{well.y}}px; width: {{well.w}}px; height: {{well.h}}px"></div>diff --git a/GeneralsMD/Code/GameEngine/Include/GameClient/InGameUI.h b/GeneralsMD/Code/GameEngine/Include/GameClient/InGameUI.hindex 36deab56c..f8fb4265c 100644--- a/GeneralsMD/Code/GameEngine/Include/GameClient/InGameUI.h+++ b/GeneralsMD/Code/GameEngine/Include/GameClient/InGameUI.h@@ -433,6 +433,8 @@ public: // ********************************************************************void drawPromotionPage( GameWindow *parent, Bool front );/** TRUE once the promotion screen is the page's, so the painted screen's own fade-in stays off. */Bool isPromotionPageShown( void ) const { return m_promotionPageLoaded && !m_promotionPage.empty(); }+ /** The promotion screen is coming up: its page and the dimmed screen under it fade in from now. */+ void openPromotionPage( void );/** The Esc menu hands its look to Window/Html/QuitMenu.html: `parent` draws the page and its keys* draw nothing and keep their clicks. Left as it is when there is no page. */void themeQuitMenu( GameWindow *parent );@@ -1248,6 +1250,8 @@ protected:std::vector< HtmlValues > m_cellFrontCells[ CELL_GRID_COUNT ]; ///< each grid's cells as the bar's page last placed themBool m_promotionPageLoaded;std::string m_promotionPage;+ Int m_promotionShownMs; ///< how far the promotion screen has come up, -1 before its first picture+ UnsignedInt m_promotionDrawnAt; ///< the wall clock at its last pictureHtmlOverlay * m_quitMenuOverlay;std::vector< HtmlOverlay * > m_quitMenuKeyOverlays; ///< one for each of the menu's keys, each fading in on its ownBool m_quitMenuPageLoaded;diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/ControlBar/ControlBar.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/ControlBar/ControlBar.cppindex 58b158867..ffb99b749 100644--- a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/ControlBar/ControlBar.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/ControlBar/ControlBar.cpp@@ -5569,6 +5569,7 @@ void ControlBar::showPurchaseScience( void )m_purchaseScienceOpen = TRUE;//switchToContext(CB_CONTEXT_PURCHASE_SCIENCE, NULL);m_contextParent[ CP_PURCHASE_SCIENCE ]->winHide(FALSE);+ TheInGameUI->openPromotionPage();// the fade holds the screen hidden for nine frames and draws the side's old painting of it fading// in, which the page has replacedif (TheGlobalData->m_animateWindows && !TheInGameUI->isPromotionPageShown())diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/InGameUI.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/InGameUI.cppindex a104bef76..250847c20 100644--- a/GeneralsMD/Code/GameEngine/Source/GameClient/InGameUI.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/InGameUI.cpp@@ -1229,6 +1229,8 @@ InGameUI::InGameUI()for( Int grid = 0; grid < CELL_GRID_COUNT; grid++ )m_cellFrontOverlay[ grid ] = NULL;m_promotionPageLoaded = FALSE;+ m_promotionShownMs = 0;+ m_promotionDrawnAt = 0;m_quitMenuOverlay = NULL;m_quitMenuPageLoaded = FALSE;m_quitMenuShownMs = 0;@@ -11497,6 +11499,18 @@ static const char *promotionState( GameWindow *button )* the scheme put them; the promotions are the bar's buttons and paint over the back of the page,* and the `front` of it, the grid's frames, paints over them. *///-------------------------------------------------------------------------------------------------+/** The promotion screen coming up the way the Esc menu does: the screen dims and the page fades in+ * over PROMOTION_FADE_MS of the wall clock from its first picture, never more than+ * PROMOTION_MOST_MS_A_PICTURE a picture, so a slow first picture does not skip the fade. */+static const Int PROMOTION_FADE_MS = 120;+static const Int PROMOTION_MOST_MS_A_PICTURE = 25;+static const Int PROMOTION_NOT_DRAWN = -1;++void InGameUI::openPromotionPage( void )+{+ m_promotionShownMs = PROMOTION_NOT_DRAWN;+}+void InGameUI::drawPromotionPage( GameWindow *parent, Bool front ){enum@@ -11522,6 +11536,24 @@ void InGameUI::drawPromotionPage( GameWindow *parent, Bool front )IRegion2D panel;controlBarWindowRect( parent, panel );putPageRect( values, "panel", panel, TRUE );+ IRegion2D screen;+ screen.lo.x = screen.lo.y = 0;+ screen.hi.x = TheDisplay->getWidth();+ screen.hi.y = TheDisplay->getHeight();+ putPageRect( values, "screen", screen, TRUE );++ // the back draws first each picture and moves the coming up on for both layers+ if( !front )+ {+ const UnsignedInt now = timeGetTime();+ if( m_promotionShownMs == PROMOTION_NOT_DRAWN )+ m_promotionShownMs = 0;+ else+ m_promotionShownMs = min( m_promotionShownMs + min( (Int)( now - m_promotionDrawnAt ), PROMOTION_MOST_MS_A_PICTURE ),+ PROMOTION_FADE_MS );+ m_promotionDrawnAt = now;+ }+ overlay->setAlpha( max( 0, m_promotionShownMs ) * OPAQUE_PAGE / PROMOTION_FADE_MS );static const char *const PLACED[] = { "StaticTextTitle", "ProgressBarExperience", "StaticTextRankPointsAvailable", "ButtonExit" };for( Int each = 0; each < (Int)ARRAY_SIZE( PLACED ); each++ )