Skip to content

Commit

Permalink
Clean up Gamestate restartgameplay flag
Browse files Browse the repository at this point in the history
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
  • Loading branch information
poco0317 committed Sep 17, 2019
1 parent d71d937 commit 149cf04
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 9 deletions.
16 changes: 13 additions & 3 deletions src/Etterna/Screen/Gameplay/ScreenGameplay.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,7 @@ ScreenGameplay::Init()

m_GiveUpTimer.SetZero();
m_gave_up = false;
GAMESTATE->m_bRestartedGameplay = false;
}

bool
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -1360,9 +1372,7 @@ ScreenGameplay::Input(const InputEventPlus& input)
bHoldingRestart |= input.MenuI == GAME_BUTTON_RESTART;
}
if (bHoldingRestart) {
SCREENMAN->GetTopScreen()->SetPrevScreenName(
"ScreenStageInformation");
BeginBackingOutFromGameplay();
RestartGameplay();
}
}

Expand Down
2 changes: 2 additions & 0 deletions src/Etterna/Screen/Gameplay/ScreenGameplay.h
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,8 @@ class ScreenGameplay : public ScreenWithMenuElements
void SaveReplay();
bool AllAreFailing();

void RestartGameplay();

virtual void InitSongQueues();

/** @brief The different game states of ScreenGameplay. */
Expand Down
2 changes: 1 addition & 1 deletion src/Etterna/Screen/Gameplay/ScreenGameplayPractice.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
6 changes: 1 addition & 5 deletions src/Etterna/Screen/Gameplay/ScreenGameplayReplay.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,6 @@ ScreenGameplayReplay::~ScreenGameplayReplay()

m_GameplayAssist.StopPlaying();

if (!GAMESTATE->m_bRestartedGameplay)
GAMESTATE->m_gameplayMode.Set(GameplayMode_Normal);

DLMAN->UpdateDLSpeed(false);
}

Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 149cf04

Please sign in to comment.