Only UpdateMeterSort when necessary (when sorting), account for other games and styles.
Songs are already sorted by title so no need to do so again (otherwise big boi lag)
This commit is contained in:
+2
-3
@@ -571,6 +571,8 @@ void MusicWheel::BuildWheelItemDatas( std::vector<MusicWheelItemData *> &arrayWh
|
|||||||
switch( so )
|
switch( so )
|
||||||
{
|
{
|
||||||
case SORT_METER:
|
case SORT_METER:
|
||||||
|
SONGMAN->UpdateMeterSort(arraySongs);
|
||||||
|
break;
|
||||||
case SORT_PREFERRED:
|
case SORT_PREFERRED:
|
||||||
// obey order specified by the preferred sort list
|
// obey order specified by the preferred sort list
|
||||||
break;
|
break;
|
||||||
@@ -715,12 +717,9 @@ void MusicWheel::BuildWheelItemDatas( std::vector<MusicWheelItemData *> &arrayWh
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case SORT_METER:
|
case SORT_METER:
|
||||||
// If the sort order is Preferred handle it differently because we already know the sections
|
|
||||||
if( bUseSections )
|
if( bUseSections )
|
||||||
{
|
{
|
||||||
int iSectionCount = 0;
|
int iSectionCount = 0;
|
||||||
// // Get all section names
|
|
||||||
std::map<int, std::vector<Song*>> meterSortSongsMap = SONGMAN->GetMeterToSongsMap();
|
|
||||||
for (auto const& [sectionName, songs] : SONGMAN->GetMeterToSongsMap()) {
|
for (auto const& [sectionName, songs] : SONGMAN->GetMeterToSongsMap()) {
|
||||||
RageColor colorSection = SECTION_COLORS.GetValue(iSectionColorIndex);
|
RageColor colorSection = SECTION_COLORS.GetValue(iSectionColorIndex);
|
||||||
iSectionColorIndex = (iSectionColorIndex+1) % NUM_SECTION_COLORS;
|
iSectionColorIndex = (iSectionColorIndex+1) % NUM_SECTION_COLORS;
|
||||||
|
|||||||
+9
-15
@@ -214,7 +214,6 @@ void SongManager::Reload( bool bAllowFastLoad, LoadingWindow *ld )
|
|||||||
PREFSMAN->m_bFastLoad.Set( oldVal );
|
PREFSMAN->m_bFastLoad.Set( oldVal );
|
||||||
|
|
||||||
UpdatePreferredSort();
|
UpdatePreferredSort();
|
||||||
UpdateMeterSort();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void SongManager::LoadAdditions( LoadingWindow *ld )
|
void SongManager::LoadAdditions( LoadingWindow *ld )
|
||||||
@@ -228,7 +227,6 @@ void SongManager::LoadAdditions( LoadingWindow *ld )
|
|||||||
UNLOCKMAN->Reload();
|
UNLOCKMAN->Reload();
|
||||||
|
|
||||||
UpdatePreferredSort();
|
UpdatePreferredSort();
|
||||||
UpdateMeterSort();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void SongManager::InitSongsFromDisk( LoadingWindow *ld, bool onlyAdditions )
|
void SongManager::InitSongsFromDisk( LoadingWindow *ld, bool onlyAdditions )
|
||||||
@@ -1237,7 +1235,6 @@ void SongManager::Invalidate( const Song *pStaleSong )
|
|||||||
|
|
||||||
UpdatePopular();
|
UpdatePopular();
|
||||||
UpdateShuffled();
|
UpdateShuffled();
|
||||||
UpdateMeterSort();
|
|
||||||
RefreshCourseGroupInfo();
|
RefreshCourseGroupInfo();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1630,17 +1627,19 @@ void SongManager::UpdatePopular()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void SongManager::UpdateMeterSort() {
|
std::map<int, std::vector<Song*>> SongManager::UpdateMeterSort( std::vector<Song*> songs) {
|
||||||
std::vector<Song*> apDifficultSongs = m_pSongs;
|
// Empty the map
|
||||||
|
m_mapSongsByDifficulty.clear();
|
||||||
|
std::vector<Song*> apDifficultSongs = songs;
|
||||||
// For each song, for each step
|
// For each song, for each step
|
||||||
for( unsigned i = 0; i < apDifficultSongs.size(); ++i )
|
for( unsigned i = 0; i < apDifficultSongs.size(); ++i )
|
||||||
{
|
{
|
||||||
const std::vector<Steps*> &vSteps = apDifficultSongs[i]->GetAllSteps();
|
std::vector<Steps*> vpSteps;
|
||||||
for( unsigned j = 0; j < vSteps.size(); ++j )
|
SongUtil::GetPlayableSteps( apDifficultSongs[i], vpSteps );
|
||||||
|
for( unsigned j = 0; j < vpSteps.size(); ++j )
|
||||||
{
|
{
|
||||||
Steps *pSteps = vSteps[j];
|
Steps *pSteps = vpSteps[j];
|
||||||
// Check if the meter is already in m_mapSongsByDifficulty
|
// Check if the meter is already in m_mapSongsByDifficulty
|
||||||
|
|
||||||
if (std::find(m_mapSongsByDifficulty[pSteps->GetMeter()].begin(), m_mapSongsByDifficulty[pSteps->GetMeter()].end(), apDifficultSongs[i]) != m_mapSongsByDifficulty[pSteps->GetMeter()].end())
|
if (std::find(m_mapSongsByDifficulty[pSteps->GetMeter()].begin(), m_mapSongsByDifficulty[pSteps->GetMeter()].end(), apDifficultSongs[i]) != m_mapSongsByDifficulty[pSteps->GetMeter()].end())
|
||||||
continue;
|
continue;
|
||||||
else {
|
else {
|
||||||
@@ -1648,12 +1647,7 @@ void SongManager::UpdateMeterSort() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return m_mapSongsByDifficulty;
|
||||||
// For each meter in m_mapSongsByDifficulty, sort the songs by title
|
|
||||||
for( unsigned i = 0; i < m_mapSongsByDifficulty.size(); ++i )
|
|
||||||
{
|
|
||||||
SongUtil::SortSongPointerArrayByTitle( m_mapSongsByDifficulty[i] );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -189,7 +189,7 @@ public:
|
|||||||
|
|
||||||
void UpdatePopular();
|
void UpdatePopular();
|
||||||
void UpdateShuffled(); // re-shuffle songs and courses
|
void UpdateShuffled(); // re-shuffle songs and courses
|
||||||
void UpdateMeterSort();
|
std::map<int, std::vector<Song*>> UpdateMeterSort( std::vector<Song*> songs);
|
||||||
void SetPreferredSongs(RString sPreferredSongs, bool bIsAbsolute = false);
|
void SetPreferredSongs(RString sPreferredSongs, bool bIsAbsolute = false);
|
||||||
void SetPreferredCourses(RString sPreferredCourses, bool bIsAbsolute = false);
|
void SetPreferredCourses(RString sPreferredCourses, bool bIsAbsolute = false);
|
||||||
void UpdatePreferredSort(RString sPreferredSongs = "PreferredSongs.txt", RString sPreferredCourses = "PreferredCourses.txt");
|
void UpdatePreferredSort(RString sPreferredSongs = "PreferredSongs.txt", RString sPreferredCourses = "PreferredCourses.txt");
|
||||||
|
|||||||
@@ -146,7 +146,6 @@ namespace SongUtil
|
|||||||
void SortSongPointerArrayByNumPlays( std::vector<Song*> &vpSongsInOut, ProfileSlot slot, bool bDescending );
|
void SortSongPointerArrayByNumPlays( std::vector<Song*> &vpSongsInOut, ProfileSlot slot, bool bDescending );
|
||||||
void SortSongPointerArrayByNumPlays( std::vector<Song*> &vpSongsInOut, const Profile* pProfile, bool bDescending );
|
void SortSongPointerArrayByNumPlays( std::vector<Song*> &vpSongsInOut, const Profile* pProfile, bool bDescending );
|
||||||
void SortSongPointerArrayByStepsTypeAndMeter( std::vector<Song*> &vpSongsInOut, StepsType st, Difficulty dc );
|
void SortSongPointerArrayByStepsTypeAndMeter( std::vector<Song*> &vpSongsInOut, StepsType st, Difficulty dc );
|
||||||
void SortSongPointerArrayByStepsTypeAndLevel( std::vector<Song*> &vpSongsInOut, StepsType st, int iMeter );
|
|
||||||
RString GetSectionNameFromSongAndSort( const Song *pSong, SortOrder so );
|
RString GetSectionNameFromSongAndSort( const Song *pSong, SortOrder so );
|
||||||
void SortSongPointerArrayBySectionName( std::vector<Song*> &vpSongsInOut, SortOrder so );
|
void SortSongPointerArrayBySectionName( std::vector<Song*> &vpSongsInOut, SortOrder so );
|
||||||
void SortByMostRecentlyPlayedForMachine( std::vector<Song*> &vpSongsInOut );
|
void SortByMostRecentlyPlayedForMachine( std::vector<Song*> &vpSongsInOut );
|
||||||
|
|||||||
@@ -1006,7 +1006,6 @@ int sm_main(int argc, char* argv[])
|
|||||||
UNLOCKMAN = new UnlockManager;
|
UNLOCKMAN = new UnlockManager;
|
||||||
SONGMAN->UpdatePopular();
|
SONGMAN->UpdatePopular();
|
||||||
SONGMAN->UpdatePreferredSort();
|
SONGMAN->UpdatePreferredSort();
|
||||||
SONGMAN->UpdateMeterSort();
|
|
||||||
NETWORK = new NetworkManager;
|
NETWORK = new NetworkManager;
|
||||||
STATSMAN = new StatsManager;
|
STATSMAN = new StatsManager;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user