add sort by genre

This commit is contained in:
Chris Danford
2005-03-02 01:48:38 +00:00
parent 75efd91ee2
commit 5cceae246e
6 changed files with 31 additions and 8 deletions
+1
View File
@@ -2303,6 +2303,7 @@ ChoiceBpm=name,BPM;sort,BPM
ChoicePopularity=name,PLAYERS' BEST;sort,Popularity
ChoiceTopGrade=name,TOP GRADE;sort,TopGrade
ChoiceArtist=name,ARTIST;sort,Artist
ChoiceGenre=name,GENRE;sort,Genre
ChoiceEasyMeter=name,EASY METER;sort,EasyMeter
ChoiceMediumMeter=name,MEDIUM METER;sort,MediumMeter
ChoiceHardMeter=name,HARD METER;sort,HardMeter
+1
View File
@@ -106,6 +106,7 @@ static const CString SortOrderNames[NUM_SORT_ORDERS] = {
"Popularity",
"TopGrade",
"Artist",
"Genre",
"EasyMeter",
"MediumMeter",
"HardMeter",
+1
View File
@@ -100,6 +100,7 @@ enum SortOrder {
SORT_MOST_PLAYED,
SORT_GRADE,
SORT_ARTIST,
SORT_GENRE,
SORT_EASY_METER,
SORT_MEDIUM_METER,
SORT_HARD_METER,
+11 -7
View File
@@ -62,17 +62,17 @@ ThemeMetric<float> NUM_WHEEL_ITEMS_TO_DRAW ("MusicWheel","NumWheelItems");
const int MAX_WHEEL_SOUND_SPEED = 15;
static const SortOrder SORT_ORDERS[] =
static const SortOrder g_SongSortOrders[] =
{
SORT_GROUP,
SORT_TITLE,
SORT_BPM,
SORT_MOST_PLAYED,
SORT_ARTIST,
SORT_GENRE,
};
// use ARRAYSIZE(SortOrder)
// Why? -Chris
vector<SortOrder> SONG_SORT_ORDERS( g_SongSortOrders, g_SongSortOrders + ARRAYSIZE(g_SongSortOrders) );
MusicWheel::MusicWheel()
{
}
@@ -497,6 +497,7 @@ void MusicWheel::BuildWheelItemDatas( vector<WheelItemData> &arrayWheelItemDatas
case SORT_MOST_PLAYED:
case SORT_GRADE:
case SORT_ARTIST:
case SORT_GENRE:
case SORT_EASY_METER:
case SORT_MEDIUM_METER:
case SORT_HARD_METER:
@@ -540,6 +541,9 @@ void MusicWheel::BuildWheelItemDatas( vector<WheelItemData> &arrayWheelItemDatas
case SORT_ARTIST:
SongUtil::SortSongPointerArrayByArtist( arraySongs );
break;
case SORT_GENRE:
SongUtil::SortSongPointerArrayByGenre( arraySongs );
break;
case SORT_EASY_METER:
SongUtil::SortSongPointerArrayByMeter( arraySongs, DIFFICULTY_EASY );
break;
@@ -1201,15 +1205,15 @@ bool MusicWheel::NextSort() // return true if change successful
// find the index of the current sort
int cur = 0;
while( cur < int(ARRAYSIZE(SORT_ORDERS)) && SORT_ORDERS[cur] != m_SortOrder )
while( cur < int(SONG_SORT_ORDERS.size()) && SONG_SORT_ORDERS[cur] != m_SortOrder )
++cur;
// move to the next sort with wrapping
++cur;
wrap( cur, ARRAYSIZE(SORT_ORDERS) );
wrap( cur, SONG_SORT_ORDERS.size() );
// apply new sort
SortOrder soNew = SORT_ORDERS[cur];
SortOrder soNew = SONG_SORT_ORDERS[cur];
return ChangeSort( soNew );
}
+16 -1
View File
@@ -151,6 +151,16 @@ void SongUtil::SortSongPointerArrayByDisplayArtist( vector<Song*> &arraySongPoin
stable_sort( arraySongPointers.begin(), arraySongPointers.end(), CompareSongPointersBySortValueAscending );
}
static int CompareSongPointersByGenre(const Song *pSong1, const Song *pSong2)
{
return pSong1->m_sGenre < pSong2->m_sGenre;
}
void SongUtil::SortSongPointerArrayByGenre( vector<Song*> &arraySongPointers )
{
stable_sort( arraySongPointers.begin(), arraySongPointers.end(), CompareSongPointersByGenre );
}
static int CompareSongPointersByGroup(const Song *pSong1, const Song *pSong2)
{
return pSong1->m_sGroupName < pSong2->m_sGroupName;
@@ -207,7 +217,8 @@ CString SongUtil::GetSectionNameFromSongAndSort( const Song* pSong, SortOrder so
{
case SORT_PREFERRED:
return "";
case SORT_GROUP:
case SORT_GROUP:
// guaranteed not empty
return pSong->m_sGroupName;
case SORT_TITLE:
case SORT_ARTIST:
@@ -230,6 +241,10 @@ CString SongUtil::GetSectionNameFromSongAndSort( const Song* pSong, SortOrder so
else
return s.Left(1);
}
case SORT_GENRE:
if( !pSong->m_sGenre.empty() )
return pSong->m_sGenre;
return "N/A";
case SORT_BPM:
{
const int iBPMGroupSize = 20;
+1
View File
@@ -18,6 +18,7 @@ namespace SongUtil
void SortSongPointerArrayByGrade( vector<Song*> &arraySongPointers );
void SortSongPointerArrayByArtist( vector<Song*> &arraySongPointers );
void SortSongPointerArrayByDisplayArtist( vector<Song*> &arraySongPointers );
void SortSongPointerArrayByGenre( vector<Song*> &arraySongPointers );
void SortSongPointerArrayByGroupAndDifficulty( vector<Song*> &arraySongPointers );
void SortSongPointerArrayByGroupAndTitle( vector<Song*> &arraySongPointers );
void SortSongPointerArrayByNumPlays( vector<Song*> &arraySongPointers, ProfileSlot slot, bool bDescending );