diff --git a/src/GameState.cpp b/src/GameState.cpp index 9370add5b8..7829c75cec 100644 --- a/src/GameState.cpp +++ b/src/GameState.cpp @@ -175,7 +175,7 @@ GameState::GameState() : m_Environment = new LuaTable; m_bDopefish = false; - + sLastOpenSection = ""; sExpandedSectionName = ""; // Don't reset yet; let the first screen do it, so we can use PREFSMAN and THEME. diff --git a/src/GameState.h b/src/GameState.h index 94e8e813d8..ddb3ca305a 100644 --- a/src/GameState.h +++ b/src/GameState.h @@ -222,6 +222,8 @@ public: RString sExpandedSectionName; + RString sLastOpenSection; + static int GetNumStagesMultiplierForSong( const Song* pSong ); static int GetNumStagesForSongAndStyleType( const Song* pSong, StyleType st ); int GetNumStagesForCurrentSongAndStepsOrCourse() const; diff --git a/src/MusicWheel.cpp b/src/MusicWheel.cpp index aaa30bbd7e..8557e99060 100644 --- a/src/MusicWheel.cpp +++ b/src/MusicWheel.cpp @@ -335,16 +335,28 @@ bool MusicWheel::SelectSong( const Song *p ) unsigned i; std::vector &from = getWheelItemsData(GAMESTATE->m_SortOrder); - for( i=0; im_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; im_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; im_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; im_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; diff --git a/src/WheelBase.cpp b/src/WheelBase.cpp index fa3a3d39b3..067a2a7097 100644 --- a/src/WheelBase.cpp +++ b/src/WheelBase.cpp @@ -290,12 +290,14 @@ bool WheelBase::Select() // return true if this selection can end the screen RString sThisItemSectionName = m_CurWheelItemData[m_iSelection]->m_sText; if( m_sExpandedSectionName == sThisItemSectionName ) // already expanded { + GAMESTATE->sLastOpenSection = sThisItemSectionName; // remember this section SetOpenSection( "" ); // collapse it m_soundCollapse.Play(true); } else // already collapsed { SetOpenSection( sThisItemSectionName ); // expand it + GAMESTATE->sLastOpenSection = sThisItemSectionName; // remember this section m_soundExpand.Play(true); } }