From ff5ec77fec5eca15434ef5b3babccc02d5309494 Mon Sep 17 00:00:00 2001 From: Chris Danford Date: Wed, 26 May 2004 05:50:22 +0000 Subject: [PATCH] fix "unlocking a song doesn't automatically select it" --- stepmania/src/GameState.cpp | 18 ++++++++++-------- stepmania/src/GameState.h | 8 ++++++++ stepmania/src/ModeChoice.cpp | 6 ++++++ stepmania/src/MusicWheel.cpp | 4 +--- stepmania/src/Profile.cpp | 3 +++ stepmania/src/Profile.h | 1 + stepmania/src/ScreenSelectMusic.cpp | 7 +++++-- 7 files changed, 34 insertions(+), 13 deletions(-) diff --git a/stepmania/src/GameState.cpp b/stepmania/src/GameState.cpp index 59b75bedf4..14f4362439 100644 --- a/stepmania/src/GameState.cpp +++ b/stepmania/src/GameState.cpp @@ -142,9 +142,11 @@ void GameState::Reset() m_iRoundSeed = rand(); m_pCurSong = NULL; + m_pPreferredSong = NULL; FOREACH_PlayerNumber( p ) m_pCurSteps[p] = NULL; m_pCurCourse = NULL; + m_pPreferredCourse = NULL; FOREACH_PlayerNumber( p ) m_pCurTrail[p] = NULL; @@ -270,11 +272,11 @@ void GameState::PlayersFinalized() if( m_SortOrder == SORT_INVALID && pProfile->m_SortOrder != SORT_INVALID ) m_SortOrder = pProfile->m_SortOrder; if( pProfile->m_LastDifficulty != DIFFICULTY_INVALID ) - GAMESTATE->m_PreferredDifficulty[pn] = pProfile->m_LastDifficulty; + m_PreferredDifficulty[pn] = pProfile->m_LastDifficulty; if( pProfile->m_LastCourseDifficulty != COURSE_DIFFICULTY_INVALID ) - GAMESTATE->m_PreferredCourseDifficulty[pn] = pProfile->m_LastCourseDifficulty; - if( m_pCurSong == NULL && pProfile->m_pLastSong ) - m_pCurSong = pProfile->m_pLastSong; + m_PreferredCourseDifficulty[pn] = pProfile->m_LastCourseDifficulty; + if( m_pPreferredSong == NULL && pProfile->m_pLastSong ) + m_pPreferredSong = pProfile->m_pLastSong; } FOREACH_PlayerNumber( pn ) @@ -374,10 +376,6 @@ void GameState::EndGame() Profile* pProfile = PROFILEMAN->GetProfile(pn); - // persist settings - if( !g_vPlayedStageStats.empty() ) - pProfile->m_pLastSong = g_vPlayedStageStats.back().pSong; - PROFILEMAN->SaveProfile( pn ); PROFILEMAN->UnloadProfile( pn ); } @@ -405,6 +403,10 @@ void GameState::SaveCurrentSettingsToProfile( PlayerNumber pn ) pProfile->m_LastDifficulty = m_PreferredDifficulty[pn]; if( m_PreferredCourseDifficulty[pn] != COURSE_DIFFICULTY_INVALID ) pProfile->m_LastCourseDifficulty = m_PreferredCourseDifficulty[pn]; + if( m_pPreferredSong ) + pProfile->m_pLastSong = m_pPreferredSong; + if( m_pPreferredCourse ) + pProfile->m_pLastCourse = m_pPreferredCourse; } void GameState::Update( float fDelta ) diff --git a/stepmania/src/GameState.h b/stepmania/src/GameState.h index 426fe85caa..b08955ab24 100644 --- a/stepmania/src/GameState.h +++ b/stepmania/src/GameState.h @@ -139,9 +139,17 @@ public: // // State Info used during gameplay // + + // NULL on ScreenSelectMusic if the currently selected wheel item isn't a Song. Song* m_pCurSong; + // The last Song that the user manually changed to. + Song* m_pPreferredSong; Steps* m_pCurSteps[NUM_PLAYERS]; + + // NULL on ScreenSelectMusic if the currently selected wheel item isn't a Course. Course* m_pCurCourse; + // The last Course that the user manually changed to. + Course* m_pPreferredCourse; Course* m_pCurTrail[NUM_PLAYERS]; diff --git a/stepmania/src/ModeChoice.cpp b/stepmania/src/ModeChoice.cpp index 33efb74ec2..24288e50bf 100644 --- a/stepmania/src/ModeChoice.cpp +++ b/stepmania/src/ModeChoice.cpp @@ -422,11 +422,17 @@ void ModeChoice::Apply( PlayerNumber pn ) const if( m_sModifiers != "" ) GAMESTATE->ApplyModifiers( pn, m_sModifiers ); if( m_pSong ) + { GAMESTATE->m_pCurSong = m_pSong; + GAMESTATE->m_pPreferredSong = m_pSong; + } if( m_pSteps ) GAMESTATE->m_pCurSteps[pn] = m_pSteps; if( m_pCourse ) + { GAMESTATE->m_pCurCourse = m_pCourse; + GAMESTATE->m_pPreferredCourse = m_pCourse; + } if( m_pCharacter ) GAMESTATE->m_pCurCharacters[pn] = m_pCharacter; if( m_CourseDifficulty != COURSE_DIFFICULTY_INVALID ) diff --git a/stepmania/src/MusicWheel.cpp b/stepmania/src/MusicWheel.cpp index fd8d4b2661..d0cd534665 100644 --- a/stepmania/src/MusicWheel.cpp +++ b/stepmania/src/MusicWheel.cpp @@ -160,7 +160,7 @@ void MusicWheel::Load() pSteps, po, so ); - GAMESTATE->m_pCurSong = pSong; + GAMESTATE->m_pCurSong = GAMESTATE->m_pPreferredSong = pSong; FOREACH_PlayerNumber( p ) { if( GAMESTATE->IsHumanPlayer(p) ) @@ -269,8 +269,6 @@ bool MusicWheel::SelectSong( Song *p ) if(p == NULL) return false; - GAMESTATE->m_pCurSong = p; - unsigned i; vector &from = m_WheelItemDatas[GAMESTATE->m_SortOrder]; for( i=0; iAppendChild( "LastDifficulty", DifficultyToString(m_LastDifficulty) ); pGeneralDataNode->AppendChild( "LastCourseDifficulty", CourseDifficultyToString(m_LastCourseDifficulty) ); if( m_pLastSong ) pGeneralDataNode->AppendChild( "LastSong", m_pLastSong->GetSongDir() ); + if( m_pLastCourse ) pGeneralDataNode->AppendChild( "LastCourse",m_pLastCourse->m_sPath ); pGeneralDataNode->AppendChild( "TotalPlays", m_iTotalPlays ); pGeneralDataNode->AppendChild( "TotalPlaySeconds", m_iTotalPlaySeconds ); pGeneralDataNode->AppendChild( "TotalGameplaySeconds", m_iTotalGameplaySeconds ); @@ -881,6 +883,7 @@ void Profile::LoadGeneralDataFromNode( const XNode* pNode ) pNode->GetChildValue( "LastDifficulty", s ); m_LastDifficulty = StringToDifficulty( s ); pNode->GetChildValue( "LastCourseDifficulty", s ); m_LastCourseDifficulty = StringToCourseDifficulty( s ); pNode->GetChildValue( "LastSong", s ); m_pLastSong = SONGMAN->GetSongFromDir(s); + pNode->GetChildValue( "LastCourse", s ); m_pLastCourse = SONGMAN->GetCourseFromPath(s); pNode->GetChildValue( "TotalPlays", m_iTotalPlays ); pNode->GetChildValue( "TotalPlaySeconds", m_iTotalPlaySeconds ); pNode->GetChildValue( "TotalGameplaySeconds", m_iTotalGameplaySeconds ); diff --git a/stepmania/src/Profile.h b/stepmania/src/Profile.h index a45a4c2ecd..0b598403df 100644 --- a/stepmania/src/Profile.h +++ b/stepmania/src/Profile.h @@ -102,6 +102,7 @@ public: Difficulty m_LastDifficulty; CourseDifficulty m_LastCourseDifficulty; Song* m_pLastSong; + Course* m_pLastCourse; int m_iTotalPlays; int m_iTotalPlaySeconds; int m_iTotalGameplaySeconds; diff --git a/stepmania/src/ScreenSelectMusic.cpp b/stepmania/src/ScreenSelectMusic.cpp index 4c8911bebd..b5f9bba614 100644 --- a/stepmania/src/ScreenSelectMusic.cpp +++ b/stepmania/src/ScreenSelectMusic.cpp @@ -1291,14 +1291,17 @@ void ScreenSelectMusic::AfterMusicChange() } Song* pSong = m_MusicWheel.GetSelectedSong(); + GAMESTATE->m_pCurSong = pSong; if( pSong ) - GAMESTATE->m_pCurSong = pSong; + GAMESTATE->m_pPreferredSong = pSong; m_GrooveGraph.SetFromSong( pSong ); Course* pCourse = m_MusicWheel.GetSelectedCourse(); + GAMESTATE->m_pCurCourse = pCourse; if( pCourse ) - GAMESTATE->m_pCurCourse = pCourse; + GAMESTATE->m_pPreferredCourse = pCourse; + int pn; for( pn = 0; pn < NUM_PLAYERS; ++pn)