From 824fe8c13827cb1a8e8195a51d8d6dfb6612eccc Mon Sep 17 00:00:00 2001 From: Aaron VonderHaar Date: Sun, 14 Sep 2003 21:00:23 +0000 Subject: [PATCH] Disable rave mode on ScreenSelectDifficulty when appropriate (doubles and solo) --- stepmania/src/GameState.cpp | 33 ++++++++----- stepmania/src/ScreenSelectDifficulty.cpp | 63 +++++++++++++++++++++--- 2 files changed, 76 insertions(+), 20 deletions(-) diff --git a/stepmania/src/GameState.cpp b/stepmania/src/GameState.cpp index 4234e0cdf4..fbc4f03756 100644 --- a/stepmania/src/GameState.cpp +++ b/stepmania/src/GameState.cpp @@ -304,24 +304,33 @@ const StyleDef* GameState::GetCurrentStyleDef() bool GameState::IsPlayable( const ModeChoice& mc ) { + // Mode doesn't interest the caller, presumably because + // a style has not been chosen yet. + if ( mc.pm == PLAY_MODE_INVALID ) + return mc.numSidesJoinedToPlay == GAMESTATE->GetNumSidesJoined(); + + // A style has been chosen, so now consider modes + const Style &style = (mc.style != STYLE_INVALID) ? mc.style : m_CurStyle; + ASSERT(style != STYLE_INVALID); + if( mc.pm == PLAY_MODE_RAVE ) { // Can't play Rave without characters for attack definitions. - if( m_pCharacters.empty() ) - return false; - - // Can't play rave unless there is room for two players - if( mc.style != STYLE_INVALID && - GAMEMAN->GetStyleDefForStyle(mc.style)->m_StyleType == StyleDef::ONE_PLAYER_TWO_CREDITS ) - return false; - - // Can't play rave unless there is room for two players - if( m_CurStyle != STYLE_INVALID && - GAMEMAN->GetStyleDefForStyle(m_CurStyle)->m_StyleType == StyleDef::ONE_PLAYER_TWO_CREDITS ) + //X ... but we'll let ScreenSelectDifficulty give that message + //X (since that will give the user an explanation) + //X + //Xif( m_pCharacters.empty() ) + //X return false; + + // Can't play rave if there isn't enough room for two players. + // This is correct for dance (ie, no rave for solo and doubles), + // and should be okay for pump .. not sure about other game types. + if( GAMEMAN->GetStyleDefForStyle(style)->m_iColsPerPlayer >= 6 ) return false; + } - return mc.numSidesJoinedToPlay == GAMESTATE->GetNumSidesJoined(); + return true; // why not? } bool GameState::IsPlayerEnabled( PlayerNumber pn ) diff --git a/stepmania/src/ScreenSelectDifficulty.cpp b/stepmania/src/ScreenSelectDifficulty.cpp index cf30b9ba29..89d8f683e7 100644 --- a/stepmania/src/ScreenSelectDifficulty.cpp +++ b/stepmania/src/ScreenSelectDifficulty.cpp @@ -118,6 +118,8 @@ ScreenSelectDifficulty::ScreenSelectDifficulty() : ScreenSelect( "ScreenSelectDi m_soundDifficult.Load( ANNOUNCER->GetPathTo("select difficulty challenge") ); m_fLockInputTime = LOCK_INPUT_SECONDS; + + this->UpdateSelectableChoices(); TweenOnScreen(); } @@ -188,13 +190,25 @@ void ScreenSelectDifficulty::MenuLeft( PlayerNumber pn ) // return; if( m_bChosen[pn] ) return; - if( m_iChoiceOnPage[pn] == 0 ) // can't go left any more + + int iSwitchToIndex = -1; + for( int i=m_iChoiceOnPage[pn]-1; i>=0; i-- ) + { + if( GAMESTATE->IsPlayable(m_ModeChoices[m_CurrentPage][i])) + { + iSwitchToIndex = i; + break; + } + } + + if( iSwitchToIndex == -1 ) { if( m_CurrentPage > 0 ) ChangePage( (Page)(m_CurrentPage-1) ); + return; } - else - ChangeWithinPage( pn, m_iChoiceOnPage[pn]-1, false ); + + ChangeWithinPage( pn, iSwitchToIndex, false ); } @@ -204,16 +218,28 @@ void ScreenSelectDifficulty::MenuRight( PlayerNumber pn ) // return; if( m_bChosen[pn] ) return; - if( m_iChoiceOnPage[pn] == (int)m_ModeChoices[m_CurrentPage].size()-1 ) // can't go right any more + + int iSwitchToIndex = -1; + for( int i=m_iChoiceOnPage[pn]+1; iIsPlayable(m_ModeChoices[m_CurrentPage][i])) + { + iSwitchToIndex = i; + break; + } + } + + if( iSwitchToIndex == -1 ) { if( m_ModeChoices[m_CurrentPage+1].size()==0 ) // there is no page 2 return; if( m_CurrentPage < NUM_PAGES-1 ) ChangePage( (Page)(m_CurrentPage+1) ); + return; } - else - ChangeWithinPage( pn, m_iChoiceOnPage[pn]+1, false ); + + ChangeWithinPage( pn, iSwitchToIndex, false ); } void ScreenSelectDifficulty::ChangePage( Page newPage ) @@ -235,10 +261,31 @@ void ScreenSelectDifficulty::ChangePage( Page newPage ) m_soundDifficult.PlayRandom(); } + // Find the first Playable mode on the new page + int iSwitchToIndex = -1; + if( !bPageIncreasing ) { + for( int i=m_ModeChoices[newPage].size()-1; i>=0; i-- ) + { + if( GAMESTATE->IsPlayable(m_ModeChoices[newPage][i])) + { + iSwitchToIndex = i; + break; + } + } + } else { + for( int i=0; iIsPlayable(m_ModeChoices[newPage][i])) + { + iSwitchToIndex = i; + break; + } + } + } + // change both players - int iNewChoice = bPageIncreasing ? 0 : m_ModeChoices[m_CurrentPage].size()-1; for( p=0; p