From 149cf04a78842e56ef2f2980cce966d6c33bad80 Mon Sep 17 00:00:00 2001 From: Barinade Date: Mon, 16 Sep 2019 20:23:15 -0500 Subject: [PATCH] Clean up Gamestate restartgameplay flag This means that practice mode is FORCED OFF when you exit gameplay 100% of the time unless you somehow exit gameplay in the middle of gameplay init --- src/Etterna/Screen/Gameplay/ScreenGameplay.cpp | 16 +++++++++++++--- src/Etterna/Screen/Gameplay/ScreenGameplay.h | 2 ++ .../Screen/Gameplay/ScreenGameplayPractice.h | 2 +- .../Screen/Gameplay/ScreenGameplayReplay.cpp | 6 +----- 4 files changed, 17 insertions(+), 9 deletions(-) diff --git a/src/Etterna/Screen/Gameplay/ScreenGameplay.cpp b/src/Etterna/Screen/Gameplay/ScreenGameplay.cpp index 8e9652d306..e32abe4a1d 100644 --- a/src/Etterna/Screen/Gameplay/ScreenGameplay.cpp +++ b/src/Etterna/Screen/Gameplay/ScreenGameplay.cpp @@ -328,6 +328,7 @@ ScreenGameplay::Init() m_GiveUpTimer.SetZero(); m_gave_up = false; + GAMESTATE->m_bRestartedGameplay = false; } bool @@ -383,6 +384,11 @@ ScreenGameplay::~ScreenGameplay() if (GAMESTATE->m_bPlayingMulti) NSMAN->ReportSongOver(); DLMAN->UpdateDLSpeed(false); + + if (!GAMESTATE->m_bRestartedGameplay) { + GAMESTATE->m_gameplayMode.Set(GameplayMode_Normal); + GAMESTATE->TogglePracticeMode(false); + } } void @@ -1202,8 +1208,14 @@ ScreenGameplay::BeginBackingOutFromGameplay() this->ClearMessageQueue(); m_Cancel.StartTransitioning(SM_DoPrevScreen); +} +void +ScreenGameplay::RestartGameplay() +{ GAMESTATE->m_bRestartedGameplay = true; + SCREENMAN->GetTopScreen()->SetPrevScreenName("ScreenStageInformation"); + BeginBackingOutFromGameplay(); } void @@ -1360,9 +1372,7 @@ ScreenGameplay::Input(const InputEventPlus& input) bHoldingRestart |= input.MenuI == GAME_BUTTON_RESTART; } if (bHoldingRestart) { - SCREENMAN->GetTopScreen()->SetPrevScreenName( - "ScreenStageInformation"); - BeginBackingOutFromGameplay(); + RestartGameplay(); } } diff --git a/src/Etterna/Screen/Gameplay/ScreenGameplay.h b/src/Etterna/Screen/Gameplay/ScreenGameplay.h index ce8783c872..1924a08066 100644 --- a/src/Etterna/Screen/Gameplay/ScreenGameplay.h +++ b/src/Etterna/Screen/Gameplay/ScreenGameplay.h @@ -111,6 +111,8 @@ class ScreenGameplay : public ScreenWithMenuElements void SaveReplay(); bool AllAreFailing(); + void RestartGameplay(); + virtual void InitSongQueues(); /** @brief The different game states of ScreenGameplay. */ diff --git a/src/Etterna/Screen/Gameplay/ScreenGameplayPractice.h b/src/Etterna/Screen/Gameplay/ScreenGameplayPractice.h index 434ba81384..6e8e78a865 100644 --- a/src/Etterna/Screen/Gameplay/ScreenGameplayPractice.h +++ b/src/Etterna/Screen/Gameplay/ScreenGameplayPractice.h @@ -22,7 +22,7 @@ class ScreenGameplayPractice : public ScreenGameplay void FailFadeRemovePlayer(PlayerInfo* pi); void FailFadeRemovePlayer(PlayerNumber pn); - void BeginBackingOutFromGameplay(); + // void BeginBackingOutFromGameplay(); // Set the playback rate in the middle of gameplay float SetRate(float newRate); diff --git a/src/Etterna/Screen/Gameplay/ScreenGameplayReplay.cpp b/src/Etterna/Screen/Gameplay/ScreenGameplayReplay.cpp index d2d02cfa16..97bc254534 100644 --- a/src/Etterna/Screen/Gameplay/ScreenGameplayReplay.cpp +++ b/src/Etterna/Screen/Gameplay/ScreenGameplayReplay.cpp @@ -77,9 +77,6 @@ ScreenGameplayReplay::~ScreenGameplayReplay() m_GameplayAssist.StopPlaying(); - if (!GAMESTATE->m_bRestartedGameplay) - GAMESTATE->m_gameplayMode.Set(GameplayMode_Normal); - DLMAN->UpdateDLSpeed(false); } @@ -218,8 +215,7 @@ ScreenGameplayReplay::Input(const InputEventPlus& input) bHoldingRestart |= input.MenuI == GAME_BUTTON_RESTART; } if (bHoldingRestart) { - SCREENMAN->GetTopScreen()->SetPrevScreenName("ScreenStageInformation"); - BeginBackingOutFromGameplay(); + RestartGameplay(); } return false;