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
fix(gameengine): esc keys fade through the pause stutter, drop-downs fold on outside clicks
Olcay Seygan1b51ed657254
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex cea0f6582..41949684e 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -494,7 +494,7 @@ found and fixed — EA's own, not port damage.**- A general who has taken Artillery Barrage to level 3 shows one Artillery Barrage on the promotions strip, not three copies of the same picture in a row.- The strips close up again: across a row the trays slide an eighth of a tray under each other, so a row reads as one run of metal. The cameos never overlap each other, because every tray goes down before any picture does.- Watching, the top left corner is clear. The promotions and superweapon shelves that stood there are gone: every general's promotions and superweapons are on the Tab scoreboard.-- Watching, an observer's board sits on the right of the screen, built from the command bar's own steel, and the steel is the watched side's: grey for America, red for China, sand for GLA, changing when you select a unit of another side: every player's general, his name in his colour, the number in gold, and under it a bar in the same colour as his name. In a two-sided match the bars used to go green for one side and red for the other, so a blue name could stand over a red bar. It opens on net worth, the cash in hand plus what everything the player has standing would cost to build again, counted twice a second, richest first.+- Watching, an observer's board sits on the right of the screen, built from the command bar's own steel, and the steel is the watched side's: grey for America, red for China, sand for GLA, changing when you select a unit of another side: every player's general, his name in his colour, the number in gold, and under it a bar in the same colour as his name. In a two-sided match the bars used to go green for one side and red for the other, so a blue name could stand over a red bar. It opens on net worth, the cash in hand plus what everything the player has standing would cost to build again, counted twice a second, richest first. Its drop-downs close when you click anywhere else, on the battlefield, the radar or another drop-down, instead of staying open until you picked something in them.- The number the board ranks by is yours to pick from the drop-down at its top: net worth, cash, income per minute, army value, kills and losses, the general's rank and power. The list re-sorts the moment you choose. The command bar's top row of keys picks them too while you watch, Q W E R T Y U, or Q E R T Y U I with the WASD camera, and the drop-down writes each stat's key beside it.- A button under the list opens the armies: every player's six most expensive kinds of unit in cameo trays, with how many of each he has on the field. The generals' emblems on the board stand bare, with no tray round them.- The drop-downs on the right open over the board instead of pushing it down the screen.@@ -514,7 +514,7 @@ found and fixed — EA's own, not port damage.**- The top of the screen is battlefield. The players, their teams, their superweapons with the seconds left and the match clock are all on Tab, which already had every one of them, so the column of superweapon countdowns that used to sit in the top right is gone while you play, and so is a strip of flags that repeated the scoreboard across the top edge.- The steel between the build buttons, the portrait's grid and the promotion screen's cells is half as wide as it was, so the pictures take the room. The queue's tray has a thinner rim. The portrait and its upgrade icons sit under the portrait's grid, framed the same way as every other picture on the bar.- The command bar slides up from the bottom of the screen again when a match starts. The new steel frame had been drawn at its final place from the first frame, so the buttons rose into a frame that was already standing.-- The Escape menu is in the bar's steel too: a plate in your side's colour, no bigger than its keys, in the middle of the screen, the keys sunk in a well and lit gold under the pointer and pressed in when clicked. The Generals logo that took the top third of it is gone. It comes up over a dimmed battlefield: the screen darkens as the plate fades in, then the keys fade in top to bottom out of nothing, each lit bright in your side's own steel for a moment as it lands: pale steel for America, red for China, sand for the GLA. The old menu's flash used to light up a patch of the screen where the old, bigger menu had stood; that is gone, and the menu closes at once. The promotion screen opens across the middle of the screen. Restart reads Surrender or Restart Mission as the game you are in calls for.+- The Escape menu is in the bar's steel too: a plate in your side's colour, no bigger than its keys, in the middle of the screen, the keys sunk in a well and lit gold under the pointer and pressed in when clicked. The Generals logo that took the top third of it is gone. It comes up over a dimmed battlefield: the screen darkens as the plate fades in, then the keys fade in top to bottom out of nothing, each lit bright in your side's own steel for a moment as it lands: pale steel for America, red for China, sand for the GLA. A single-player game stutters for half a second as it pauses under the menu, and the fade no longer races through in those few frames: the keys used to seem to pop up at once there. The old menu's flash used to light up a patch of the screen where the old, bigger menu had stood; that is gone, and the menu closes at once. The promotion screen opens across the middle of the screen. Restart reads Surrender or Restart Mission as the game you are in calls for.## Placing buildingsdiff --git a/GeneralsMD/Code/GameEngine/Include/GameClient/InGameUI.h b/GeneralsMD/Code/GameEngine/Include/GameClient/InGameUI.hindex e53bd191b..7ecf5b540 100644--- a/GeneralsMD/Code/GameEngine/Include/GameClient/InGameUI.h+++ b/GeneralsMD/Code/GameEngine/Include/GameClient/InGameUI.h@@ -822,6 +822,7 @@ public: // ********************************************************************/// a click landed on the strip: jump to that producer, or cancel the item when 'cancel' is setBool handleProductionStripClick( const ICoord2D *mouse, Bool cancel );+ void foldSpectatorDropDowns( const ICoord2D &mouse ); ///< a press off the spectator's page closes its drop-downs//// One superweapon countdown of the top right strip. The list is rebuilt every frame out of@@ -1259,7 +1260,8 @@ protected:std::vector< HtmlOverlay * > m_quitMenuKeyOverlays; ///< one for each of the menu's keys, each fading in on its ownBool m_quitMenuPageLoaded;std::string m_quitMenuPage;- UnsignedInt m_quitMenuOpenedMs; ///< when themeQuitMenu last put the menu up, wall clock: the game is paused under it+ Int m_quitMenuShownMs; ///< how far the menu's coming up has run, -1 until its first picture+ UnsignedInt m_quitMenuDrawnAt; ///< the wall clock at its last picture: the game is paused under itBool m_signalsWereShown; ///< the smoke signal column was up last frameUnsignedInt m_signalsRiseStartMs; ///< when it last came up, the start of its buttons' risediff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/InGameUI.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/InGameUI.cppindex d87d05311..c4da2c5a4 100644--- a/GeneralsMD/Code/GameEngine/Source/GameClient/InGameUI.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/InGameUI.cpp@@ -1228,7 +1228,8 @@ InGameUI::InGameUI()m_promotionPageLoaded = FALSE;m_quitMenuOverlay = NULL;m_quitMenuPageLoaded = FALSE;- m_quitMenuOpenedMs = 0;+ m_quitMenuShownMs = 0;+ m_quitMenuDrawnAt = 0;m_controlBarPageShown = FALSE;m_tooltipOverlay = NULL;m_tooltipPageLoaded = FALSE;@@ -2313,9 +2314,29 @@ Bool InGameUI::handleSpectatorPageClick( const ICoord2D *mouse, Bool act )return TRUE;}+/** The page's three drop-downs, each opened by a flip of its name. */+static const std::string *const SPECTATOR_DROP_DOWNS[] = { &CAMERA_GROUP, &FOLLOW_GROUP, &STAT_GROUP };++//-------------------------------------------------------------------------------------------------+/** Any button pressed anywhere but on the page, over a window or over the world, folds up whichever+ * drop-down is open. A press on the page is the page's, and runSpectatorAction folds the rest. */+//-------------------------------------------------------------------------------------------------+void InGameUI::foldSpectatorDropDowns( const ICoord2D &mouse )+{+ if( !m_spectatorPageShown || m_spectatorOverlay->hover( mouse ) )+ return;+ for( Int each = 0; each < (Int)ARRAY_SIZE( SPECTATOR_DROP_DOWNS ); each++ )+ m_spectatorFlipped.erase( *SPECTATOR_DROP_DOWNS[ each ] );+}+//-------------------------------------------------------------------------------------------------void InGameUI::runSpectatorAction( const std::string &action ){+ // whatever the page was clicked for, every drop-down but the one it opens folds up+ for( Int each = 0; each < (Int)ARRAY_SIZE( SPECTATOR_DROP_DOWNS ); each++ )+ if( action != FLIP_ACTION + *SPECTATOR_DROP_DOWNS[ each ] )+ m_spectatorFlipped.erase( *SPECTATOR_DROP_DOWNS[ each ] );+if( action.compare( 0, FLIP_ACTION.size(), FLIP_ACTION ) == 0 ){const std::string name = action.substr( FLIP_ACTION.size() );@@ -11777,6 +11798,12 @@ enumQUIT_MENU_KEY_FLASH_MS = 220 ///< how long a key stays lit when it comes in, its fade included};+/** The most one picture moves the menu's coming up on. A single-player game pausing under the menu+ * draws at ten frames a second for the first half second or so, and on the wall clock alone the+ * keys had all come in within four pictures: they seemed to pop up with no fade at all. */+static const Int QUIT_MENU_MOST_MS_A_PICTURE = 25;+static const Int QUIT_MENU_NOT_DRAWN = -1; ///< m_quitMenuShownMs until the menu's first picture+/** A window of the same layout as `parent`, by its name there. */static GameWindow *quitMenuWindow( GameWindow *parent, const char *name ){@@ -11800,7 +11827,7 @@ void InGameUI::themeQuitMenu( GameWindow *parent )if( m_quitMenuPage.empty() )return;- m_quitMenuOpenedMs = timeGetTime();+ m_quitMenuShownMs = QUIT_MENU_NOT_DRAWN;parent->winSetDrawFunc( drawQuitMenu );for( Int key = 0; key < (Int)ARRAY_SIZE( QUIT_MENU_KEYS ); key++ ){@@ -11882,7 +11909,15 @@ void InGameUI::drawQuitMenuPage( GameWindow *parent )putPageRect( values, "panel", panel, controlBarWindowRect( parent, panel ) );putPageRect( values, "well", well, TRUE );- const Int openMs = (Int)( timeGetTime() - m_quitMenuOpenedMs );+ // the coming up starts on the menu's first picture and moves on with the wall clock, but never+ // by more than QUIT_MENU_MOST_MS_A_PICTURE a picture+ const UnsignedInt now = timeGetTime();+ if( m_quitMenuShownMs == QUIT_MENU_NOT_DRAWN )+ m_quitMenuShownMs = 0;+ else+ m_quitMenuShownMs += min( (Int)( now - m_quitMenuDrawnAt ), QUIT_MENU_MOST_MS_A_PICTURE );+ m_quitMenuDrawnAt = now;+ const Int openMs = m_quitMenuShownMs;const Int pageAlpha = min( 255, openMs * 255 / QUIT_MENU_FADE_MS );// a key still fading in is drawn alone on the same page with the rest of it bare, the page havingdiff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/WindowXlat.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/WindowXlat.cppindex 6b9ab7aa0..a5b59684f 100644--- a/GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/WindowXlat.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/WindowXlat.cpp@@ -274,6 +274,14 @@ GameMessageDisposition WindowTranslator::translateGameMessage(const GameMessageTheMousePos.y = mousePos.y;#endif+ // a press off the spectator's page closes its drop-downs, before a window can take it+ if( TheInGameUI && ( msg->getType() == GameMessage::MSG_RAW_MOUSE_LEFT_BUTTON_DOWN+ || msg->getType() == GameMessage::MSG_RAW_MOUSE_LEFT_DOUBLE_CLICK+ || msg->getType() == GameMessage::MSG_RAW_MOUSE_MIDDLE_BUTTON_DOWN+ || msg->getType() == GameMessage::MSG_RAW_MOUSE_RIGHT_BUTTON_DOWN+ || msg->getType() == GameMessage::MSG_RAW_MOUSE_RIGHT_DOUBLE_CLICK ) )+ TheInGameUI->foldSpectatorDropDowns( mousePos );+// process the mouse event positionGameWindowMessage gwm = rawMouseToWindowMessage( msg );if( TheWindowManager )