don't use PlayOnce in performance critical places
This commit is contained in:
@@ -198,7 +198,7 @@ bool Screen::JoinInput( const DeviceInput& DeviceI, const InputEventType type, c
|
||||
PROFILEMAN->LoadFirstAvailableProfile( MenuI.player );
|
||||
SCREENMAN->RefreshCreditsMessages();
|
||||
|
||||
SOUND->PlayOnce( THEME->GetPathToS("Common start") );
|
||||
SCREENMAN->PlayStartSound();
|
||||
|
||||
// if first player to join, set start time
|
||||
if( GAMESTATE->GetNumSidesJoined() == 1 )
|
||||
|
||||
@@ -114,7 +114,7 @@ void ScreenAttract::AttractInput( const DeviceInput& DeviceI, const InputEventTy
|
||||
SOUND->StopMusic();
|
||||
/* We already played the coin sound. Don't play it again. */
|
||||
if( MenuI.button != MENU_BUTTON_COIN )
|
||||
SOUND->PlayOnce( THEME->GetPathToS("Common coin") );
|
||||
SCREENMAN->PlayCoinSound();
|
||||
SDL_Delay( (int)(JOIN_PAUSE_SECONDS*1000) ); // do a little pause, like the arcade does
|
||||
LOG->Trace("ScreenAttract::AttractInput: go to ScreenTitleMenu" );
|
||||
SCREENMAN->SetNewScreen( "ScreenTitleMenu" );
|
||||
|
||||
@@ -105,7 +105,7 @@ void ScreenBookkeeping::MenuStart( PlayerNumber pn )
|
||||
{
|
||||
if( !m_Menu.IsTransitioning() )
|
||||
{
|
||||
SOUND->PlayOnce( THEME->GetPathToS("Common start") );
|
||||
SCREENMAN->PlayStartSound();
|
||||
m_Menu.StartTransitioning( SM_GoToNextScreen );
|
||||
}
|
||||
}
|
||||
@@ -114,7 +114,7 @@ void ScreenBookkeeping::MenuBack( PlayerNumber pn )
|
||||
{
|
||||
if(!m_Menu.IsTransitioning())
|
||||
{
|
||||
SOUND->PlayOnce( THEME->GetPathToS("Common start") );
|
||||
SCREENMAN->PlayStartSound();
|
||||
m_Menu.StartTransitioning( SM_GoToPrevScreen );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -342,6 +342,12 @@ ScreenManager::ScreenManager()
|
||||
m_ScreenBuffered = NULL;
|
||||
|
||||
m_MessageSendOnPop = SM_None;
|
||||
|
||||
|
||||
m_soundStart.Load( THEME->GetPathS("Common","start") );
|
||||
m_soundCoin.Load( THEME->GetPathS("Common","coin") );
|
||||
m_soundInvalid.Load( THEME->GetPathS("Common","invalid") );
|
||||
m_soundScreenshot.Load( THEME->GetPathS("Common","screenshot") );
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
#include "MenuInput.h"
|
||||
#include "StyleInput.h"
|
||||
#include "BitmapText.h"
|
||||
#include "RageSound.h"
|
||||
|
||||
class Screen;
|
||||
struct Menu;
|
||||
@@ -71,6 +72,19 @@ private:
|
||||
Screen* MakeNewScreen( CString sClassName );
|
||||
void SetFromNewScreen( Screen *pNewScreen, bool Stack );
|
||||
CString m_DelayedScreen;
|
||||
|
||||
// Keep these sounds always loaded, because they could be
|
||||
// played at any time. We want to eliminate SOUND->PlayOnce
|
||||
public:
|
||||
void PlayStartSound() { m_soundStart.Play(); }
|
||||
void PlayCoinSound() { m_soundCoin.Play(); }
|
||||
void PlayInvalidSound() { m_soundInvalid.Play(); }
|
||||
void PlayScreenshotSound() { m_soundScreenshot.Play(); }
|
||||
private:
|
||||
RageSound m_soundStart;
|
||||
RageSound m_soundCoin;
|
||||
RageSound m_soundInvalid;
|
||||
RageSound m_soundScreenshot;
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -114,7 +114,7 @@ void ScreenPlayerOptions::Input( const DeviceInput& DeviceI, const InputEventTyp
|
||||
{
|
||||
m_bGoToOptions = true;
|
||||
m_sprOptionsMessage.SetState( 1 );
|
||||
SOUND->PlayOnce( THEME->GetPathToS("Common start") );
|
||||
SCREENMAN->PlayStartSound();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -726,7 +726,7 @@ void ScreenSelectMusic::Input( const DeviceInput& DeviceI, InputEventType type,
|
||||
|
||||
m_bGoToOptions = true;
|
||||
m_sprOptionsMessage.SetState( 1 );
|
||||
SOUND->PlayOnce( THEME->GetPathToS("Common start") );
|
||||
SCREENMAN->PlayStartSound();
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -128,7 +128,7 @@ void ScreenTestInput::MenuBack( PlayerNumber pn )
|
||||
{
|
||||
if(!m_Menu.IsTransitioning())
|
||||
{
|
||||
SOUND->PlayOnce( THEME->GetPathToS("Common start") );
|
||||
SCREENMAN->PlayStartSound();
|
||||
m_Menu.StartTransitioning( SM_GoToPrevScreen );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -103,7 +103,7 @@ void ScreenTestLights::MenuBack( PlayerNumber pn )
|
||||
{
|
||||
if(!m_Menu.IsTransitioning())
|
||||
{
|
||||
SOUND->PlayOnce( THEME->GetPathToS("Common start") );
|
||||
SCREENMAN->PlayStartSound();
|
||||
m_Menu.StartTransitioning( SM_GoToPrevScreen );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1146,11 +1146,11 @@ CString SaveScreenshot( CString sDir, bool bSaveCompressed, bool bMakeSignature,
|
||||
bool bResult = DISPLAY->SaveScreenshot( sPath, fmt );
|
||||
if( !bResult )
|
||||
{
|
||||
SOUND->PlayOnce( THEME->GetPathToS("Common invalid") );
|
||||
SCREENMAN->PlayInvalidSound();
|
||||
return "";
|
||||
}
|
||||
|
||||
SOUND->PlayOnce( THEME->GetPathToS("Common screenshot") );
|
||||
SCREENMAN->PlayScreenshotSound();
|
||||
|
||||
// We wrote a new file, and SignFile won't pick it up unless we invalidate
|
||||
// the Dir cache. There's got to be a better way of doing this than
|
||||
@@ -1198,7 +1198,7 @@ bool HandleGlobalInputs( DeviceInput DeviceI, InputEventType type, GameInput Gam
|
||||
LOG->Trace("%i coins inserted, %i needed to play", GAMESTATE->m_iCoins, PREFSMAN->m_iCoinsPerCredit);
|
||||
BOOKKEEPER->CoinInserted();
|
||||
SCREENMAN->RefreshCreditsMessages();
|
||||
SOUND->PlayOnce( THEME->GetPathToS("Common coin") );
|
||||
SCREENMAN->PlayCoinSound();
|
||||
return false; // Attract need to know because they go to TitleMenu on > 1 credit
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user