per-memcard SONGMAN->GetBestSongs
This commit is contained in:
+10
-11
@@ -1235,7 +1235,7 @@ Steps::MemCardData::HighScore Song::GetHighScoreForDifficulty( const StyleDef *s
|
||||
|
||||
bool Song::IsNew() const
|
||||
{
|
||||
return GetNumTimesPlayed()==0;
|
||||
return GetNumTimesPlayed(MEMORY_CARD_MACHINE) == 0;
|
||||
}
|
||||
|
||||
bool Song::IsEasy( StepsType nt ) const
|
||||
@@ -1456,9 +1456,9 @@ void SortSongPointerArrayByGroupAndTitle( vector<Song*> &arraySongPointers )
|
||||
sort( arraySongPointers.begin(), arraySongPointers.end(), CompareSongPointersByGroupAndTitle );
|
||||
}
|
||||
|
||||
bool CompareSongPointersByMostPlayed(const Song *pSong1, const Song *pSong2)
|
||||
{
|
||||
return pSong1->GetNumTimesPlayed() < pSong2->GetNumTimesPlayed();
|
||||
//bool CompareSongPointersByMostPlayed(const Song *pSong1, const Song *pSong2)
|
||||
//{
|
||||
// return pSong1->GetNumTimesPlayed() < pSong2->GetNumTimesPlayed();
|
||||
/*
|
||||
Comparing titles is slow, and this makes course selection choppy. Turning this
|
||||
off means we don't get consistent orderings of songs that have been played
|
||||
@@ -1479,7 +1479,7 @@ that have all been played 0 times.
|
||||
return false;
|
||||
return CompareSongPointersByTitle( pSong1, pSong2 );
|
||||
*/
|
||||
}
|
||||
//}
|
||||
/* Actually, just calculating GetNumTimesPlayed within the sort is pretty
|
||||
* slow, so let's precompute it. (This could be generalized with a template.) */
|
||||
map<const Song*, CString> song_sort_val;
|
||||
@@ -1489,10 +1489,10 @@ bool CompareSongPointersBySortVal(const Song *pSong1, const Song *pSong2)
|
||||
return song_sort_val[pSong1] < song_sort_val[pSong2];
|
||||
}
|
||||
|
||||
void SortSongPointerArrayByMostPlayed( vector<Song*> &arraySongPointers )
|
||||
void SortSongPointerArrayByMostPlayed( vector<Song*> &arraySongPointers, MemoryCard card )
|
||||
{
|
||||
for(unsigned i = 0; i < arraySongPointers.size(); ++i)
|
||||
song_sort_val[arraySongPointers[i]] = ssprintf("%9i", arraySongPointers[i]->GetNumTimesPlayed());
|
||||
song_sort_val[arraySongPointers[i]] = ssprintf("%9i", arraySongPointers[i]->GetNumTimesPlayed(card));
|
||||
stable_sort( arraySongPointers.begin(), arraySongPointers.end(), CompareSongPointersBySortVal );
|
||||
reverse( arraySongPointers.begin(), arraySongPointers.end() );
|
||||
song_sort_val.clear();
|
||||
@@ -1543,13 +1543,12 @@ bool Song::HasBackground() const {return m_sBackgroundFile != "" && IsAFile(G
|
||||
bool Song::HasCDTitle() const {return m_sCDTitleFile != "" && IsAFile(GetCDTitlePath()); }
|
||||
bool Song::HasBGChanges() const {return !m_BackgroundChanges.empty(); }
|
||||
|
||||
int Song::GetNumTimesPlayed() const
|
||||
int Song::GetNumTimesPlayed( MemoryCard card ) const
|
||||
{
|
||||
int iTotalNumTimesPlayed = 0;
|
||||
for( unsigned i=0; i<m_apNotes.size(); i++ )
|
||||
{
|
||||
iTotalNumTimesPlayed += m_apNotes[i]->GetNumTimesPlayed(MEMORY_CARD_MACHINE);
|
||||
}
|
||||
iTotalNumTimesPlayed += m_apNotes[i]->GetNumTimesPlayed( card );
|
||||
|
||||
return iTotalNumTimesPlayed;
|
||||
}
|
||||
|
||||
|
||||
@@ -1321,8 +1321,11 @@ Course *SongManager::FindCourse( CString sName )
|
||||
|
||||
void SongManager::UpdateBest()
|
||||
{
|
||||
m_pBestSongs = m_pSongs;
|
||||
SortSongPointerArrayByMostPlayed( m_pBestSongs );
|
||||
for( int i = 0; i < NUM_MEMORY_CARDS; ++i )
|
||||
{
|
||||
m_pBestSongs[i] = m_pSongs;
|
||||
SortSongPointerArrayByMostPlayed( m_pBestSongs[i], (MemoryCard) i );
|
||||
}
|
||||
}
|
||||
|
||||
void SongManager::UpdateRankingCourses()
|
||||
|
||||
@@ -58,7 +58,7 @@ public:
|
||||
|
||||
// Lookup
|
||||
const vector<Song*> &GetAllSongs() const { return m_pSongs; }
|
||||
const vector<Song*> &GetBestSongs() const { return m_pBestSongs; }
|
||||
const vector<Song*> &GetBestSongs( MemoryCard card=MEMORY_CARD_MACHINE ) const { return m_pBestSongs[MEMORY_CARD_MACHINE]; }
|
||||
void GetSongs( vector<Song*> &AddTo, CString sGroupName, int iMaxStages = 100000 /*inf*/ ) const;
|
||||
void GetSongs( vector<Song*> &AddTo, int iMaxStages ) const { GetSongs(AddTo,"",iMaxStages); }
|
||||
void GetSongs( vector<Song*> &AddTo ) const { GetSongs(AddTo,"",100000 /*inf*/ ); }
|
||||
@@ -144,7 +144,7 @@ protected:
|
||||
void WriteStatsWebPage();
|
||||
|
||||
vector<Song*> m_pSongs; // all songs that can be played
|
||||
vector<Song*> m_pBestSongs;
|
||||
vector<Song*> m_pBestSongs[NUM_MEMORY_CARDS];
|
||||
CStringArray m_sGroupNames;
|
||||
CStringArray m_sGroupBannerPaths; // each song group may have a banner associated with it
|
||||
vector<Course*> m_pCourses;
|
||||
|
||||
@@ -249,7 +249,7 @@ public:
|
||||
Steps* GetStepsByDescription( StepsType nt, CString sDescription, bool bIncludeAutoGen = true ) const;
|
||||
Steps* GetClosestNotes( StepsType nt, Difficulty dc, bool bIncludeAutoGen = true ) const;
|
||||
void GetEdits( vector<Steps*>& arrayAddTo, StepsType nt, bool bIncludeAutoGen = true ) const;
|
||||
int GetNumTimesPlayed() const;
|
||||
int GetNumTimesPlayed( MemoryCard card ) const;
|
||||
bool IsNew() const;
|
||||
bool IsEasy( StepsType nt ) const;
|
||||
bool HasEdits( StepsType nt ) const;
|
||||
@@ -270,7 +270,7 @@ void SortSongPointerArrayByGrade( vector<Song*> &arraySongPointers );
|
||||
void SortSongPointerArrayByArtist( vector<Song*> &arraySongPointers );
|
||||
void SortSongPointerArrayByGroupAndDifficulty( vector<Song*> &arraySongPointers );
|
||||
void SortSongPointerArrayByGroupAndTitle( vector<Song*> &arraySongPointers );
|
||||
void SortSongPointerArrayByMostPlayed( vector<Song*> &arraySongPointers );
|
||||
void SortSongPointerArrayByMostPlayed( vector<Song*> &arraySongPointers, MemoryCard card );
|
||||
void SortSongPointerArrayByMeter( vector<Song*> &arraySongPointers, Difficulty dc );
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user