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