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.

fix(gameclient): control bar minimise, and the keyboard options screen

Olcay Seygane2dfc6645610
diff --git a/CHANGELOG.md b/CHANGELOG.md
index f632162b8..54b7b2985 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -445,8 +445,10 @@ found and fixed — EA's own, not port damage.**
- On a widescreen monitor the command bar is three pieces instead of one stretched strip. It was drawn for a 4:3 screen and every measurement in it is multiplied by your resolution separately across and down, so at 16:9 the whole thing came out a third wider than it is tall: square build pictures as rectangles, and one slab of metal across the entire bottom edge. The radar now sits hard in the left corner, the build grid in the middle, the selected unit's panel hard in the right corner, each at the size it was drawn at, and the battlefield shows through the two gaps that opens. At 4:3 the three pieces meet and it is the bar it has always been. The three pieces reach the screen: the paintings stop a pixel or two inside their own edges, which left a hairline of ground down both sides and along the bottom, and anything that close to an edge is now that edge. The American middle piece stands on the bottom edge like the other two sides' do, instead of hanging ten units high with a band of battlefield under the build grid, your money now sits in the middle of its readout instead of riding the top rim of it, and the build buttons are centred in the panel they are drawn on instead of pushing against its left edge with a strip of empty metal on the right. The stray pixels along the right-hand edges of the pieces are gone: a one-pixel light line down the side of the middle piece, and a lit speck sitting in the battlefield next to the bottom corner of the Chinese radar. Both were the same thing. The bar's artwork was being rescaled as it went to the graphics card, which left the last column of each picture holding a mirrored copy of it, and the last column of pixels on screen drew from there.
- The rest of the interface is drawn at the command bar's size, not the screen's width. The queue strip, the superweapon countdowns, the generals' powers bar down the right edge and the rank screen were each measured against how wide your monitor is, and the bar they sit beside is measured against the smaller of the two dimensions - so on a 16:9 screen a queue picture came out a third bigger than the build button it is a picture of, and the power slots were oblong where they were drawn square. One size for all of it now, and it is the bar's own.
- The writing on a build button keeps its size against the button. The hotkey letter, the price, the build time and the queue count were sized off how wide your monitor is while the bar they sit on is sized off the smaller of its width and its height, so the wider the screen the further the lettering grew away from the cameo underneath it. One size for both now, and it is the bar's.
-- Every key the game answers to is in the options screen, and you can move any of them. The keyboard screen has been in the game since 2003 - the code for it, anyway; the layout it needed was never shipped in any data file, which is why the button that opens it was authored hidden and parked off the right edge, and why its Assign button had an empty body with a comment where the work should be. It is built now: every command in one list with the key it answers to beside it, click a row and press the key you want. A key can only mean one thing, so whatever was on it gives it up. Your changes go in `Keybinds.ini` next to `Options.ini` and hold only what you moved, so a patch that adds commands does not wipe them - and none of it is in the multiplayer checksum, so two players in one match can hold completely different keyboards.
-- Minimising the command bar sends the radar and the whole middle off the bottom of the screen, and they slide back up when you bring them back. The old minimise dropped the bar a tenth of the screen and left a strip of metal, a readable money box and the top of the radar dish lying along the bottom edge, which is neither the bar nor out of the way. The selection panel stays where it is, because that is where the button that puts the rest back lives.
+- Every key the game answers to is in the options screen, and you can move any of them. The keyboard screen has been in the game since 2003 - the code for it, anyway; the layout it needed was never shipped in any data file, which is why the button that opens it was authored hidden and parked off the right edge, and why its Assign button had an empty body with a comment where the work should be. It is built now: every command in one list with the key it answers to beside it, click a row and press the key you want. A key can only mean one thing, so whatever was on it gives it up. Your changes go in `Keybinds.ini` next to `Options.ini` and hold only what you moved, so a patch that adds commands does not wipe them - and none of it is in the multiplayer checksum, so two players in one match can hold completely different keyboards. It opens over a running match and closes back onto the options screen you opened it from: it used to be filed with the menus the shell keeps, so opening it mid-match put the skirmish lobby back on screen and cancel left the lobby, the pause menu and the options panel stacked on top of the battlefield. Its button on the options screen wears the game's own lettering instead of the one face in that layout that was still Times New Roman.
+- Minimising the command bar sends all three panels down, and they slide back up when you bring them back. The old minimise dropped the bar a tenth of the screen and left a strip of metal, a readable money box and the top of the radar dish lying along the bottom edge, which is neither the bar nor out of the way. The radar and the middle go off the screen entirely; the selection panel stops with the row its minimise tab is in standing on the bottom corner, so what you click to bring the bar back is that tab with its own artwork behind it, not a button floating over the battlefield. That tab sits where the painting puts it now: every faction's panel paints its own minimise tab, arrow and all, and none of them paints it where the 2003 layout put the button, so the button was drawing a second tab beside the painted one - two arrows, up to nineteen pixels apart.
+- Two stray letters, an "S" and an "M", no longer appear over the battlefield beside the selection panel the first time you minimise the bar and bring it back. They are the labels on the two unused minimise buttons the 2003 layout ships hidden; minimising hid them a second time and un-hid them on the way back.
+- The markings on a build button - the shortcut letters, the price, the build time, the queue count - are set bold. At seven points against a busy cameo the light weight read as part of the picture.
- Menu panels slide in at the same speed whatever your monitor is. They travel the width of the
screen but moved at a fixed forty pixels a step, so the wider the screen the longer every
transition took: twenty steps at 800 wide, sixty-four at 2560.
diff --git a/GeneralsMD/Code/CMakeLists.txt b/GeneralsMD/Code/CMakeLists.txt
index a03295585..35a431598 100644
--- a/GeneralsMD/Code/CMakeLists.txt
+++ b/GeneralsMD/Code/CMakeLists.txt
@@ -594,9 +594,11 @@ set_target_properties(test_gameengine PROPERTIES CXX_STANDARD 17)
# GameLogic or Common has gone back to calling sinf().
# fxlist_reborn_ini_parses_and_keeps_its_light runs the fork's own FXList file through the real
# INI parser, so it needs the tracked master rather than whatever sits in Run/.
+# the_options_menu_buttons_all_wear_one_font reads the tracked layout master, not Run/'s copy.
target_compile_definitions(test_gameengine PRIVATE
GAMEENGINE_SOURCE_DIR="${CMAKE_CURRENT_SOURCE_DIR}/GameEngine"
- FXLIST_REBORN_INI="${CMAKE_CURRENT_SOURCE_DIR}/Data/INI/FXListReborn.ini")
+ FXLIST_REBORN_INI="${CMAKE_CURRENT_SOURCE_DIR}/Data/INI/FXListReborn.ini"
+ OPTIONS_MENU_WND="${CMAKE_CURRENT_SOURCE_DIR}/Data/Window/Menus/OptionsMenu.wnd")
# The three hand-written self-checks predate the harness; run them from ctest
# too so one command covers everything.
diff --git a/GeneralsMD/Code/Data/Window/Menus/OptionsMenu.wnd b/GeneralsMD/Code/Data/Window/Menus/OptionsMenu.wnd
index 1c176aae6..745fa1ebc 100644
--- a/GeneralsMD/Code/Data/Window/Menus/OptionsMenu.wnd
+++ b/GeneralsMD/Code/Data/Window/Menus/OptionsMenu.wnd
@@ -546,7 +546,7 @@ WINDOW
INPUTCALLBACK = "[None]";
TOOLTIPCALLBACK = "[None]";
DRAWCALLBACK = "[None]";
- FONT = NAME: "Times New Roman", SIZE: 14, BOLD: 0;
+ FONT = NAME: "Generals", SIZE: 15, BOLD: 0;
HEADERTEMPLATE = "[NONE]";
TOOLTIPDELAY = -1;
TEXT = "GUI:KeyboardOptions";
diff --git a/GeneralsMD/Code/GameEngine/Include/GameClient/ControlBar.h b/GeneralsMD/Code/GameEngine/Include/GameClient/ControlBar.h
index c8b9c4501..bed73a36d 100644
--- a/GeneralsMD/Code/GameEngine/Include/GameClient/ControlBar.h
+++ b/GeneralsMD/Code/GameEngine/Include/GameClient/ControlBar.h
@@ -1060,6 +1060,7 @@ protected:
Bool m_panelHidden[ CB_PANEL_COUNT ]; ///< minimised: the radar and the middle stand down
Real m_panelSlide[ CB_PANEL_COUNT ]; ///< 0 home, 1 clear of the bottom edge
Real m_panelSlideTo[ CB_PANEL_COUNT ]; ///< where each one is heading
+ Int m_panelDropCap[ CB_PANEL_COUNT ]; ///< pixels a panel may travel; 0 = all the way off
UnsignedInt m_panelSlideMs; ///< wall clock of the last slide step
void updatePanelSlide( void ); ///< step the slide and put the windows where it says
@@ -1318,6 +1319,7 @@ struct ControlBarPlate
Int readoutShiftY; ///< design units the money readout moves to sit in this art's box
Int gridShiftX; ///< design units the command grid moves to centre in this art's field
Int artW, artH; ///< texels of painting in the targa; the rest is power-of-two padding
+ IRegion2D minTab; ///< the minimise tab this art paints, in design units; ButtonLarge takes it
};
/** The plate 'panel' wears while the bar is dressed in 'side'. A general's scheme names a side
diff --git a/GeneralsMD/Code/GameEngine/Include/GameClient/GUICallbacks.h b/GeneralsMD/Code/GameEngine/Include/GameClient/GUICallbacks.h
index 8d3bfd23f..14863fcb2 100644
--- a/GeneralsMD/Code/GameEngine/Include/GameClient/GUICallbacks.h
+++ b/GeneralsMD/Code/GameEngine/Include/GameClient/GUICallbacks.h
@@ -133,6 +133,15 @@ extern void KeyboardOptionsMenuUpdate( WindowLayout *layout, void *userData );
extern void KeyboardOptionsMenuShutdown( WindowLayout *layout, void *userData );
extern WindowMsgHandledType KeyboardOptionsMenuSystem( GameWindow *window, UnsignedInt msg, WindowMsgData mData1, WindowMsgData mData2 );
extern WindowMsgHandledType KeyboardOptionsMenuInput( GameWindow *window, UnsignedInt msg, WindowMsgData mData1, WindowMsgData mData2 );
+//
+// The keyboard screen is a layout of its own laid over whatever is underneath, the way the options
+// menu is, and not a shell screen. Pushing it on the shell stack shut down whatever screen the
+// shell was parked on, so opening it from a running game brought the skirmish lobby back up over
+// the battlefield and left the quit menu and the options menu drawn on top of it.
+//
+extern void OpenKeyboardOptionsMenu( void );
+extern void CloseKeyboardOptionsMenu( void );
+extern Bool IsKeyboardOptionsMenuOpen( void );
// Lan Lobby Menu ----------------------------------------------------------------------------------
extern void LanLobbyMenuInit( WindowLayout *layout, void *userData );
diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/ControlBar/ControlBar.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/ControlBar/ControlBar.cpp
index 48a519d9d..46cd44c23 100644
--- a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/ControlBar/ControlBar.cpp
+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/ControlBar/ControlBar.cpp
@@ -1115,6 +1115,7 @@ ControlBar::ControlBar( void )
m_panelHidden[ i ] = FALSE;
m_panelSlide[ i ] = 0.0f;
m_panelSlideTo[ i ] = 0.0f;
+ m_panelDropCap[ i ] = 0;
}
m_panelSlideMs = 0;
m_panelOrigin.x = m_panelOrigin.y = 0;
@@ -1550,6 +1551,14 @@ struct ControlBarPlateSet
ControlBarPlate plate[ ControlBar::CB_PANEL_COUNT ];
};
+//
+// Every one of the nine plates paints its own minimise tab, arrow and all, because each is that
+// side's own composition rather than a cut of the shipped bar - and none of them paints it where
+// ControlBar.wnd puts ButtonLarge (666,445 to 714,473). Left alone the button drew a second tab
+// beside the painted one, up to nineteen design units across and twelve down at 1920x1080. The
+// rectangle below is the tab as the art paints it, measured off the targa: the button takes it, and
+// the image it draws lands on the painting instead of next to it.
+//
static const ControlBarPlateSet thePlateSets[] =
{
{ "America",
@@ -1567,21 +1576,24 @@ static const ControlBarPlateSet thePlateSets[] =
column overhangs the left bezel by a unit and a half while eleven units stand empty
on the right. Six to the right centres the block in the field. */
{ "RebornBarAmericaCenter.tga", { { 180, 429 }, { 623, 599 } }, 10, 6, 706, 271 },
- { "RebornBarAmericaRight.tga", { { 610, 433 }, { 800, 599 } }, 0, 0, 304, 268 },
+ { "RebornBarAmericaRight.tga", { { 610, 433 }, { 800, 599 } }, 0, 0, 304, 268,
+ { { 648, 434 }, { 717, 460 } } },
}
},
{ "China",
{
{ "RebornBarChinaLeft.tga", { { 1, 417 }, { 196, 598 } }, 0, 0, 315, 295 },
{ "RebornBarChinaCenter.tga", { { 176, 433 }, { 617, 597 } }, 0, 0, 718, 269 },
- { "RebornBarChinaRight.tga", { { 611, 424 }, { 798, 598 } }, 0, 0, 303, 284 },
+ { "RebornBarChinaRight.tga", { { 611, 424 }, { 798, 598 } }, 0, 0, 303, 284,
+ { { 639, 430 }, { 686, 463 } } },
}
},
{ "GLA",
{
{ "RebornBarGLALeft.tga", { { 0, 416 }, { 215, 599 } }, 0, 0, 345, 295 },
{ "RebornBarGLACenter.tga", { { 168, 437 }, { 617, 599 } }, 0, 0, 720, 261 },
- { "RebornBarGLARight.tga", { { 612, 423 }, { 799, 599 } }, 0, 0, 300, 284 },
+ { "RebornBarGLARight.tga", { { 612, 423 }, { 799, 599 } }, 0, 0, 300, 284,
+ { { 631, 428 }, { 705, 465 } } },
}
},
};
@@ -1678,6 +1690,19 @@ void ControlBar::placeInPanel( GameWindow *win, Int panel,
if( plate && strcmp( shortName, "MoneyDisplay" ) == 0 )
newY += REAL_TO_INT_FLOOR( plate->readoutShiftY * s );
+ //
+ // The minimise button is not where the .wnd says either: every plate paints its own tab for it,
+ // and the button takes that rectangle rather than the authored one. Otherwise it draws its own
+ // tab beside the painted one and you get two arrows.
+ //
+ if( plate && plate->minTab.width() > 0 && strcmp( shortName, "ButtonLarge" ) == 0 )
+ {
+ newX = REAL_TO_INT_FLOOR( originX + plate->minTab.lo.x * s );
+ newY = REAL_TO_INT_FLOOR( dispH - ( CONTROL_BAR_DESIGN_H - plate->minTab.lo.y ) * s );
+ newW = REAL_TO_INT_CEIL( plate->minTab.width() * s );
+ newH = REAL_TO_INT_CEIL( plate->minTab.height() * s );
+ }
+
// the grid shift starts at CenterBackground and is inherited by everything under it
Int childShiftX = shiftX;
if( strcmp( shortName, "CenterBackground" ) == 0 )
@@ -1741,8 +1766,16 @@ Int ControlBar::getPanelSlideOffset( Int panel ) const
if( m_panelSlide[ panel ] <= 0.0f )
return 0;
- // far enough that the top edge of the frame is off the bottom of the screen, so everything is
- const Real drop = (Real)( TheDisplay->getHeight() - m_panelOrigin.y );
+ //
+ // Far enough that the top edge of the frame is off the bottom of the screen, so everything is -
+ // except a panel with a cap, which travels only as far as the cap says and keeps the strip above
+ // it on screen. The selection panel has one: it carries the button that puts the bar back, and
+ // it stops with that button's row standing on the bottom edge. It takes the same quarter of a
+ // second to travel the shorter distance, so all three still move as one.
+ //
+ const Real drop = ( m_panelDropCap[ panel ] > 0 )
+ ? (Real)m_panelDropCap[ panel ]
+ : (Real)( TheDisplay->getHeight() - m_panelOrigin.y );
return REAL_TO_INT_FLOOR( m_panelSlide[ panel ] * drop );
}
@@ -1781,11 +1814,15 @@ void ControlBar::applyPanelSlide( void )
// Clear of the bottom edge and staying there: stop drawing it at all. Only what we hid do
// we ever un-hide - the context system hides windows of its own all the time (the unused
// minimise buttons, a beacon pane, an empty portrait) and a blanket winHide(FALSE) over the
- // panel put every one of them back on screen.
+ // panel put every one of them back on screen. Which is why a window that was already hidden
+ // when the panel went down is not counted as ours: hiding it changes nothing and remembering
+ // it puts it on screen the first time the bar is minimised and brought back. ControlBar.wnd
+ // authors ButtonSmall and ButtonMedium hidden, and that is where the stray "S" and "M" over
+ // the battlefield came from.
//
if( m_panelHidden[ panel ] )
{
- if( !place.weHid )
+ if( !place.weHid && !child->winIsHidden() )
{
child->winHide( TRUE );
place.weHid = TRUE;
@@ -1835,7 +1872,8 @@ void ControlBar::updatePanelSlide( void )
if( m_panelSlide[ p ] >= m_panelSlideTo[ p ] )
{
m_panelSlide[ p ] = m_panelSlideTo[ p ];
- m_panelHidden[ p ] = TRUE; // arrived off screen
+ // arrived - off screen, unless the cap kept a strip of it on
+ m_panelHidden[ p ] = ( m_panelDropCap[ p ] <= 0 );
}
}
else if( m_panelSlide[ p ] > m_panelSlideTo[ p ] )
@@ -1868,7 +1906,7 @@ void ControlBar::showPanel( Int panel, Bool show, Bool immediate )
if( immediate )
{
m_panelSlide[ panel ] = m_panelSlideTo[ panel ];
- m_panelHidden[ panel ] = !show;
+ m_panelHidden[ panel ] = !show && ( m_panelDropCap[ panel ] <= 0 );
}
m_panelSlideMs = timeGetTime();
@@ -1936,6 +1974,26 @@ void ControlBar::layoutPanels( void )
m_panelOrigin.x = 0;
m_panelOrigin.y = parentTop;
+ //
+ // Two of the three panels go all the way off the bottom. The selection panel stops with the row
+ // its minimise tab is in standing on the bottom edge: the button that puts the bar back is in
+ // that row, and so is the plate that paints it, so the tab a minimised player clicks is real
+ // artwork and not a button floating over the battlefield.
+ //
+ for( p = 0; p < CB_PANEL_COUNT; p++ )
+ m_panelDropCap[ p ] = 0;
+ if( m_controlBarSchemeManager )
+ {
+ const ControlBarPlate *rightPlate =
+ ControlBarPlateForSide( m_controlBarSchemeManager->getCurrentSide(), CB_PANEL_RIGHT );
+ if( rightPlate == NULL )
+ rightPlate = ControlBarPlateForSide( m_controlBarSchemeManager->getCurrentArtTwinSide(),
+ CB_PANEL_RIGHT );
+ if( rightPlate && rightPlate->minTab.height() > 0 )
+ m_panelDropCap[ CB_PANEL_RIGHT ] =
+ REAL_TO_INT_FLOOR( ( CONTROL_BAR_DESIGN_H - rightPlate->minTab.hi.y ) * s );
+ }
+
for( GameWindow *child = parent->winGetChild(); child; child = child->winGetNext() )
{
// the nameless panes go by where they were authored, so ask the cache before it is rewritten
@@ -5017,9 +5075,10 @@ void ControlBar::setDefaultControlBarConfig( void )
m_contextParent[ CP_MASTER ]->winSetPosition(m_defaultControlBarPosition.x, m_defaultControlBarPosition.y);
m_contextParent[ CP_MASTER ]->winHide(FALSE);
- // the two panels the minimised bar stands down
+ // the three panels the minimised bar stands down
showPanel( CB_PANEL_LEFT, TRUE );
showPanel( CB_PANEL_CENTER, TRUE );
+ showPanel( CB_PANEL_RIGHT, TRUE );
repopulateBuildTooltipLayout();
setUpDownImages();
@@ -5044,11 +5103,11 @@ void ControlBar::setLowControlBarConfig( void )
m_currentControlBarStage = CONTROL_BAR_STAGE_LOW;
//
- // Minimised is the radar and the middle gone, not the whole bar slid down a tenth of the screen
- // with its top edge still showing. Sliding it left a strip of metal, a readable money box and
- // the top of the radar dish lying along the bottom of the picture, which is neither the bar nor
- // out of the way. The selection side stays where it is: it is where the button that puts the
- // rest back lives, and it is the panel a minimising player is keeping.
+ // Minimised is all three panels gone, not the whole bar slid down a tenth of the screen with its
+ // top edge still showing. Sliding it left a strip of metal, a readable money box and the top of
+ // the radar dish lying along the bottom of the picture, which is neither the bar nor out of the
+ // way. The one thing that stays is the button that puts it all back: applyPanelSlide rides it
+ // down with the selection panel and stops it on the bottom edge of the screen.
//
TheTacticalView->setHeight((Int)(TheDisplay->getHeight()));
m_contextParent[ CP_MASTER ]->winSetPosition(m_defaultControlBarPosition.x, m_defaultControlBarPosition.y);
@@ -5056,6 +5115,7 @@ void ControlBar::setLowControlBarConfig( void )
showPanel( CB_PANEL_LEFT, FALSE );
showPanel( CB_PANEL_CENTER, FALSE );
+ showPanel( CB_PANEL_RIGHT, FALSE );
setUpDownImages();
diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/KeyboardOptionsMenu.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/KeyboardOptionsMenu.cpp
index 153bdef84..4a04f8bb1 100644
--- a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/KeyboardOptionsMenu.cpp
+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/KeyboardOptionsMenu.cpp
@@ -61,6 +61,7 @@
#include "GameClient/Shell.h"
#include "GameClient/KeyDefs.h"
#include "GameClient/GameWindowManager.h"
+#include "GameClient/GUICallbacks.h"
#include "GameClient/Mouse.h"
#include "GameClient/GameText.h"
#include "GameClient/MetaEvent.h"
@@ -118,6 +119,15 @@ static MetaMapRec *theSelectedRec = NULL;
static MappableKeyType thePendingKey = MK_NONE;
static MappableKeyModState thePendingMods = NONE;
+//
+// The screen is one layout laid over whatever is underneath. It used to be a shell screen, pushed
+// with TheShell->push, and the shell stack is not somewhere an in-game menu can go: pushing shut
+// down the screen the shell was parked on and popping brought it back, so opening this from a
+// running game put the skirmish lobby back on screen with the quit menu and the options menu still
+// drawn over it.
+//
+static WindowLayout *theKeyboardOptionsLayout = NULL;
+
static UnicodeString bindingText( const MetaMapRec *rec );
static UnicodeString bindingTextFor( MappableKeyType key, MappableKeyModState mods );
static Bool catchBindingKey( WindowMsgData mData1, WindowMsgData mData2 );
@@ -531,6 +541,67 @@ void doKeyDown(EntryData *e, UnicodeString mod )
}
+//-------------------------------------------------------------------------------------------------
+Bool IsKeyboardOptionsMenuOpen( void )
+{
+ return theKeyboardOptionsLayout != NULL;
+}
+
+//-------------------------------------------------------------------------------------------------
+/** Put the keyboard screen up over whatever is already there, and stand the options menu it was
+ * opened from down while it is up. */
+//-------------------------------------------------------------------------------------------------
+void OpenKeyboardOptionsMenu( void )
+{
+ if( theKeyboardOptionsLayout != NULL )
+ return;
+
+ theKeyboardOptionsLayout = TheWindowManager->winCreateLayout( AsciiString( "Menus/KeyboardOptionsMenu.wnd" ) );
+ DEBUG_ASSERTCRASH( theKeyboardOptionsLayout, ("Unable to create the keyboard options layout\n") );
+ if( theKeyboardOptionsLayout == NULL )
+ return;
+
+ WindowLayout *optLayout = TheShell ? TheShell->getOptionsLayout( FALSE ) : NULL;
+ if( optLayout )
+ optLayout->hide( TRUE );
+
+ theKeyboardOptionsLayout->runInit();
+ theKeyboardOptionsLayout->hide( FALSE );
+ theKeyboardOptionsLayout->bringForward();
+}
+
+//-------------------------------------------------------------------------------------------------
+void CloseKeyboardOptionsMenu( void )
+{
+ if( theKeyboardOptionsLayout == NULL )
+ return;
+
+ theKeyboardOptionsLayout->destroyWindows();
+ theKeyboardOptionsLayout->deleteInstance();
+ theKeyboardOptionsLayout = NULL;
+
+ parentKeyboardOptionsMenu = NULL;
+ comboBoxCategoryList = NULL;
+ listBoxCommandList = NULL;
+ staticTextDescription = NULL;
+ staticTextCurrentHotkey = NULL;
+ buttonResetAll = NULL;
+ textEntryAssignHotkey = NULL;
+ buttonAssign = NULL;
+ buttonBack = NULL;
+ theSelectedRec = NULL;
+ thePendingKey = MK_NONE;
+ thePendingMods = NONE;
+
+ // the options menu was hidden rather than destroyed, so it comes back where it was
+ WindowLayout *optLayout = TheShell ? TheShell->getOptionsLayout( FALSE ) : NULL;
+ if( optLayout )
+ {
+ optLayout->hide( FALSE );
+ optLayout->bringForward();
+ }
+}
+
//-------------------------------------------------------------------------------------------------
/** Initialize the options menu */
//-------------------------------------------------------------------------------------------------
@@ -609,11 +680,12 @@ void KeyboardOptionsMenuInit( WindowLayout *layout, void *userData )
//-------------------------------------------------------------------------------------------------
void KeyboardOptionsMenuShutdown( WindowLayout *layout, void *userData )
{
- // hide menu
+ //
+ // This is not a shell screen, so there is no shell stack waiting on a shutdownComplete - saying
+ // there was would pop whatever the shell really is parked on. CloseKeyboardOptionsMenu is what
+ // takes the screen down.
+ //
layout->hide( TRUE );
-
- // our shutdown is complete
- TheShell->shutdownComplete( layout );
}
//-------------------------------------------------------------------------------------------------
@@ -802,8 +874,8 @@ WindowMsgHandledType KeyboardOptionsMenuSystem( GameWindow *window, UnsignedInt
if( controlID == buttonBackID )
{
- // go back one screen
- TheShell->pop();
+ // take this screen down and give back whatever it was laid over
+ CloseKeyboardOptionsMenu();
} // end if
else if( controlID == buttonAssignID )
diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/OptionsMenu.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/OptionsMenu.cpp
index 1ec6c1ec4..3c1793c3b 100644
--- a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/OptionsMenu.cpp
+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/OptionsMenu.cpp
@@ -1558,6 +1558,9 @@ static void saveOptions( void )
static void DestroyOptionsLayout() {
+ // the keyboard screen is laid over this one; leaving it up would leave it over nothing
+ CloseKeyboardOptionsMenu();
+
SignalUIInteraction(SHELL_SCRIPT_HOOK_OPTIONS_CLOSED);
TheShell->destroyOptionsLayout();
@@ -2352,7 +2355,7 @@ WindowMsgHandledType OptionsMenuSystem( GameWindow *window, UnsignedInt msg,
}
else if ( controlID == buttonKeyboardOptionsMenu )
{
- TheShell->push( AsciiString( "Menus/KeyboardOptionsMenu.wnd" ) );
+ OpenKeyboardOptionsMenu();
}
else if(controlID == checkDrawAnchorID )
{
diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/QuitMenu.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/QuitMenu.cpp
index 3df988332..42e844c75 100644
--- a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/QuitMenu.cpp
+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/QuitMenu.cpp
@@ -305,6 +305,11 @@ void ToggleQuitMenu()
// BGC- this is kind of hackish, but its the safest way to do it I think.
// Basically we're seeing if either the save/load window or the options window is up
// and if one of them is, we quit out of them rather than toggle the quit menu.
+ // the keyboard screen sits over the options menu, so escape has to take it first
+ if (IsKeyboardOptionsMenuOpen()) {
+ CloseKeyboardOptionsMenu();
+ return;
+ }
if (TheShell->getOptionsLayout(FALSE) != FALSE) {
WindowLayout *optLayout = TheShell->getOptionsLayout(FALSE);
GameWindow *optionsParent = optLayout->getFirstWindow();
diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/Shell/Shell.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/Shell/Shell.cpp
index 0867f1be5..22feb30a8 100644
--- a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/Shell/Shell.cpp
+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/Shell/Shell.cpp
@@ -38,6 +38,7 @@
#include "GameClient/IMEManager.h"
#include "GameClient/AnimateWindowManager.h"
#include "GameClient/ShellMenuScheme.h"
+#include "GameClient/GUICallbacks.h"
#include "GameLogic/GameLogic.h"
#include "GameNetwork/GameSpyOverlay.h"
#include "GameNetwork/GameSpy/PeerDefsImplementation.h"
@@ -124,6 +125,9 @@ Shell::~Shell( void )
} //end if
+ // the keyboard screen is laid over the options menu, so it goes first
+ CloseKeyboardOptionsMenu();
+
// delete the options menu if present.
if (m_optionsLayout != NULL) {
m_optionsLayout->destroyWindows();
diff --git a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/GUI/Gadget/W3DPushButton.cpp b/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/GUI/Gadget/W3DPushButton.cpp
index eda847649..c1b6f9cf3 100644
--- a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/GUI/Gadget/W3DPushButton.cpp
+++ b/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/GUI/Gadget/W3DPushButton.cpp
@@ -117,10 +117,12 @@ static GameFont *getBadgeFont( GameWindow *window )
if( pointSize < 6 )
pointSize = 6;
- if( pointSize == font->pointSize )
+ // bold, because these are markings on a picture: at seven points against a busy cameo the light
+ // weight reads as noise on the artwork rather than as a letter
+ if( pointSize == font->pointSize && font->bold )
return font;
- return TheFontLibrary->getFont( font->nameString, pointSize, font->bold );
+ return TheFontLibrary->getFont( font->nameString, pointSize, TRUE );
} // end getBadgeFont
diff --git a/GeneralsMD/Code/Tests/test_gameengine.cpp b/GeneralsMD/Code/Tests/test_gameengine.cpp
index e3e9c3b11..8cba60686 100644
--- a/GeneralsMD/Code/Tests/test_gameengine.cpp
+++ b/GeneralsMD/Code/Tests/test_gameengine.cpp
@@ -8095,6 +8095,112 @@ TEST(the_grid_and_the_readout_follow_the_plate_that_paints_them)
}
}
+TEST(the_minimise_button_sits_on_the_tab_its_plate_paints)
+{
+ /* Each right-hand plate paints its own minimise tab, green arrow and all, and none of them
+ paints it where ControlBar.wnd puts ButtonLarge - 666,445 to 714,473. Left on the authored
+ rectangle the button drew a second tab beside the painted one, which at 1920x1080 was up to
+ nineteen pixels of doubled metal and two arrows. The rectangles below were measured off the
+ three targas; placeInPanel hands them to ButtonLarge instead of the authored one. */
+ static const char *const sides[] = { "America", "China", "GLA", NULL };
+
+ // what the .wnd says, which is the thing every one of these has to disagree with
+ const Int wndLeft = 666, wndTop = 445, wndRight = 714, wndBottom = 473;
+ const Int wndWidth = wndRight - wndLeft, wndHeight = wndBottom - wndTop;
+
+ for( const char *const *s = sides; *s; s++ )
+ {
+ const ControlBarPlate *plate = ControlBarPlateForSide( AsciiString( *s ), ControlBar::CB_PANEL_RIGHT );
+ CHECK( plate != NULL );
+
+ // a tab at all - a zeroed rectangle means the button went back to the authored place
+ CHECK( plate->minTab.width() > 0 );
+ CHECK( plate->minTab.height() > 0 );
+
+ // it has to be on the plate, not hanging in the battlefield beside it
+ CHECK( plate->minTab.lo.x >= plate->design.lo.x );
+ CHECK( plate->minTab.hi.x <= plate->design.hi.x );
+ CHECK( plate->minTab.lo.y >= plate->design.lo.y );
+ CHECK( plate->minTab.hi.y <= plate->design.hi.y );
+
+ // and it has to be a tab-sized thing: the arrow art is stretched into it, so a fat-fingered
+ // number that makes the button half the panel is the failure worth catching
+ CHECK( plate->minTab.width() >= wndWidth / 2 );
+ CHECK( plate->minTab.width() <= wndWidth * 2 );
+ CHECK( plate->minTab.height() >= wndHeight / 2 );
+ CHECK( plate->minTab.height() <= wndHeight * 2 );
+
+ // every one of the three moved; a rectangle equal to the .wnd's would be the bug back
+ CHECK( plate->minTab.lo.x != wndLeft || plate->minTab.lo.y != wndTop );
+
+ //
+ // The tab is also what stops the minimised bar: the selection panel drops until this
+ // rectangle's bottom edge stands on the bottom of the screen, so the tab and the metal it is
+ // painted on stay reachable and the portrait below goes off. A tab whose bottom is the
+ // plate's bottom would give a drop of nothing and the panel would not move at all.
+ //
+ CHECK( plate->minTab.hi.y < plate->design.hi.y );
+ }
+}
+
+/* The keyboard screen is opened by a button on the options menu, and that button was the only one
+ in the layout still wearing Times New Roman while every other button on the screen wears the
+ game's own face. It read as a different program's dialog dropped into the menu. */
+TEST(the_options_menu_buttons_all_wear_one_font)
+{
+ FILE *fp = fopen( OPTIONS_MENU_WND, "rb" );
+ CHECK( fp != NULL );
+ if( fp == NULL )
+ return;
+
+ // walk the file remembering the last window name seen; FONT comes a few lines after NAME
+ static const char *const buttons[] =
+ {
+ "OptionsMenu.wnd:ButtonBack", "OptionsMenu.wnd:ButtonAccept",
+ "OptionsMenu.wnd:ButtonDefaults", "OptionsMenu.wnd:ButtonKeyboardOptions", NULL
+ };
+
+ char line[ 1024 ], name[ 256 ];
+ Int found = 0, agreed = 0;
+ name[ 0 ] = 0;
+ while( fgets( line, sizeof( line ), fp ) != NULL )
+ {
+ const char *at = strstr( line, "NAME = \"" );
+ if( at != NULL )
+ {
+ at += 8;
+ Int i = 0;
+ while( at[ i ] && at[ i ] != '"' && i < (Int)sizeof( name ) - 1 )
+ {
+ name[ i ] = at[ i ];
+ ++i;
+ }
+ name[ i ] = 0;
+ continue;
+ }
+
+ at = strstr( line, "FONT = NAME:" );
+ if( at == NULL || name[ 0 ] == 0 )
+ continue;
+
+ for( const char *const *b = buttons; *b; b++ )
+ if( strcmp( name, *b ) == 0 )
+ {
+ ++found;
+ if( strstr( at, "\"Generals\"" ) != NULL && strstr( at, "SIZE: 15" ) != NULL )
+ ++agreed;
+ else
+ printf( " %s wears %s", name, at );
+ }
+ name[ 0 ] = 0;
+ }
+ fclose( fp );
+
+ // a scan that matched nothing would pass silently
+ CHECK_EQ( found, 4 );
+ CHECK_EQ( agreed, found );
+}
+
TEST(every_plate_that_touches_a_design_edge_touches_the_screen_edge)
{
/* The plate rectangles were measured against the paintings, and a painting stops a pixel or two