From dd84b4ffd6be7af5bfdb5b0f25c015ca5982d858 Mon Sep 17 00:00:00 2001 From: Chris Danford Date: Thu, 7 Apr 2005 08:46:40 +0000 Subject: [PATCH] separate course popularities for each PlayMode don't calculate autogen courses in best list if they're not shown --- stepmania/src/Course.cpp | 17 ++++++++++--- stepmania/src/Course.h | 14 +++++++++++ stepmania/src/MusicWheel.cpp | 6 ++--- stepmania/src/PaneDisplay.cpp | 16 +++++++----- stepmania/src/ScreenSelectMusic.cpp | 3 ++- stepmania/src/SongManager.cpp | 39 +++++++++++------------------ stepmania/src/SongManager.h | 10 +++----- 7 files changed, 61 insertions(+), 44 deletions(-) diff --git a/stepmania/src/Course.cpp b/stepmania/src/Course.cpp index d4c44353ab..7f0bc7b380 100644 --- a/stepmania/src/Course.cpp +++ b/stepmania/src/Course.cpp @@ -40,11 +40,22 @@ Course::Course() Init(); } -PlayMode Course::GetPlayMode() const +CourseType Course::GetCourseType() const { if( m_bRepeat ) - return PLAY_MODE_ENDLESS; - return m_iLives > 0? PLAY_MODE_ONI:PLAY_MODE_NONSTOP; + return COURSE_TYPE_ENDLESS; + return m_iLives > 0? COURSE_TYPE_ONI:COURSE_TYPE_NONSTOP; +} + +PlayMode Course::GetPlayMode() const +{ + switch( GetCourseType() ) + { + case COURSE_TYPE_ENDLESS: return PLAY_MODE_ENDLESS; + case COURSE_TYPE_ONI: return PLAY_MODE_ONI; + case COURSE_TYPE_NONSTOP: return PLAY_MODE_NONSTOP; + default: ASSERT(0); return PLAY_MODE_INVALID; + } } void Course::LoadFromCRSFile( CString sPath ) diff --git a/stepmania/src/Course.h b/stepmania/src/Course.h index 03d2b738ef..62924a10ba 100644 --- a/stepmania/src/Course.h +++ b/stepmania/src/Course.h @@ -9,6 +9,7 @@ #include #include "Trail.h" #include +#include "EnumHelper.h" struct PlayerOptions; struct SongOptions; @@ -17,6 +18,18 @@ class Steps; class Profile; struct lua_State; +enum CourseType +{ + COURSE_TYPE_NONSTOP, // if life meter type is BAR + COURSE_TYPE_ONI, // if life meter type is BATTERY + COURSE_TYPE_ENDLESS, // if set to REPEAT + NUM_COURSE_TYPES +}; +#define FOREACH_CourseType( i ) FOREACH_ENUM( CourseType, NUM_COURSE_TYPES, i ) + +inline PlayMode CourseTypeToPlayMode( CourseType ct ) { return (PlayMode)(PLAY_MODE_NONSTOP+ct); } +inline CourseType PlayModeToCourseType( PlayMode pm ) { return (CourseType)(pm-PLAY_MODE_NONSTOP); } + enum CourseEntryType { COURSE_ENTRY_FIXED, @@ -125,6 +138,7 @@ public: bool IsNonstop() const { return GetPlayMode() == PLAY_MODE_NONSTOP; } bool IsOni() const { return GetPlayMode() == PLAY_MODE_ONI; } bool IsEndless() const { return GetPlayMode() == PLAY_MODE_ENDLESS; } + CourseType GetCourseType() const; PlayMode GetPlayMode() const; bool IsFixed() const; diff --git a/stepmania/src/MusicWheel.cpp b/stepmania/src/MusicWheel.cpp index 5b7b9fbfb3..47889ef8ad 100644 --- a/stepmania/src/MusicWheel.cpp +++ b/stepmania/src/MusicWheel.cpp @@ -684,9 +684,9 @@ void MusicWheel::BuildWheelItemDatas( vector &arrayWheelItemDatas vector apCourses; switch( so ) { - case SORT_NONSTOP_COURSES: SONGMAN->GetNonstopCourses( apCourses, PREFSMAN->m_bAutogenGroupCourses ); break; - case SORT_ONI_COURSES: SONGMAN->GetOniCourses( apCourses, PREFSMAN->m_bAutogenGroupCourses ); break; - case SORT_ENDLESS_COURSES: SONGMAN->GetEndlessCourses( apCourses, PREFSMAN->m_bAutogenGroupCourses ); break; + case SORT_NONSTOP_COURSES: SONGMAN->GetCourses( COURSE_TYPE_NONSTOP, apCourses, PREFSMAN->m_bAutogenGroupCourses ); break; + case SORT_ONI_COURSES: SONGMAN->GetCourses( COURSE_TYPE_ONI, apCourses, PREFSMAN->m_bAutogenGroupCourses ); break; + case SORT_ENDLESS_COURSES: SONGMAN->GetCourses( COURSE_TYPE_ENDLESS, apCourses, PREFSMAN->m_bAutogenGroupCourses ); break; case SORT_ALL_COURSES: SONGMAN->GetAllCourses( apCourses, PREFSMAN->m_bAutogenGroupCourses ); break; default: ASSERT(0); break; } diff --git a/stepmania/src/PaneDisplay.cpp b/stepmania/src/PaneDisplay.cpp index afd8fc25c7..350ae010aa 100644 --- a/stepmania/src/PaneDisplay.cpp +++ b/stepmania/src/PaneDisplay.cpp @@ -250,9 +250,10 @@ void PaneDisplay::SetContent( PaneContents c ) case COURSE_MACHINE_RANK: { - const vector best = SONGMAN->GetBestCourses( PROFILE_SLOT_MACHINE ); - val = (float) FindIndex( best.begin(), best.end(), pCourse ); - val += 1; + CourseType ct = PlayModeToCourseType( GAMESTATE->m_PlayMode ); + const vector best = SONGMAN->GetBestCourses( ct, PROFILE_SLOT_MACHINE ); + val = (float) FindIndex( best.begin(), best.end(), pCourse ); + val += 1; } break; @@ -264,9 +265,12 @@ void PaneDisplay::SetContent( PaneContents c ) break; case COURSE_PROFILE_RANK: - const vector best = SONGMAN->GetBestCourses( PlayerMemCard(m_PlayerNumber) ); - val = (float) FindIndex( best.begin(), best.end(), pCourse ); - val += 1; + { + CourseType ct = PlayModeToCourseType( GAMESTATE->m_PlayMode ); + const vector best = SONGMAN->GetBestCourses( ct, PlayerMemCard(m_PlayerNumber) ); + val = (float) FindIndex( best.begin(), best.end(), pCourse ); + val += 1; + } break; }; diff --git a/stepmania/src/ScreenSelectMusic.cpp b/stepmania/src/ScreenSelectMusic.cpp index b78cdd6bad..a5a9a5dbc9 100644 --- a/stepmania/src/ScreenSelectMusic.cpp +++ b/stepmania/src/ScreenSelectMusic.cpp @@ -1709,7 +1709,8 @@ void ScreenSelectMusic::AfterMusicChange() } } - const vector best = SONGMAN->GetBestCourses( PROFILE_SLOT_MACHINE ); + CourseType ct = PlayModeToCourseType( GAMESTATE->m_PlayMode ); + const vector best = SONGMAN->GetBestCourses( ct, PROFILE_SLOT_MACHINE ); const int index = FindCourseIndexOfSameMode( best.begin(), best.end(), pCourse ); if( index != -1 ) m_MachineRank.SetText( AddNumberSuffix( index+1 ) ); diff --git a/stepmania/src/SongManager.cpp b/stepmania/src/SongManager.cpp index 882a7871ac..964e659ee7 100644 --- a/stepmania/src/SongManager.cpp +++ b/stepmania/src/SongManager.cpp @@ -642,7 +642,8 @@ void SongManager::FreeCourses() m_pCourses.clear(); for( int i = 0; i < NUM_PROFILE_SLOTS; ++i ) - m_pBestCourses[i].clear(); + FOREACH_CourseType( ct ) + m_pBestCourses[i][ct].clear(); m_pShuffledCourses.clear(); } @@ -845,31 +846,14 @@ void SongManager::GetAllCourses( vector &AddTo, bool bIncludeAutogen ) AddTo.push_back( m_pCourses[i] ); } -void SongManager::GetNonstopCourses( vector &AddTo, bool bIncludeAutogen ) +void SongManager::GetCourses( CourseType ct, vector &AddTo, bool bIncludeAutogen ) { for( unsigned i=0; iIsNonstop() ) + if( m_pCourses[i]->GetCourseType() == ct ) if( bIncludeAutogen || !m_pCourses[i]->m_bIsAutogen ) AddTo.push_back( m_pCourses[i] ); } -void SongManager::GetOniCourses( vector &AddTo, bool bIncludeAutogen ) -{ - for( unsigned i=0; iIsOni() ) - if( bIncludeAutogen || !m_pCourses[i]->m_bIsAutogen ) - AddTo.push_back( m_pCourses[i] ); -} - -void SongManager::GetEndlessCourses( vector &AddTo, bool bIncludeAutogen ) -{ - for( unsigned i=0; iIsEndless() ) - if( bIncludeAutogen || !m_pCourses[i]->m_bIsAutogen ) - AddTo.push_back( m_pCourses[i] ); -} - - bool SongManager::GetExtraStageInfoFromCourse( bool bExtra2, CString sPreferredGroup, Song*& pSongOut, Steps*& pStepsOut, PlayerOptions& po_out, SongOptions& so_out ) { @@ -1117,7 +1101,7 @@ Course *SongManager::FindCourse( CString sName ) void SongManager::UpdateBest() { // update players best - for( int i = 0; i < NUM_PROFILE_SLOTS; ++i ) + FOREACH_ProfileSlot( i ) { vector &Best = m_pBestSongs[i]; Best = m_pSongs; @@ -1141,11 +1125,16 @@ void SongManager::UpdateBest() } SongUtil::SortSongPointerArrayByTitle( m_pBestSongs[i] ); - SongUtil::SortSongPointerArrayByNumPlays( m_pBestSongs[i], (ProfileSlot) i, true ); + SongUtil::SortSongPointerArrayByNumPlays( m_pBestSongs[i], i, true ); - m_pBestCourses[i] = m_pCourses; - CourseUtil::SortCoursePointerArrayByTitle( m_pBestCourses[i] ); - CourseUtil::SortCoursePointerArrayByNumPlays( m_pBestCourses[i], (ProfileSlot) i, true ); + FOREACH_CourseType( ct ) + { + vector &vpCourses = m_pBestCourses[i][ct]; + vpCourses.clear(); + GetCourses( ct, vpCourses, PREFSMAN->m_bAutogenGroupCourses ); + CourseUtil::SortCoursePointerArrayByTitle( vpCourses ); + CourseUtil::SortCoursePointerArrayByNumPlays( vpCourses, i, true ); + } } } diff --git a/stepmania/src/SongManager.h b/stepmania/src/SongManager.h index 45bb2016aa..103f872763 100644 --- a/stepmania/src/SongManager.h +++ b/stepmania/src/SongManager.h @@ -6,7 +6,6 @@ class LoadingWindow; class Song; class Style; -class Course; class Steps; struct PlayerOptions; struct lua_State; @@ -17,6 +16,7 @@ struct lua_State; #include "PlayerOptions.h" #include "PlayerNumber.h" #include "Difficulty.h" +#include "Course.h" class SongManager { @@ -65,7 +65,7 @@ public: const vector &GetAllSongs() const { return m_pSongs; } void GetBestSongs( vector &AddTo, CString sGroupName, int iMaxStages = INT_MAX, ProfileSlot slot=PROFILE_SLOT_MACHINE ) const; const vector &GetBestSongs( ProfileSlot slot=PROFILE_SLOT_MACHINE ) const { return m_pBestSongs[slot]; } - const vector &GetBestCourses( ProfileSlot slot=PROFILE_SLOT_MACHINE ) const { return m_pBestCourses[slot]; } + const vector &GetBestCourses( CourseType ct, ProfileSlot slot=PROFILE_SLOT_MACHINE ) const { return m_pBestCourses[slot][ct]; } void GetSongs( vector &AddTo, CString sGroupName, int iMaxStages = INT_MAX ) const; void GetSongs( vector &AddTo, int iMaxStages ) const { GetSongs(AddTo,GROUP_ALL_MUSIC,iMaxStages); } void GetSongs( vector &AddTo ) const { GetSongs(AddTo,GROUP_ALL_MUSIC,INT_MAX); } @@ -79,9 +79,7 @@ public: void GetAllCourses( vector &AddTo, bool bIncludeAutogen ); - void GetNonstopCourses( vector &AddTo, bool bIncludeAutogen ); // add to if life meter type is BAR. - void GetOniCourses( vector &AddTo, bool bIncludeAutogen ); // add to if life meter type is BATTERY. - void GetEndlessCourses( vector &AddTo, bool bIncludeAutogen ); // add to if set to REPEAT. + void GetCourses( CourseType ct, vector &AddTo, bool bIncludeAutogen ); void GetExtraStageInfo( bool bExtra2, const Style *s, Song*& pSongOut, Steps*& pStepsOut, PlayerOptions& po_out, SongOptions& so_out ); @@ -116,7 +114,7 @@ protected: CStringArray m_sGroupNames; CStringArray m_sGroupBannerPaths; // each song group may have a banner associated with it vector m_pCourses; - vector m_pBestCourses[NUM_PROFILE_SLOTS]; + vector m_pBestCourses[NUM_PROFILE_SLOTS][NUM_COURSE_TYPES]; vector m_pShuffledCourses; // used by GetRandomCourse };