Skip to content

Commit

Permalink
Undo rate change when viewing replay/eval screen
Browse files Browse the repository at this point in the history
  • Loading branch information
poco0317 committed Sep 7, 2018
1 parent dbe67c7 commit 0de270a
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/GameManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2746,6 +2746,8 @@ static const Game *g_Games[] =

GameManager::GameManager()
{
m_bSetSongRateInEvalScreen = false;
m_fPreviousRate = 1.f;
// Register with Lua.
{
Lua *L = LUA->Get();
Expand Down
3 changes: 3 additions & 0 deletions src/GameManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@ class GameManager
const Style* GameAndStringToStyle( const Game* pGame, const RString &sStyle );
RString StyleToLocalizedString( const Style* s );

bool m_bSetSongRateInEvalScreen;
float m_fPreviousRate;


// Lua
void PushSelf( lua_State *L );
Expand Down
10 changes: 10 additions & 0 deletions src/ScreenEvaluation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -754,6 +754,16 @@ void ScreenEvaluation::HandleMenuStart()
stepsid.FromSteps(GAMESTATE->m_pCurSteps[PLAYER_1]);
SongID songid;
songid.FromSong(GAMESTATE->m_pCurSong);
if (GAMEMAN->m_bSetSongRateInEvalScreen)
{
float oldRate = GAMEMAN->m_fPreviousRate;
GAMESTATE->m_SongOptions.GetSong().m_fMusicRate = oldRate;
GAMESTATE->m_SongOptions.GetCurrent().m_fMusicRate = oldRate;
GAMESTATE->m_SongOptions.GetPreferred().m_fMusicRate = oldRate;
GAMEMAN->m_bSetSongRateInEvalScreen = false;
MESSAGEMAN->Broadcast("RateChanged");

}
StartTransitioningScreen( SM_GoToNextScreen );
}

Expand Down
13 changes: 13 additions & 0 deletions src/ScreenSelectMusic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1878,14 +1878,20 @@ class LunaScreenSelectMusic : public Luna<ScreenSelectMusic>

// set the heck out of the current rate to make sure everything runs correctly
float scoreRate = hs->GetMusicRate();
float oldRate = GAMESTATE->m_SongOptions.GetPreferred().m_fMusicRate;
GAMESTATE->m_SongOptions.GetSong().m_fMusicRate = scoreRate;
GAMESTATE->m_SongOptions.GetCurrent().m_fMusicRate = scoreRate;
GAMESTATE->m_SongOptions.GetPreferred().m_fMusicRate = scoreRate;
MESSAGEMAN->Broadcast("RateChanged");

// lock the game into replay mode and GO
LOG->Trace("Viewing replay for score key %s", hs->GetScoreKey());
GamePreferences::m_AutoPlay.Set(PC_REPLAY);
p->SelectCurrent(PLAYER_1);

// set rate back to what it was before
GAMEMAN->m_bSetSongRateInEvalScreen = true;
GAMEMAN->m_fPreviousRate = oldRate;
return 1;
}

Expand Down Expand Up @@ -1931,13 +1937,20 @@ class LunaScreenSelectMusic : public Luna<ScreenSelectMusic>
// this might confuse the player after leaving eval screen because of the new rate
// but whatever, for now
float scoreRate = hs->GetMusicRate();
float oldRate = GAMESTATE->m_SongOptions.GetPreferred().m_fMusicRate;
GAMESTATE->m_SongOptions.GetSong().m_fMusicRate = scoreRate;
GAMESTATE->m_SongOptions.GetCurrent().m_fMusicRate = scoreRate;
GAMESTATE->m_SongOptions.GetPreferred().m_fMusicRate = scoreRate;
MESSAGEMAN->Broadcast("RateChanged");

// go
LOG->Trace("Viewing evaluation screen for score key %s", score->GetScoreKey());
SCREENMAN->SetNewScreen("ScreenEvaluationNormal");

// set rate back to what it was before
GAMEMAN->m_bSetSongRateInEvalScreen = true;
GAMEMAN->m_fPreviousRate = oldRate;

return 1;
}

Expand Down

0 comments on commit 0de270a

Please sign in to comment.