forked from electronicarts/CnC_Generals_Zero_Hour
-
Notifications
You must be signed in to change notification settings - Fork 167
feature(gamelogic): Implement ALT + F4 and Window X button to close game #2336
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
githubawn
wants to merge
7
commits into
TheSuperHackers:main
Choose a base branch
from
githubawn:fix/graceful-exit-logic
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
765d92b
Implement graceful exit for Alt+F4 and window close events
githubawn 4fda496
Implement graceful exit during loading and movie screens
githubawn 4465409
Backport graceful exit logic from GeneralsMD
githubawn 036ed84
Implemented feedback
githubawn 27abc6b
Merge branch 'main' into fix/graceful-exit-logic
githubawn 6b28aed
Apply suggestion from @greptile-apps[bot]
githubawn 6f2b0b8
refine graceful exit logic and apply suggestions
githubawn File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -244,6 +244,7 @@ GameLogic::GameLogic() | |
| m_logicTimeScaleEnabledMemory = FALSE; | ||
| m_loadScreen = nullptr; | ||
| m_forceGameStartByTimeOut = FALSE; | ||
| m_quitToDesktopAfterMatch = FALSE; | ||
| #ifdef DUMP_PERF_STATS | ||
| m_overallFailedPathfinds = 0; | ||
| #endif | ||
|
|
@@ -911,6 +912,8 @@ static void populateRandomStartPosition( GameInfo *game ) | |
| } | ||
| } | ||
|
|
||
| struct QuitGameException {}; | ||
|
|
||
| // ------------------------------------------------------------------------------------------------ | ||
| /** Update the load screen progress */ | ||
| // ------------------------------------------------------------------------------------------------ | ||
|
|
@@ -920,6 +923,10 @@ void GameLogic::updateLoadProgress( Int progress ) | |
| if( m_loadScreen ) | ||
| m_loadScreen->update( progress ); | ||
|
|
||
| if (TheGameEngine->getQuitting() || m_quitToDesktopAfterMatch) | ||
| { | ||
| throw QuitGameException(); | ||
| } | ||
| } | ||
|
|
||
| // ------------------------------------------------------------------------------------------------ | ||
|
|
@@ -966,6 +973,8 @@ void GameLogic::setGameMode( GameMode mode ) | |
| // ------------------------------------------------------------------------------------------------ | ||
| void GameLogic::startNewGame( Bool saveGame ) | ||
| { | ||
| try | ||
| { | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Perhaps do void GameLogic::startNewGame( Bool saveGame )
{
try
{
tryStartNewGame(saveGame);
}
catch ..
{
}
} |
||
|
|
||
| #ifdef DUMP_PERF_STATS | ||
| __int64 startTime64; | ||
|
|
@@ -2067,7 +2076,11 @@ void GameLogic::startNewGame( Bool saveGame ) | |
| TheInGameUI->messageNoFormat( TheGameText->FETCH_OR_SUBSTITUTE( "GUI:FastForwardInstructions", L"Press F to toggle Fast Forward" ) ); | ||
| } | ||
|
|
||
|
|
||
| } | ||
| catch (QuitGameException&) | ||
| { | ||
| // TheSuperHackers @info The application is cleanly aborting the loading process | ||
| } | ||
| } | ||
|
|
||
| //----------------------------------------------------------------------------------------- | ||
|
|
@@ -3619,6 +3632,64 @@ void GameLogic::exitGame() | |
| TheMessageStream->appendMessage(GameMessage::MSG_CLEAR_GAME_DATA); | ||
| } | ||
|
|
||
| // ------------------------------------------------------------------------------------------------ | ||
| void GameLogic::quit(Bool toDesktop) | ||
| { | ||
| if (isInGame()) | ||
| { | ||
| const Bool isSandbox = TheGameInfo && TheGameInfo->isSandbox(); | ||
|
|
||
| if (isInMultiplayerGame() && TheGameInfo && !isSandbox) | ||
| { | ||
| GameMessage *msg = TheMessageStream->appendMessage(GameMessage::MSG_SELF_DESTRUCT); | ||
| msg->appendBooleanArgument(TRUE); | ||
| } | ||
|
|
||
| if (TheRecorder && TheRecorder->getMode() == RECORDERMODETYPE_RECORD) | ||
| { | ||
| TheRecorder->stopRecording(); | ||
| } | ||
|
|
||
| setGamePaused(FALSE); | ||
|
|
||
| if (TheScriptEngine) | ||
| { | ||
| TheScriptEngine->forceUnfreezeTime(); | ||
| TheScriptEngine->doUnfreezeTime(); | ||
| } | ||
|
|
||
| if (toDesktop) | ||
| { | ||
| if (isInMultiplayerGame()) | ||
| { | ||
| m_quitToDesktopAfterMatch = TRUE; | ||
| exitGame(); | ||
| } | ||
| else | ||
| { | ||
| clearGameData(); | ||
| } | ||
| } | ||
| else | ||
| { | ||
| exitGame(); | ||
| } | ||
| } | ||
|
|
||
| if (toDesktop) | ||
| { | ||
| if (!isInMultiplayerGame()) | ||
| { | ||
| TheGameEngine->setQuitting(TRUE); | ||
| } | ||
| } | ||
|
|
||
| if (TheInGameUI) | ||
| { | ||
| TheInGameUI->setClientQuiet(TRUE); | ||
| } | ||
| } | ||
|
|
||
| // ------------------------------------------------------------------------------------------------ | ||
| /** A new GameLogic object has been constructed, therefore create | ||
| * a corresponding drawable and bind them together. */ | ||
|
|
||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.