simplify and optimize section sort
fix two "OTHER" groups
This commit is contained in:
@@ -316,25 +316,27 @@ void MusicWheel::GetSongList(vector<Song*> &arraySongs, SongSortOrder so, CStrin
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
extern map<const Song*, CString> song_sort_val;
|
||||||
//struct CompareSongPointerArrayBySectionName
|
bool CompareSongPointersBySortVal(const Song *pSong1, const Song *pSong2);
|
||||||
//{
|
|
||||||
// SongSortOrder so;
|
void MusicWheel::SortSongPointerArrayBySectionName( vector<Song*> &arraySongPointers, SongSortOrder so )
|
||||||
// CompareSongPointerArrayBySectionName( SongSortOrder so_ ): so(so_) { }
|
{
|
||||||
// bool operator() (const Song *p1, const Song *p2) const
|
for(unsigned i = 0; i < arraySongPointers.size(); ++i)
|
||||||
// {
|
{
|
||||||
// CString sec1 = MusicWheel::GetSectionNameFromSongAndSort( p1, so );
|
CString val = MusicWheel::GetSectionNameFromSongAndSort( arraySongPointers[i], so );
|
||||||
// CString sec2 = MusicWheel::GetSectionNameFromSongAndSort( p2, so );
|
|
||||||
//
|
/* Make sure NUM comes first and OTHER comes last. */
|
||||||
// /* In the TITLE sort, make sure NUM comes first and OTHER comes last. */
|
if( val == "NUM" ) val = "0";
|
||||||
// if(so == SORT_TITLE && sec1 == "NUM" && sec2 != "NUM") return true;
|
else if( val == "OTHER" ) val = "2";
|
||||||
// if(so == SORT_TITLE && sec1 != "NUM" && sec2 == "NUM") return false;
|
else val = "1" + val;
|
||||||
// if(so == SORT_TITLE && sec1 != "OTHER" && sec2 == "OTHER") return true;
|
|
||||||
// if(so == SORT_TITLE && sec1 == "OTHER" && sec2 != "OTHER") return false;
|
song_sort_val[arraySongPointers[i]] = val;
|
||||||
//
|
}
|
||||||
// return sec1 < sec2;
|
|
||||||
// }
|
stable_sort( arraySongPointers.begin(), arraySongPointers.end(), CompareSongPointersBySortVal );
|
||||||
//};
|
song_sort_val.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void MusicWheel::BuildWheelItemDatas( vector<WheelItemData> &arrayWheelItemDatas, SongSortOrder so )
|
void MusicWheel::BuildWheelItemDatas( vector<WheelItemData> &arrayWheelItemDatas, SongSortOrder so )
|
||||||
{
|
{
|
||||||
@@ -422,10 +424,14 @@ void MusicWheel::BuildWheelItemDatas( vector<WheelItemData> &arrayWheelItemDatas
|
|||||||
{
|
{
|
||||||
// Sorting twice isn't necessary. Instead, modify the compatator functions
|
// Sorting twice isn't necessary. Instead, modify the compatator functions
|
||||||
// in Song.cpp to have the desired effect. -Chris
|
// in Song.cpp to have the desired effect. -Chris
|
||||||
|
/* Keeping groups together with the sorts is tricky and brittle; we
|
||||||
|
* keep getting OTHER split up without this. However, it puts the
|
||||||
|
* Grade and BPM sorts in the wrong order, and they're already correct,
|
||||||
|
* so don't re-sort for them. */
|
||||||
// /* We're using sections, so use the section name as the top-level
|
// /* We're using sections, so use the section name as the top-level
|
||||||
// * sort. */
|
// * sort. */
|
||||||
// stable_sort(arraySongs.begin(), arraySongs.end(),
|
if( so != SORT_GRADE && so != SORT_BPM )
|
||||||
// CompareSongPointerArrayBySectionName(so));
|
SortSongPointerArrayBySectionName(arraySongs, so);
|
||||||
|
|
||||||
// make WheelItemDatas with sections
|
// make WheelItemDatas with sections
|
||||||
CString sLastSection = "";
|
CString sLastSection = "";
|
||||||
|
|||||||
@@ -126,6 +126,7 @@ protected:
|
|||||||
RageSound m_soundLocked;
|
RageSound m_soundLocked;
|
||||||
|
|
||||||
static CString GetSectionNameFromSongAndSort( const Song* pSong, SongSortOrder so );
|
static CString GetSectionNameFromSongAndSort( const Song* pSong, SongSortOrder so );
|
||||||
|
static void SortSongPointerArrayBySectionName( vector<Song*> &arraySongPointers, SongSortOrder so );
|
||||||
bool WheelItemIsVisible(int n);
|
bool WheelItemIsVisible(int n);
|
||||||
void UpdateScrollbar();
|
void UpdateScrollbar();
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user