Fix Level and Preferred Sorts to account for a song being in multiple sections

This commit properly returns you to the correct pack when leaving a folder or returning from another screen.
This is achieved by returning you to your last open section. Previously behavior searched for the first instance of the song in your sort and put you in that section.
This commit is contained in:
Crash Cringle
2024-07-07 16:14:07 -07:00
committed by teejusb
parent 0447d9ae58
commit 667d27b361
4 changed files with 35 additions and 9 deletions
+30 -8
View File
@@ -335,16 +335,28 @@ bool MusicWheel::SelectSong( const Song *p )
unsigned i;
std::vector<MusicWheelItemData *> &from = getWheelItemsData(GAMESTATE->m_SortOrder);
for( i=0; i<from.size(); i++ )
{
if( from[i]->m_pSong == p )
if (GAMESTATE->sLastOpenSection != "" && (GAMESTATE->m_SortOrder == SORT_PREFERRED || GAMESTATE->m_SortOrder == SORT_METER)) {
// Return to the last open section if it is defined and exists in the current sort
for( i=0; i<from.size(); i++ )
{
// make its group the currently expanded group
SetOpenSection( from[i]->m_sText );
break;
if( from[i]->m_sText == GAMESTATE->sLastOpenSection )
{
// make its group the currently expanded group
SetOpenSection( from[i]->m_sText );
break;
}
}
} else {
for( i=0; i<from.size(); i++ )
{
if( from[i]->m_pSong == p )
{
// make its group the currently expanded group
SetOpenSection( from[i]->m_sText );
break;
}
}
}
if( i == from.size() )
return false;
@@ -1262,6 +1274,8 @@ void MusicWheel::ChangeMusic( int iDist )
bool MusicWheel::ChangeSort( SortOrder new_so, bool allowSameSort ) // return true if change successful
{
ASSERT( new_so < NUM_SortOrder );
// Reset LastOpenSection as sections differ between sorts
GAMESTATE->sLastOpenSection = "";
// NOTE(crashcringle): Ignore allowSameSort if we're using SORT_PREFERRED.
// Each player has their own preferred songs which sorts the songs differently
if( GAMESTATE->m_SortOrder == new_so && (!allowSameSort && new_so != SORT_PREFERRED ))
@@ -1503,7 +1517,15 @@ void MusicWheel::SetOpenSection( RString group )
for( unsigned i=0; i<m_CurWheelItemData.size(); i++ )
{
if( m_CurWheelItemData[i] == old )
if (GAMESTATE->m_SortOrder == SORT_PREFERRED && !GAMESTATE->sLastOpenSection.empty()) {
// old doesn't always have data, use LastOpenSection instead
if( m_CurWheelItemData[i]->m_sText == GAMESTATE->sLastOpenSection)
{
m_iSelection=i;
break;
}
} else if( m_CurWheelItemData[i] == old )
{
m_iSelection=i;
break;