Skip to content

Commit

Permalink
fix msd sorts and add length sort back
Browse files Browse the repository at this point in the history
  • Loading branch information
MinaciousGrace committed Jul 20, 2018
1 parent 9e23ad8 commit 8c08e92
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand Down
1 change: 1 addition & 0 deletions Themes/_fallback/Languages/en.ini
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,7 @@ StaminaText=Stamina
JackSpeedText=JackSpeed
ChordjackText=Chordjack
TechnicalText=Technical
LengthText=Length
TopGradesText=Top Grades
[NetworkSyncManager]
Expand Down
3 changes: 2 additions & 1 deletion Themes/_fallback/metrics.ini
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -923,6 +923,7 @@ ChoiceStamina="sort,Stamina"
ChoiceJackSpeed="sort,JackSpeed"
ChoiceChordjack="sort,Chordjack"
ChoiceTechnical="sort,Technical"
ChoiceLength="sort,Length"

CustomWheelItemNames=""

Expand Down
3 changes: 2 additions & 1 deletion src/GameConstantsAndTypes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,8 @@ static const char *SortOrderNames[] = {
"Stamina",
"JackSpeed",
"Chordjack",
"Technical"
"Technical",
"Length"
};
XToString( SortOrder );
StringToX( SortOrder );
Expand Down
1 change: 1 addition & 0 deletions src/GameConstantsAndTypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,7 @@ enum SortOrder
SORT_JackSpeed,
SORT_Chordjack,
SORT_Technical,
SORT_LENGTH,
NUM_SortOrder,
SortOrder_Invalid
};
Expand Down
3 changes: 3 additions & 0 deletions src/MusicWheel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -729,6 +729,9 @@ void MusicWheel::BuildWheelItemDatas( vector<MusicWheelItemData *> &arrayWheelIt
case SORT_Technical:
SongUtil::SortSongPointerArrayByGroupAndMSD(arraySongs, Skill_Technical);
break;
case SORT_LENGTH:
SongUtil::SortSongPointerArrayByLength(arraySongs);
break;
default:
FAIL_M("Unhandled sort order! Aborting...");
}
Expand Down
10 changes: 9 additions & 1 deletion src/SongUtil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -529,7 +529,7 @@ static int CompareSongPointersByGroup(const Song *pSong1, const Song *pSong2)
}
std::function<int(const Song *pSong1, const Song *pSong2)> 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. */
Expand Down Expand Up @@ -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<int>(pSong->m_fMusicLengthSeconds);
iMaxLength += (iSortLengthSize - (iMaxLength%iSortLengthSize) - 1);
int iMinLength = iMaxLength - (iSortLengthSize - 1);
return ssprintf("%s-%s", SecondsToMMSS(static_cast<float>(iMinLength)).c_str(), SecondsToMMSS(static_cast<float>(iMaxLength)).c_str());
}
case SORT_TOP_GRADES:
{
auto p = PROFILEMAN->GetProfile(PLAYER_1);
Expand Down

0 comments on commit 8c08e92

Please sign in to comment.