add sorting by music length

This commit is contained in:
AJ Kelly
2007-10-07 21:09:52 +00:00
parent 426747656a
commit c3e0c494f0
8 changed files with 30 additions and 1 deletions
Binary file not shown.

After

Width:  |  Height:  |  Size: 621 B

@@ -232,6 +232,7 @@ EasyMeterText=EASY METER
GenreText=GENRE GenreText=GENRE
GroupText=GROUP GroupText=GROUP
HardMeterText=HARD METER HardMeterText=HARD METER
LengthText=LENGTH
MediumMeterText=MEDIUM METER MediumMeterText=MEDIUM METER
PopularityText=PLAYERS' BEST PopularityText=PLAYERS' BEST
Portal=PORTAL Portal=PORTAL
+2 -1
View File
@@ -1769,7 +1769,7 @@ Use3D=false
Wheel3DRadius=245 -- Possibly safe defaults? Wheel3DRadius=245 -- Possibly safe defaults?
CirclePercent=0.5 CirclePercent=0.5
MostPlayedSongsToShow=30 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" ChoicePreferred="sort,Preferred"
ChoiceGroup="sort,Group" ChoiceGroup="sort,Group"
ChoiceTitle="sort,Title" ChoiceTitle="sort,Title"
@@ -1781,6 +1781,7 @@ ChoiceGenre="sort,Genre"
ChoiceEasyMeter="sort,EasyMeter" ChoiceEasyMeter="sort,EasyMeter"
ChoiceMediumMeter="sort,MediumMeter" ChoiceMediumMeter="sort,MediumMeter"
ChoiceHardMeter="sort,HardMeter" ChoiceHardMeter="sort,HardMeter"
ChoiceLength="sort,Length"
[RoomWheel] [RoomWheel]
Fallback="MusicWheel" Fallback="MusicWheel"
+1
View File
@@ -151,6 +151,7 @@ static const char *SortOrderNames[] = {
"Nonstop", "Nonstop",
"Oni", "Oni",
"Endless", "Endless",
"Length",
"Roulette", "Roulette",
}; };
XToString( SortOrder ); XToString( SortOrder );
+1
View File
@@ -119,6 +119,7 @@ enum SortOrder
SORT_NONSTOP_COURSES, SORT_NONSTOP_COURSES,
SORT_ONI_COURSES, SORT_ONI_COURSES,
SORT_ENDLESS_COURSES, SORT_ENDLESS_COURSES,
SORT_LENGTH,
SORT_ROULETTE, SORT_ROULETTE,
NUM_SortOrder, NUM_SortOrder,
SortOrder_Invalid SortOrder_Invalid
+4
View File
@@ -417,6 +417,7 @@ void MusicWheel::BuildWheelItemDatas( vector<WheelItemData *> &arrayWheelItemDat
case SORT_MEDIUM_METER: case SORT_MEDIUM_METER:
case SORT_HARD_METER: case SORT_HARD_METER:
case SORT_CHALLENGE_METER: case SORT_CHALLENGE_METER:
case SORT_LENGTH:
{ {
/////////////////////////////////// ///////////////////////////////////
// Make an array of Song*, then sort them // Make an array of Song*, then sort them
@@ -463,6 +464,9 @@ void MusicWheel::BuildWheelItemDatas( vector<WheelItemData *> &arrayWheelItemDat
case SORT_GENRE: case SORT_GENRE:
SongUtil::SortSongPointerArrayByGenre( arraySongs ); SongUtil::SortSongPointerArrayByGenre( arraySongs );
break; break;
case SORT_LENGTH:
SongUtil::SortSongPointerArrayByLength( arraySongs );
break;
case SORT_EASY_METER: case SORT_EASY_METER:
SongUtil::SortSongPointerArrayByMeter( arraySongs, Difficulty_Easy ); SongUtil::SortSongPointerArrayByMeter( arraySongs, Difficulty_Easy );
break; break;
+20
View File
@@ -400,6 +400,25 @@ void SongUtil::SortSongPointerArrayByBPM( vector<Song*> &vpSongsInOut )
sort( vpSongsInOut.begin(), vpSongsInOut.end(), CompareSongPointersByBPM ); 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<Song*> &vpSongsInOut )
{
sort( vpSongsInOut.begin(), vpSongsInOut.end(), CompareSongPointersByLength );
}
void AppendOctal( int n, int digits, RString &out ) void AppendOctal( int n, int digits, RString &out )
{ {
for( int p = digits-1; p >= 0; --p ) 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; iMaxBPM += iBPMGroupSize - (iMaxBPM%iBPMGroupSize) - 1;
return ssprintf("%03d-%03d",iMaxBPM-(iBPMGroupSize-1), iMaxBPM); return ssprintf("%03d-%03d",iMaxBPM-(iBPMGroupSize-1), iMaxBPM);
} }
case SORT_LENGTH:
case SORT_POPULARITY: case SORT_POPULARITY:
return RString(); return RString();
case SORT_TOP_GRADES: case SORT_TOP_GRADES:
+1
View File
@@ -100,6 +100,7 @@ namespace SongUtil
RString GetSectionNameFromSongAndSort( const Song *pSong, SortOrder so ); RString GetSectionNameFromSongAndSort( const Song *pSong, SortOrder so );
void SortSongPointerArrayBySectionName( vector<Song*> &vpSongsInOut, SortOrder so ); void SortSongPointerArrayBySectionName( vector<Song*> &vpSongsInOut, SortOrder so );
void SortByMostRecentlyPlayedForMachine( vector<Song*> &vpSongsInOut ); void SortByMostRecentlyPlayedForMachine( vector<Song*> &vpSongsInOut );
void SortSongPointerArrayByLength( vector<Song*> &vpSongsInOut );
int CompareSongPointersByGroup(const Song *pSong1, const Song *pSong2); int CompareSongPointersByGroup(const Song *pSong1, const Song *pSong2);