Skip to content

Zero Hour rebuilt from EA's source: x64, Direct3D 11, VS2022/CMake, ~60 original bugs fixed, an AI that builds a base. Bring your own game.

feat(gameengine): esc menu fades in over a dimmed screen, keys drop in

Olcay Seygan8c73be034cba
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 096a1d118..bc196f426 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -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 opens and closes at once, where the old menu's flash used to light up a patch of the screen where the old, bigger menu had stood. 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 drop in top to bottom, each lit bright for a moment as it lands. 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 buildings
diff --git a/GeneralsMD/Code/Data/Window/Html/QuitMenu.html b/GeneralsMD/Code/Data/Window/Html/QuitMenu.html
index 656dc20c6..7081c1fe3 100644
--- a/GeneralsMD/Code/Data/Window/Html/QuitMenu.html
+++ b/GeneralsMD/Code/Data/Window/Html/QuitMenu.html
@@ -7,11 +7,15 @@
The game fills in, every frame the menu is up (InGameUI::drawQuitMenuPage):
{{side}} "america", "china" or "gla"
+ {{screen.x}} .y .w .h the whole screen, dimmed under the menu
{{panel.x}} .y .w .h the menu's plate
{{well.x}} .y .w .h the well the keys stand in
data-each="keys" every key the menu shows, top to bottom, {{key.x}} .y .w .h, {{label}} the
- button's own text and {{state}} any of "disabled", "hilite", "pushed"
- All in the page's pixels, a pixel of an 800x600 screen. Without this page the menu draws as EA
+ button's own text and {{state}} any of "disabled", "hilite", "pushed",
+ or while the menu comes up "waiting" before the key comes in and
+ "flash" for a moment as it does
+ All in the page's pixels, a pixel of an 800x600 screen. The game fades the whole page in as the
+ menu comes up. Without this page the menu draws as EA
drew it.
-->
<html>
@@ -48,11 +52,17 @@
.gla .key.hilite { background: linear-gradient(to bottom, #cabe86, #766a3a); }
.key.pushed { background: linear-gradient(to bottom, #151a1f, #3a414a); border-color: #e8d27a; color: #f2cf4a; }
.key.disabled { color: #5d666f; }
+ .key.waiting { display: none; }
+ .key.flash { background: linear-gradient(to bottom, #fff6d0, #e8d27a); border-color: #fff6d0; color: #ffffff; }
+
+ /* the battlefield behind the menu, dimmed while the game waits on it */
+ .dim { background-color: rgba(0, 0, 0, 0.45); }
.key .label { position: absolute; left: 0; right: 0; top: 50%; margin-top: -7px; line-height: 14px; }
</style>
</head>
<body>
<div class="{{side}}">
+ <div class="piece dim" style="left: {{screen.x}}px; top: {{screen.y}}px; width: {{screen.w}}px; height: {{screen.h}}px"></div>
<div class="piece plate" style="left: {{panel.x}}px; top: {{panel.y}}px; width: {{panel.w}}px; height: {{panel.h}}px"></div>
<div class="piece well" style="left: {{well.x}}px; top: {{well.y}}px; width: {{well.w}}px; height: {{well.h}}px"></div>
<div class="piece key {{state}}" data-each="keys" style="left: {{key.x}}px; top: {{key.y}}px; width: {{key.w}}px; height: {{key.h}}px"><div class="label">{{label}}</div></div>
diff --git a/GeneralsMD/Code/GameEngine/Include/GameClient/InGameUI.h b/GeneralsMD/Code/GameEngine/Include/GameClient/InGameUI.h
index f511941fc..757e94f5b 100644
--- a/GeneralsMD/Code/GameEngine/Include/GameClient/InGameUI.h
+++ b/GeneralsMD/Code/GameEngine/Include/GameClient/InGameUI.h
@@ -1258,6 +1258,7 @@ protected:
HtmlOverlay * m_quitMenuOverlay;
Bool m_quitMenuPageLoaded;
std::string m_quitMenuPage;
+ UnsignedInt m_quitMenuOpenedMs; ///< when themeQuitMenu last put the menu up, wall clock: the game is paused under it
Bool m_signalsWereShown; ///< the smoke signal column was up last frame
UnsignedInt m_signalsRiseStartMs; ///< when it last came up, the start of its buttons' rise
diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/InGameUI.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/InGameUI.cpp
index a5e5f6948..d4469a424 100644
--- a/GeneralsMD/Code/GameEngine/Source/GameClient/InGameUI.cpp
+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/InGameUI.cpp
@@ -1228,6 +1228,7 @@ InGameUI::InGameUI()
m_promotionPageLoaded = FALSE;
m_quitMenuOverlay = NULL;
m_quitMenuPageLoaded = FALSE;
+ m_quitMenuOpenedMs = 0;
m_controlBarPageShown = FALSE;
m_tooltipOverlay = NULL;
m_tooltipPageLoaded = FALSE;
@@ -11761,6 +11762,16 @@ enum
QUIT_MENU_MARGIN = 12 ///< the plate round the keys' well
};
+/** The menu coming up, in milliseconds of the wall clock: the dimmed screen and the plate fade in,
+ * then the keys come in top to bottom, each lit bright for a moment the way EA's keys flashed. */
+enum
+{
+ QUIT_MENU_FADE_MS = 120,
+ QUIT_MENU_KEY_FIRST_MS = 80, ///< the first key, after the plate is mostly there
+ QUIT_MENU_KEY_STEP_MS = 45, ///< each key after the one over it
+ QUIT_MENU_KEY_FLASH_MS = 120 ///< how long a key stays lit when it comes in
+};
+
/** A window of the same layout as `parent`, by its name there. */
static GameWindow *quitMenuWindow( GameWindow *parent, const char *name )
{
@@ -11784,6 +11795,7 @@ void InGameUI::themeQuitMenu( GameWindow *parent )
if( m_quitMenuPage.empty() )
return;
+ m_quitMenuOpenedMs = timeGetTime();
parent->winSetDrawFunc( drawQuitMenu );
for( Int key = 0; key < (Int)ARRAY_SIZE( QUIT_MENU_KEYS ); key++ )
{
@@ -11856,10 +11868,16 @@ void InGameUI::drawQuitMenuPage( GameWindow *parent )
HtmlValues values;
HtmlLists lists;
values[ "side" ] = spectatorSide();
+ IRegion2D screen;
+ screen.lo.x = screen.lo.y = 0;
+ screen.hi.x = TheDisplay->getWidth();
+ screen.hi.y = TheDisplay->getHeight();
+ putPageRect( values, "screen", screen, TRUE );
IRegion2D panel;
putPageRect( values, "panel", panel, controlBarWindowRect( parent, panel ) );
putPageRect( values, "well", well, TRUE );
+ const Int openMs = (Int)( timeGetTime() - m_quitMenuOpenedMs );
std::vector< HtmlValues > &keys = lists[ "keys" ];
for( Int key = 0; key < (Int)ARRAY_SIZE( QUIT_MENU_KEYS ); key++ )
{
@@ -11870,12 +11888,19 @@ void InGameUI::drawQuitMenuPage( GameWindow *parent )
HtmlValues entry;
putPageRect( entry, "key", rect, TRUE );
- entry[ "state" ] = controlBarWindowState( button );
+ const Int keyMs = openMs - QUIT_MENU_KEY_FIRST_MS - (Int)keys.size() * QUIT_MENU_KEY_STEP_MS;
+ if( keyMs < 0 )
+ entry[ "state" ] = "waiting";
+ else if( keyMs < QUIT_MENU_KEY_FLASH_MS )
+ entry[ "state" ] = "flash";
+ else
+ entry[ "state" ] = controlBarWindowState( button );
entry[ "label" ] = WideCharStringToMultiByte( button->winGetInstanceData()->getText().str() );
keys.push_back( entry );
}
m_quitMenuOverlay->setPage( HtmlTemplate_expand( m_quitMenuPage, values, lists, lookupGameText ) );
+ m_quitMenuOverlay->setAlpha( min( 255, openMs * 255 / QUIT_MENU_FADE_MS ) );
m_quitMenuOverlay->draw();
}