From dde02a286edc3f639fa2bf3c8daea32d1dbea087 Mon Sep 17 00:00:00 2001 From: Glenn Maynard Date: Mon, 16 Jan 2006 20:39:52 +0000 Subject: [PATCH] split out ScreenOptions::GetNextScreenForSelection --- stepmania/src/ScreenOptions.cpp | 46 +++++++++++++++++---------------- stepmania/src/ScreenOptions.h | 1 + 2 files changed, 25 insertions(+), 22 deletions(-) diff --git a/stepmania/src/ScreenOptions.cpp b/stepmania/src/ScreenOptions.cpp index 70d07def3f..d5b392b339 100644 --- a/stepmania/src/ScreenOptions.cpp +++ b/stepmania/src/ScreenOptions.cpp @@ -960,30 +960,32 @@ void ScreenOptions::StoreFocus( PlayerNumber pn ) m_iCurrentRow[pn], row.GetChoiceInRowWithFocus(pn), m_iFocusX[pn]); } +CString ScreenOptions::GetNextScreenForSelection( PlayerNumber pn ) const +{ + int iCurRow = this->GetCurrentRow( pn ); + ASSERT( iCurRow >= 0 && iCurRow < (int)m_pRows.size() ); + const OptionRow *pRow = m_pRows[iCurRow]; + + int iChoice = pRow->GetChoiceInRowWithFocus( pn ); + if( pRow->GetFirstItemGoesDown() ) + iChoice--; + + // not the "goes down" item + if( iChoice == -1 ) + return RString(); + + const OptionRowHandler *pHand = pRow->GetHandler(); + if( pHand == NULL ) + return RString(); + return pHand->GetScreen( iChoice ); +} + void ScreenOptions::BeginFadingOut() { - /* If the selection is on a LIST, and the selected LIST option sets the screen, - * honor it. */ - int iCurRow = this->GetCurrentRow(); - ASSERT( iCurRow >= 0 && iCurRow < (int)m_pRows.size() ); - const OptionRow &row = *m_pRows[iCurRow]; - - { - int iChoice = row.GetChoiceInRowWithFocus( GAMESTATE->m_MasterPlayerNumber ); - if( row.GetFirstItemGoesDown() ) - iChoice--; - // not the "goes down" item - if( iChoice != -1 ) - { - const OptionRowHandler *pHand = row.GetHandler(); - if( pHand != NULL ) - { - CString sThisScreen = pHand->GetScreen( iChoice ); - if( sThisScreen != "" ) - m_sNextScreen = sThisScreen; - } - } - } + /* If the selected option sets a screen, honor it. */ + CString sThisScreen = GetNextScreenForSelection( GAMESTATE->m_MasterPlayerNumber ); + if( sThisScreen != "" ) + m_sNextScreen = sThisScreen; // If options set a NextScreen or one is specified in metrics, then fade out if( GetNextScreen() != "" ) diff --git a/stepmania/src/ScreenOptions.h b/stepmania/src/ScreenOptions.h index d12d36c69c..3d3a315146 100644 --- a/stepmania/src/ScreenOptions.h +++ b/stepmania/src/ScreenOptions.h @@ -63,6 +63,7 @@ protected: void StoreFocus( PlayerNumber pn ); void BeginFadingOut(); + CString GetNextScreenForSelection( PlayerNumber pn ) const; void ChangeValueInRowRelative( int iRow, PlayerNumber pn, int iDelta, bool bRepeat ); void ChangeValueInRowAbsolute( int iRow, PlayerNumber pn, int iChoiceIndex, bool bRepeat );