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 keys fade in, lit in the side's steel

Olcay Seygan398ed7bdf770
diff --git a/CHANGELOG.md b/CHANGELOG.md
index bc196f426..cea0f6582 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 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.
+- 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.
## Placing buildings
diff --git a/GeneralsMD/Code/Data/Window/Html/QuitMenu.html b/GeneralsMD/Code/Data/Window/Html/QuitMenu.html
index 13d977c17..d9172529d 100644
--- a/GeneralsMD/Code/Data/Window/Html/QuitMenu.html
+++ b/GeneralsMD/Code/Data/Window/Html/QuitMenu.html
@@ -12,10 +12,11 @@
{{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",
- or while the menu comes up "waiting" before the key comes in and
- "flash" for a moment as it does
+ or "flash" for a moment as the key comes in
+ {{frame}} "bare" when the page is drawn for one key alone, fading in over the
+ menu: everything but the keys stands down
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
+ menu comes up, and each key after it. Without this page the menu draws as EA
drew it.
-->
<html>
@@ -52,8 +53,11 @@
.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; }
+ /* a key coming in is lit bright in its side's own steel */
+ .key.flash { background: linear-gradient(to bottom, #f4f8fb, #9aa3ad); border-color: #ffffff; color: #ffffff; }
+ .china .key.flash { background: linear-gradient(to bottom, #ffd6c8, #c06a52); border-color: #ffe6dc; }
+ .gla .key.flash { background: linear-gradient(to bottom, #fff4c8, #b8ab6e); border-color: #fff8dc; }
+ .bare .dim, .bare .plate, .bare .well { display: none; }
/* the battlefield behind the menu, dimmed while the game waits on it */
.dim { background-color: rgba(0, 0, 0, 0.65); }
@@ -61,7 +65,7 @@
</style>
</head>
<body>
-<div class="{{side}}">
+<div class="{{side}} {{frame}}">
<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>
diff --git a/GeneralsMD/Code/GameEngine/Include/GameClient/InGameUI.h b/GeneralsMD/Code/GameEngine/Include/GameClient/InGameUI.h
index 757e94f5b..e53bd191b 100644
--- a/GeneralsMD/Code/GameEngine/Include/GameClient/InGameUI.h
+++ b/GeneralsMD/Code/GameEngine/Include/GameClient/InGameUI.h
@@ -1256,6 +1256,7 @@ protected:
Bool m_promotionPageLoaded;
std::string m_promotionPage;
HtmlOverlay * m_quitMenuOverlay;
+ std::vector< HtmlOverlay * > m_quitMenuKeyOverlays; ///< one for each of the menu's keys, each fading in on its own
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
diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/InGameUI.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/InGameUI.cpp
index d4469a424..d87d05311 100644
--- a/GeneralsMD/Code/GameEngine/Source/GameClient/InGameUI.cpp
+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/InGameUI.cpp
@@ -1367,6 +1367,9 @@ InGameUI::~InGameUI()
m_promotionFrontOverlay = NULL;
delete m_quitMenuOverlay;
m_quitMenuOverlay = NULL;
+ for( size_t key = 0; key < m_quitMenuKeyOverlays.size(); key++ )
+ delete m_quitMenuKeyOverlays[ key ];
+ m_quitMenuKeyOverlays.clear();
for( Int grid = 0; grid < CELL_GRID_COUNT; grid++ )
{
delete m_cellFrontOverlay[ grid ];
@@ -11763,13 +11766,15 @@ enum
};
/** 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. */
+ * then the keys come in top to bottom, each fading in from nothing lit bright in the side's steel,
+ * 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
+ QUIT_MENU_KEY_FADE_MS = 150, ///< a key from nothing to whole
+ QUIT_MENU_KEY_FLASH_MS = 220 ///< how long a key stays lit when it comes in, its fade included
};
/** A window of the same layout as `parent`, by its name there. */
@@ -11878,7 +11883,14 @@ void InGameUI::drawQuitMenuPage( GameWindow *parent )
putPageRect( values, "well", well, TRUE );
const Int openMs = (Int)( timeGetTime() - m_quitMenuOpenedMs );
+ 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 having
+ // no opacity of its own for one element; the keys already whole are on the menu's page
+ struct FadingKey { HtmlValues entry; Int alpha; };
+ std::vector< FadingKey > fading;
std::vector< HtmlValues > &keys = lists[ "keys" ];
+ Int shown = 0;
for( Int key = 0; key < (Int)ARRAY_SIZE( QUIT_MENU_KEYS ); key++ )
{
GameWindow *button = quitMenuWindow( parent, QUIT_MENU_KEYS[ key ] );
@@ -11886,22 +11898,40 @@ void InGameUI::drawQuitMenuPage( GameWindow *parent )
if( !controlBarWindowRect( button, rect ) )
continue;
+ const Int keyMs = openMs - QUIT_MENU_KEY_FIRST_MS - shown * QUIT_MENU_KEY_STEP_MS;
+ shown++;
+ if( keyMs < 0 )
+ continue;
+
HtmlValues entry;
putPageRect( entry, "key", rect, TRUE );
- 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[ "state" ] = keyMs < QUIT_MENU_KEY_FLASH_MS ? "flash" : controlBarWindowState( button );
entry[ "label" ] = WideCharStringToMultiByte( button->winGetInstanceData()->getText().str() );
- keys.push_back( entry );
+ if( keyMs < QUIT_MENU_KEY_FADE_MS )
+ {
+ FadingKey fade;
+ fade.entry = entry;
+ fade.alpha = keyMs * pageAlpha / QUIT_MENU_KEY_FADE_MS;
+ fading.push_back( fade );
+ }
+ else
+ 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->setAlpha( pageAlpha );
m_quitMenuOverlay->draw();
+
+ values[ "frame" ] = "bare";
+ for( size_t each = 0; each < fading.size(); each++ )
+ {
+ if( m_quitMenuKeyOverlays.size() <= each )
+ m_quitMenuKeyOverlays.push_back( new HtmlOverlay( m_superweaponNormalFont ) );
+ keys.assign( 1, fading[ each ].entry );
+ m_quitMenuKeyOverlays[ each ]->setPage( HtmlTemplate_expand( m_quitMenuPage, values, lists, lookupGameText ) );
+ m_quitMenuKeyOverlays[ each ]->setAlpha( fading[ each ].alpha );
+ m_quitMenuKeyOverlays[ each ]->draw();
+ }
}
//-------------------------------------------------------------------------------------------------