From 8c08e925476a0e51715f226e86bc9d4c913fd6cc Mon Sep 17 00:00:00 2001 From: Unknown Date: Thu, 19 Jul 2018 23:24:54 -0400 Subject: [PATCH] fix msd sorts and add length sort back --- .../ScreenSelectMusic overlay/currentsort.lua | 3 ++- Themes/_fallback/Languages/en.ini | 1 + Themes/_fallback/metrics.ini | 3 ++- src/GameConstantsAndTypes.cpp | 3 ++- src/GameConstantsAndTypes.h | 1 + src/MusicWheel.cpp | 3 +++ src/SongUtil.cpp | 10 +++++++++- 7 files changed, 20 insertions(+), 4 deletions(-) diff --git a/Themes/Til Death/BGAnimations/ScreenSelectMusic overlay/currentsort.lua b/Themes/Til Death/BGAnimations/ScreenSelectMusic overlay/currentsort.lua index 820454c4b7..b5f769d5f6 100644 --- a/Themes/Til Death/BGAnimations/ScreenSelectMusic overlay/currentsort.lua +++ b/Themes/Til Death/BGAnimations/ScreenSelectMusic overlay/currentsort.lua @@ -25,7 +25,8 @@ local sortTable = { SortOrder_Stamina = 'Stamina', SortOrder_JackSpeed = 'JackSpeed', SortOrder_Chordjack = 'Chordjack', - SortOrder_Technical = 'Technical' + SortOrder_Technical = 'Technical', + SortOrder_Length = 'Length', } t[#t+1] = Def.Quad{ diff --git a/Themes/_fallback/Languages/en.ini b/Themes/_fallback/Languages/en.ini index 41a3f78bbf..93f05f4299 100644 --- a/Themes/_fallback/Languages/en.ini +++ b/Themes/_fallback/Languages/en.ini @@ -306,6 +306,7 @@ StaminaText=Stamina JackSpeedText=JackSpeed ChordjackText=Chordjack TechnicalText=Technical +LengthText=Length TopGradesText=Top Grades [NetworkSyncManager] diff --git a/Themes/_fallback/metrics.ini b/Themes/_fallback/metrics.ini index 9ce83cb75d..63b98803e6 100644 --- a/Themes/_fallback/metrics.ini +++ b/Themes/_fallback/metrics.ini @@ -904,7 +904,7 @@ RecentSongsToShow=30 UseEasyMarkerFlag=false -ModeMenuChoiceNames="Preferred,Group,Title,Bpm,Popularity,TopGrades,Artist,Genre,Recent,Favorites,Overall,Stream,Jumpstream,Handstream,Stamina,JackSpeed,Chordjack,Technical" +ModeMenuChoiceNames="Preferred,Group,Title,Bpm,Popularity,TopGrades,Artist,Genre,Recent,Favorites,Overall,Stream,Jumpstream,Handstream,Stamina,JackSpeed,Chordjack,Technical,Length" ChoicePreferred="sort,Preferred" ChoiceGroup="sort,Group" ChoiceTitle="sort,Title" @@ -923,6 +923,7 @@ ChoiceStamina="sort,Stamina" ChoiceJackSpeed="sort,JackSpeed" ChoiceChordjack="sort,Chordjack" ChoiceTechnical="sort,Technical" +ChoiceLength="sort,Length" CustomWheelItemNames="" diff --git a/src/GameConstantsAndTypes.cpp b/src/GameConstantsAndTypes.cpp index dc545abbf4..2cec290104 100644 --- a/src/GameConstantsAndTypes.cpp +++ b/src/GameConstantsAndTypes.cpp @@ -142,7 +142,8 @@ static const char *SortOrderNames[] = { "Stamina", "JackSpeed", "Chordjack", - "Technical" + "Technical", + "Length" }; XToString( SortOrder ); StringToX( SortOrder ); diff --git a/src/GameConstantsAndTypes.h b/src/GameConstantsAndTypes.h index c0d7503d4d..d1886467f2 100644 --- a/src/GameConstantsAndTypes.h +++ b/src/GameConstantsAndTypes.h @@ -180,6 +180,7 @@ enum SortOrder SORT_JackSpeed, SORT_Chordjack, SORT_Technical, + SORT_LENGTH, NUM_SortOrder, SortOrder_Invalid }; diff --git a/src/MusicWheel.cpp b/src/MusicWheel.cpp index 4ac5e7e09c..e4da131156 100644 --- a/src/MusicWheel.cpp +++ b/src/MusicWheel.cpp @@ -729,6 +729,9 @@ void MusicWheel::BuildWheelItemDatas( vector &arrayWheelIt case SORT_Technical: SongUtil::SortSongPointerArrayByGroupAndMSD(arraySongs, Skill_Technical); break; + case SORT_LENGTH: + SongUtil::SortSongPointerArrayByLength(arraySongs); + break; default: FAIL_M("Unhandled sort order! Aborting..."); } diff --git a/src/SongUtil.cpp b/src/SongUtil.cpp index 5a3f2a4782..25a74dc646 100644 --- a/src/SongUtil.cpp +++ b/src/SongUtil.cpp @@ -529,7 +529,7 @@ static int CompareSongPointersByGroup(const Song *pSong1, const Song *pSong2) } std::function CompareSongPointersByGroupAndMSD(Skillset ss) { - return [&ss](const Song *pSong1, const Song *pSong2) { + return [ss](const Song *pSong1, const Song *pSong2) { int g = CompareSongPointersByGroup(pSong1, pSong2); if (g == 0) /* Same group; compare by MSD. */ @@ -627,6 +627,14 @@ RString SongUtil::GetSectionNameFromSongAndSort( const Song* pSong, SortOrder so case SORT_POPULARITY: case SORT_RECENT: return RString(); + case SORT_LENGTH: + { + const int iSortLengthSize = 60; + int iMaxLength = static_cast(pSong->m_fMusicLengthSeconds); + iMaxLength += (iSortLengthSize - (iMaxLength%iSortLengthSize) - 1); + int iMinLength = iMaxLength - (iSortLengthSize - 1); + return ssprintf("%s-%s", SecondsToMMSS(static_cast(iMinLength)).c_str(), SecondsToMMSS(static_cast(iMaxLength)).c_str()); + } case SORT_TOP_GRADES: { auto p = PROFILEMAN->GetProfile(PLAYER_1);