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:
+1
-1
@@ -175,7 +175,7 @@ GameState::GameState() :
|
|||||||
m_Environment = new LuaTable;
|
m_Environment = new LuaTable;
|
||||||
|
|
||||||
m_bDopefish = false;
|
m_bDopefish = false;
|
||||||
|
sLastOpenSection = "";
|
||||||
sExpandedSectionName = "";
|
sExpandedSectionName = "";
|
||||||
|
|
||||||
// Don't reset yet; let the first screen do it, so we can use PREFSMAN and THEME.
|
// Don't reset yet; let the first screen do it, so we can use PREFSMAN and THEME.
|
||||||
|
|||||||
@@ -222,6 +222,8 @@ public:
|
|||||||
|
|
||||||
RString sExpandedSectionName;
|
RString sExpandedSectionName;
|
||||||
|
|
||||||
|
RString sLastOpenSection;
|
||||||
|
|
||||||
static int GetNumStagesMultiplierForSong( const Song* pSong );
|
static int GetNumStagesMultiplierForSong( const Song* pSong );
|
||||||
static int GetNumStagesForSongAndStyleType( const Song* pSong, StyleType st );
|
static int GetNumStagesForSongAndStyleType( const Song* pSong, StyleType st );
|
||||||
int GetNumStagesForCurrentSongAndStepsOrCourse() const;
|
int GetNumStagesForCurrentSongAndStepsOrCourse() const;
|
||||||
|
|||||||
+30
-8
@@ -335,16 +335,28 @@ bool MusicWheel::SelectSong( const Song *p )
|
|||||||
|
|
||||||
unsigned i;
|
unsigned i;
|
||||||
std::vector<MusicWheelItemData *> &from = getWheelItemsData(GAMESTATE->m_SortOrder);
|
std::vector<MusicWheelItemData *> &from = getWheelItemsData(GAMESTATE->m_SortOrder);
|
||||||
for( i=0; i<from.size(); i++ )
|
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
|
||||||
if( from[i]->m_pSong == p )
|
for( i=0; i<from.size(); i++ )
|
||||||
{
|
{
|
||||||
// make its group the currently expanded group
|
if( from[i]->m_sText == GAMESTATE->sLastOpenSection )
|
||||||
SetOpenSection( from[i]->m_sText );
|
{
|
||||||
break;
|
// 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() )
|
if( i == from.size() )
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
@@ -1262,6 +1274,8 @@ void MusicWheel::ChangeMusic( int iDist )
|
|||||||
bool MusicWheel::ChangeSort( SortOrder new_so, bool allowSameSort ) // return true if change successful
|
bool MusicWheel::ChangeSort( SortOrder new_so, bool allowSameSort ) // return true if change successful
|
||||||
{
|
{
|
||||||
ASSERT( new_so < NUM_SortOrder );
|
ASSERT( new_so < NUM_SortOrder );
|
||||||
|
// Reset LastOpenSection as sections differ between sorts
|
||||||
|
GAMESTATE->sLastOpenSection = "";
|
||||||
// NOTE(crashcringle): Ignore allowSameSort if we're using SORT_PREFERRED.
|
// NOTE(crashcringle): Ignore allowSameSort if we're using SORT_PREFERRED.
|
||||||
// Each player has their own preferred songs which sorts the songs differently
|
// Each player has their own preferred songs which sorts the songs differently
|
||||||
if( GAMESTATE->m_SortOrder == new_so && (!allowSameSort && new_so != SORT_PREFERRED ))
|
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++ )
|
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;
|
m_iSelection=i;
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -290,12 +290,14 @@ bool WheelBase::Select() // return true if this selection can end the screen
|
|||||||
RString sThisItemSectionName = m_CurWheelItemData[m_iSelection]->m_sText;
|
RString sThisItemSectionName = m_CurWheelItemData[m_iSelection]->m_sText;
|
||||||
if( m_sExpandedSectionName == sThisItemSectionName ) // already expanded
|
if( m_sExpandedSectionName == sThisItemSectionName ) // already expanded
|
||||||
{
|
{
|
||||||
|
GAMESTATE->sLastOpenSection = sThisItemSectionName; // remember this section
|
||||||
SetOpenSection( "" ); // collapse it
|
SetOpenSection( "" ); // collapse it
|
||||||
m_soundCollapse.Play(true);
|
m_soundCollapse.Play(true);
|
||||||
}
|
}
|
||||||
else // already collapsed
|
else // already collapsed
|
||||||
{
|
{
|
||||||
SetOpenSection( sThisItemSectionName ); // expand it
|
SetOpenSection( sThisItemSectionName ); // expand it
|
||||||
|
GAMESTATE->sLastOpenSection = sThisItemSectionName; // remember this section
|
||||||
m_soundExpand.Play(true);
|
m_soundExpand.Play(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user