diff --git a/stepmania/Themes/default/metrics.ini b/stepmania/Themes/default/metrics.ini index 9cb4cd63b3..46c91106ea 100644 --- a/stepmania/Themes/default/metrics.ini +++ b/stepmania/Themes/default/metrics.ini @@ -2219,6 +2219,7 @@ OptionRowType=OptionRowNoUnderline FrameOnCommand= FrameOffCommand= OptionRowType=OptionRowEditMenu +ShowExitRow=0 NumRowsShown=8 RowYOffScreenTop=SCREEN_CENTER_Y-152+34*(-0.5) @@ -2494,6 +2495,7 @@ ScrollBarTime=0 ShowBpmInSpeedTitle=0 FrameOnCommand=addx,-SCREEN_WIDTH;decelerate,0.3;addx,SCREEN_WIDTH FrameOffCommand=accelerate,0.3;addx,SCREEN_WIDTH +ShowExitRow=1 SeparateExitRow=0 SeparateExitRowY=0 MoreX= diff --git a/stepmania/src/OptionRowHandler.cpp b/stepmania/src/OptionRowHandler.cpp index 7815a19ca7..a1ae1dac40 100644 --- a/stepmania/src/OptionRowHandler.cpp +++ b/stepmania/src/OptionRowHandler.cpp @@ -982,12 +982,9 @@ public: defOut.choices.push_back( "none" ); } - if( m_ppStepsToFill->Get() == NULL ) - { - if( m_pDifficultyToFill ) - m_pDifficultyToFill->Set( m_vDifficulties[0] ); - m_ppStepsToFill->Set( m_vSteps[0] ); - } + if( m_pDifficultyToFill ) + m_pDifficultyToFill->Set( m_vDifficulties[0] ); + m_ppStepsToFill->Set( m_vSteps[0] ); } virtual void ImportOption( const OptionRowDefinition &def, PlayerNumber pn, vector &vbSelectedOut ) const { diff --git a/stepmania/src/ScreenOptions.cpp b/stepmania/src/ScreenOptions.cpp index 3fc2d1e3b5..d05fe1636e 100644 --- a/stepmania/src/ScreenOptions.cpp +++ b/stepmania/src/ScreenOptions.cpp @@ -91,6 +91,7 @@ ScreenOptions::ScreenOptions( CString sClassName ) : ScreenWithMenuElements(sCla SHOW_BPM_IN_SPEED_TITLE (m_sName,"ShowBpmInSpeedTitle"), FRAME_ON_COMMAND (m_sName,"FrameOnCommand"), FRAME_OFF_COMMAND (m_sName,"FrameOffCommand"), + SHOW_EXIT_ROW (m_sName,"ShowExitRow"), SEPARATE_EXIT_ROW (m_sName,"SeparateExitRow"), SEPARATE_EXIT_ROW_Y (m_sName,"SeparateExitRowY"), OPTION_ROW_TYPE (m_sName,"OptionRowType") @@ -191,9 +192,9 @@ void ScreenOptions::InitMenu( InputMode im, const vector &v m_framePage.AddChild( &row ); } - if( SEPARATE_EXIT_ROW ) + if( SHOW_EXIT_ROW ) { - // TRICKY: Add one more item. This will be "EXIT" + // TRICKY: Add "EXIT" item m_Rows.push_back( new OptionRow() ); OptionRow &row = *m_Rows.back(); row.LoadMetrics( OPTION_ROW_TYPE ); @@ -298,10 +299,9 @@ ScreenOptions::~ScreenOptions() CString ScreenOptions::GetExplanationText( int iRow ) const { OptionRow &row = *m_Rows[iRow]; - if( row.GetRowType() == OptionRow::ROW_EXIT ) - return ""; CString sLineName = row.GetRowDef().name; + ASSERT( !sLineName.empty() ); sLineName.Replace("\n-",""); sLineName.Replace("\n",""); sLineName.Replace(" ",""); @@ -311,8 +311,6 @@ CString ScreenOptions::GetExplanationText( int iRow ) const CString ScreenOptions::GetExplanationTitle( int iRow ) const { OptionRow &row = *m_Rows[iRow]; - if( row.GetRowType() == OptionRow::ROW_EXIT ) - return ""; CString sLineName = row.GetRowDef().name; sLineName.Replace("\n-",""); @@ -515,7 +513,7 @@ void ScreenOptions::HandleScreenMessage( const ScreenMessage SM ) switch( SM ) { case SM_MenuTimer: - StartGoToNextScreen(); + this->BeginFadingOut(); break; case SM_GoToPrevScreen: // this->ExportOptions(); // Don't save options if we're going back! @@ -738,16 +736,19 @@ void ScreenOptions::MenuBack( PlayerNumber pn ) Back( SM_GoToPrevScreen ); } -void ScreenOptions::StartGoToNextScreen() +bool ScreenOptions::IsOnLastRow( PlayerNumber pn ) const { - this->PostScreenMessage( SM_BeginFadingOut, 0 ); + int iCurRow = m_iCurrentRow[pn]; + return iCurRow == (int)(m_Rows.size()-1); } -bool ScreenOptions::AllAreOnExit() const +bool ScreenOptions::AllAreOnLastRow() const { FOREACH_HumanPlayer( p ) - if( m_Rows[m_iCurrentRow[p]]->GetRowType() != OptionRow::ROW_EXIT ) + { + if( !IsOnLastRow(p) ) return false; + } return true; } @@ -766,7 +767,8 @@ void ScreenOptions::MenuStart( PlayerNumber pn, const InputEventType selectType break; } - OptionRow &row = *m_Rows[m_iCurrentRow[pn]]; + int iCurRow = m_iCurrentRow[pn]; + OptionRow &row = *m_Rows[iCurRow]; /* If we are in a three-button mode, check to see if MENU_BUTTON_LEFT and @@ -789,11 +791,11 @@ void ScreenOptions::MenuStart( PlayerNumber pn, const InputEventType selectType // If on exit, check it all players are on "Exit" - if( row.GetRowType() == OptionRow::ROW_EXIT ) + if( IsOnLastRow(pn) ) { /* Don't accept START to go to the next screen if we're still transitioning in. */ - if( AllAreOnExit() && selectType == IET_FIRST_PRESS && !IsTransitioning() ) - StartGoToNextScreen(); + if( AllAreOnLastRow() && selectType == IET_FIRST_PRESS && !IsTransitioning() ) + this->BeginFadingOut(); return; } @@ -851,7 +853,7 @@ void ScreenOptions::MenuStart( PlayerNumber pn, const InputEventType selectType case NAV_THREE_KEY_MENU: /* Don't accept START to go to the next screen if we're still transitioning in. */ if( selectType == IET_FIRST_PRESS && !IsTransitioning() ) - StartGoToNextScreen(); + this->BeginFadingOut(); break; case NAV_FIVE_KEY: /* Jump to the exit row. (If everyone's already on the exit row, then @@ -882,7 +884,10 @@ void ScreenOptions::ChangeValueInRow( PlayerNumber pn, int iDelta, bool Repeat ) const int iCurRow = m_iCurrentRow[pn]; OptionRow &row = *m_Rows[iCurRow]; - const int iNumOptions = (row.GetRowType() == OptionRow::ROW_EXIT)? 1: row.GetRowDef().choices.size(); + if( row.GetRowType() == OptionRow::ROW_EXIT ) // EXIT is selected + return; // don't allow a move + + const int iNumOptions = row.GetRowDef().choices.size(); if( m_OptionsNavigation == NAV_THREE_KEY_MENU && iNumOptions <= 1 ) // 1 or 0 { /* There are no other options on the row; move up or down instead of left and right. @@ -897,9 +902,6 @@ void ScreenOptions::ChangeValueInRow( PlayerNumber pn, int iDelta, bool Repeat ) if( Repeat ) return; - if( row.GetRowType() == OptionRow::ROW_EXIT ) // EXIT is selected - return; // don't allow a move - bool bOneChanged = false; diff --git a/stepmania/src/ScreenOptions.h b/stepmania/src/ScreenOptions.h index e2b7ce78a5..7c2f64dc8d 100644 --- a/stepmania/src/ScreenOptions.h +++ b/stepmania/src/ScreenOptions.h @@ -53,8 +53,7 @@ protected: virtual void MenuBack( PlayerNumber pn ); virtual void MenuStart( PlayerNumber pn, const InputEventType type ); - void StartGoToNextScreen(); - + virtual void BeginFadingOut() { this->PostScreenMessage( SM_BeginFadingOut, 0 ); } virtual void GoToNextScreen() = 0; virtual void GoToPrevScreen() = 0; @@ -68,7 +67,8 @@ protected: /* Returns -1 if on a row with no OptionRowDefinition (eg. EXIT). */ int GetCurrentRow(PlayerNumber pn = PLAYER_1) const; - bool AllAreOnExit() const; + bool IsOnLastRow( PlayerNumber pn ) const; + bool AllAreOnLastRow() const; protected: // derived classes need access to these void LoadOptionIcon( PlayerNumber pn, int iRow, CString sText ); @@ -133,6 +133,7 @@ protected: ThemeMetric SHOW_BPM_IN_SPEED_TITLE; ThemeMetric FRAME_ON_COMMAND; ThemeMetric FRAME_OFF_COMMAND; + ThemeMetric SHOW_EXIT_ROW; ThemeMetric SEPARATE_EXIT_ROW; ThemeMetric SEPARATE_EXIT_ROW_Y; ThemeMetric OPTION_ROW_TYPE; diff --git a/stepmania/src/ScreenOptionsMaster.cpp b/stepmania/src/ScreenOptionsMaster.cpp index b19dde2771..0748c3e0fb 100644 --- a/stepmania/src/ScreenOptionsMaster.cpp +++ b/stepmania/src/ScreenOptionsMaster.cpp @@ -69,12 +69,13 @@ void ScreenOptionsMaster::Init() RageException::Throw( "Unknown flag \"%s\"", sFlag.c_str() ); } - m_OptionRowAlloc.resize( asLineNames.size() ); + vector OptionRowDefs; + OptionRowDefs.resize( asLineNames.size() ); OptionRowHandlers.resize( asLineNames.size() ); for( unsigned i = 0; i < asLineNames.size(); ++i ) { CString sLineName = asLineNames[i]; - OptionRowDefinition &def = m_OptionRowAlloc[i]; + OptionRowDefinition &def = OptionRowDefs[i]; CString sRowCommands = LINE(sLineName); OptionRowHandler* &pHand = OptionRowHandlers[i]; pHand = NULL; @@ -92,7 +93,7 @@ void ScreenOptionsMaster::Init() ASSERT( OptionRowHandlers.size() == asLineNames.size() ); - InitMenu( im, m_OptionRowAlloc, OptionRowHandlers ); + InitMenu( im, OptionRowDefs, OptionRowHandlers ); } ScreenOptionsMaster::~ScreenOptionsMaster() @@ -147,6 +148,41 @@ void ScreenOptionsMaster::ExportOptions( int r ) m_iChangeMask |= row.ExportOptions(); } +void ScreenOptionsMaster::BeginFadingOut() +{ + /* If the selection is on a LIST, and the selected LIST option sets the screen, + * honor it. */ + m_sNextScreen = ""; + + const unsigned uFocusRow = this->GetCurrentRow(); + + for( unsigned r = 0; r < OptionRowHandlers.size(); ++r ) + { + OptionRow &row = *m_Rows[r]; + + CHECKPOINT_M( ssprintf("%i/%i", r, int(OptionRowHandlers.size())) ); + + /* If SELECT_NONE, only apply it if it's the selected option. */ + if( row.GetRowDef().selectType == SELECT_NONE && r != uFocusRow ) + continue; + + OptionRowHandler *pHand = OptionRowHandlers[r]; + + const int iChoice = row.GetChoiceInRowWithFocus(GAMESTATE->m_MasterPlayerNumber); + CString sScreen = pHand->GetAndEraseScreen( iChoice ); + if( !sScreen.empty() ) + m_sNextScreen = sScreen; + } + CHECKPOINT; + + // NEXT_SCREEN; + if( m_sNextScreen == "" ) + m_sNextScreen = NEXT_SCREEN; + + if( !m_sNextScreen.empty() ) + ScreenOptions::BeginFadingOut(); +} + void ScreenOptionsMaster::GoToNextScreen() { if( GAMESTATE->m_bEditing ) @@ -221,36 +257,14 @@ void ScreenOptionsMaster::HandleScreenMessage( const ScreenMessage SM ) CHECKPOINT; - const unsigned uFocusRow = this->GetCurrentRow(); - /* If the selection is on a LIST, and the selected LIST option sets the screen, - * honor it. */ - m_sNextScreen = ""; - for( unsigned r = 0; r < OptionRowHandlers.size(); ++r ) { - OptionRow &row = *m_Rows[r]; + const OptionRow &row = *m_Rows[r]; CHECKPOINT_M( ssprintf("%i/%i", r, int(OptionRowHandlers.size())) ); - - /* If SELECT_NONE, only apply it if it's the selected option. */ - const OptionRowDefinition &def = m_OptionRowAlloc[r]; - if( def.selectType == SELECT_NONE && r != uFocusRow ) - continue; - - OptionRowHandler *pHand = OptionRowHandlers[r]; - - const int iChoice = row.GetChoiceInRowWithFocus(GAMESTATE->m_MasterPlayerNumber); - CString sScreen = pHand->GetAndEraseScreen( iChoice ); - if( !sScreen.empty() ) - m_sNextScreen = sScreen; - + ExportOptions( r ); } - CHECKPOINT; - - // NEXT_SCREEN; - if( m_sNextScreen == "" ) - m_sNextScreen = NEXT_SCREEN; if( m_iChangeMask & OPT_APPLY_ASPECT_RATIO ) { diff --git a/stepmania/src/ScreenOptionsMaster.h b/stepmania/src/ScreenOptionsMaster.h index 394f7badd0..825c3c6878 100644 --- a/stepmania/src/ScreenOptionsMaster.h +++ b/stepmania/src/ScreenOptionsMaster.h @@ -5,7 +5,7 @@ class OptionRowHandler; -class ScreenOptionsMaster: public ScreenOptions +class ScreenOptionsMaster : public ScreenOptions { public: ScreenOptionsMaster( CString sName ); @@ -19,7 +19,6 @@ protected: CString m_sNextScreen; vector OptionRowHandlers; - vector m_OptionRowAlloc; protected: void HandleScreenMessage( const ScreenMessage SM ); @@ -28,6 +27,7 @@ protected: virtual void ExportOptions( int row ); virtual void ImportOptionsForPlayer( PlayerNumber pn ); // used by ScreenPlayerOptions + virtual void BeginFadingOut(); virtual void GoToNextScreen(); virtual void GoToPrevScreen();