diff --git a/stepmania/Themes/default/Graphics/MusicSortDisplay length.png b/stepmania/Themes/default/Graphics/MusicSortDisplay length.png new file mode 100644 index 0000000000..f4cce6ae20 Binary files /dev/null and b/stepmania/Themes/default/Graphics/MusicSortDisplay length.png differ diff --git a/stepmania/Themes/default/Languages/en.ini b/stepmania/Themes/default/Languages/en.ini index a7e747eb0a..3e4e483538 100644 --- a/stepmania/Themes/default/Languages/en.ini +++ b/stepmania/Themes/default/Languages/en.ini @@ -232,6 +232,7 @@ EasyMeterText=EASY METER GenreText=GENRE GroupText=GROUP HardMeterText=HARD METER +LengthText=LENGTH MediumMeterText=MEDIUM METER PopularityText=PLAYERS' BEST Portal=PORTAL diff --git a/stepmania/Themes/default/metrics.ini b/stepmania/Themes/default/metrics.ini index 05a62ba977..fdc9de9e37 100644 --- a/stepmania/Themes/default/metrics.ini +++ b/stepmania/Themes/default/metrics.ini @@ -1769,7 +1769,7 @@ Use3D=false Wheel3DRadius=245 -- Possibly safe defaults? CirclePercent=0.5 MostPlayedSongsToShow=30 -ModeMenuChoiceNames="Preferred,Group,Title,Bpm,Popularity,TopGrades,Artist,EasyMeter,MediumMeter,HardMeter,Genre" +ModeMenuChoiceNames="Preferred,Group,Title,Bpm,Popularity,TopGrades,Artist,EasyMeter,MediumMeter,HardMeter,Genre,Length" ChoicePreferred="sort,Preferred" ChoiceGroup="sort,Group" ChoiceTitle="sort,Title" @@ -1781,6 +1781,7 @@ ChoiceGenre="sort,Genre" ChoiceEasyMeter="sort,EasyMeter" ChoiceMediumMeter="sort,MediumMeter" ChoiceHardMeter="sort,HardMeter" +ChoiceLength="sort,Length" [RoomWheel] Fallback="MusicWheel" diff --git a/stepmania/src/GameConstantsAndTypes.cpp b/stepmania/src/GameConstantsAndTypes.cpp index f521372c8c..4c44fe1061 100644 --- a/stepmania/src/GameConstantsAndTypes.cpp +++ b/stepmania/src/GameConstantsAndTypes.cpp @@ -151,6 +151,7 @@ static const char *SortOrderNames[] = { "Nonstop", "Oni", "Endless", + "Length", "Roulette", }; XToString( SortOrder ); diff --git a/stepmania/src/GameConstantsAndTypes.h b/stepmania/src/GameConstantsAndTypes.h index 5bc3bdecfb..f7afa72498 100644 --- a/stepmania/src/GameConstantsAndTypes.h +++ b/stepmania/src/GameConstantsAndTypes.h @@ -119,6 +119,7 @@ enum SortOrder SORT_NONSTOP_COURSES, SORT_ONI_COURSES, SORT_ENDLESS_COURSES, + SORT_LENGTH, SORT_ROULETTE, NUM_SortOrder, SortOrder_Invalid diff --git a/stepmania/src/MusicWheel.cpp b/stepmania/src/MusicWheel.cpp index 01eabed48d..285f620958 100644 --- a/stepmania/src/MusicWheel.cpp +++ b/stepmania/src/MusicWheel.cpp @@ -417,6 +417,7 @@ void MusicWheel::BuildWheelItemDatas( vector &arrayWheelItemDat case SORT_MEDIUM_METER: case SORT_HARD_METER: case SORT_CHALLENGE_METER: + case SORT_LENGTH: { /////////////////////////////////// // Make an array of Song*, then sort them @@ -463,6 +464,9 @@ void MusicWheel::BuildWheelItemDatas( vector &arrayWheelItemDat case SORT_GENRE: SongUtil::SortSongPointerArrayByGenre( arraySongs ); break; + case SORT_LENGTH: + SongUtil::SortSongPointerArrayByLength( arraySongs ); + break; case SORT_EASY_METER: SongUtil::SortSongPointerArrayByMeter( arraySongs, Difficulty_Easy ); break; diff --git a/stepmania/src/SongUtil.cpp b/stepmania/src/SongUtil.cpp index c414123438..aebca145ad 100644 --- a/stepmania/src/SongUtil.cpp +++ b/stepmania/src/SongUtil.cpp @@ -400,6 +400,25 @@ void SongUtil::SortSongPointerArrayByBPM( vector &vpSongsInOut ) sort( vpSongsInOut.begin(), vpSongsInOut.end(), CompareSongPointersByBPM ); } +static bool CompareSongPointersByLength( const Song *pSong1, const Song *pSong2 ) +{ + float length1, length2; + length1 = pSong1->m_fMusicLengthSeconds; + length2 = pSong2->m_fMusicLengthSeconds; + + if( length1 < length2 ) + return true; + if( length1 > length2 ) + return false; + + return CompareRStringsAsc( pSong1->GetSongFilePath(), pSong2->GetSongFilePath() ); +} + +void SongUtil::SortSongPointerArrayByLength( vector &vpSongsInOut ) +{ + sort( vpSongsInOut.begin(), vpSongsInOut.end(), CompareSongPointersByLength ); +} + void AppendOctal( int n, int digits, RString &out ) { for( int p = digits-1; p >= 0; --p ) @@ -566,6 +585,7 @@ RString SongUtil::GetSectionNameFromSongAndSort( const Song* pSong, SortOrder so iMaxBPM += iBPMGroupSize - (iMaxBPM%iBPMGroupSize) - 1; return ssprintf("%03d-%03d",iMaxBPM-(iBPMGroupSize-1), iMaxBPM); } + case SORT_LENGTH: case SORT_POPULARITY: return RString(); case SORT_TOP_GRADES: diff --git a/stepmania/src/SongUtil.h b/stepmania/src/SongUtil.h index 2d305d24d5..fdb0b3f003 100644 --- a/stepmania/src/SongUtil.h +++ b/stepmania/src/SongUtil.h @@ -100,6 +100,7 @@ namespace SongUtil RString GetSectionNameFromSongAndSort( const Song *pSong, SortOrder so ); void SortSongPointerArrayBySectionName( vector &vpSongsInOut, SortOrder so ); void SortByMostRecentlyPlayedForMachine( vector &vpSongsInOut ); + void SortSongPointerArrayByLength( vector &vpSongsInOut ); int CompareSongPointersByGroup(const Song *pSong1, const Song *pSong2);