fix duplicate start sounds
don't BeginFadingOut if the selected choice doesn't specify a screen
This commit is contained in:
@@ -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.
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -28,7 +28,6 @@ public:
|
||||
protected:
|
||||
virtual int GetSelectionIndex( PlayerNumber pn ) = 0;
|
||||
virtual void UpdateSelectableChoices() = 0; // derived screens must handle this
|
||||
void FinalizeChoices();
|
||||
|
||||
vector<BGAnimation*> m_vpBGAnimations;
|
||||
vector<GameCommand> m_aGameCommands; // derived classes should look here for what choices are available
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user