From 9415cea26aa1a14e24c4cfe79b3381b854d251c8 Mon Sep 17 00:00:00 2001 From: Chris Danford Date: Sat, 8 Jan 2005 09:50:59 +0000 Subject: [PATCH] fix duplicate start sounds don't BeginFadingOut if the selected choice doesn't specify a screen --- stepmania/src/Screen.cpp | 9 +++-- stepmania/src/Screen.h | 2 +- stepmania/src/ScreenSelect.cpp | 50 ++++++++++++++-------------- stepmania/src/ScreenSelect.h | 1 - stepmania/src/ScreenSelectMaster.cpp | 17 +++++++++- 5 files changed, 49 insertions(+), 30 deletions(-) diff --git a/stepmania/src/Screen.cpp b/stepmania/src/Screen.cpp index 67d9d08476..d6315b75ba 100644 --- a/stepmania/src/Screen.cpp +++ b/stepmania/src/Screen.cpp @@ -180,7 +180,7 @@ bool Screen::ChangeCoinModeInput( const DeviceInput& DeviceI, const InputEventTy return false; } -bool Screen::JoinInput( const DeviceInput& DeviceI, const InputEventType type, const GameInput &GameI, const MenuInput &MenuI, const StyleInput &StyleI ) +bool Screen::JoinInput( const MenuInput &MenuI ) { if( !GAMESTATE->PlayersCanJoin() ) return false; @@ -206,7 +206,12 @@ bool Screen::JoinInput( const DeviceInput& DeviceI, const InputEventType type, c else GAMESTATE->m_iCoins -= iCoinsToCharge; - SCREENMAN->PlayStartSound(); + // HACK: Only play start sound for the 2nd player who joins. The + // start sound for the 1st player will be played by ScreenTitleMenu + // when the player makes a selection on the screen. + if( GAMESTATE->GetNumSidesJoined() > 0 ) + SCREENMAN->PlayStartSound(); + GAMESTATE->JoinPlayer( MenuI.player ); // don't load memory card profiles here. It's slow and can cause a big skip. diff --git a/stepmania/src/Screen.h b/stepmania/src/Screen.h index 838411d60c..0ce42080cc 100644 --- a/stepmania/src/Screen.h +++ b/stepmania/src/Screen.h @@ -41,7 +41,7 @@ public: virtual bool UsesBackground() const { return true; } // override and set false if this screen shouldn't load a background 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 + static bool JoinInput( const MenuInput &MenuI ); // return true if a player joined protected: // structure for holding messages sent to a Screen diff --git a/stepmania/src/ScreenSelect.cpp b/stepmania/src/ScreenSelect.cpp index a0fd3ff3df..baa0443665 100644 --- a/stepmania/src/ScreenSelect.cpp +++ b/stepmania/src/ScreenSelect.cpp @@ -160,15 +160,19 @@ void ScreenSelect::Input( const DeviceInput& DeviceI, const InputEventType type, m_timerIdleComment.GetDeltaTime(); m_timerIdleTimeout.GetDeltaTime(); + + // HACK: Don't process JoinInput on the TitleMenu. Otherwise, if the user presses start + // on a choice that doesn't move to a new screen, the player will be joined and the + // user will still be on the title menu. + bool bAllowJoinInput = !ALLOW_DISABLED_PLAYER_INPUT; + if( MenuI.button == MENU_BUTTON_COIN || - Screen::JoinInput(DeviceI, type, GameI, MenuI, StyleI) ) + (bAllowJoinInput && Screen::JoinInput(MenuI)) ) { if( type == IET_FIRST_PRESS ) this->UpdateSelectableChoices(); - if( ALLOW_DISABLED_PLAYER_INPUT ) - ; - else + if( !ALLOW_DISABLED_PLAYER_INPUT ) return; // don't let the screen handle the MENU_START press } @@ -190,35 +194,31 @@ void ScreenSelect::Input( const DeviceInput& DeviceI, const InputEventType type, Screen::Input( DeviceI, type, GameI, MenuI, StyleI ); // default input handler } -void ScreenSelect::FinalizeChoices() -{ - /* At this point, we're tweening out; we can't change the selection. - * We don't want to allow players to join if the style will be set, - * since that can change the available selection and is likely to - * invalidate the choice we've already made. Hack: apply the style. - * (Applying the style may have other side-effects, so it'll be re-applied - * in SM_GoToNextScreen.) */ - FOREACH_HumanPlayer( p ) - { - const int sel = GetSelectionIndex( p ); - if( m_aGameCommands[sel].m_pStyle ) - GAMESTATE->m_pCurStyle = m_aGameCommands[sel].m_pStyle; - } - SCREENMAN->RefreshCreditsMessages(); -} - void ScreenSelect::HandleScreenMessage( const ScreenMessage SM ) { switch( SM ) { - /* Screen is starting to tween out. */ - case SM_BeginFadingOut: - FinalizeChoices(); + /* Screen is starting to tween out. */ + case SM_BeginFadingOut: + { + /* At this point, we're tweening out; we can't change the selection. + * We don't want to allow players to join if the style will be set, + * since that can change the available selection and is likely to + * invalidate the choice we've already made. Hack: apply the style. + * (Applying the style may have other side-effects, so it'll be re-applied + * in SM_GoToNextScreen.) */ + FOREACH_HumanPlayer( p ) + { + const int sel = GetSelectionIndex( p ); + if( m_aGameCommands[sel].m_pStyle ) + GAMESTATE->m_pCurStyle = m_aGameCommands[sel].m_pStyle; + } + SCREENMAN->RefreshCreditsMessages(); + } break; /* It's our turn to tween out. */ case SM_AllDoneChoosing: - FinalizeChoices(); if( !IsTransitioning() ) StartTransitioning( SM_GoToNextScreen ); break; diff --git a/stepmania/src/ScreenSelect.h b/stepmania/src/ScreenSelect.h index a2fdc26a85..e8116ba2e8 100644 --- a/stepmania/src/ScreenSelect.h +++ b/stepmania/src/ScreenSelect.h @@ -28,7 +28,6 @@ public: protected: virtual int GetSelectionIndex( PlayerNumber pn ) = 0; virtual void UpdateSelectableChoices() = 0; // derived screens must handle this - void FinalizeChoices(); vector m_vpBGAnimations; vector m_aGameCommands; // derived classes should look here for what choices are available diff --git a/stepmania/src/ScreenSelectMaster.cpp b/stepmania/src/ScreenSelectMaster.cpp index 84611030f5..1e4fa1f670 100644 --- a/stepmania/src/ScreenSelectMaster.cpp +++ b/stepmania/src/ScreenSelectMaster.cpp @@ -594,7 +594,22 @@ void ScreenSelectMaster::MenuStart( PlayerNumber pn ) GameCommand &mc = m_aGameCommands[m_iChoice[pn]]; SOUND->PlayOnceFromDir( ANNOUNCER->GetPathTo(ssprintf("%s comment %s",m_sName.c_str(), mc.m_sName.c_str())) ); - m_soundStart.Play(); + + if( mc.m_sSoundPath.empty() ) + m_soundStart.Play(); + + if( mc.m_sScreen.empty() ) + { + mc.ApplyToAllPlayers(); + return; + } + + // If the player isn't already joined, join them. + MenuInput MenuI; + MenuI.player = pn; + MenuI.button = MENU_BUTTON_START; + Screen::JoinInput( MenuI ); + float fSecs = 0; bool bAllDone = true;