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(gameclient): compact esc menu without the logo, promotions under the strip

Olcay Seygan64bd6c2cd428
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 1fcaf1626..59122e7e5 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -510,7 +510,7 @@ found and fixed — EA's own, not port damage.**
- Every player in the match hangs from the top edge of the screen, your own team on the left. Each one is their general's flag in a hairline frame with the player's colour along its top, and a band of colour under it for their superweapons: green once one can fire, blue while it is still charging, grey when they have none. A team hangs in a plate of the command bar's steel, grey, red or sand for your side, with its name under the flags, Team 1 to Team 4 in a four-team game. The match clock is on Tab, so the strip is only flags. A free for all is all eight flags in one row, which fits with room to spare. The column of superweapon countdowns that used to sit in the top right is gone while you play; the full list with the seconds is on Tab.
- 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 with sunk keys that light gold under the pointer and press in when clicked. 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. The promotion screen opens across the middle of the screen, just under the players along the top edge, rather than over them. 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 960d6fe5a..656dc20c6 100644
--- a/GeneralsMD/Code/Data/Window/Html/QuitMenu.html
+++ b/GeneralsMD/Code/Data/Window/Html/QuitMenu.html
@@ -1,12 +1,14 @@
<!DOCTYPE html>
<!--
- The Esc menu in the command bar's steel, drawn as the menu's own plate. Its keys are the menu's
- buttons, drawing nothing now and still taking their clicks; the logo over them is the menu's own
- picture and draws over this page. Same materials as Window/Html/Promotion.html.
+ The Esc menu in the command bar's steel, drawn as the menu's own plate in the middle of the
+ screen. Its keys are the menu's buttons, drawing nothing now and still taking their clicks, laid
+ out again every frame in a stack; the logo is stood down. Same materials as
+ Window/Html/Promotion.html.
The game fills in, every frame the menu is up (InGameUI::drawQuitMenuPage):
{{side}} "america", "china" or "gla"
{{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
@@ -28,6 +30,13 @@
.china .plate { background: linear-gradient(to bottom, #c06a52, #7a3120 12%, #3f160f); border-top-color: #f0b8a4; border-left-color: #d58a70; }
.gla .plate { background: linear-gradient(to bottom, #b8ab6e, #766a3a 12%, #3c3519); border-top-color: #ebe2b4; border-left-color: #cabe86; }
+ /* the keys stand in a well sunk two pixels, dark along the top and left and lit along the bottom
+ and right */
+ .well { margin: -2px 0 0 -2px; border: 2px solid #06090b; border-bottom-color: #b4bec8; border-right-color: #b4bec8;
+ background-color: #3a414a; }
+ .china .well { border-bottom-color: #d98a72; border-right-color: #d98a72; background-color: #45190f; }
+ .gla .well { border-bottom-color: #cbbf82; border-right-color: #cbbf82; background-color: #423a1c; }
+
/* a key sunk in the steel, lit steel with a gold rim under the pointer, pressed in while held, and
dim when it does nothing */
.key { border: 1px solid #06090b; border-bottom-color: #9aa4ae; border-right-color: #9aa4ae; background-color: rgba(4, 8, 10, 0.9);
@@ -45,6 +54,7 @@
<body>
<div class="{{side}}">
<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>
</div>
</body>
diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/InGameUI.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/InGameUI.cpp
index b5185b1d4..39e3668ee 100644
--- a/GeneralsMD/Code/GameEngine/Source/GameClient/InGameUI.cpp
+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/InGameUI.cpp
@@ -11365,7 +11365,8 @@ enum
PROMOTION_TITLE = 14, ///< the rank's name's line, the points beside it
PROMOTION_BAR = 7, ///< the experience bar under it
PROMOTION_BAR_GAP = 3,
- PROMOTION_HEADING = 12 ///< a row's heading over its first button
+ PROMOTION_HEADING = 12, ///< a row's heading over its first button
+ PROMOTION_TOP = 44 ///< clear of the players' strip, a team's name under its flags included
};
/** One place in the screen's grids, screen pixels, and the promotion's button standing in it: NULL
@@ -11402,8 +11403,8 @@ static void placePromotionWindow( const std::string &name, Int x, Int y, Int wid
* row a grid five places wide in command button cells with a hair of steel between them, the way
* the command bar's grid is, in a well of its own with its heading, a plate's margin between one
* well and the next; the rank's name and the points on one line with the bar under them, and the
- * close button in the last row's fifth place, which no side fills. Centred at the top of the screen
- * where the layout hung it. `layout` gets every place, filled or not, the headings and the wells,
+ * close button in the last row's fifth place, which no side fills. Centred across the screen, its
+ * top under the players' strip. `layout` gets every place, filled or not, the headings and the wells,
* in screen pixels. */
//-------------------------------------------------------------------------------------------------
static void layoutPromotionScreen( GameWindow *parent, PromotionLayout &layout )
@@ -11428,10 +11429,10 @@ static void layoutPromotionScreen( GameWindow *parent, PromotionLayout &layout )
placePromotionWindow( "ProgressBarExperience", margin, margin + titleHeight + Page::px( PROMOTION_BAR_GAP, scale ),
width - 3 * margin - pointsWidth, Page::px( PROMOTION_BAR, scale ) );
- // the parent goes first, so the places can be handed out in screen pixels
- Int parentX = 0, parentY = 0;
- parent->winGetPosition( &parentX, &parentY );
- parentX = ( TheDisplay->getWidth() - width ) / 2;
+ // the parent goes first, across the middle of the screen just under the players hanging from its
+ // top edge, so the places can be handed out in screen pixels
+ const Int parentX = ( TheDisplay->getWidth() - width ) / 2;
+ const Int parentY = Page::px( PROMOTION_TOP, scale );
parent->winSetPosition( parentX, parentY );
// each row's well stands a margin under the one before, the first a margin under the bar and the
@@ -11643,6 +11644,18 @@ static const char *const QUIT_MENU_PAGE = "Window\\Html\\QuitMenu.html";
* and replays, all but the first. */
static const char *const QUIT_MENU_KEYS[] = { "ButtonSaveLoad", "ButtonOptions", "ButtonRestart", "ButtonExit", "ButtonReturn" };
+/** The game's logo over the keys, one name in each layout; the page stands it down. */
+static const char *const QUIT_MENU_LOGOS[] = { "WinLoad", "WinLogo" };
+
+/** The menu's measures, 800x600 pixels. */
+enum
+{
+ QUIT_MENU_KEY_WIDTH = 176,
+ QUIT_MENU_KEY_HEIGHT = 24,
+ QUIT_MENU_KEY_GAP = 6,
+ QUIT_MENU_MARGIN = 12 ///< the plate round the keys' well
+};
+
/** A window of the same layout as `parent`, by its name there. */
static GameWindow *quitMenuWindow( GameWindow *parent, const char *name )
{
@@ -11675,6 +11688,53 @@ void InGameUI::themeQuitMenu( GameWindow *parent )
}
}
+//-------------------------------------------------------------------------------------------------
+/** The Esc menu laid out compact every frame it draws, before its keys draw: the logo stood down,
+ * the keys the layout shows stacked in a well a plate's margin in from the edge, the plate only as
+ * big as that and in the middle of the screen. `well` gets the well, in screen pixels. */
+//-------------------------------------------------------------------------------------------------
+static void layoutQuitMenu( GameWindow *parent, IRegion2D &well )
+{
+ const Real scale = ControlBarUniformScale();
+ const Int keyWidth = REAL_TO_INT( QUIT_MENU_KEY_WIDTH * scale );
+ const Int keyHeight = REAL_TO_INT( QUIT_MENU_KEY_HEIGHT * scale );
+ const Int gap = REAL_TO_INT( QUIT_MENU_KEY_GAP * scale );
+ const Int margin = REAL_TO_INT( QUIT_MENU_MARGIN * scale );
+
+ for( Int logo = 0; logo < (Int)ARRAY_SIZE( QUIT_MENU_LOGOS ); logo++ )
+ {
+ GameWindow *window = quitMenuWindow( parent, QUIT_MENU_LOGOS[ logo ] );
+ if( window && !window->winIsHidden() )
+ window->winHide( TRUE );
+ }
+
+ std::vector< GameWindow * > shown;
+ for( Int key = 0; key < (Int)ARRAY_SIZE( QUIT_MENU_KEYS ); key++ )
+ {
+ GameWindow *button = quitMenuWindow( parent, QUIT_MENU_KEYS[ key ] );
+ if( button && !button->winIsHidden() )
+ shown.push_back( button );
+ }
+
+ const Int keysHeight = (Int)shown.size() * ( keyHeight + gap ) - gap;
+ const Int width = keyWidth + 4 * margin;
+ const Int height = keysHeight + 4 * margin;
+ const Int parentX = ( TheDisplay->getWidth() - width ) / 2;
+ const Int parentY = ( TheDisplay->getHeight() - height ) / 2;
+ parent->winSetPosition( parentX, parentY );
+ parent->winSetSize( width, height );
+ for( size_t key = 0; key < shown.size(); key++ )
+ {
+ shown[ key ]->winSetPosition( 2 * margin, 2 * margin + (Int)key * ( keyHeight + gap ) );
+ shown[ key ]->winSetSize( keyWidth, keyHeight );
+ }
+
+ well.lo.x = parentX + margin;
+ well.lo.y = parentY + margin;
+ well.hi.x = parentX + width - margin;
+ well.hi.y = parentY + height - margin;
+}
+
//-------------------------------------------------------------------------------------------------
/** The Esc menu from Window/Html/QuitMenu.html, drawn as the menu's plate: every key where its
* button stands, with the button's own label, so the restart key reads Surrender or Restart Mission
@@ -11685,11 +11745,15 @@ void InGameUI::drawQuitMenuPage( GameWindow *parent )
if( m_quitMenuOverlay == NULL )
m_quitMenuOverlay = new HtmlOverlay( m_superweaponNormalFont );
+ IRegion2D well;
+ layoutQuitMenu( parent, well );
+
HtmlValues values;
HtmlLists lists;
values[ "side" ] = spectatorSide();
IRegion2D panel;
putPageRect( values, "panel", panel, controlBarWindowRect( parent, panel ) );
+ putPageRect( values, "well", well, TRUE );
std::vector< HtmlValues > &keys = lists[ "keys" ];
for( Int key = 0; key < (Int)ARRAY_SIZE( QUIT_MENU_KEYS ); key++ )