From 14665b396d17f3672448cc5aac58cf095229f578 Mon Sep 17 00:00:00 2001 From: xezon <4720891+xezon@users.noreply.github.com> Date: Sun, 8 Jun 2025 10:43:32 +0200 Subject: [PATCH 01/10] [ZH] No longer close the Options Menu when changing Display Resolution --- GeneralsMD/Code/GameEngine/CMakeLists.txt | 2 + .../Include/GameClient/GameWindowManager.h | 2 +- .../GameClient/GameWindowTransitions.h | 19 ++-- .../GameEngine/Include/GameClient/Shell.h | 5 +- .../GameEngine/Include/GameClient/ShellUtil.h | 28 +++++ .../Include/GameClient/WindowLayout.h | 16 +-- .../GUI/GUICallbacks/Menus/MainMenu.cpp | 20 ++-- .../GUI/GUICallbacks/Menus/OptionsMenu.cpp | 17 +-- .../GameClient/GUI/GameWindowTransitions.cpp | 63 ++++++++--- .../Source/GameClient/GUI/Shell/Shell.cpp | 9 ++ .../Source/GameClient/GUI/Shell/ShellUtil.cpp | 101 ++++++++++++++++++ 11 files changed, 224 insertions(+), 58 deletions(-) create mode 100644 GeneralsMD/Code/GameEngine/Include/GameClient/ShellUtil.h create mode 100644 GeneralsMD/Code/GameEngine/Source/GameClient/GUI/Shell/ShellUtil.cpp diff --git a/GeneralsMD/Code/GameEngine/CMakeLists.txt b/GeneralsMD/Code/GameEngine/CMakeLists.txt index 343a0fe28f..19b7005ba4 100644 --- a/GeneralsMD/Code/GameEngine/CMakeLists.txt +++ b/GeneralsMD/Code/GameEngine/CMakeLists.txt @@ -216,6 +216,7 @@ set(GAMEENGINE_SRC Include/GameClient/Shell.h Include/GameClient/ShellHooks.h Include/GameClient/ShellMenuScheme.h + Include/GameClient/ShellUtil.h Include/GameClient/Smudge.h Include/GameClient/Snow.h Include/GameClient/Statistics.h @@ -785,6 +786,7 @@ set(GAMEENGINE_SRC Source/GameClient/GUI/ProcessAnimateWindow.cpp Source/GameClient/GUI/Shell/Shell.cpp Source/GameClient/GUI/Shell/ShellMenuScheme.cpp + Source/GameClient/GUI/Shell/ShellUtil.cpp Source/GameClient/GUI/WindowLayout.cpp Source/GameClient/GUI/WindowVideoManager.cpp Source/GameClient/GUI/WinInstanceData.cpp diff --git a/GeneralsMD/Code/GameEngine/Include/GameClient/GameWindowManager.h b/GeneralsMD/Code/GameEngine/Include/GameClient/GameWindowManager.h index fda79052f3..3914093788 100644 --- a/GeneralsMD/Code/GameEngine/Include/GameClient/GameWindowManager.h +++ b/GeneralsMD/Code/GameEngine/Include/GameClient/GameWindowManager.h @@ -257,7 +257,7 @@ friend class GameWindow; virtual void winSetLoneWindow( GameWindow *window ); ///< set the open window virtual Bool isEnabled( GameWindow *win ); ///< is window or parents enabled - virtual Bool isHidden( GameWindow *win ); ///< is parent or parents hidden + virtual Bool isHidden( GameWindow *win ); ///< is window or parents hidden virtual void addWindowToParent( GameWindow *window, GameWindow *parent ); virtual void addWindowToParentAtEnd( GameWindow *window, GameWindow *parent ); diff --git a/GeneralsMD/Code/GameEngine/Include/GameClient/GameWindowTransitions.h b/GeneralsMD/Code/GameEngine/Include/GameClient/GameWindowTransitions.h index e0d5a43d4a..6a83ca60c8 100644 --- a/GeneralsMD/Code/GameEngine/Include/GameClient/GameWindowTransitions.h +++ b/GeneralsMD/Code/GameEngine/Include/GameClient/GameWindowTransitions.h @@ -622,7 +622,7 @@ class TransitionWindow // standard vars NameKeyType m_winID; GameWindow *m_win; - Transition *m_transition; // each window is allowed one trasition + Transition *m_transition; // each window is allowed one transition Int m_currentFrameDelay; // this will change based on if we're going forward or backwards }; @@ -638,7 +638,11 @@ class TransitionGroup Bool isFinished( void ); void reverse( void ); void draw( void ); - + + // Returns the number of hidden (or shown) game windows that this transition refers to. + // Can be used to test whether the transition is necessary to play. + Int getHiddenGameWindowCount(Bool hidden = true) const; + void skip ( void ); AsciiString getName( void ) { return m_name; } void setName( AsciiString name){ m_name = name; } @@ -646,11 +650,12 @@ class TransitionGroup Bool isReversed( void ); Bool isFireOnce( void ) { return m_fireOnce; } Bool m_fireOnce; + private: typedef std::list TransitionWindowList; TransitionWindowList m_transitionWindowList; Int m_directionMultiplier; - Int m_currentFrame; ///< maintain how long we've spent on this transition; + Int m_currentFrame; ///< maintain how long we've spent on this transition. AsciiString m_name; }; @@ -671,18 +676,20 @@ class GameWindowTransitionsHandler: public SubsystemInterface static const FieldParse m_gameWindowTransitionsFieldParseTable[]; ///< the parse table static void parseWindow( INI* ini, void *instance, void *store, const void *userData ); - void setGroup(AsciiString groupName, Bool immidiate = FALSE); // THis will be the next group to fire off. + void setGroup(AsciiString groupName, Bool immediate = FALSE, Bool skip = FALSE); // This will be the next group to fire off. void reverse( AsciiString groupName );// reverse the animations for the current group. void remove( AsciiString groupName, Bool skipPending = FALSE );// remove the animation from the current or pending groups. TransitionGroup *getNewGroup( AsciiString name ); + const TransitionGroup *findGroup( AsciiString groupName ) const; + private: - TransitionGroup *findGroup( AsciiString groupName ); + TransitionGroup *findGroupInternal( AsciiString groupName ); typedef std::list TransitionGroupList; TransitionGroupList m_transitionGroupList; TransitionGroup *m_currentGroup; TransitionGroup *m_pendingGroup; TransitionGroup *m_drawGroup; - TransitionGroup *m_secondaryDrawGroup; // needed to draw the last frame of the previvous draw group once more. + TransitionGroup *m_secondaryDrawGroup; // needed to draw the last frame of the previous draw group once more. }; void PushButtonImageDrawThree(GameWindow *window, Int alpha ); diff --git a/GeneralsMD/Code/GameEngine/Include/GameClient/Shell.h b/GeneralsMD/Code/GameEngine/Include/GameClient/Shell.h index 0caf3ed653..f6700c0e29 100644 --- a/GeneralsMD/Code/GameEngine/Include/GameClient/Shell.h +++ b/GeneralsMD/Code/GameEngine/Include/GameClient/Shell.h @@ -141,8 +141,6 @@ class Shell : public SubsystemInterface WindowLayout *findScreenByFilename( AsciiString filename ); ///< find screen inline Bool isShellActive( void ) { return m_isShellActive; } ///< Returns true if the shell is active - - inline Int getScreenCount(void) { return m_screenCount; } ///< Return the current number of screens void registerWithAnimateManager( GameWindow *win, AnimTypes animType, Bool needsToFinish, UnsignedInt delayMS = 0); Bool isAnimFinished( void ); @@ -152,6 +150,9 @@ class Shell : public SubsystemInterface void loadScheme( AsciiString name ); ShellMenuSchemeManager *getShellMenuSchemeManager( void ) { return m_schemeManager; } + Int getScreenCount( void ) const { return m_screenCount; } ///< Return the current number of screens + WindowLayout *getScreenLayout( Int index ) const; + WindowLayout *getSaveLoadMenuLayout( void ); ///< create if necessary and return layout for save load menu WindowLayout *getPopupReplayLayout( void ); ///< create if necessary and return layout for replay save menu WindowLayout *getOptionsLayout( Bool create ); ///< return layout for options menu, create if necessary and we are allowed to. diff --git a/GeneralsMD/Code/GameEngine/Include/GameClient/ShellUtil.h b/GeneralsMD/Code/GameEngine/Include/GameClient/ShellUtil.h new file mode 100644 index 0000000000..4181b602c1 --- /dev/null +++ b/GeneralsMD/Code/GameEngine/Include/GameClient/ShellUtil.h @@ -0,0 +1,28 @@ +/* +** Command & Conquer Generals Zero Hour(tm) +** Copyright 2025 TheSuperHackers +** +** This program is free software: you can redistribute it and/or modify +** it under the terms of the GNU General Public License as published by +** the Free Software Foundation, either version 3 of the License, or +** (at your option) any later version. +** +** This program is distributed in the hope that it will be useful, +** but WITHOUT ANY WARRANTY; without even the implied warranty of +** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +** GNU General Public License for more details. +** +** You should have received a copy of the GNU General Public License +** along with this program. If not, see . +*/ + +#pragma once + +namespace shell +{ + +// Will recreate the Shell with the same state that it was left with. +// Currently works correctly in the Main Menu only. +void recreateShell(); + +} diff --git a/GeneralsMD/Code/GameEngine/Include/GameClient/WindowLayout.h b/GeneralsMD/Code/GameEngine/Include/GameClient/WindowLayout.h index 719ab1e639..9770c3ce4e 100644 --- a/GeneralsMD/Code/GameEngine/Include/GameClient/WindowLayout.h +++ b/GeneralsMD/Code/GameEngine/Include/GameClient/WindowLayout.h @@ -62,17 +62,17 @@ class WindowLayout : public MemoryPoolObject // ~WindowLayout( void ); ///< defined by memory pool glue // manipulating screen properties --------------------------------------------------------------- - AsciiString getFilename( void ); ///< return source window filename - Bool load( AsciiString filename ); ///< create windows and load from .wnd file - void hide( Bool hide ); ///< hide/unhide all windows on this screen - Bool isHidden( void ); ///< return visible state of screen + AsciiString getFilename( void ) const; ///< return source window filename + Bool load( AsciiString filename ); ///< create windows and load from .wnd file + void hide( Bool hide ); ///< hide/show all windows on this screen + Bool isHidden( void ) const; ///< return visible state of screen void bringForward( void ); ///< bring all windows in this screen forward // manipulating window lists -------------------------------------------------------------------- void addWindow( GameWindow *window ); ///< add window to screen void removeWindow( GameWindow *window ); ///< remove window from screen void destroyWindows( void ); ///< destroy all windows in this screen - GameWindow *getFirstWindow( void ); ///< get first window in list for screen + GameWindow *getFirstWindow( void ) const; ///< get first window in list for screen // accessing layout callbacks ------------------------------------------------------------------ void runInit( void *userData = NULL ); ///< run the init method if available @@ -110,9 +110,9 @@ class WindowLayout : public MemoryPoolObject }; // end class WindowLayout // INLINING /////////////////////////////////////////////////////////////////////////////////////// -inline AsciiString WindowLayout::getFilename( void ) { return m_filenameString; } -inline GameWindow *WindowLayout::getFirstWindow( void ) { return m_windowList; } -inline Bool WindowLayout::isHidden( void ) { return m_hidden; } +inline AsciiString WindowLayout::getFilename( void ) const { return m_filenameString; } +inline GameWindow *WindowLayout::getFirstWindow( void ) const { return m_windowList; } +inline Bool WindowLayout::isHidden( void ) const { return m_hidden; } inline void WindowLayout::runInit( void *userData ) { if( m_init ) m_init( this, userData ); } inline void WindowLayout::runUpdate( void *userData ) { if( m_update ) m_update( this, userData ); } 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 f507410f4d..51d0988af8 100644 --- a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/MainMenu.cpp +++ b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/MainMenu.cpp @@ -52,6 +52,7 @@ #include "GameClient/MapUtil.h" #include "GameClient/Shell.h" #include "GameClient/ShellHooks.h" +#include "GameClient/ShellUtil.h" #include "GameClient/KeyDefs.h" #include "GameClient/GameWindowManager.h" #include "GameClient/GadgetStaticText.h" @@ -761,18 +762,7 @@ void DeclineResolution() optionPref["Resolution"] = prefString; optionPref.write(); - // delete the shell - delete TheShell; - TheShell = NULL; - - // create the shell - TheShell = MSGNEW("GameClientSubsystem") Shell; - if( TheShell ) - TheShell->init(); - - TheInGameUI->recreateControlBar(); - - TheShell->push( AsciiString("Menus/MainMenu.wnd") ); + shell::recreateShell(); } } @@ -860,7 +850,11 @@ void MainMenuUpdate( WindowLayout *layout, void *userData ) { if(initialGadgetDelay == 1) { - TheTransitionHandler->setGroup("MainMenuDefaultMenuLogoFade"); + const TransitionGroup* transitionGroup = TheTransitionHandler->findGroup("MainMenuDefaultMenuLogoFade"); + if (transitionGroup != NULL && transitionGroup->getHiddenGameWindowCount() > 0) + { + TheTransitionHandler->setGroup("MainMenuDefaultMenuLogoFade"); + } TheWindowManager->winSetFocus( parentMainMenu ); initialGadgetDelay = 2; justEntered = FALSE; 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 29d0afddb7..2350ce3307 100644 --- a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/OptionsMenu.cpp +++ b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/OptionsMenu.cpp @@ -54,6 +54,7 @@ #include "GameClient/GadgetSlider.h" #include "GameClient/HeaderTemplate.h" #include "GameClient/Shell.h" +#include "GameClient/ShellUtil.h" #include "GameClient/KeyDefs.h" #include "GameClient/GameWindowManager.h" #include "GameClient/Mouse.h" @@ -1301,18 +1302,7 @@ static void saveOptions( void ) prefString.format("%d %d", xres, yres ); (*pref)["Resolution"] = prefString; - // delete the shell - delete TheShell; - TheShell = NULL; - - // create the shell - TheShell = MSGNEW("GameClientSubsystem") Shell; - if( TheShell ) - TheShell->init(); - - TheInGameUI->recreateControlBar(); - - TheShell->push( AsciiString("Menus/MainMenu.wnd") ); + shell::recreateShell(); } } } @@ -2052,8 +2042,6 @@ WindowMsgHandledType OptionsMenuSystem( GameWindow *window, UnsignedInt msg, if (pref) { pref->write(); - delete pref; - pref = NULL; } comboBoxLANIP = NULL; @@ -2067,7 +2055,6 @@ WindowMsgHandledType OptionsMenuSystem( GameWindow *window, UnsignedInt msg, GameSpyCloseOverlay(GSOVERLAY_OPTIONS); else { - DestroyOptionsLayout(); if (dispChanged) { DoResolutionDialog(); diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GameWindowTransitions.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GameWindowTransitions.cpp index 6bdb319c9c..d158285696 100644 --- a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GameWindowTransitions.cpp +++ b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GameWindowTransitions.cpp @@ -346,6 +346,33 @@ void TransitionGroup::skip ( void ) } } +Int TransitionGroup::getHiddenGameWindowCount(Bool hidden) const +{ + Int count = 0; + TransitionWindowList::const_iterator it = m_transitionWindowList.begin(); + while (it != m_transitionWindowList.end()) + { + TransitionWindow *tWin = *it; + if (tWin->m_win != NULL) + { + if (TheWindowManager->isHidden(tWin->m_win) == hidden) + ++count; + } + else + { + GameWindow* gameWin = TheWindowManager->winGetWindowFromId(NULL, TheNameKeyGenerator->nameToKey(tWin->m_winName)); + if (gameWin != NULL) + { + if (TheWindowManager->isHidden(gameWin) == hidden) + ++count; + } + } + + ++it; + } + return count; +} + void TransitionGroup::draw ( void ) { TransitionWindowList::iterator it = m_transitionWindowList.begin(); @@ -458,14 +485,14 @@ void GameWindowTransitionsHandler::draw( void ) m_secondaryDrawGroup->draw(); } -void GameWindowTransitionsHandler::setGroup(AsciiString groupName, Bool immidiate ) +void GameWindowTransitionsHandler::setGroup(AsciiString groupName, Bool immediate, Bool skip ) { - if(groupName.isEmpty() && immidiate) + if(groupName.isEmpty() && immediate) m_currentGroup = NULL; - if(immidiate && m_currentGroup) + if(immediate && m_currentGroup) { m_currentGroup->skip(); - m_currentGroup = findGroup(groupName); + m_currentGroup = findGroupInternal(groupName); if(m_currentGroup) m_currentGroup->init(); return; @@ -475,23 +502,28 @@ void GameWindowTransitionsHandler::setGroup(AsciiString groupName, Bool immidiat { if(!m_currentGroup->isFireOnce() && !m_currentGroup->isReversed()) m_currentGroup->reverse(); - m_pendingGroup = findGroup(groupName); + m_pendingGroup = findGroupInternal(groupName); if(m_pendingGroup) + { m_pendingGroup->init(); + if (skip) + m_pendingGroup->skip(); + } return; } - m_currentGroup = findGroup(groupName); + m_currentGroup = findGroupInternal(groupName); if(m_currentGroup) + { m_currentGroup->init(); - - - + if (skip) + m_currentGroup->skip(); + } } void GameWindowTransitionsHandler::reverse( AsciiString groupName ) { - TransitionGroup *g = findGroup(groupName); + TransitionGroup *g = findGroupInternal(groupName); if( m_currentGroup == g ) { m_currentGroup->reverse(); @@ -516,7 +548,7 @@ void GameWindowTransitionsHandler::reverse( AsciiString groupName ) void GameWindowTransitionsHandler::remove( AsciiString groupName, Bool skipPending ) { - TransitionGroup *g = findGroup(groupName); + TransitionGroup *g = findGroupInternal(groupName); if(m_pendingGroup == g) { if(skipPending) @@ -538,7 +570,7 @@ TransitionGroup *GameWindowTransitionsHandler::getNewGroup( AsciiString name ) if(name.isEmpty()) return NULL; - // test to see if we're trying to add an already exisitng group. + // test to see if we're trying to add an already existing group. if(findGroup(name)) { DEBUG_ASSERTCRASH(FALSE, ("GameWindowTransitionsHandler::getNewGroup - We already have a group %s", name.str())); @@ -557,10 +589,15 @@ Bool GameWindowTransitionsHandler::isFinished( void ) return TRUE; } +const TransitionGroup *GameWindowTransitionsHandler::findGroup( AsciiString groupName ) const +{ + return const_cast(this)->findGroup(groupName); +} + //----------------------------------------------------------------------------- // PRIVATE FUNCTIONS ////////////////////////////////////////////////////////// //----------------------------------------------------------------------------- -TransitionGroup *GameWindowTransitionsHandler::findGroup( AsciiString groupName ) +TransitionGroup *GameWindowTransitionsHandler::findGroupInternal( AsciiString groupName ) { if(groupName.isEmpty()) return NULL; diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/Shell/Shell.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/Shell/Shell.cpp index ea50ed4e8f..41e0908cae 100644 --- a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/Shell/Shell.cpp +++ b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/Shell/Shell.cpp @@ -242,6 +242,15 @@ WindowLayout *Shell::findScreenByFilename( AsciiString filename ) } // end findScreenByFilename +//------------------------------------------------------------------------------------------------- +WindowLayout *Shell::getScreenLayout( Int index ) const +{ + if (index >= 0 && index < m_screenCount) + return m_screenStack[index]; + + return NULL; +} + //------------------------------------------------------------------------------------------------- /** Hide or unhide all window layouts loaded */ //------------------------------------------------------------------------------------------------- diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/Shell/ShellUtil.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/Shell/ShellUtil.cpp new file mode 100644 index 0000000000..dc776cf55f --- /dev/null +++ b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/Shell/ShellUtil.cpp @@ -0,0 +1,101 @@ +/* +** Command & Conquer Generals Zero Hour(tm) +** Copyright 2025 TheSuperHackers +** +** This program is free software: you can redistribute it and/or modify +** it under the terms of the GNU General Public License as published by +** the Free Software Foundation, either version 3 of the License, or +** (at your option) any later version. +** +** This program is distributed in the hope that it will be useful, +** but WITHOUT ANY WARRANTY; without even the implied warranty of +** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +** GNU General Public License for more details. +** +** You should have received a copy of the GNU General Public License +** along with this program. If not, see . +*/ + +#include "PreRTS.h" + +#include "GameClient/ShellUtil.h" + +#include "GameClient/GameWindowTransitions.h" +#include "GameClient/InGameUI.h" +#include "GameClient/Shell.h" +#include "GameClient/WindowLayout.h" + +namespace shell +{ + +namespace +{ + struct ScreenInfo + { + ScreenInfo() : isHidden(false) {} + AsciiString filename; + bool isHidden; + }; +} + +void recreateShell() +{ + // collect state of the current shell + const Int screenCount = TheShell->getScreenCount(); + std::vector screenStackInfos; + Bool showOptions = false; + + { + screenStackInfos.resize(screenCount); + Int screenIndex = 0; + for (; screenIndex < screenCount; ++screenIndex) + { + const WindowLayout* layout = TheShell->getScreenLayout(screenIndex); + ScreenInfo& screenInfo = screenStackInfos[screenIndex]; + screenInfo.filename = layout->getFilename(); + screenInfo.isHidden = layout->isHidden(); + } + + const WindowLayout* optionsLayout = TheShell->getOptionsLayout(false); + if (optionsLayout != NULL) + { + DEBUG_ASSERTCRASH(!optionsLayout->isHidden(), ("options menu layout is hidden\n")); + showOptions = true; + } + } + + // recreate the shell + delete TheShell; + TheShell = MSGNEW("GameClientSubsystem") Shell; + TheShell->init(); + + // restore the screen stack + Int screenIndex = 0; + for (; screenIndex < screenCount; ++screenIndex) + { + const ScreenInfo& screenInfo = screenStackInfos[screenIndex]; + TheShell->push(screenInfo.filename); + + WindowLayout* layout = TheShell->getScreenLayout(screenIndex); + layout->hide(screenInfo.isHidden); + } + + if (showOptions) + { + // restore the options menu + WindowLayout* layout = TheShell->getOptionsLayout(true); + DEBUG_ASSERTCRASH(layout != NULL, ("options menu layout is NULL\n")); + layout->runInit(); + layout->hide(false); + layout->bringForward(); + } + + // Show the main menu logo and buttons right away. + const Bool immediate = true; + const Bool skip = true; + TheTransitionHandler->setGroup("MainMenuDefaultMenuLogoFade", immediate, skip); + + TheInGameUI->recreateControlBar(); +} + +} // namespace shell From 40776cc0f78667144717c13403faeb990c852ac6 Mon Sep 17 00:00:00 2001 From: xezon <4720891+xezon@users.noreply.github.com> Date: Mon, 9 Jun 2025 21:12:04 +0200 Subject: [PATCH 02/10] Simplify GameWindowTransitionsHandler::setGroup function --- .../GameClient/GameWindowTransitions.h | 5 ++- .../GameClient/GUI/GameWindowTransitions.cpp | 33 +++++++------------ .../Source/GameClient/GUI/Shell/ShellUtil.cpp | 7 ++-- 3 files changed, 18 insertions(+), 27 deletions(-) diff --git a/GeneralsMD/Code/GameEngine/Include/GameClient/GameWindowTransitions.h b/GeneralsMD/Code/GameEngine/Include/GameClient/GameWindowTransitions.h index 6a83ca60c8..ad1b07c12e 100644 --- a/GeneralsMD/Code/GameEngine/Include/GameClient/GameWindowTransitions.h +++ b/GeneralsMD/Code/GameEngine/Include/GameClient/GameWindowTransitions.h @@ -676,14 +676,13 @@ class GameWindowTransitionsHandler: public SubsystemInterface static const FieldParse m_gameWindowTransitionsFieldParseTable[]; ///< the parse table static void parseWindow( INI* ini, void *instance, void *store, const void *userData ); - void setGroup(AsciiString groupName, Bool immediate = FALSE, Bool skip = FALSE); // This will be the next group to fire off. + TransitionGroup *setGroup(AsciiString groupName, Bool immediate = FALSE); // This will be the next group to fire off. void reverse( AsciiString groupName );// reverse the animations for the current group. void remove( AsciiString groupName, Bool skipPending = FALSE );// remove the animation from the current or pending groups. TransitionGroup *getNewGroup( AsciiString name ); - const TransitionGroup *findGroup( AsciiString groupName ) const; + TransitionGroup *findGroup( AsciiString groupName ); private: - TransitionGroup *findGroupInternal( AsciiString groupName ); typedef std::list TransitionGroupList; TransitionGroupList m_transitionGroupList; TransitionGroup *m_currentGroup; diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GameWindowTransitions.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GameWindowTransitions.cpp index d158285696..f89be1e764 100644 --- a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GameWindowTransitions.cpp +++ b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GameWindowTransitions.cpp @@ -485,45 +485,44 @@ void GameWindowTransitionsHandler::draw( void ) m_secondaryDrawGroup->draw(); } -void GameWindowTransitionsHandler::setGroup(AsciiString groupName, Bool immediate, Bool skip ) +TransitionGroup *GameWindowTransitionsHandler::setGroup(AsciiString groupName, Bool immediate ) { if(groupName.isEmpty() && immediate) m_currentGroup = NULL; if(immediate && m_currentGroup) { m_currentGroup->skip(); - m_currentGroup = findGroupInternal(groupName); + m_currentGroup = findGroup(groupName); if(m_currentGroup) + { m_currentGroup->init(); - return; + } + return m_currentGroup; } if(m_currentGroup) { if(!m_currentGroup->isFireOnce() && !m_currentGroup->isReversed()) m_currentGroup->reverse(); - m_pendingGroup = findGroupInternal(groupName); + m_pendingGroup = findGroup(groupName); if(m_pendingGroup) { m_pendingGroup->init(); - if (skip) - m_pendingGroup->skip(); } - return; + return m_pendingGroup; } - m_currentGroup = findGroupInternal(groupName); + m_currentGroup = findGroup(groupName); if(m_currentGroup) { m_currentGroup->init(); - if (skip) - m_currentGroup->skip(); } + return m_currentGroup; } void GameWindowTransitionsHandler::reverse( AsciiString groupName ) { - TransitionGroup *g = findGroupInternal(groupName); + TransitionGroup *g = findGroup(groupName); if( m_currentGroup == g ) { m_currentGroup->reverse(); @@ -548,7 +547,7 @@ void GameWindowTransitionsHandler::reverse( AsciiString groupName ) void GameWindowTransitionsHandler::remove( AsciiString groupName, Bool skipPending ) { - TransitionGroup *g = findGroupInternal(groupName); + TransitionGroup *g = findGroup(groupName); if(m_pendingGroup == g) { if(skipPending) @@ -589,15 +588,7 @@ Bool GameWindowTransitionsHandler::isFinished( void ) return TRUE; } -const TransitionGroup *GameWindowTransitionsHandler::findGroup( AsciiString groupName ) const -{ - return const_cast(this)->findGroup(groupName); -} - -//----------------------------------------------------------------------------- -// PRIVATE FUNCTIONS ////////////////////////////////////////////////////////// -//----------------------------------------------------------------------------- -TransitionGroup *GameWindowTransitionsHandler::findGroupInternal( AsciiString groupName ) +TransitionGroup *GameWindowTransitionsHandler::findGroup( AsciiString groupName ) { if(groupName.isEmpty()) return NULL; diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/Shell/ShellUtil.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/Shell/ShellUtil.cpp index dc776cf55f..849a767dfd 100644 --- a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/Shell/ShellUtil.cpp +++ b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/Shell/ShellUtil.cpp @@ -91,9 +91,10 @@ void recreateShell() } // Show the main menu logo and buttons right away. - const Bool immediate = true; - const Bool skip = true; - TheTransitionHandler->setGroup("MainMenuDefaultMenuLogoFade", immediate, skip); + if (TransitionGroup* transitionGroup = TheTransitionHandler->setGroup("MainMenuDefaultMenuLogoFade", true)) + { + transitionGroup->skip(); + } TheInGameUI->recreateControlBar(); } From a40bac0db892b7b017020f0ccd9607ccee15a7c6 Mon Sep 17 00:00:00 2001 From: xezon <4720891+xezon@users.noreply.github.com> Date: Mon, 9 Jun 2025 21:13:57 +0200 Subject: [PATCH 03/10] Reduce diff --- .../Source/GameClient/GUI/GameWindowTransitions.cpp | 6 ------ 1 file changed, 6 deletions(-) diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GameWindowTransitions.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GameWindowTransitions.cpp index f89be1e764..4f2d300052 100644 --- a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GameWindowTransitions.cpp +++ b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GameWindowTransitions.cpp @@ -494,9 +494,7 @@ TransitionGroup *GameWindowTransitionsHandler::setGroup(AsciiString groupName, B m_currentGroup->skip(); m_currentGroup = findGroup(groupName); if(m_currentGroup) - { m_currentGroup->init(); - } return m_currentGroup; } @@ -506,17 +504,13 @@ TransitionGroup *GameWindowTransitionsHandler::setGroup(AsciiString groupName, B m_currentGroup->reverse(); m_pendingGroup = findGroup(groupName); if(m_pendingGroup) - { m_pendingGroup->init(); - } return m_pendingGroup; } m_currentGroup = findGroup(groupName); if(m_currentGroup) - { m_currentGroup->init(); - } return m_currentGroup; } From 888695f48a1f1c1e6d7651bb55e04267819a1d07 Mon Sep 17 00:00:00 2001 From: xezon <4720891+xezon@users.noreply.github.com> Date: Tue, 10 Jun 2025 20:07:18 +0200 Subject: [PATCH 04/10] Move some of the code from ShellUtil into Shell and avoid deleting TheShell --- .../GameEngine/Include/GameClient/Shell.h | 5 + .../GameEngine/Include/GameClient/ShellUtil.h | 7 +- .../GUI/GUICallbacks/Menus/MainMenu.cpp | 2 +- .../GUI/GUICallbacks/Menus/OptionsMenu.cpp | 2 +- .../Source/GameClient/GUI/Shell/Shell.cpp | 99 ++++++++++++++++--- .../Source/GameClient/GUI/Shell/ShellUtil.cpp | 79 ++++----------- 6 files changed, 117 insertions(+), 77 deletions(-) diff --git a/GeneralsMD/Code/GameEngine/Include/GameClient/Shell.h b/GeneralsMD/Code/GameEngine/Include/GameClient/Shell.h index f6700c0e29..4a25ff67c0 100644 --- a/GeneralsMD/Code/GameEngine/Include/GameClient/Shell.h +++ b/GeneralsMD/Code/GameEngine/Include/GameClient/Shell.h @@ -125,6 +125,8 @@ class Shell : public SubsystemInterface virtual void update( void ); //=============================================================================================== + void recreateWindowLayouts(); + void showShellMap(Bool useShellMap ); ///< access function to turn on and off the shell map void hide( Bool hide ); ///< show/hide all shell layouts @@ -160,6 +162,9 @@ class Shell : public SubsystemInterface protected: + void construct( void ); + void deconstruct( void ); + void linkScreen( WindowLayout *screen ); ///< link screen to list void unlinkScreen( WindowLayout *screen ); ///< remove screen from list diff --git a/GeneralsMD/Code/GameEngine/Include/GameClient/ShellUtil.h b/GeneralsMD/Code/GameEngine/Include/GameClient/ShellUtil.h index 4181b602c1..3969d2c199 100644 --- a/GeneralsMD/Code/GameEngine/Include/GameClient/ShellUtil.h +++ b/GeneralsMD/Code/GameEngine/Include/GameClient/ShellUtil.h @@ -21,8 +21,9 @@ namespace shell { -// Will recreate the Shell with the same state that it was left with. -// Currently works correctly in the Main Menu only. -void recreateShell(); +// Will recreate the UI. Currently works correctly in the Main Menu only. +void recreateUI(); + +void showMainMenuButtons(); } 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 51d0988af8..376fed00fa 100644 --- a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/MainMenu.cpp +++ b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/MainMenu.cpp @@ -762,7 +762,7 @@ void DeclineResolution() optionPref["Resolution"] = prefString; optionPref.write(); - shell::recreateShell(); + shell::recreateUI(); } } 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 2350ce3307..fe37f26236 100644 --- a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/OptionsMenu.cpp +++ b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/OptionsMenu.cpp @@ -1302,7 +1302,7 @@ static void saveOptions( void ) prefString.format("%d %d", xres, yres ); (*pref)["Resolution"] = prefString; - shell::recreateShell(); + shell::recreateUI(); } } } diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/Shell/Shell.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/Shell/Shell.cpp index 41e0908cae..ee77de7eab 100644 --- a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/Shell/Shell.cpp +++ b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/Shell/Shell.cpp @@ -57,6 +57,21 @@ Shell *TheShell = NULL; ///< the shell singleton definition //------------------------------------------------------------------------------------------------- //------------------------------------------------------------------------------------------------- Shell::Shell( void ) +{ + construct(); + +} // end Shell + +//------------------------------------------------------------------------------------------------- +//------------------------------------------------------------------------------------------------- +Shell::~Shell( void ) +{ + deconstruct(); + +} // end ~Shell + +//------------------------------------------------------------------------------------------------- +void Shell::construct( void ) { Int i; @@ -80,12 +95,10 @@ Shell::Shell( void ) m_optionsLayout = NULL; m_screenCount = 0; // - -} // end Shell +} //------------------------------------------------------------------------------------------------- -//------------------------------------------------------------------------------------------------- -Shell::~Shell( void ) +void Shell::deconstruct( void ) { WindowLayout *newTop = top(); while(newTop) @@ -101,12 +114,10 @@ Shell::~Shell( void ) m_background = NULL; } - if(m_animateWindowManager) - delete m_animateWindowManager; + delete m_animateWindowManager; m_animateWindowManager = NULL; - if(m_schemeManager) - delete m_schemeManager; + delete m_schemeManager; m_schemeManager = NULL; // delete the save/load menu if present @@ -135,8 +146,7 @@ Shell::~Shell( void ) deleteInstance(m_optionsLayout); m_optionsLayout = NULL; } - -} // end ~Shell +} //------------------------------------------------------------------------------------------------- /** Initialize the shell system */ @@ -165,7 +175,7 @@ void Shell::reset( void ) // pop all screens while( m_screenCount ) - pop(); + popImmediate(); m_animateWindowManager->reset(); @@ -217,6 +227,71 @@ void Shell::update( void ) } // end update +//------------------------------------------------------------------------------------------------- +namespace +{ + struct ScreenInfo + { + ScreenInfo() : isHidden(false) {} + AsciiString filename; + bool isHidden; + }; +} + +//------------------------------------------------------------------------------------------------- +void Shell::recreateWindowLayouts() +{ + // collect state of the current shell + const Int screenCount = getScreenCount(); + std::vector screenStackInfos; + Bool showOptions = false; + + { + screenStackInfos.resize(screenCount); + Int screenIndex = 0; + for (; screenIndex < screenCount; ++screenIndex) + { + const WindowLayout* layout = getScreenLayout(screenIndex); + ScreenInfo& screenInfo = screenStackInfos[screenIndex]; + screenInfo.filename = layout->getFilename(); + screenInfo.isHidden = layout->isHidden(); + } + + const WindowLayout* optionsLayout = getOptionsLayout(false); + if (optionsLayout != NULL) + { + DEBUG_ASSERTCRASH(!optionsLayout->isHidden(), ("options menu layout is hidden\n")); + showOptions = true; + } + } + + // reconstruct the shell now + deconstruct(); + construct(); + init(); + + // restore the screen stack + Int screenIndex = 0; + for (; screenIndex < screenCount; ++screenIndex) + { + const ScreenInfo& screenInfo = screenStackInfos[screenIndex]; + push(screenInfo.filename); + + WindowLayout* layout = getScreenLayout(screenIndex); + layout->hide(screenInfo.isHidden); + } + + if (showOptions) + { + // restore the options menu + WindowLayout* layout = getOptionsLayout(true); + DEBUG_ASSERTCRASH(layout != NULL, ("options menu layout is NULL\n")); + layout->runInit(); + layout->hide(false); + layout->bringForward(); + } +} + //------------------------------------------------------------------------------------------------- /** Find a screen via the .wnd script filename loaded */ //------------------------------------------------------------------------------------------------- @@ -473,7 +548,7 @@ void Shell::showShell( Bool runInit ) Profile::StopRange("init"); #endif //else - TheShell->push( AsciiString("Menus/MainMenu.wnd") ); + push( AsciiString("Menus/MainMenu.wnd") ); } m_isShellActive = TRUE; } // end showShell diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/Shell/ShellUtil.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/Shell/ShellUtil.cpp index 849a767dfd..b98f0607f2 100644 --- a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/Shell/ShellUtil.cpp +++ b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/Shell/ShellUtil.cpp @@ -28,75 +28,34 @@ namespace shell { -namespace +void recreateUI() { - struct ScreenInfo - { - ScreenInfo() : isHidden(false) {} - AsciiString filename; - bool isHidden; - }; -} - -void recreateShell() -{ - // collect state of the current shell - const Int screenCount = TheShell->getScreenCount(); - std::vector screenStackInfos; - Bool showOptions = false; + TheShell->recreateWindowLayouts(); - { - screenStackInfos.resize(screenCount); - Int screenIndex = 0; - for (; screenIndex < screenCount; ++screenIndex) - { - const WindowLayout* layout = TheShell->getScreenLayout(screenIndex); - ScreenInfo& screenInfo = screenStackInfos[screenIndex]; - screenInfo.filename = layout->getFilename(); - screenInfo.isHidden = layout->isHidden(); - } + showMainMenuButtons(); - const WindowLayout* optionsLayout = TheShell->getOptionsLayout(false); - if (optionsLayout != NULL) - { - DEBUG_ASSERTCRASH(!optionsLayout->isHidden(), ("options menu layout is hidden\n")); - showOptions = true; - } - } - - // recreate the shell - delete TheShell; - TheShell = MSGNEW("GameClientSubsystem") Shell; - TheShell->init(); + TheInGameUI->recreateControlBar(); +} - // restore the screen stack +void showMainMenuButtons() +{ + Int screenCount = TheShell->getScreenCount(); Int screenIndex = 0; for (; screenIndex < screenCount; ++screenIndex) { - const ScreenInfo& screenInfo = screenStackInfos[screenIndex]; - TheShell->push(screenInfo.filename); - WindowLayout* layout = TheShell->getScreenLayout(screenIndex); - layout->hide(screenInfo.isHidden); - } - - if (showOptions) - { - // restore the options menu - WindowLayout* layout = TheShell->getOptionsLayout(true); - DEBUG_ASSERTCRASH(layout != NULL, ("options menu layout is NULL\n")); - layout->runInit(); - layout->hide(false); - layout->bringForward(); - } - - // Show the main menu logo and buttons right away. - if (TransitionGroup* transitionGroup = TheTransitionHandler->setGroup("MainMenuDefaultMenuLogoFade", true)) - { - transitionGroup->skip(); + if (0 == layout->getFilename().compareNoCase("Menus/MainMenu.wnd")) + { + if (!layout->isHidden()) + { + if (TransitionGroup* transitionGroup = TheTransitionHandler->setGroup("MainMenuDefaultMenuLogoFade", true)) + { + transitionGroup->skip(); + } + } + break; + } } - - TheInGameUI->recreateControlBar(); } } // namespace shell From b8defb01ead62ab21a4e842c365e2cb182b34b50 Mon Sep 17 00:00:00 2001 From: xezon <4720891+xezon@users.noreply.github.com> Date: Wed, 11 Jun 2025 19:26:10 +0200 Subject: [PATCH 05/10] Close the OptionsMenu on resolution change again --- .../GameClient/GameWindowTransitions.h | 4 --- .../GameEngine/Include/GameClient/Shell.h | 2 +- .../GameEngine/Include/GameClient/ShellUtil.h | 2 -- .../GUI/GUICallbacks/Menus/MainMenu.cpp | 6 +---- .../GUI/GUICallbacks/Menus/OptionsMenu.cpp | 1 + .../GameClient/GUI/GameWindowTransitions.cpp | 27 ------------------- .../Source/GameClient/GUI/Shell/Shell.cpp | 20 +------------- .../Source/GameClient/GUI/Shell/ShellUtil.cpp | 23 ---------------- 8 files changed, 4 insertions(+), 81 deletions(-) diff --git a/GeneralsMD/Code/GameEngine/Include/GameClient/GameWindowTransitions.h b/GeneralsMD/Code/GameEngine/Include/GameClient/GameWindowTransitions.h index ad1b07c12e..1f61362c15 100644 --- a/GeneralsMD/Code/GameEngine/Include/GameClient/GameWindowTransitions.h +++ b/GeneralsMD/Code/GameEngine/Include/GameClient/GameWindowTransitions.h @@ -639,10 +639,6 @@ class TransitionGroup void reverse( void ); void draw( void ); - // Returns the number of hidden (or shown) game windows that this transition refers to. - // Can be used to test whether the transition is necessary to play. - Int getHiddenGameWindowCount(Bool hidden = true) const; - void skip ( void ); AsciiString getName( void ) { return m_name; } void setName( AsciiString name){ m_name = name; } diff --git a/GeneralsMD/Code/GameEngine/Include/GameClient/Shell.h b/GeneralsMD/Code/GameEngine/Include/GameClient/Shell.h index 4a25ff67c0..656a1764f1 100644 --- a/GeneralsMD/Code/GameEngine/Include/GameClient/Shell.h +++ b/GeneralsMD/Code/GameEngine/Include/GameClient/Shell.h @@ -125,7 +125,7 @@ class Shell : public SubsystemInterface virtual void update( void ); //=============================================================================================== - void recreateWindowLayouts(); + void recreateWindowLayouts( void ); void showShellMap(Bool useShellMap ); ///< access function to turn on and off the shell map diff --git a/GeneralsMD/Code/GameEngine/Include/GameClient/ShellUtil.h b/GeneralsMD/Code/GameEngine/Include/GameClient/ShellUtil.h index 3969d2c199..e5b836400c 100644 --- a/GeneralsMD/Code/GameEngine/Include/GameClient/ShellUtil.h +++ b/GeneralsMD/Code/GameEngine/Include/GameClient/ShellUtil.h @@ -24,6 +24,4 @@ namespace shell // Will recreate the UI. Currently works correctly in the Main Menu only. void recreateUI(); -void showMainMenuButtons(); - } 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 376fed00fa..0f89c35aa9 100644 --- a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/MainMenu.cpp +++ b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/MainMenu.cpp @@ -850,11 +850,7 @@ void MainMenuUpdate( WindowLayout *layout, void *userData ) { if(initialGadgetDelay == 1) { - const TransitionGroup* transitionGroup = TheTransitionHandler->findGroup("MainMenuDefaultMenuLogoFade"); - if (transitionGroup != NULL && transitionGroup->getHiddenGameWindowCount() > 0) - { - TheTransitionHandler->setGroup("MainMenuDefaultMenuLogoFade"); - } + TheTransitionHandler->setGroup("MainMenuDefaultMenuLogoFade"); TheWindowManager->winSetFocus( parentMainMenu ); initialGadgetDelay = 2; justEntered = FALSE; 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 fe37f26236..07ababbb4e 100644 --- a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/OptionsMenu.cpp +++ b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/OptionsMenu.cpp @@ -2055,6 +2055,7 @@ WindowMsgHandledType OptionsMenuSystem( GameWindow *window, UnsignedInt msg, GameSpyCloseOverlay(GSOVERLAY_OPTIONS); else { + DestroyOptionsLayout(); if (dispChanged) { DoResolutionDialog(); diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GameWindowTransitions.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GameWindowTransitions.cpp index 4f2d300052..a85e264fc0 100644 --- a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GameWindowTransitions.cpp +++ b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GameWindowTransitions.cpp @@ -346,33 +346,6 @@ void TransitionGroup::skip ( void ) } } -Int TransitionGroup::getHiddenGameWindowCount(Bool hidden) const -{ - Int count = 0; - TransitionWindowList::const_iterator it = m_transitionWindowList.begin(); - while (it != m_transitionWindowList.end()) - { - TransitionWindow *tWin = *it; - if (tWin->m_win != NULL) - { - if (TheWindowManager->isHidden(tWin->m_win) == hidden) - ++count; - } - else - { - GameWindow* gameWin = TheWindowManager->winGetWindowFromId(NULL, TheNameKeyGenerator->nameToKey(tWin->m_winName)); - if (gameWin != NULL) - { - if (TheWindowManager->isHidden(gameWin) == hidden) - ++count; - } - } - - ++it; - } - return count; -} - void TransitionGroup::draw ( void ) { TransitionWindowList::iterator it = m_transitionWindowList.begin(); diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/Shell/Shell.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/Shell/Shell.cpp index ee77de7eab..b10205578d 100644 --- a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/Shell/Shell.cpp +++ b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/Shell/Shell.cpp @@ -239,12 +239,11 @@ namespace } //------------------------------------------------------------------------------------------------- -void Shell::recreateWindowLayouts() +void Shell::recreateWindowLayouts( void ) { // collect state of the current shell const Int screenCount = getScreenCount(); std::vector screenStackInfos; - Bool showOptions = false; { screenStackInfos.resize(screenCount); @@ -256,13 +255,6 @@ void Shell::recreateWindowLayouts() screenInfo.filename = layout->getFilename(); screenInfo.isHidden = layout->isHidden(); } - - const WindowLayout* optionsLayout = getOptionsLayout(false); - if (optionsLayout != NULL) - { - DEBUG_ASSERTCRASH(!optionsLayout->isHidden(), ("options menu layout is hidden\n")); - showOptions = true; - } } // reconstruct the shell now @@ -280,16 +272,6 @@ void Shell::recreateWindowLayouts() WindowLayout* layout = getScreenLayout(screenIndex); layout->hide(screenInfo.isHidden); } - - if (showOptions) - { - // restore the options menu - WindowLayout* layout = getOptionsLayout(true); - DEBUG_ASSERTCRASH(layout != NULL, ("options menu layout is NULL\n")); - layout->runInit(); - layout->hide(false); - layout->bringForward(); - } } //------------------------------------------------------------------------------------------------- diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/Shell/ShellUtil.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/Shell/ShellUtil.cpp index b98f0607f2..60d0123ef7 100644 --- a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/Shell/ShellUtil.cpp +++ b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/Shell/ShellUtil.cpp @@ -32,30 +32,7 @@ void recreateUI() { TheShell->recreateWindowLayouts(); - showMainMenuButtons(); - TheInGameUI->recreateControlBar(); } -void showMainMenuButtons() -{ - Int screenCount = TheShell->getScreenCount(); - Int screenIndex = 0; - for (; screenIndex < screenCount; ++screenIndex) - { - WindowLayout* layout = TheShell->getScreenLayout(screenIndex); - if (0 == layout->getFilename().compareNoCase("Menus/MainMenu.wnd")) - { - if (!layout->isHidden()) - { - if (TransitionGroup* transitionGroup = TheTransitionHandler->setGroup("MainMenuDefaultMenuLogoFade", true)) - { - transitionGroup->skip(); - } - } - break; - } - } -} - } // namespace shell From 06e25db7c2e7ae67355d8730fc110caa3e097aaa Mon Sep 17 00:00:00 2001 From: xezon <4720891+xezon@users.noreply.github.com> Date: Wed, 11 Jun 2025 19:29:35 +0200 Subject: [PATCH 06/10] Delete the pref again --- .../Source/GameClient/GUI/GUICallbacks/Menus/OptionsMenu.cpp | 2 ++ 1 file changed, 2 insertions(+) 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 07ababbb4e..891a87e0f7 100644 --- a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/OptionsMenu.cpp +++ b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/OptionsMenu.cpp @@ -2042,6 +2042,8 @@ WindowMsgHandledType OptionsMenuSystem( GameWindow *window, UnsignedInt msg, if (pref) { pref->write(); + delete pref; + pref = NULL; } comboBoxLANIP = NULL; From 850067f9bcf07cebef6b8bc98c1ba4a99a5eb362 Mon Sep 17 00:00:00 2001 From: xezon <4720891+xezon@users.noreply.github.com> Date: Wed, 11 Jun 2025 19:34:30 +0200 Subject: [PATCH 07/10] Remove the ShellUtil files again --- GeneralsMD/Code/GameEngine/CMakeLists.txt | 2 - .../GameEngine/Include/GameClient/ShellUtil.h | 27 ------------- .../GUI/GUICallbacks/Menus/MainMenu.cpp | 5 ++- .../GUI/GUICallbacks/Menus/OptionsMenu.cpp | 5 ++- .../Source/GameClient/GUI/Shell/ShellUtil.cpp | 38 ------------------- 5 files changed, 6 insertions(+), 71 deletions(-) delete mode 100644 GeneralsMD/Code/GameEngine/Include/GameClient/ShellUtil.h delete mode 100644 GeneralsMD/Code/GameEngine/Source/GameClient/GUI/Shell/ShellUtil.cpp diff --git a/GeneralsMD/Code/GameEngine/CMakeLists.txt b/GeneralsMD/Code/GameEngine/CMakeLists.txt index 19b7005ba4..343a0fe28f 100644 --- a/GeneralsMD/Code/GameEngine/CMakeLists.txt +++ b/GeneralsMD/Code/GameEngine/CMakeLists.txt @@ -216,7 +216,6 @@ set(GAMEENGINE_SRC Include/GameClient/Shell.h Include/GameClient/ShellHooks.h Include/GameClient/ShellMenuScheme.h - Include/GameClient/ShellUtil.h Include/GameClient/Smudge.h Include/GameClient/Snow.h Include/GameClient/Statistics.h @@ -786,7 +785,6 @@ set(GAMEENGINE_SRC Source/GameClient/GUI/ProcessAnimateWindow.cpp Source/GameClient/GUI/Shell/Shell.cpp Source/GameClient/GUI/Shell/ShellMenuScheme.cpp - Source/GameClient/GUI/Shell/ShellUtil.cpp Source/GameClient/GUI/WindowLayout.cpp Source/GameClient/GUI/WindowVideoManager.cpp Source/GameClient/GUI/WinInstanceData.cpp diff --git a/GeneralsMD/Code/GameEngine/Include/GameClient/ShellUtil.h b/GeneralsMD/Code/GameEngine/Include/GameClient/ShellUtil.h deleted file mode 100644 index e5b836400c..0000000000 --- a/GeneralsMD/Code/GameEngine/Include/GameClient/ShellUtil.h +++ /dev/null @@ -1,27 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 TheSuperHackers -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -#pragma once - -namespace shell -{ - -// Will recreate the UI. Currently works correctly in the Main Menu only. -void recreateUI(); - -} 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 0f89c35aa9..7b6052efff 100644 --- a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/MainMenu.cpp +++ b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/MainMenu.cpp @@ -52,7 +52,6 @@ #include "GameClient/MapUtil.h" #include "GameClient/Shell.h" #include "GameClient/ShellHooks.h" -#include "GameClient/ShellUtil.h" #include "GameClient/KeyDefs.h" #include "GameClient/GameWindowManager.h" #include "GameClient/GadgetStaticText.h" @@ -762,7 +761,9 @@ void DeclineResolution() optionPref["Resolution"] = prefString; optionPref.write(); - shell::recreateUI(); + TheShell->recreateWindowLayouts(); + + TheInGameUI->recreateControlBar(); } } 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 891a87e0f7..e45ffb2f46 100644 --- a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/OptionsMenu.cpp +++ b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/OptionsMenu.cpp @@ -54,7 +54,6 @@ #include "GameClient/GadgetSlider.h" #include "GameClient/HeaderTemplate.h" #include "GameClient/Shell.h" -#include "GameClient/ShellUtil.h" #include "GameClient/KeyDefs.h" #include "GameClient/GameWindowManager.h" #include "GameClient/Mouse.h" @@ -1302,7 +1301,9 @@ static void saveOptions( void ) prefString.format("%d %d", xres, yres ); (*pref)["Resolution"] = prefString; - shell::recreateUI(); + TheShell->recreateWindowLayouts(); + + TheInGameUI->recreateControlBar(); } } } diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/Shell/ShellUtil.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/Shell/ShellUtil.cpp deleted file mode 100644 index 60d0123ef7..0000000000 --- a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/Shell/ShellUtil.cpp +++ /dev/null @@ -1,38 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 TheSuperHackers -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -#include "PreRTS.h" - -#include "GameClient/ShellUtil.h" - -#include "GameClient/GameWindowTransitions.h" -#include "GameClient/InGameUI.h" -#include "GameClient/Shell.h" -#include "GameClient/WindowLayout.h" - -namespace shell -{ - -void recreateUI() -{ - TheShell->recreateWindowLayouts(); - - TheInGameUI->recreateControlBar(); -} - -} // namespace shell From 63d1cbba58b6cca4eded7c43957378f5447d7fd0 Mon Sep 17 00:00:00 2001 From: xezon <4720891+xezon@users.noreply.github.com> Date: Sun, 15 Jun 2025 12:50:32 +0200 Subject: [PATCH 08/10] Revert now unnecessary refactors in GameWindowManager, GameWindowTransitions --- .../Include/GameClient/GameWindowManager.h | 2 +- .../GameClient/GameWindowTransitions.h | 12 +++++------ .../GameClient/GUI/GameWindowTransitions.cpp | 20 ++++++++++++------- 3 files changed, 19 insertions(+), 15 deletions(-) diff --git a/GeneralsMD/Code/GameEngine/Include/GameClient/GameWindowManager.h b/GeneralsMD/Code/GameEngine/Include/GameClient/GameWindowManager.h index 3914093788..fda79052f3 100644 --- a/GeneralsMD/Code/GameEngine/Include/GameClient/GameWindowManager.h +++ b/GeneralsMD/Code/GameEngine/Include/GameClient/GameWindowManager.h @@ -257,7 +257,7 @@ friend class GameWindow; virtual void winSetLoneWindow( GameWindow *window ); ///< set the open window virtual Bool isEnabled( GameWindow *win ); ///< is window or parents enabled - virtual Bool isHidden( GameWindow *win ); ///< is window or parents hidden + virtual Bool isHidden( GameWindow *win ); ///< is parent or parents hidden virtual void addWindowToParent( GameWindow *window, GameWindow *parent ); virtual void addWindowToParentAtEnd( GameWindow *window, GameWindow *parent ); diff --git a/GeneralsMD/Code/GameEngine/Include/GameClient/GameWindowTransitions.h b/GeneralsMD/Code/GameEngine/Include/GameClient/GameWindowTransitions.h index 1f61362c15..042cef9179 100644 --- a/GeneralsMD/Code/GameEngine/Include/GameClient/GameWindowTransitions.h +++ b/GeneralsMD/Code/GameEngine/Include/GameClient/GameWindowTransitions.h @@ -622,7 +622,7 @@ class TransitionWindow // standard vars NameKeyType m_winID; GameWindow *m_win; - Transition *m_transition; // each window is allowed one transition + Transition *m_transition; // each window is allowed one trasition Int m_currentFrameDelay; // this will change based on if we're going forward or backwards }; @@ -638,7 +638,7 @@ class TransitionGroup Bool isFinished( void ); void reverse( void ); void draw( void ); - + void skip ( void ); AsciiString getName( void ) { return m_name; } void setName( AsciiString name){ m_name = name; } @@ -646,12 +646,11 @@ class TransitionGroup Bool isReversed( void ); Bool isFireOnce( void ) { return m_fireOnce; } Bool m_fireOnce; - private: typedef std::list TransitionWindowList; TransitionWindowList m_transitionWindowList; Int m_directionMultiplier; - Int m_currentFrame; ///< maintain how long we've spent on this transition. + Int m_currentFrame; ///< maintain how long we've spent on this transition; AsciiString m_name; }; @@ -672,13 +671,12 @@ class GameWindowTransitionsHandler: public SubsystemInterface static const FieldParse m_gameWindowTransitionsFieldParseTable[]; ///< the parse table static void parseWindow( INI* ini, void *instance, void *store, const void *userData ); - TransitionGroup *setGroup(AsciiString groupName, Bool immediate = FALSE); // This will be the next group to fire off. + void setGroup(AsciiString groupName, Bool immidiate = FALSE); // This will be the next group to fire off. void reverse( AsciiString groupName );// reverse the animations for the current group. void remove( AsciiString groupName, Bool skipPending = FALSE );// remove the animation from the current or pending groups. TransitionGroup *getNewGroup( AsciiString name ); - TransitionGroup *findGroup( AsciiString groupName ); - private: + TransitionGroup *findGroup( AsciiString groupName ); typedef std::list TransitionGroupList; TransitionGroupList m_transitionGroupList; TransitionGroup *m_currentGroup; diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GameWindowTransitions.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GameWindowTransitions.cpp index a85e264fc0..5e1486c676 100644 --- a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GameWindowTransitions.cpp +++ b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GameWindowTransitions.cpp @@ -458,17 +458,17 @@ void GameWindowTransitionsHandler::draw( void ) m_secondaryDrawGroup->draw(); } -TransitionGroup *GameWindowTransitionsHandler::setGroup(AsciiString groupName, Bool immediate ) +void GameWindowTransitionsHandler::setGroup(AsciiString groupName, Bool immidiate ) { - if(groupName.isEmpty() && immediate) + if(groupName.isEmpty() && immidiate) m_currentGroup = NULL; - if(immediate && m_currentGroup) + if(immidiate && m_currentGroup) { m_currentGroup->skip(); m_currentGroup = findGroup(groupName); if(m_currentGroup) m_currentGroup->init(); - return m_currentGroup; + return; } if(m_currentGroup) @@ -478,13 +478,16 @@ TransitionGroup *GameWindowTransitionsHandler::setGroup(AsciiString groupName, B m_pendingGroup = findGroup(groupName); if(m_pendingGroup) m_pendingGroup->init(); - return m_pendingGroup; + return; } m_currentGroup = findGroup(groupName); if(m_currentGroup) m_currentGroup->init(); - return m_currentGroup; + + + + return; } void GameWindowTransitionsHandler::reverse( AsciiString groupName ) @@ -536,7 +539,7 @@ TransitionGroup *GameWindowTransitionsHandler::getNewGroup( AsciiString name ) if(name.isEmpty()) return NULL; - // test to see if we're trying to add an already existing group. + // test to see if we're trying to add an already exisitng group. if(findGroup(name)) { DEBUG_ASSERTCRASH(FALSE, ("GameWindowTransitionsHandler::getNewGroup - We already have a group %s", name.str())); @@ -555,6 +558,9 @@ Bool GameWindowTransitionsHandler::isFinished( void ) return TRUE; } +//----------------------------------------------------------------------------- +// PRIVATE FUNCTIONS ////////////////////////////////////////////////////////// +//----------------------------------------------------------------------------- TransitionGroup *GameWindowTransitionsHandler::findGroup( AsciiString groupName ) { if(groupName.isEmpty()) From eb5b8ef267c23e6f58bff1135c01ca91c52779fc Mon Sep 17 00:00:00 2001 From: xezon <4720891+xezon@users.noreply.github.com> Date: Sun, 15 Jun 2025 12:52:26 +0200 Subject: [PATCH 09/10] Revert now unnecessary refactors in GameWindowManager, GameWindowTransitions 2 --- .../GameEngine/Include/GameClient/GameWindowTransitions.h | 4 ++-- .../Source/GameClient/GUI/GameWindowTransitions.cpp | 1 - 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/GeneralsMD/Code/GameEngine/Include/GameClient/GameWindowTransitions.h b/GeneralsMD/Code/GameEngine/Include/GameClient/GameWindowTransitions.h index 042cef9179..e0d5a43d4a 100644 --- a/GeneralsMD/Code/GameEngine/Include/GameClient/GameWindowTransitions.h +++ b/GeneralsMD/Code/GameEngine/Include/GameClient/GameWindowTransitions.h @@ -671,7 +671,7 @@ class GameWindowTransitionsHandler: public SubsystemInterface static const FieldParse m_gameWindowTransitionsFieldParseTable[]; ///< the parse table static void parseWindow( INI* ini, void *instance, void *store, const void *userData ); - void setGroup(AsciiString groupName, Bool immidiate = FALSE); // This will be the next group to fire off. + void setGroup(AsciiString groupName, Bool immidiate = FALSE); // THis will be the next group to fire off. void reverse( AsciiString groupName );// reverse the animations for the current group. void remove( AsciiString groupName, Bool skipPending = FALSE );// remove the animation from the current or pending groups. TransitionGroup *getNewGroup( AsciiString name ); @@ -682,7 +682,7 @@ class GameWindowTransitionsHandler: public SubsystemInterface TransitionGroup *m_currentGroup; TransitionGroup *m_pendingGroup; TransitionGroup *m_drawGroup; - TransitionGroup *m_secondaryDrawGroup; // needed to draw the last frame of the previous draw group once more. + TransitionGroup *m_secondaryDrawGroup; // needed to draw the last frame of the previvous draw group once more. }; void PushButtonImageDrawThree(GameWindow *window, Int alpha ); diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GameWindowTransitions.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GameWindowTransitions.cpp index 5e1486c676..36fa26766f 100644 --- a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GameWindowTransitions.cpp +++ b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GameWindowTransitions.cpp @@ -487,7 +487,6 @@ void GameWindowTransitionsHandler::setGroup(AsciiString groupName, Bool immidiat - return; } void GameWindowTransitionsHandler::reverse( AsciiString groupName ) From 373a9f3b281bf71c377415207c576e9046a59423 Mon Sep 17 00:00:00 2001 From: xezon <4720891+xezon@users.noreply.github.com> Date: Sun, 15 Jun 2025 12:53:09 +0200 Subject: [PATCH 10/10] Revert now unnecessary refactors in GameWindowManager, GameWindowTransitions 3 --- .../Source/GameClient/GUI/GameWindowTransitions.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GameWindowTransitions.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GameWindowTransitions.cpp index 36fa26766f..6bdb319c9c 100644 --- a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GameWindowTransitions.cpp +++ b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GameWindowTransitions.cpp @@ -485,8 +485,8 @@ void GameWindowTransitionsHandler::setGroup(AsciiString groupName, Bool immidiat if(m_currentGroup) m_currentGroup->init(); - - + + } void GameWindowTransitionsHandler::reverse( AsciiString groupName )