diff --git a/stepmania/src/Course.cpp b/stepmania/src/Course.cpp index 88a05db990..1612c8dca8 100644 --- a/stepmania/src/Course.cpp +++ b/stepmania/src/Course.cpp @@ -51,7 +51,7 @@ PlayMode Course::GetPlayMode() const float Course::GetMeterForPlayer( PlayerNumber pn ) const { - return GetMeter( GAMESTATE->m_CourseDifficulty[pn] ); + return GetMeter( GAMESTATE->m_PreferredCourseDifficulty[pn] ); } float Course::GetMeter( CourseDifficulty cd ) const diff --git a/stepmania/src/CourseContentsList.cpp b/stepmania/src/CourseContentsList.cpp index f2030071b0..58b661784a 100644 --- a/stepmania/src/CourseContentsList.cpp +++ b/stepmania/src/CourseContentsList.cpp @@ -59,7 +59,7 @@ void CourseContentsList::SetFromCourse( const Course* pCourse ) vector ci[NUM_PLAYERS]; for( int pn = 0; pn < NUM_PLAYERS; ++pn ) - pCourse->GetCourseInfo( GAMESTATE->GetCurrentStyleDef()->m_StepsType, ci[pn], GAMESTATE->m_CourseDifficulty[pn] ); + pCourse->GetCourseInfo( GAMESTATE->GetCurrentStyleDef()->m_StepsType, ci[pn], GAMESTATE->m_PreferredCourseDifficulty[pn] ); m_iNumContents = 0; for( int i=0; i #include "MemoryCardManager.h" #include "StageStats.h" +#include "GameConstantsAndTypes.h" #define DEFAULT_MODIFIERS THEME->GetMetric( "Common","DefaultModifiers" ) @@ -91,7 +92,7 @@ void GameState::Reset() for( p=0; pm_PlayerOptions[pn].Init(); GAMESTATE->ApplyModifiers( pn, pProfile->m_sDefaultModifiers ); } + // Only set the sort order if it wasn't already set by a ModeChoice + if( m_SortOrder == SORT_INVALID ) + m_SortOrder = pProfile->m_SortOrder; if( pProfile->m_PreferredDifficulty != DIFFICULTY_INVALID ) GAMESTATE->m_PreferredDifficulty[pn] = pProfile->m_PreferredDifficulty; + if( pProfile->m_PreferredCourseDifficulty != COURSE_DIFFICULTY_INVALID ) + GAMESTATE->m_PreferredCourseDifficulty[pn] = pProfile->m_PreferredCourseDifficulty; } @@ -301,8 +307,15 @@ void GameState::EndGame() Profile* pProfile = PROFILEMAN->GetProfile(pn); - // persist current settings - pProfile->m_PreferredDifficulty = m_PreferredDifficulty[pn]; + // persist settings + pProfile->m_bUsingProfileDefaultModifiers = true; + pProfile->m_sDefaultModifiers = m_PlayerOptions[pn].GetString(); + if( IsSongSort(m_SortOrder) ) + pProfile->m_SortOrder = m_SortOrder; + if( m_PreferredDifficulty[pn] != DIFFICULTY_INVALID ) + pProfile->m_PreferredDifficulty = m_PreferredDifficulty[pn]; + if( m_PreferredCourseDifficulty[pn] != COURSE_DIFFICULTY_INVALID ) + pProfile->m_PreferredCourseDifficulty = m_PreferredCourseDifficulty[pn]; PROFILEMAN->SaveProfile( pn ); PROFILEMAN->UnloadProfile( pn ); @@ -1305,7 +1318,7 @@ void GameState::GetRankingFeats( PlayerNumber pn, vector &asFeatsOu StepsType nt = this->GetCurrentStyleDef()->m_StepsType; Course* pCourse = this->m_pCurCourse; ASSERT( pCourse ); - CourseDifficulty cd = this->m_CourseDifficulty[pn]; + CourseDifficulty cd = this->m_PreferredCourseDifficulty[pn]; // Find Machine Records { @@ -1445,14 +1458,14 @@ bool GameState::IsTimeToPlayAttractSounds() bool GameState::ChangeCourseDifficulty( PlayerNumber pn, int dir ) { - CourseDifficulty diff = (CourseDifficulty)(m_CourseDifficulty[pn]+dir); + CourseDifficulty diff = (CourseDifficulty)(m_PreferredCourseDifficulty[pn]+dir); if( diff < 0 || diff >= NUM_COURSE_DIFFICULTIES ) return false; - this->m_CourseDifficulty[pn] = diff; + this->m_PreferredCourseDifficulty[pn] = diff; if( PREFSMAN->m_bLockCourseDifficulties ) for( int p = 0; p < NUM_PLAYERS; ++p ) - m_CourseDifficulty[p] = m_CourseDifficulty[pn]; + m_PreferredCourseDifficulty[p] = m_PreferredCourseDifficulty[pn]; return true; } diff --git a/stepmania/src/GameState.h b/stepmania/src/GameState.h index a691fc563f..bb1bf7255b 100644 --- a/stepmania/src/GameState.h +++ b/stepmania/src/GameState.h @@ -49,16 +49,16 @@ public: // // Main state info // - Game m_CurGame; - Style m_CurStyle; - bool m_bSideIsJoined[NUM_PLAYERS]; // left side, right side - PlayMode m_PlayMode; // many screens display different info depending on this value - int m_iCoins; // not "credits" - PlayerNumber m_MasterPlayerNumber; // used in Styles where one player controls both sides - bool m_bIsOnSystemMenu; // system screens will not be effected by the operator key -- Miryokuteki - CourseDifficulty m_CourseDifficulty[NUM_PLAYERS]; // used in nonstop + Game m_CurGame; + Style m_CurStyle; + bool m_bSideIsJoined[NUM_PLAYERS]; // left side, right side + PlayMode m_PlayMode; // many screens display different info depending on this value + int m_iCoins; // not "credits" + PlayerNumber m_MasterPlayerNumber; // used in Styles where one player controls both sides + bool m_bIsOnSystemMenu; // system screens will not be effected by the operator key -- Miryokuteki + CourseDifficulty m_PreferredCourseDifficulty[NUM_PLAYERS]; // used in nonstop bool ChangeCourseDifficulty( PlayerNumber pn, int dir ); - RageTimer m_timeGameStarted; // from the moment the first player pressed Start + RageTimer m_timeGameStarted; // from the moment the first player pressed Start /* This is set to a random number per-game/round; it can be used for a random seed. */ int m_iGameSeed, m_iRoundSeed; diff --git a/stepmania/src/ModeChoice.cpp b/stepmania/src/ModeChoice.cpp index 5d0172e871..8c429cc021 100644 --- a/stepmania/src/ModeChoice.cpp +++ b/stepmania/src/ModeChoice.cpp @@ -86,7 +86,7 @@ bool ModeChoice::DescribesCurrentMode( PlayerNumber pn ) const return false; if( m_pCharacter && GAMESTATE->m_pCurCharacters[pn] != m_pCharacter ) return false; - if( m_CourseDifficulty != COURSE_DIFFICULTY_INVALID && GAMESTATE->m_CourseDifficulty[pn] != m_CourseDifficulty ) + if( m_CourseDifficulty != COURSE_DIFFICULTY_INVALID && GAMESTATE->m_PreferredCourseDifficulty[pn] != m_CourseDifficulty ) return false; return true; @@ -322,10 +322,10 @@ void ModeChoice::Apply( PlayerNumber pn ) const GAMESTATE->m_pCurCharacters[pn] = m_pCharacter; if( m_CourseDifficulty != COURSE_DIFFICULTY_INVALID ) { - GAMESTATE->m_CourseDifficulty[pn] = m_CourseDifficulty; + GAMESTATE->m_PreferredCourseDifficulty[pn] = m_CourseDifficulty; if( PREFSMAN->m_bLockCourseDifficulties ) for( int p = 0; p < NUM_PLAYERS; ++p ) - GAMESTATE->m_CourseDifficulty[p] = GAMESTATE->m_CourseDifficulty[pn]; + GAMESTATE->m_PreferredCourseDifficulty[p] = GAMESTATE->m_PreferredCourseDifficulty[pn]; } // HACK: Set life type to BATTERY just once here so it happens once and diff --git a/stepmania/src/MusicWheel.cpp b/stepmania/src/MusicWheel.cpp index 94934b088a..979730330d 100644 --- a/stepmania/src/MusicWheel.cpp +++ b/stepmania/src/MusicWheel.cpp @@ -33,7 +33,6 @@ #include "UnlockSystem.h" #include "ModeChoice.h" #include "ActorUtil.h" -#include "ProfileManager.h" #define FADE_SECONDS THEME->GetMetricF("MusicWheel","FadeSeconds") @@ -173,34 +172,21 @@ void MusicWheel::Load() GAMESTATE->m_SongOptions = so; } - if( GAMESTATE->m_SortOrder == SORT_INVALID ) + switch( GAMESTATE->m_PlayMode ) { - switch( GAMESTATE->m_PlayMode ) + // in course modes, force a particular sort + case PLAY_MODE_ONI: GAMESTATE->m_SortOrder = SORT_ONI_COURSES; break; + case PLAY_MODE_NONSTOP: GAMESTATE->m_SortOrder = SORT_NONSTOP_COURSES; break; + case PLAY_MODE_ENDLESS: GAMESTATE->m_SortOrder = SORT_ENDLESS_COURSES; break; + default: + // if no player preferred sort, fall back to theme default + if( GAMESTATE->m_SortOrder == SORT_INVALID ) { - case PLAY_MODE_ONI: GAMESTATE->m_SortOrder = SORT_ONI_COURSES; break; - case PLAY_MODE_NONSTOP: GAMESTATE->m_SortOrder = SORT_NONSTOP_COURSES; break; - case PLAY_MODE_ENDLESS: GAMESTATE->m_SortOrder = SORT_ENDLESS_COURSES; break; - default: - // look for a player's saved sort - FOREACH_HumanPlayer( pn ) - { - if( PROFILEMAN->IsUsingProfile(pn) ) - { - GAMESTATE->m_SortOrder = PROFILEMAN->GetProfile(pn)->m_SortOrder; - if( GAMESTATE->m_SortOrder != SORT_INVALID ) // we found one - break; // stop searching - } - } - - // if no player preferred sort, fall back to theme default - if( GAMESTATE->m_SortOrder == SORT_INVALID ) - { - GAMESTATE->m_SortOrder = StringToSortOrder( DEFAULT_SORT ); - ASSERT( GAMESTATE->m_SortOrder != SORT_INVALID ); - } - - break; + GAMESTATE->m_SortOrder = StringToSortOrder( DEFAULT_SORT ); + ASSERT( GAMESTATE->m_SortOrder != SORT_INVALID ); } + + break; } /* Update for SORT_MOST_PLAYED. */ @@ -1171,17 +1157,6 @@ bool MusicWheel::ChangeSort( SortOrder new_so ) // return true if change success m_LastSortOrder = GAMESTATE->m_SortOrder; GAMESTATE->m_SortOrder = new_so; - // Save the new sort to all profiles - // HACK: Don't save course sorts - if( IsSongSort(new_so) ) - { - FOREACH_HumanPlayer( pn ) - { - if( PROFILEMAN->IsUsingProfile(pn) ) - PROFILEMAN->GetProfile(pn)->m_SortOrder = new_so; - } - } - m_WheelState = STATE_FLYING_OFF_BEFORE_NEXT_SORT; return true; } diff --git a/stepmania/src/PaneDisplay.cpp b/stepmania/src/PaneDisplay.cpp index f6481b7b83..f1f50cbcde 100644 --- a/stepmania/src/PaneDisplay.cpp +++ b/stepmania/src/PaneDisplay.cpp @@ -158,7 +158,7 @@ void PaneDisplay::SetContent( PaneContents c ) else if( g_Contents[c].req&NEED_COURSE ) { vector ci; - CourseDifficulty cd = GAMESTATE->m_CourseDifficulty[m_PlayerNumber]; + CourseDifficulty cd = GAMESTATE->m_PreferredCourseDifficulty[m_PlayerNumber]; StepsType st = GAMESTATE->GetCurrentStyleDef()->m_StepsType; rv = GAMESTATE->m_pCurCourse->GetRadarValues( st, cd ); } @@ -167,7 +167,7 @@ void PaneDisplay::SetContent( PaneContents c ) const Steps *pSteps = GAMESTATE->m_pCurNotes[m_PlayerNumber]; StepsType st = GAMESTATE->GetCurrentStyleDef()->m_StepsType; const Course *pCourse = GAMESTATE->m_pCurCourse; - const CourseDifficulty cd = GAMESTATE->m_CourseDifficulty[m_PlayerNumber]; + const CourseDifficulty cd = GAMESTATE->m_PreferredCourseDifficulty[m_PlayerNumber]; float val = 0; CString str; diff --git a/stepmania/src/Profile.cpp b/stepmania/src/Profile.cpp index fa85c33c5b..1a3a567190 100644 --- a/stepmania/src/Profile.cpp +++ b/stepmania/src/Profile.cpp @@ -70,6 +70,7 @@ void Profile::InitGeneralData() m_sDefaultModifiers = ""; m_SortOrder = SORT_INVALID; m_PreferredDifficulty = DIFFICULTY_INVALID; + m_PreferredCourseDifficulty = COURSE_DIFFICULTY_INVALID; m_iTotalPlays = 0; m_iTotalPlaySeconds = 0; m_iTotalGameplaySeconds = 0; @@ -570,6 +571,7 @@ XNode* Profile::SaveGeneralDataCreateNode() const pGeneralDataNode->AppendChild( "DefaultModifiers", m_sDefaultModifiers ); pGeneralDataNode->AppendChild( "SortOrder", SortOrderToString(m_SortOrder) ); pGeneralDataNode->AppendChild( "PreferredDifficulty", DifficultyToString(m_PreferredDifficulty) ); + pGeneralDataNode->AppendChild( "PreferredCourseDifficulty", CourseDifficultyToString(m_PreferredCourseDifficulty) ); pGeneralDataNode->AppendChild( "TotalPlays", m_iTotalPlays ); pGeneralDataNode->AppendChild( "TotalPlaySeconds", m_iTotalPlaySeconds ); pGeneralDataNode->AppendChild( "TotalGameplaySeconds", m_iTotalGameplaySeconds ); @@ -702,13 +704,13 @@ void Profile::LoadGeneralDataFromNode( const XNode* pNode ) { ASSERT( pNode->name == "GeneralData" ); + CString s; + pNode->GetChildValue( "UsingProfileDefaultModifiers", m_bUsingProfileDefaultModifiers ); pNode->GetChildValue( "DefaultModifiers", m_sDefaultModifiers ); - CString s; - pNode->GetChildValue( "SortOrder", s ); - m_SortOrder = StringToSortOrder( s ); - pNode->GetChildValue( "PreferredDifficulty", s ); - m_PreferredDifficulty = StringToDifficulty( s ); + pNode->GetChildValue( "SortOrder", s ); m_SortOrder = StringToSortOrder( s ); + pNode->GetChildValue( "PreferredDifficulty", s ); m_PreferredDifficulty = StringToDifficulty( s ); + pNode->GetChildValue( "PreferredCourseDifficulty", s ); m_PreferredCourseDifficulty = StringToCourseDifficulty( 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 6b95e38974..56995b0c6b 100644 --- a/stepmania/src/Profile.h +++ b/stepmania/src/Profile.h @@ -90,6 +90,7 @@ public: CString m_sDefaultModifiers; SortOrder m_SortOrder; Difficulty m_PreferredDifficulty; + CourseDifficulty m_PreferredCourseDifficulty; int m_iTotalPlays; int m_iTotalPlaySeconds; int m_iTotalGameplaySeconds; diff --git a/stepmania/src/ScreenEvaluation.cpp b/stepmania/src/ScreenEvaluation.cpp index 8b8c5c8ecd..8efd29f12c 100644 --- a/stepmania/src/ScreenEvaluation.cpp +++ b/stepmania/src/ScreenEvaluation.cpp @@ -912,7 +912,7 @@ void ScreenEvaluation::CommitScores( const StageStats &stageStats, int iPersonal case course: { Course* pCourse = GAMESTATE->m_pCurCourse; - CourseDifficulty cd = GAMESTATE->m_CourseDifficulty[p]; + CourseDifficulty cd = GAMESTATE->m_PreferredCourseDifficulty[p]; ASSERT( pCourse ); // don't save scores for a failed Nonstop diff --git a/stepmania/src/ScreenGameplay.cpp b/stepmania/src/ScreenGameplay.cpp index f739e7912a..4cd2653a27 100644 --- a/stepmania/src/ScreenGameplay.cpp +++ b/stepmania/src/ScreenGameplay.cpp @@ -176,12 +176,12 @@ void ScreenGameplay::Init() if( !m_bDemonstration ) for( p=0; pIsPlayerEnabled(p) ) - PROFILEMAN->IncrementCoursePlayCount( GAMESTATE->m_pCurCourse, st, GAMESTATE->m_CourseDifficulty[p], (PlayerNumber)p ); + PROFILEMAN->IncrementCoursePlayCount( GAMESTATE->m_pCurCourse, st, GAMESTATE->m_PreferredCourseDifficulty[p], (PlayerNumber)p ); for( int p=0; p ci; - GAMESTATE->m_pCurCourse->GetCourseInfo( GAMESTATE->GetCurrentStyleDef()->m_StepsType, ci, GAMESTATE->m_CourseDifficulty[p] ); + GAMESTATE->m_pCurCourse->GetCourseInfo( GAMESTATE->GetCurrentStyleDef()->m_StepsType, ci, GAMESTATE->m_PreferredCourseDifficulty[p] ); m_apNotesQueue[p].clear(); m_asModifiersQueue[p].clear(); diff --git a/stepmania/src/ScreenNameEntryTraditional.cpp b/stepmania/src/ScreenNameEntryTraditional.cpp index 8af6de50da..e5de0c6f0e 100644 --- a/stepmania/src/ScreenNameEntryTraditional.cpp +++ b/stepmania/src/ScreenNameEntryTraditional.cpp @@ -322,7 +322,7 @@ ScreenNameEntryTraditional::ScreenNameEntryTraditional( CString sClassName ) : S const HighScoreList& hsl = GAMESTATE->IsCourseMode() ? - PROFILEMAN->GetMachineProfile()->GetCourseHighScoreList(pCourse, GAMESTATE->GetCurrentStyleDef()->m_StepsType, GAMESTATE->m_CourseDifficulty[p]) : + PROFILEMAN->GetMachineProfile()->GetCourseHighScoreList(pCourse, GAMESTATE->GetCurrentStyleDef()->m_StepsType, GAMESTATE->m_PreferredCourseDifficulty[p]) : PROFILEMAN->GetMachineProfile()->GetStepsHighScoreList(pSteps); for( unsigned h=0; hGetPathToG(ssprintf("ScreenNameEntryTraditional difficulty icons 1x%d",NUM_DIFFICULTIES)) ); if( GAMESTATE->IsCourseMode() ) - m_FeatDisplay[p][i].m_Difficulty.SetFromCourseDifficulty( (PlayerNumber)p, GAMESTATE->m_CourseDifficulty[p] ); + m_FeatDisplay[p][i].m_Difficulty.SetFromCourseDifficulty( (PlayerNumber)p, GAMESTATE->m_PreferredCourseDifficulty[p] ); else m_FeatDisplay[p][i].m_Difficulty.SetFromNotes( (PlayerNumber)p, pSteps ); SET_ON( m_FeatDisplay[p][i].m_Difficulty ); diff --git a/stepmania/src/ScreenPlayerOptions.cpp b/stepmania/src/ScreenPlayerOptions.cpp index 093ffc037a..940f1cf119 100644 --- a/stepmania/src/ScreenPlayerOptions.cpp +++ b/stepmania/src/ScreenPlayerOptions.cpp @@ -18,7 +18,6 @@ #include "ScreenSongOptions.h" #include "PrefsManager.h" #include "CodeDetector.h" -#include "ProfileManager.h" #define PREV_SCREEN( play_mode ) THEME->GetMetric ("ScreenPlayerOptions","PrevScreen"+Capitalize(PlayModeToString(play_mode))) @@ -171,22 +170,6 @@ void ScreenPlayerOptions::HandleScreenMessage( const ScreenMessage SM ) ScreenOptionsMaster::HandleScreenMessage( SM ); } -void ScreenPlayerOptions::ExportOptions() -{ - ScreenOptionsMaster::ExportOptions(); - - // automatically save all options to profile - FOREACH_HumanPlayer( pn ) - { - if( PROFILEMAN->IsUsingProfile(pn) ) - { - Profile* pProfile = PROFILEMAN->GetProfile(pn); - pProfile->m_bUsingProfileDefaultModifiers = true; - pProfile->m_sDefaultModifiers = GAMESTATE->m_PlayerOptions[pn].GetString(); - } - } -} - void ScreenPlayerOptions::UpdateDisqualified() { // save current player options diff --git a/stepmania/src/ScreenPlayerOptions.h b/stepmania/src/ScreenPlayerOptions.h index 1c19af9f5a..4fe9df4027 100644 --- a/stepmania/src/ScreenPlayerOptions.h +++ b/stepmania/src/ScreenPlayerOptions.h @@ -25,8 +25,6 @@ private: void GoToNextState(); void GoToPrevState(); - virtual void ExportOptions(); - void UpdateDisqualified(); bool m_bAcceptedChoices; diff --git a/stepmania/src/ScreenSelectCourse.cpp b/stepmania/src/ScreenSelectCourse.cpp index aa3aa88151..8e3134f718 100644 --- a/stepmania/src/ScreenSelectCourse.cpp +++ b/stepmania/src/ScreenSelectCourse.cpp @@ -415,7 +415,7 @@ void ScreenSelectCourse::AfterCourseChange() ASSERT(pCourse); for( int p=0; pm_CourseDifficulty[p]; + CourseDifficulty cd = GAMESTATE->m_PreferredCourseDifficulty[p]; Profile* pProfile; if( PROFILEMAN->IsUsingProfile( (PlayerNumber)p ) )