diff --git a/stepmania/Themes/default/metrics.ini b/stepmania/Themes/default/metrics.ini index c2a66d2b56..71e7ad80fc 100644 --- a/stepmania/Themes/default/metrics.ini +++ b/stepmania/Themes/default/metrics.ini @@ -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 diff --git a/stepmania/src/GameConstantsAndTypes.cpp b/stepmania/src/GameConstantsAndTypes.cpp index 9a7e83086e..f6a97e3578 100644 --- a/stepmania/src/GameConstantsAndTypes.cpp +++ b/stepmania/src/GameConstantsAndTypes.cpp @@ -106,6 +106,7 @@ static const CString SortOrderNames[NUM_SORT_ORDERS] = { "Popularity", "TopGrade", "Artist", + "Genre", "EasyMeter", "MediumMeter", "HardMeter", diff --git a/stepmania/src/GameConstantsAndTypes.h b/stepmania/src/GameConstantsAndTypes.h index 0f2601c111..860c43803e 100644 --- a/stepmania/src/GameConstantsAndTypes.h +++ b/stepmania/src/GameConstantsAndTypes.h @@ -100,6 +100,7 @@ enum SortOrder { SORT_MOST_PLAYED, SORT_GRADE, SORT_ARTIST, + SORT_GENRE, SORT_EASY_METER, SORT_MEDIUM_METER, SORT_HARD_METER, diff --git a/stepmania/src/MusicWheel.cpp b/stepmania/src/MusicWheel.cpp index 93c0d06734..7ab65556e3 100644 --- a/stepmania/src/MusicWheel.cpp +++ b/stepmania/src/MusicWheel.cpp @@ -62,17 +62,17 @@ ThemeMetric 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 SONG_SORT_ORDERS( g_SongSortOrders, g_SongSortOrders + ARRAYSIZE(g_SongSortOrders) ); + MusicWheel::MusicWheel() { } @@ -497,6 +497,7 @@ void MusicWheel::BuildWheelItemDatas( vector &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 &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 ); } diff --git a/stepmania/src/SongUtil.cpp b/stepmania/src/SongUtil.cpp index 684c50271f..234c0bf485 100644 --- a/stepmania/src/SongUtil.cpp +++ b/stepmania/src/SongUtil.cpp @@ -151,6 +151,16 @@ void SongUtil::SortSongPointerArrayByDisplayArtist( vector &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 &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; diff --git a/stepmania/src/SongUtil.h b/stepmania/src/SongUtil.h index 5025a3803c..b6b96f43e4 100644 --- a/stepmania/src/SongUtil.h +++ b/stepmania/src/SongUtil.h @@ -18,6 +18,7 @@ namespace SongUtil void SortSongPointerArrayByGrade( vector &arraySongPointers ); void SortSongPointerArrayByArtist( vector &arraySongPointers ); void SortSongPointerArrayByDisplayArtist( vector &arraySongPointers ); + void SortSongPointerArrayByGenre( vector &arraySongPointers ); void SortSongPointerArrayByGroupAndDifficulty( vector &arraySongPointers ); void SortSongPointerArrayByGroupAndTitle( vector &arraySongPointers ); void SortSongPointerArrayByNumPlays( vector &arraySongPointers, ProfileSlot slot, bool bDescending );