filter locked and hidden songs from player's best in SongManager
add GetBestSongs accessor that filters like GetAllSongs
This commit is contained in:
@@ -422,14 +422,24 @@ CString SongManager::GetDifficultyThemeName( Difficulty dc ) const
|
|||||||
return THEME->GetMetric( "Common", sMetricName );
|
return THEME->GetMetric( "Common", sMetricName );
|
||||||
}
|
}
|
||||||
|
|
||||||
void SongManager::GetSongs( vector<Song*> &AddTo, CString sGroupName, int iMaxStages ) const
|
static void GetSongsFromVector( const vector<Song*> &Songs, vector<Song*> &AddTo, CString sGroupName, int iMaxStages )
|
||||||
{
|
{
|
||||||
AddTo.clear();
|
AddTo.clear();
|
||||||
|
|
||||||
for( unsigned i=0; i<m_pSongs.size(); i++ )
|
for( unsigned i=0; i<Songs.size(); i++ )
|
||||||
if( sGroupName==GROUP_ALL_MUSIC || sGroupName==m_pSongs[i]->m_sGroupName )
|
if( sGroupName==GROUP_ALL_MUSIC || sGroupName==Songs[i]->m_sGroupName )
|
||||||
if( GetNumStagesForSong(m_pSongs[i])<=iMaxStages )
|
if( SongManager::GetNumStagesForSong(Songs[i]) <= iMaxStages )
|
||||||
AddTo.push_back( m_pSongs[i] );
|
AddTo.push_back( Songs[i] );
|
||||||
|
}
|
||||||
|
|
||||||
|
void SongManager::GetSongs( vector<Song*> &AddTo, CString sGroupName, int iMaxStages ) const
|
||||||
|
{
|
||||||
|
GetSongsFromVector( m_pSongs, AddTo, sGroupName, iMaxStages );
|
||||||
|
}
|
||||||
|
|
||||||
|
void SongManager::GetBestSongs( vector<Song*> &AddTo, CString sGroupName, int iMaxStages, ProfileSlot slot ) const
|
||||||
|
{
|
||||||
|
GetSongsFromVector( m_pBestSongs[slot], AddTo, sGroupName, iMaxStages );
|
||||||
}
|
}
|
||||||
|
|
||||||
int SongManager::GetNumSongs() const
|
int SongManager::GetNumSongs() const
|
||||||
@@ -873,13 +883,33 @@ Course *SongManager::FindCourse( CString sName )
|
|||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
#include "UnlockSystem.h"
|
||||||
|
|
||||||
void SongManager::UpdateBest()
|
void SongManager::UpdateBest()
|
||||||
{
|
{
|
||||||
// update players best
|
// update players best
|
||||||
for( int i = 0; i < NUM_PROFILE_SLOTS; ++i )
|
for( int i = 0; i < NUM_PROFILE_SLOTS; ++i )
|
||||||
{
|
{
|
||||||
m_pBestSongs[i] = m_pSongs;
|
vector<Song*> &Best = m_pBestSongs[i];
|
||||||
|
Best = m_pSongs;
|
||||||
|
|
||||||
|
for ( unsigned j=0; j < Best.size() ; ++j )
|
||||||
|
{
|
||||||
|
bool bFiltered = false;
|
||||||
|
/* Filter out hidden songs. */
|
||||||
|
if( Best[j]->GetDisplayed() != Song::SHOW_ALWAYS )
|
||||||
|
bFiltered = true;
|
||||||
|
/* Filter out locked songs. */
|
||||||
|
if( UNLOCKMAN->SongIsLocked(Best[j]) )
|
||||||
|
bFiltered = true;
|
||||||
|
if( !bFiltered )
|
||||||
|
continue;
|
||||||
|
|
||||||
|
/* Remove it. */
|
||||||
|
swap( Best[j], Best.back() );
|
||||||
|
Best.erase( Best.end()-1 );
|
||||||
|
}
|
||||||
|
|
||||||
SortSongPointerArrayByNumPlays( m_pBestSongs[i], (ProfileSlot) i, true );
|
SortSongPointerArrayByNumPlays( m_pBestSongs[i], (ProfileSlot) i, true );
|
||||||
|
|
||||||
m_pBestCourses[i] = m_pCourses;
|
m_pBestCourses[i] = m_pCourses;
|
||||||
|
|||||||
@@ -64,6 +64,7 @@ public:
|
|||||||
|
|
||||||
// Lookup
|
// Lookup
|
||||||
const vector<Song*> &GetAllSongs() const { return m_pSongs; }
|
const vector<Song*> &GetAllSongs() const { return m_pSongs; }
|
||||||
|
void GetBestSongs( vector<Song*> &AddTo, CString sGroupName, int iMaxStages = 100000 /*inf*/, ProfileSlot slot=PROFILE_SLOT_MACHINE ) const;
|
||||||
const vector<Song*> &GetBestSongs( ProfileSlot slot=PROFILE_SLOT_MACHINE ) const { return m_pBestSongs[slot]; }
|
const vector<Song*> &GetBestSongs( ProfileSlot slot=PROFILE_SLOT_MACHINE ) const { return m_pBestSongs[slot]; }
|
||||||
const vector<Course*> &GetBestCourses( ProfileSlot slot=PROFILE_SLOT_MACHINE ) const { return m_pBestCourses[slot]; }
|
const vector<Course*> &GetBestCourses( ProfileSlot slot=PROFILE_SLOT_MACHINE ) const { return m_pBestCourses[slot]; }
|
||||||
void GetSongs( vector<Song*> &AddTo, CString sGroupName, int iMaxStages = 100000 /*inf*/ ) const;
|
void GetSongs( vector<Song*> &AddTo, CString sGroupName, int iMaxStages = 100000 /*inf*/ ) const;
|
||||||
|
|||||||
Reference in New Issue
Block a user