diff --git a/stepmania/src/GameState.cpp b/stepmania/src/GameState.cpp index 08ac30c6c5..bbdf7f4d3c 100644 --- a/stepmania/src/GameState.cpp +++ b/stepmania/src/GameState.cpp @@ -261,9 +261,12 @@ bool GameState::IsPlayable( const ModeChoice& mc ) bool GameState::IsPlayerEnabled( PlayerNumber pn ) { - if( m_CurStyle == STYLE_INVALID ) // if no style set (we're in TitleMenu, ConfigInstruments or something) + if( GAMESTATE->m_bIsOnSystemMenu ) // if no style set (we're in TitleMenu, ConfigInstruments or something) return true; // allow input from both sides + if( m_CurStyle == STYLE_INVALID ) + return m_bSideIsJoined[pn]; + switch( GetCurrentStyleDef()->m_StyleType ) { case StyleDef::TWO_PLAYERS_TWO_CREDITS: diff --git a/stepmania/src/Screen.cpp b/stepmania/src/Screen.cpp index 4029a5e9ed..a4b6ebe2b7 100644 --- a/stepmania/src/Screen.cpp +++ b/stepmania/src/Screen.cpp @@ -100,6 +100,64 @@ void Screen::Input( const DeviceInput& DeviceI, const InputEventType type, const } } +bool Screen::ChangeCoinModeInput( const DeviceInput& DeviceI, const InputEventType type, const GameInput &GameI, const MenuInput &MenuI, const StyleInput &StyleI ) +{ + if( type != IET_FIRST_PRESS ) + return false; + if( DeviceI.device == DEVICE_KEYBOARD && DeviceI.button == SDLK_F3 ) + { + (int&)PREFSMAN->m_CoinMode = (PREFSMAN->m_CoinMode+1) % PrefsManager::NUM_COIN_MODES; + /* ResetGame(); + This causes problems on ScreenIntroMovie, which results in the + movie being restarted and/or becoming out-of-synch -- Miryokuteki */ + + CString sMessage = "Coin Mode: "; + switch( PREFSMAN->m_CoinMode ) + { + case PrefsManager::COIN_HOME: sMessage += "HOME"; break; + case PrefsManager::COIN_PAY: sMessage += "PAY"; break; + case PrefsManager::COIN_FREE: sMessage += "FREE"; break; + } + SCREENMAN->RefreshCreditsMessages(); + SCREENMAN->SystemMessage( sMessage ); + return true; + } + return false; +} + +bool Screen::JoinInput( const DeviceInput& DeviceI, const InputEventType type, const GameInput &GameI, const MenuInput &MenuI, const StyleInput &StyleI ) +{ + if( !GAMESTATE->m_bPlayersCanJoin ) + return false; + + if( MenuI.IsValid() && MenuI.button==MENU_BUTTON_START ) + { + /* If this side is already in, don't re-join (and re-pay!). */ + if(GAMESTATE->m_bSideIsJoined[MenuI.player]) + return false; + + /* subtract coins */ + if( PREFSMAN->m_CoinMode == PrefsManager::COIN_PAY ) + if( GAMESTATE->m_iCoins < PREFSMAN->m_iCoinsPerCredit ) + return false; // not enough coins + else + GAMESTATE->m_iCoins -= PREFSMAN->m_iCoinsPerCredit; + + GAMESTATE->m_bSideIsJoined[MenuI.player] = true; + if( GAMESTATE->m_MasterPlayerNumber == PLAYER_INVALID ) + GAMESTATE->m_MasterPlayerNumber = MenuI.player; + + SCREENMAN->RefreshCreditsMessages(); + + SOUNDMAN->PlayOnce( THEME->GetPathTo("Sounds","Common start") ); + + return true; + } + + return false; +} + + void Screen::MenuCoin( PlayerNumber pn ) { // This is now handled globally by Stepmania.cpp -- Miryokuteki diff --git a/stepmania/src/Screen.h b/stepmania/src/Screen.h index 18bdf67bcc..213ace9cca 100644 --- a/stepmania/src/Screen.h +++ b/stepmania/src/Screen.h @@ -33,6 +33,8 @@ public: virtual void Update( float fDeltaTime ); virtual void Input( const DeviceInput& DeviceI, const InputEventType type, const GameInput &GameI, const MenuInput &MenuI, const StyleInput &StyleI ); + static bool ChangeCoinModeInput( const DeviceInput& DeviceI, const InputEventType type, const GameInput &GameI, const MenuInput &MenuI, const StyleInput &StyleI ); // return true if CoinMode changed + static bool JoinInput( const DeviceInput& DeviceI, const InputEventType type, const GameInput &GameI, const MenuInput &MenuI, const StyleInput &StyleI ); // return true if a player joined virtual void HandleScreenMessage( const ScreenMessage SM ) {}; void SendScreenMessage( const ScreenMessage SM, const float fDelay ); diff --git a/stepmania/src/ScreenAttract.cpp b/stepmania/src/ScreenAttract.cpp index 5d2b82f322..44c5dc6077 100644 --- a/stepmania/src/ScreenAttract.cpp +++ b/stepmania/src/ScreenAttract.cpp @@ -76,31 +76,6 @@ void ScreenAttract::Input( const DeviceInput& DeviceI, const InputEventType type AttractInput( DeviceI, type, GameI, MenuI, StyleI, m_In.IsTransitioning() || m_Out.IsTransitioning() ); } -bool ScreenAttract::ChangeCoinModeInput( const DeviceInput& DeviceI, const InputEventType type, const GameInput &GameI, const MenuInput &MenuI, const StyleInput &StyleI ) -{ - if( type != IET_FIRST_PRESS ) - return false; - if( DeviceI.device == DEVICE_KEYBOARD && DeviceI.button == SDLK_F3 ) - { - (int&)PREFSMAN->m_CoinMode = (PREFSMAN->m_CoinMode+1) % PrefsManager::NUM_COIN_MODES; - /* ResetGame(); - This causes problems on ScreenIntroMovie, which results in the - movie being restarted and/or becoming out-of-synch -- Miryokuteki */ - - CString sMessage = "Coin Mode: "; - switch( PREFSMAN->m_CoinMode ) - { - case PrefsManager::COIN_HOME: sMessage += "HOME"; break; - case PrefsManager::COIN_PAY: sMessage += "PAY"; break; - case PrefsManager::COIN_FREE: sMessage += "FREE"; break; - } - SCREENMAN->RefreshCreditsMessages(); - SCREENMAN->SystemMessage( sMessage ); - return true; - } - return false; -} - void ScreenAttract::AttractInput( const DeviceInput& DeviceI, const InputEventType type, const GameInput &GameI, const MenuInput &MenuI, const StyleInput &StyleI, bool bTransitioning ) { if(type != IET_FIRST_PRESS) @@ -124,7 +99,9 @@ void ScreenAttract::AttractInput( const DeviceInput& DeviceI, const InputEventTy case PrefsManager::COIN_FREE: case PrefsManager::COIN_HOME: SOUNDMAN->StopMusic(); - SOUNDMAN->PlayOnce( THEME->GetPathTo("Sounds","Common coin") ); + /* We already played the it was a coin was inserted. Don't play it again. */ + if( MenuI.button != MENU_BUTTON_COIN ) + SOUNDMAN->PlayOnce( THEME->GetPathTo("Sounds","Common coin") ); SDL_Delay( 800 ); // do a little pause, like the arcade does SCREENMAN->SetNewScreen( "ScreenTitleMenu" ); break; diff --git a/stepmania/src/ScreenAttract.h b/stepmania/src/ScreenAttract.h index 21cd00f346..974945575b 100644 --- a/stepmania/src/ScreenAttract.h +++ b/stepmania/src/ScreenAttract.h @@ -29,7 +29,6 @@ public: virtual ~ScreenAttract(); virtual void Input( const DeviceInput& DeviceI, const InputEventType type, const GameInput &GameI, const MenuInput &MenuI, const StyleInput &StyleI ); - static bool ChangeCoinModeInput( const DeviceInput& DeviceI, const InputEventType type, const GameInput &GameI, const MenuInput &MenuI, const StyleInput &StyleI ); /* return true if CoinMode changed */ static void AttractInput( const DeviceInput& DeviceI, const InputEventType type, const GameInput &GameI, const MenuInput &MenuI, const StyleInput &StyleI, bool bTransitioning ); virtual void Update( float fDelta ); virtual void HandleScreenMessage( const ScreenMessage SM ); diff --git a/stepmania/src/ScreenCaution.cpp b/stepmania/src/ScreenCaution.cpp index d6c234da2b..f3e8a22b73 100644 --- a/stepmania/src/ScreenCaution.cpp +++ b/stepmania/src/ScreenCaution.cpp @@ -57,17 +57,8 @@ ScreenCaution::ScreenCaution() void ScreenCaution::Input( const DeviceInput& DeviceI, const InputEventType type, const GameInput &GameI, const MenuInput &MenuI, const StyleInput &StyleI ) { - PlayerNumber pn = MenuI.player; - if( MenuI.IsValid() && pn!=PLAYER_INVALID && !GAMESTATE->m_bSideIsJoined[pn] ) - { - GAMESTATE->m_bSideIsJoined[pn] = true; - SOUNDMAN->PlayOnce( THEME->GetPathTo("Sounds","Common start") ); - SCREENMAN->RefreshCreditsMessages(); - return; // don't fall though - } - - if( m_In.IsTransitioning() || m_Out.IsTransitioning() || m_Back.IsTransitioning() ) - return; + if( Screen::JoinInput( DeviceI, type, GameI, MenuI, StyleI ) ) + return; // handled Screen::Input( DeviceI, type, GameI, MenuI, StyleI ); } @@ -95,7 +86,8 @@ void ScreenCaution::HandleScreenMessage( const ScreenMessage SM ) void ScreenCaution::MenuStart( PlayerNumber pn ) { - m_Out.StartTransitioning( SM_GoToNextScreen ); + if( !m_Out.IsTransitioning() ) + m_Out.StartTransitioning( SM_GoToNextScreen ); } void ScreenCaution::MenuBack( PlayerNumber pn ) diff --git a/stepmania/src/ScreenDemonstration.cpp b/stepmania/src/ScreenDemonstration.cpp index 5c8253564c..34d960a389 100644 --- a/stepmania/src/ScreenDemonstration.cpp +++ b/stepmania/src/ScreenDemonstration.cpp @@ -86,32 +86,18 @@ void ScreenDemonstration::Input( const DeviceInput& DeviceI, const InputEventTyp //LOG->Trace( "ScreenDemonstration::Input()" ); - // Stop music on Start or Coin - // TODO: Change ScreenGameplay to play sound through the global sound object - // so that this don't need to be special cased. if( MenuI.IsValid() ) { switch( MenuI.button ) { case MENU_BUTTON_COIN: - m_soundMusic.Stop(); - break; case MENU_BUTTON_START: case MENU_BUTTON_BACK: - switch( PREFSMAN->m_CoinMode ) - { - case PrefsManager::COIN_PAY: + if( PREFSMAN->m_CoinMode == PrefsManager::COIN_PAY ) if( GAMESTATE->m_iCoins < PREFSMAN->m_iCoinsPerCredit ) break; // don't fall through - // fall through - case PrefsManager::COIN_FREE: - case PrefsManager::COIN_HOME: - m_soundMusic.Stop(); - break; - default: - ASSERT(0); - } + m_soundMusic.Stop(); break; } } diff --git a/stepmania/src/ScreenTitleMenu.cpp b/stepmania/src/ScreenTitleMenu.cpp index 09c1c1fb36..36dd56b3b2 100644 --- a/stepmania/src/ScreenTitleMenu.cpp +++ b/stepmania/src/ScreenTitleMenu.cpp @@ -51,6 +51,8 @@ ScreenTitleMenu::ScreenTitleMenu() { LOG->Trace( "ScreenTitleMenu::ScreenTitleMenu()" ); + GAMESTATE->m_bPlayersCanJoin = true; + if( PREFSMAN->m_CoinMode!=PrefsManager::COIN_HOME && PREFSMAN->m_bJointPremium ) { m_JointPremium.LoadFromAniDir( THEME->GetPathTo("BGAnimations","ScreenTitleMenu joint premium") ); @@ -159,119 +161,74 @@ void ScreenTitleMenu::Input( const DeviceInput& DeviceI, const InputEventType ty if( !MenuI.IsValid() ) return; - switch( PREFSMAN->m_CoinMode ) + + + switch( MenuI.button ) { - case PrefsManager::COIN_HOME: - switch( MenuI.button ) + case MENU_BUTTON_UP: + if( PREFSMAN->m_CoinMode != PrefsManager::COIN_HOME ) + break; + if( m_In.IsTransitioning() || m_Out.IsTransitioning() ) + break; + TimeToDemonstration.GetDeltaTime(); /* Reset the demonstration timer when a key is pressed. */ + LoseFocus( m_Choice ); + if( m_Choice == 0 ) // wrap around + m_Choice = (Choice)((int)NUM_CHOICES); + m_Choice = Choice( m_Choice-1 ); + m_soundChange.Play(); + GainFocus( m_Choice ); + break; + case MENU_BUTTON_DOWN: + if( PREFSMAN->m_CoinMode != PrefsManager::COIN_HOME ) + break; + if( m_In.IsTransitioning() || m_Out.IsTransitioning() ) + break; + TimeToDemonstration.GetDeltaTime(); /* Reset the demonstration timer when a key is pressed. */ + LoseFocus( m_Choice ); + if( m_Choice == (int)ScreenTitleMenu::NUM_CHOICES-1 ) + m_Choice = (Choice)-1; // wrap around + m_Choice = Choice( m_Choice+1 ); + m_soundChange.Play(); + GainFocus( m_Choice ); + break; + case MENU_BUTTON_BACK: + if( m_In.IsTransitioning() || m_Out.IsTransitioning() ) + break; + m_Out.StartTransitioning( SM_GoToAttractLoop ); + break; + case MENU_BUTTON_START: + if( m_In.IsTransitioning() ) + break; + /* break if the choice is invalid */ + switch( m_Choice ) { - case MENU_BUTTON_UP: - if( m_In.IsTransitioning() || m_Out.IsTransitioning() ) - break; - TimeToDemonstration.GetDeltaTime(); /* Reset the demonstration timer when a key is pressed. */ - LoseFocus( m_Choice ); - if( m_Choice == 0 ) // wrap around - m_Choice = (Choice)((int)NUM_CHOICES); - m_Choice = Choice( m_Choice-1 ); - m_soundChange.Play(); - GainFocus( m_Choice ); - break; - case MENU_BUTTON_DOWN: - if( m_In.IsTransitioning() || m_Out.IsTransitioning() ) - break; - TimeToDemonstration.GetDeltaTime(); /* Reset the demonstration timer when a key is pressed. */ - LoseFocus( m_Choice ); - if( m_Choice == (int)ScreenTitleMenu::NUM_CHOICES-1 ) - m_Choice = (Choice)-1; // wrap around - m_Choice = Choice( m_Choice+1 ); - m_soundChange.Play(); - GainFocus( m_Choice ); - break; - case MENU_BUTTON_BACK: - if( m_In.IsTransitioning() || m_Out.IsTransitioning() ) - break; - m_Out.StartTransitioning( SM_GoToAttractLoop ); - break; - case MENU_BUTTON_START: - if( m_In.IsTransitioning() ) - break; - /* break if the choice is invalid */ - switch( m_Choice ) + case CHOICE_GAME_START: + case CHOICE_SELECT_GAME: + case CHOICE_OPTIONS: + #ifdef DEBUG + case CHOICE_SANDBOX: + #endif + case CHOICE_JUKEBOX: + case CHOICE_EDIT: + if( SONGMAN->GetNumSongs() == 0 ) { - case CHOICE_GAME_START: - case CHOICE_SELECT_GAME: - case CHOICE_OPTIONS: - #ifdef DEBUG - case CHOICE_SANDBOX: - #endif - case CHOICE_JUKEBOX: - case CHOICE_EDIT: - if( SONGMAN->GetNumSongs() == 0 ) - { - m_soundInvalid.Play(); - SCREENMAN->SystemMessage( "No songs are installed" ); - break; - } + m_soundInvalid.Play(); + SCREENMAN->SystemMessage( "No songs are installed" ); break; - case CHOICE_EXIT: - ExitGame(); - LOG->Trace("CHOICE_EXIT: shutting down"); - return; - default: - ASSERT(0); } - - /* If this side is already in, don't re-join (and re-pay!). */ - if(GAMESTATE->m_bSideIsJoined[MenuI.player]) - break; - - GAMESTATE->m_bSideIsJoined[MenuI.player] = true; - if( GAMESTATE->m_MasterPlayerNumber == PLAYER_INVALID ) - GAMESTATE->m_MasterPlayerNumber = MenuI.player; - - SCREENMAN->RefreshCreditsMessages(); - - m_soundSelect.Play(); - - if( m_In.IsTransitioning() || m_Out.IsTransitioning() ) - break; - m_Out.StartTransitioning( SM_GoToNextScreen ); - } - break; - case PrefsManager::COIN_PAY: - case PrefsManager::COIN_FREE: - switch( MenuI.button ) - { - case MENU_BUTTON_BACK: - m_Out.StartTransitioning( SM_GoToAttractLoop ); - break; - case MENU_BUTTON_START: - /* If this side is already in, don't re-join (and re-pay!). */ - if(GAMESTATE->m_bSideIsJoined[MenuI.player]) - break; - - /* subtract coins */ - if( PREFSMAN->m_CoinMode == PrefsManager::COIN_PAY ) - if( GAMESTATE->m_iCoins < PREFSMAN->m_iCoinsPerCredit ) - break; // not enough coins - else - GAMESTATE->m_iCoins -= PREFSMAN->m_iCoinsPerCredit; - - GAMESTATE->m_bSideIsJoined[MenuI.player] = true; - if( GAMESTATE->m_MasterPlayerNumber == PLAYER_INVALID ) - GAMESTATE->m_MasterPlayerNumber = MenuI.player; - - SCREENMAN->RefreshCreditsMessages(); - - m_soundSelect.Play(); - - if( m_In.IsTransitioning() || m_Out.IsTransitioning() ) - break; - m_Out.StartTransitioning( SM_GoToNextScreen ); break; + case CHOICE_EXIT: + ExitGame(); + LOG->Trace("CHOICE_EXIT: shutting down"); + return; + default: + ASSERT(0); } - break; + + if( Screen::JoinInput( DeviceI, type, GameI, MenuI, StyleI ) ) + if( !m_Out.IsTransitioning() ) + m_Out.StartTransitioning( SM_GoToNextScreen ); } - // Screen::Input( DeviceI, type, GameI, MenuI, StyleI ); } diff --git a/stepmania/src/StepMania.cpp b/stepmania/src/StepMania.cpp index 7d52754eb0..17b4848148 100644 --- a/stepmania/src/StepMania.cpp +++ b/stepmania/src/StepMania.cpp @@ -386,7 +386,7 @@ int main(int argc, char* argv[]) bool HandleGlobalInputs( DeviceInput DeviceI, InputEventType type, GameInput GameI, MenuInput MenuI, StyleInput StyleI ) { /* None of the globals keys act on types other than FIRST_PRESS */ - if( type == IET_FIRST_PRESS ) + if( type != IET_FIRST_PRESS ) return false; switch( MenuI.button )