From ab1bd7c2eb61ec723c7baf861a1816aecb731812 Mon Sep 17 00:00:00 2001 From: Glenn Maynard Date: Sun, 1 Feb 2004 01:13:58 +0000 Subject: [PATCH] fix choosing rave mode in the default theme with only P1 active simplify make having course modes in the center of other objects work --- stepmania/src/ScreenSelectDifficulty.cpp | 186 +++++++++++++---------- stepmania/src/ScreenSelectDifficulty.h | 4 +- 2 files changed, 103 insertions(+), 87 deletions(-) diff --git a/stepmania/src/ScreenSelectDifficulty.cpp b/stepmania/src/ScreenSelectDifficulty.cpp index 5a8d2a7046..caaae426ae 100644 --- a/stepmania/src/ScreenSelectDifficulty.cpp +++ b/stepmania/src/ScreenSelectDifficulty.cpp @@ -189,6 +189,20 @@ void ScreenSelectDifficulty::UpdateSelectableChoices() // } } +static BothPlayersModeChoice( const ModeChoice &mc ) +{ + switch( mc.m_pm ) + { + case PLAY_MODE_ONI: + case PLAY_MODE_NONSTOP: + case PLAY_MODE_ENDLESS: + case PLAY_MODE_RAVE: + return true; + } + + return false; +} + void ScreenSelectDifficulty::MenuLeft( PlayerNumber pn ) { // if( m_fLockInputTime > 0 ) @@ -196,20 +210,18 @@ void ScreenSelectDifficulty::MenuLeft( PlayerNumber pn ) if( m_bChosen[pn] ) return; - unsigned c; // GCC is bitching again. - for( c=0; c=0; i-- ) { - if( m_ModeChoices[m_CurrentPage][i].IsPlayable() ) + const ModeChoice &mc = m_ModeChoices[m_CurrentPage][i]; + if( AnotherPlayerSelected && BothPlayersModeChoice(mc) ) + continue; + if( mc.IsPlayable() ) { iSwitchToIndex = i; break; @@ -222,7 +234,8 @@ void ScreenSelectDifficulty::MenuLeft( PlayerNumber pn ) ChangePage( (Page)(m_CurrentPage-1) ); return; } - ChangeWithinPage( pn, iSwitchToIndex, false ); + if( ChangeWithinPage( pn, iSwitchToIndex, false ) ) + m_soundChange.Play(); } @@ -233,20 +246,18 @@ void ScreenSelectDifficulty::MenuRight( PlayerNumber pn ) if( m_bChosen[pn] ) return; - unsigned c; // GCC is bitching again. - for( c=0; cIsHumanPlayer(p) ) @@ -328,7 +341,10 @@ void ScreenSelectDifficulty::ChangeWithinPage( PlayerNumber pn, int iNewChoice, if( p!=pn && m_CurrentPage==PAGE_1 ) continue; // skip + if( m_iChoiceOnPage[p] == iNewChoice ) + continue; // skip + bAnyChanged = true; m_iChoiceOnPage[p] = iNewChoice; float fCursorX = GetCursorX( (PlayerNumber)p ); @@ -345,10 +361,7 @@ void ScreenSelectDifficulty::ChangeWithinPage( PlayerNumber pn, int iNewChoice, m_sprShadow[p].SetY( fCursorY + SHADOW_LENGTH_Y ); } - /* If we're changing pages, it's ChangePage's responsibility to play this - * (so we don't play it more than once). */ - if(!bChangingPages) - m_soundChange.Play(); + return bAnyChanged; } void ScreenSelectDifficulty::MenuStart( PlayerNumber pn ) @@ -363,83 +376,86 @@ void ScreenSelectDifficulty::MenuStart( PlayerNumber pn ) OFF_COMMAND( m_sprMore[page] ); const ModeChoice& mc = m_ModeChoices[m_CurrentPage][m_iChoiceOnPage[pn]]; - /* Don't play sound if we're on the second page and another player - * has already selected, since it just played. */ - bool AnotherPlayerSelected = false; - int p; - for( p=0; pPlayOnceFromDir( ANNOUNCER->GetPathTo(ssprintf("ScreenSelectDifficulty comment %s",mc.m_sName.c_str())) ); m_soundSelect.Play(); } + int p; + // courses should be selected for both players at all times - if( mc.m_pm == PLAY_MODE_ONI || mc.m_pm == PLAY_MODE_NONSTOP || mc.m_pm == PLAY_MODE_ENDLESS) + if( BothPlayersModeChoice(mc) ) { - float fCursorX = GetCursorX( (PlayerNumber)pn ); - float fCursorY = GetCursorY( (PlayerNumber)pn ); for( p=0; pIsHumanPlayer((PlayerNumber)p) || p == pn ) + continue; + + // move all cursors to the oni/nonstop selection so it graphically looks as if all players selected the same option. + ChangeWithinPage( (PlayerNumber)p, m_iChoiceOnPage[pn], false ); + bPlaySelect = false; + MenuStart( (PlayerNumber)p ); // agree everyone + bPlaySelect = true; } } else // someone must have chosen arcade style play so oni/nonstop/endless must be disabled { for( p=0; pIsHumanPlayer((PlayerNumber)p) || p == pn ) + continue; + + if( !BothPlayersModeChoice(m_ModeChoices[m_CurrentPage][m_iChoiceOnPage[p]]) ) + continue; + + /* This player is currently on a choice that is no longer available due to + * the selection just made. */ + int iSwitchToIndex = -1; + for( int i=m_iChoiceOnPage[p]+1; iSwitchToIndex == -1 && i < (int) m_ModeChoices[m_CurrentPage].size(); ++i ) + if( m_ModeChoices[m_CurrentPage][i].IsPlayable() ) + iSwitchToIndex = i; + if( iSwitchToIndex == -1 ) { - PlayMode iPlaymode = m_ModeChoices[m_CurrentPage][m_iChoiceOnPage[p]].m_pm; - // if they're currently highlighting an option that is a nonstop - if( iPlaymode == PLAY_MODE_ONI || iPlaymode == PLAY_MODE_NONSTOP || iPlaymode == PLAY_MODE_ENDLESS) - { - m_iChoiceOnPage[p] = 0; - - - // move the cursor - float fCursorX = GetCursorX( (PlayerNumber)p ); - float fCursorY = GetCursorY( (PlayerNumber)p ); - - m_sprCursor[p].StopTweening(); - m_sprCursor[p].SetX( fCursorX ); - m_sprCursor[p].SetY( fCursorY ); - - m_sprShadow[p].StopTweening(); - m_sprShadow[p].SetX( fCursorX + SHADOW_LENGTH_X ); - m_sprShadow[p].SetY( fCursorY + SHADOW_LENGTH_Y ); - } + for( i=m_iChoiceOnPage[p]-1; iSwitchToIndex == -1 && i >= 0; --i ) + if( m_ModeChoices[m_CurrentPage][i].IsPlayable() ) + iSwitchToIndex = i; } + /* We should always find a place to go--we should at least be able to choose + * the same thing pn picked. */ + ASSERT( iSwitchToIndex != -1 ); + + // move the cursor + ChangeWithinPage( (PlayerNumber) p, iSwitchToIndex, false ); } - unsigned c; // GCC is bitching again. - for( c=0; cIsHumanPlayer((PlayerNumber)p) || m_bChosen[p] || p == pn ) + continue; + bAnyPlayersLeft = true; + } + + if( bAnyPlayersLeft ) + { + for( unsigned c=0; c m_ModeChoices[NUM_PAGES]; - vector m_iaChoicesToIgnore; - Page m_CurrentPage; int m_iChoiceOnPage[NUM_PLAYERS]; bool m_bChosen[NUM_PLAYERS];