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): a click or key cuts the shell menu animations

Olcay Seyganed8a4ee129dd
diff --git a/CHANGELOG.md b/CHANGELOG.md
index fb65e43fc..fe10dfe07 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -67,6 +67,7 @@ found and fixed — EA's own, not port damage.**
- The rooms used to be a 4:3 screen pulled out to fit a wide monitor, so every emblem, start spot and the map itself came out a third wider than tall. They are drawn for 16:9 now and keep their shape on any screen: exact at 1080p, twice that at 4K, and centred between bands on a 4:3 or 16:10 monitor instead of squashed.
- The personality list opens eight lines tall with a scroll bar. Opened from a lower seat, its sixteen lines used to run off the bottom of the screen.
- The three rooms wear the same frame as the loading and score screens that follow them: the score screen's blue ruler and grid around the edge of the screen, with the panel sitting on its bright line. The LAN and online panels get the blue edge the skirmish one had, under the same blue rule; the seat rows sit on the panel's black in that blue; the colour bar is a little wider. Record and Close are in capitals like every other button, the record's heading is lettered green, and the darker names in the colour list are lifted toward white so they read on black, the way the score screen lifts them.
+- The menus no longer make you sit through their animations. A click or a key while buttons are still sliding or flashing in puts them where they were going, and the click counts: Solo Play pressed while the main menu is still coming up opens its list straight away, where it used to be ignored. A screen on its way out goes the moment you press anything, so Skirmish then a click reaches the skirmish room in about 100ms instead of half a second, and Back to the main menu in 10ms instead of 380.
## Every campaign mission is open
diff --git a/GeneralsMD/Code/GameEngine/Include/GameClient/AnimateWindowManager.h b/GeneralsMD/Code/GameEngine/Include/GameClient/AnimateWindowManager.h
index 4c948d83c..2265cf315 100644
--- a/GeneralsMD/Code/GameEngine/Include/GameClient/AnimateWindowManager.h
+++ b/GeneralsMD/Code/GameEngine/Include/GameClient/AnimateWindowManager.h
@@ -171,6 +171,7 @@ public:
Bool isFinished( void ); ///< Are all the animations that need to be finished, finished?
void reverseAnimateWindow( void ); ///< tell each animation type to setup the windows to run in reverse
void resetToRestPosition( void ); ///< Reset all windows to their rest position
+ void finish( void ); ///< put every window where its animation ends, now
Bool isReversed( void ); ///< Returns whether or not we're in our reversed state.
Bool isEmpty( void );
private:
diff --git a/GeneralsMD/Code/GameEngine/Include/GameClient/GameWindowTransitions.h b/GeneralsMD/Code/GameEngine/Include/GameClient/GameWindowTransitions.h
index 8b93cee63..c4581b0e3 100644
--- a/GeneralsMD/Code/GameEngine/Include/GameClient/GameWindowTransitions.h
+++ b/GeneralsMD/Code/GameEngine/Include/GameClient/GameWindowTransitions.h
@@ -648,6 +648,7 @@ public:
void draw( void );
void skip ( void );
+ void finish( void ); ///< play the remaining frames at once, in the current direction
AsciiString getName( void ) { return m_name; }
void setName( AsciiString name){ m_name = name; }
void addWindow( TransitionWindow *transWin );
@@ -679,6 +680,7 @@ public:
void update( void );
void draw( void );
Bool isFinished( void );
+ void finish( void ); ///< cut the running and the queued group to their end states
const FieldParse *getFieldParse() const { return m_gameWindowTransitionsFieldParseTable; } ///< returns the parsing fields
static const FieldParse m_gameWindowTransitionsFieldParseTable[]; ///< the parse table
static void parseWindow( INI* ini, void *instance, void *store, const void *userData );
diff --git a/GeneralsMD/Code/GameEngine/Include/GameClient/Shell.h b/GeneralsMD/Code/GameEngine/Include/GameClient/Shell.h
index 445fc8a0f..35533c13c 100644
--- a/GeneralsMD/Code/GameEngine/Include/GameClient/Shell.h
+++ b/GeneralsMD/Code/GameEngine/Include/GameClient/Shell.h
@@ -151,6 +151,7 @@ public:
Bool isAnimFinished( void );
void reverseAnimatewindow( void );
Bool isAnimReversed( void );
+ void cutAnimations( void ); ///< a click or key arrived: end every menu animation and finish a screen change waiting on one
void loadScheme( AsciiString name );
ShellMenuSchemeManager *getShellMenuSchemeManager( void ) { return m_schemeManager; }
diff --git a/GeneralsMD/Code/GameEngine/Source/Common/System/ControlServer.cpp b/GeneralsMD/Code/GameEngine/Source/Common/System/ControlServer.cpp
index 348a4707e..0f2bffbb2 100644
--- a/GeneralsMD/Code/GameEngine/Source/Common/System/ControlServer.cpp
+++ b/GeneralsMD/Code/GameEngine/Source/Common/System/ControlServer.cpp
@@ -39,6 +39,8 @@
#include "GameClient/Display.h"
#include "GameClient/InGameUI.h"
#include "GameClient/KeyDefs.h"
+#include "GameClient/Shell.h"
+#include "GameClient/WindowLayout.h"
#include "GameClient/MetaEvent.h"
#include "GameLogic/GameLogic.h"
#include "GameLogic/Module/BodyModule.h"
@@ -597,9 +599,14 @@ static void replyStatus( void )
std::vector<char> reply;
char piece[ 512 ];
- sprintf( piece, "{\"ok\":true,\"frame\":%d,\"inGame\":%s,\"players\":[",
+ // which front-end screen is up, so a script driving the menus can tell where its clicks landed
+ WindowLayout *screen = TheShell ? TheShell->top() : NULL;
+ WindowLayout *options = TheShell ? TheShell->getOptionsLayout( FALSE ) : NULL;
+ sprintf( piece, "{\"ok\":true,\"frame\":%d,\"inGame\":%s,\"screen\":\"%s\",\"options\":%s,\"players\":[",
TheGameLogic ? (Int)TheGameLogic->getFrame() : 0,
- inGame ? "true" : "false" );
+ inGame ? "true" : "false",
+ screen ? screen->getFilename().str() : "",
+ options && !options->isHidden() ? "true" : "false" );
for( const char *at = piece; *at; ++at )
reply.push_back( *at );
diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/AnimateWindowManager.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/AnimateWindowManager.cpp
index fd11e88f2..dfc95e808 100644
--- a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/AnimateWindowManager.cpp
+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/AnimateWindowManager.cpp
@@ -473,7 +473,29 @@ void AnimateWindowManager::resetToRestPosition( void )
it ++;
}
-
+
+}
+
+//-----------------------------------------------------------------------------
+/** A click while the windows slide: put each one where its slide ends - its resting place going in,
+ * its start off screen going out - and call the lot finished, as the last step would have. */
+void AnimateWindowManager::finish( void )
+{
+ AnimateWindowList *lists[] = { &m_winMustFinishList, &m_winList };
+ for( Int i = 0; i < 2; ++i )
+ {
+ for( AnimateWindowList::iterator it = lists[i]->begin(); it != lists[i]->end(); ++it )
+ {
+ AnimateWindow *animWin = *it;
+ if( animWin->isFinished() )
+ continue; // at rest already; a window moved since must not be pulled back
+ ICoord2D pos = m_reverse ? animWin->getStartPos() : animWin->getRestPos();
+ animWin->getGameWindow()->winSetPosition( pos.x, pos.y );
+ animWin->setCurPos( pos );
+ animWin->setFinished( TRUE );
+ }
+ }
+ m_needsUpdate = FALSE;
}
//-----------------------------------------------------------------------------
diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/MainMenu.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/MainMenu.cpp
index bb7091de3..b8fa386dc 100644
--- a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/MainMenu.cpp
+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/MainMenu.cpp
@@ -1375,6 +1375,11 @@ WindowMsgHandledType MainMenuSystem( GameWindow *window, UnsignedInt msg,
if(buttonPushed)
break;
+
+ // the press that brought this click cut the transitions (Shell::cutAnimations), so the
+ // panel it was waiting on is in place: take the click now rather than on the next update
+ if(dontAllowTransitions && TheTransitionHandler->isFinished())
+ dontAllowTransitions = FALSE;
#if defined _DEBUG || defined _INTERNAL || defined _PROFILE
if( control == buttonCampaign )
{
diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GameWindowManager.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GameWindowManager.cpp
index ec20a2c36..b0f5b0d70 100644
--- a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GameWindowManager.cpp
+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GameWindowManager.cpp
@@ -54,6 +54,7 @@
#include "GameClient/GadgetCheckBox.h"
#include "GameClient/GlobalLanguage.h"
#include "GameClient/GameWindowTransitions.h"
+#include "GameClient/Shell.h"
#include "Common/NameKeyGenerator.h"
// PUBLIC DATA ////////////////////////////////////////////////////////////////////////////////////
@@ -799,6 +800,14 @@ Int GameWindowManager::winSetFocus( GameWindow *window )
} // end WinSetFocus
+//-------------------------------------------------------------------------------------------------
+/** Front-end menus only: a game's own windows keep their animations whatever is pressed. */
+static void cutShellAnimations( void )
+{
+ if( TheShell && TheShell->isShellActive() )
+ TheShell->cutAnimations();
+}
+
//-------------------------------------------------------------------------------------------------
/** Process key press through the GUI. */
//-------------------------------------------------------------------------------------------------
@@ -807,6 +816,9 @@ WinInputReturnCode GameWindowManager::winProcessKey( UnsignedByte key,
{
WinInputReturnCode returnCode = WIN_INPUT_NOT_USED;
+ if( BitTest( state, KEY_STATE_DOWN ) )
+ cutShellAnimations();
+
// Check for keyboard focus and a legal key for sanity
if( m_keyboardFocus && (key != KEY_NONE) )
{
@@ -859,6 +871,10 @@ WinInputReturnCode GameWindowManager::winProcessMouseEvent( GameWindowMessage ms
// hotkeys still obey the normal availability check.
Bool allowDisabledCancel = msg == GWM_RIGHT_DOWN || msg == GWM_RIGHT_UP;
+ // a press lands on where the menu is going, not where its animation has got to
+ if( msg == GWM_LEFT_DOWN || msg == GWM_RIGHT_DOWN || msg == GWM_MIDDLE_DOWN )
+ cutShellAnimations();
+
// pack mouse coords into one entity for message passing
packedMouseCoords = SHORTTOLONG( mousePos->x, mousePos->y );
diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GameWindowTransitions.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GameWindowTransitions.cpp
index 33b997e8b..16170f9f4 100644
--- a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GameWindowTransitions.cpp
+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GameWindowTransitions.cpp
@@ -312,6 +312,20 @@ void TransitionGroup::update( void )
}
}
+//-----------------------------------------------------------------------------
+/** Play every remaining frame now, ignoring the clock: the group lands exactly where it would have
+ * ended, in either direction. isFinished() turns true once the frame passes the group's end, so
+ * this stops. */
+void TransitionGroup::finish( void )
+{
+ while( !isFinished() )
+ {
+ m_currentFrame += m_directionMultiplier;
+ for( TransitionWindowList::iterator it = m_transitionWindowList.begin(); it != m_transitionWindowList.end(); ++it )
+ (*it)->update( m_currentFrame );
+ }
+}
+
Bool TransitionGroup::isFinished( void )
{
// Past its last frame (or, reversed, before its first) no window takes another update, so
@@ -488,6 +502,31 @@ void GameWindowTransitionsHandler::update( void )
}
+//-----------------------------------------------------------------------------
+/** Cut the running group, and the one queued behind it, to their last frames. The hand-offs are
+ * the ones update() makes, taken without waiting a frame between them. */
+void GameWindowTransitionsHandler::finish( void )
+{
+ while( m_currentGroup || m_pendingGroup )
+ {
+ if( !m_currentGroup )
+ {
+ m_currentGroup = m_pendingGroup;
+ m_pendingGroup = NULL;
+ }
+ m_currentGroup->finish();
+ if( m_pendingGroup )
+ {
+ m_currentGroup = m_pendingGroup;
+ m_pendingGroup = NULL;
+ continue;
+ }
+ if( m_currentGroup->isFireOnce() || m_currentGroup->isReversed() )
+ m_currentGroup = NULL;
+ break;
+ }
+}
+
void GameWindowTransitionsHandler::draw( void )
{
// if( TheGameLogic->getFrame() > 0 )//if( areTransitionsEnabled() ) //KRIS
diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/Shell/Shell.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/Shell/Shell.cpp
index 6876af955..8cb86cf8f 100644
--- a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/Shell/Shell.cpp
+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/Shell/Shell.cpp
@@ -845,6 +845,27 @@ Bool Shell::isAnimFinished( void )
return TRUE;
}
+//-------------------------------------------------------------------------------------------------
+/** The menus ignored a click until the animation it landed in had played out, so a player who knew
+ * where the next button was had to wait for every slide. Now a click or key cuts the animation:
+ * every transition and slide jumps to its last frame, and a screen that was waiting on its exit
+ * animation to push or pop the next one is let go at once (its own update makes that call), so the
+ * click that cut it lands on the screen it was heading for. With nothing pressed the animations
+ * play as before. */
+//-------------------------------------------------------------------------------------------------
+void Shell::cutAnimations( void )
+{
+ TheTransitionHandler->finish();
+ m_animateWindowManager->finish();
+
+ if( (m_pendingPush || m_pendingPop) && top() )
+ {
+ top()->runUpdate( NULL );
+ TheTransitionHandler->finish();
+ m_animateWindowManager->finish();
+ }
+}
+
void Shell::reverseAnimatewindow( void )
{
if(!m_animateWindowManager)