add SortCoursePointerArrayByMostPlayed
This commit is contained in:
@@ -1016,3 +1016,27 @@ void Course::AddHighScore( StepsType st, PlayerNumber pn, MemCardData::HighScore
|
|||||||
iPersonalIndexOut = -1;
|
iPersonalIndexOut = -1;
|
||||||
m_MemCardDatas[st][MEMORY_CARD_MACHINE].AddHighScore( hs, iMachineIndexOut );
|
m_MemCardDatas[st][MEMORY_CARD_MACHINE].AddHighScore( hs, iMachineIndexOut );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int Course::GetNumTimesPlayed( MemoryCard card ) const
|
||||||
|
{
|
||||||
|
int iTotalNumTimesPlayed = 0;
|
||||||
|
for( unsigned i = 0; i < NUM_STEPS_TYPES; ++i )
|
||||||
|
iTotalNumTimesPlayed += GetNumTimesPlayed( (StepsType) i, card );
|
||||||
|
return iTotalNumTimesPlayed;
|
||||||
|
}
|
||||||
|
|
||||||
|
static map<const Course*, int> course_sort_val;
|
||||||
|
|
||||||
|
bool CompareCoursePointersBySortVal(const Course *pSong1, const Course *pSong2)
|
||||||
|
{
|
||||||
|
return course_sort_val[pSong1] < course_sort_val[pSong2];
|
||||||
|
}
|
||||||
|
|
||||||
|
void SortCoursePointerArrayByMostPlayed( vector<Course*> &arrayCoursePointers, MemoryCard card )
|
||||||
|
{
|
||||||
|
for(unsigned i = 0; i < arrayCoursePointers.size(); ++i)
|
||||||
|
course_sort_val[arrayCoursePointers[i]] = arrayCoursePointers[i]->GetNumTimesPlayed( card );
|
||||||
|
stable_sort( arrayCoursePointers.begin(), arrayCoursePointers.end(), CompareCoursePointersBySortVal );
|
||||||
|
reverse( arrayCoursePointers.begin(), arrayCoursePointers.end() );
|
||||||
|
course_sort_val.clear();
|
||||||
|
}
|
||||||
|
|||||||
@@ -183,11 +183,13 @@ public:
|
|||||||
return m_MemCardDatas[st][card].GetTopScore();
|
return m_MemCardDatas[st][card].GetTopScore();
|
||||||
}
|
}
|
||||||
|
|
||||||
int GetNumTimesPlayed( StepsType st, MemoryCard card )
|
int GetNumTimesPlayed( StepsType st, MemoryCard card ) const
|
||||||
{
|
{
|
||||||
return m_MemCardDatas[st][card].iNumTimesPlayed;
|
return m_MemCardDatas[st][card].iNumTimesPlayed;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int GetNumTimesPlayed( MemoryCard card ) const;
|
||||||
|
|
||||||
// sorting values
|
// sorting values
|
||||||
int SortOrder_TotalDifficulty;
|
int SortOrder_TotalDifficulty;
|
||||||
int SortOrder_Ranking;
|
int SortOrder_Ranking;
|
||||||
@@ -205,6 +207,7 @@ void SortCoursePointerArrayByType( vector<Course*> &apCourses );
|
|||||||
void SortCoursePointerArrayByAvgDifficulty( vector<Course*> &apCourses );
|
void SortCoursePointerArrayByAvgDifficulty( vector<Course*> &apCourses );
|
||||||
void SortCoursePointerArrayByTotalDifficulty( vector<Course*> &apCourses );
|
void SortCoursePointerArrayByTotalDifficulty( vector<Course*> &apCourses );
|
||||||
void SortCoursePointerArrayByRanking( vector<Course*> &apCourses );
|
void SortCoursePointerArrayByRanking( vector<Course*> &apCourses );
|
||||||
|
void SortCoursePointerArrayByMostPlayed( vector<Course*> &arrayCoursePointers, MemoryCard card );
|
||||||
|
|
||||||
void MoveRandomToEnd( vector<Course*> &apCourses );
|
void MoveRandomToEnd( vector<Course*> &apCourses );
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user