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 );
|
PROFILEMAN->LoadFirstAvailableProfile( MenuI.player );
|
||||||
SCREENMAN->RefreshCreditsMessages();
|
SCREENMAN->RefreshCreditsMessages();
|
||||||
|
|
||||||
SOUND->PlayOnce( THEME->GetPathToS("Common start") );
|
SCREENMAN->PlayStartSound();
|
||||||
|
|
||||||
// if first player to join, set start time
|
// if first player to join, set start time
|
||||||
if( GAMESTATE->GetNumSidesJoined() == 1 )
|
if( GAMESTATE->GetNumSidesJoined() == 1 )
|
||||||
|
|||||||
@@ -114,7 +114,7 @@ void ScreenAttract::AttractInput( const DeviceInput& DeviceI, const InputEventTy
|
|||||||
SOUND->StopMusic();
|
SOUND->StopMusic();
|
||||||
/* We already played the coin sound. Don't play it again. */
|
/* We already played the coin sound. Don't play it again. */
|
||||||
if( MenuI.button != MENU_BUTTON_COIN )
|
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
|
SDL_Delay( (int)(JOIN_PAUSE_SECONDS*1000) ); // do a little pause, like the arcade does
|
||||||
LOG->Trace("ScreenAttract::AttractInput: go to ScreenTitleMenu" );
|
LOG->Trace("ScreenAttract::AttractInput: go to ScreenTitleMenu" );
|
||||||
SCREENMAN->SetNewScreen( "ScreenTitleMenu" );
|
SCREENMAN->SetNewScreen( "ScreenTitleMenu" );
|
||||||
|
|||||||
@@ -105,7 +105,7 @@ void ScreenBookkeeping::MenuStart( PlayerNumber pn )
|
|||||||
{
|
{
|
||||||
if( !m_Menu.IsTransitioning() )
|
if( !m_Menu.IsTransitioning() )
|
||||||
{
|
{
|
||||||
SOUND->PlayOnce( THEME->GetPathToS("Common start") );
|
SCREENMAN->PlayStartSound();
|
||||||
m_Menu.StartTransitioning( SM_GoToNextScreen );
|
m_Menu.StartTransitioning( SM_GoToNextScreen );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -114,7 +114,7 @@ void ScreenBookkeeping::MenuBack( PlayerNumber pn )
|
|||||||
{
|
{
|
||||||
if(!m_Menu.IsTransitioning())
|
if(!m_Menu.IsTransitioning())
|
||||||
{
|
{
|
||||||
SOUND->PlayOnce( THEME->GetPathToS("Common start") );
|
SCREENMAN->PlayStartSound();
|
||||||
m_Menu.StartTransitioning( SM_GoToPrevScreen );
|
m_Menu.StartTransitioning( SM_GoToPrevScreen );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -342,6 +342,12 @@ ScreenManager::ScreenManager()
|
|||||||
m_ScreenBuffered = NULL;
|
m_ScreenBuffered = NULL;
|
||||||
|
|
||||||
m_MessageSendOnPop = SM_None;
|
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 "MenuInput.h"
|
||||||
#include "StyleInput.h"
|
#include "StyleInput.h"
|
||||||
#include "BitmapText.h"
|
#include "BitmapText.h"
|
||||||
|
#include "RageSound.h"
|
||||||
|
|
||||||
class Screen;
|
class Screen;
|
||||||
struct Menu;
|
struct Menu;
|
||||||
@@ -71,6 +72,19 @@ private:
|
|||||||
Screen* MakeNewScreen( CString sClassName );
|
Screen* MakeNewScreen( CString sClassName );
|
||||||
void SetFromNewScreen( Screen *pNewScreen, bool Stack );
|
void SetFromNewScreen( Screen *pNewScreen, bool Stack );
|
||||||
CString m_DelayedScreen;
|
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_bGoToOptions = true;
|
||||||
m_sprOptionsMessage.SetState( 1 );
|
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_bGoToOptions = true;
|
||||||
m_sprOptionsMessage.SetState( 1 );
|
m_sprOptionsMessage.SetState( 1 );
|
||||||
SOUND->PlayOnce( THEME->GetPathToS("Common start") );
|
SCREENMAN->PlayStartSound();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -128,7 +128,7 @@ void ScreenTestInput::MenuBack( PlayerNumber pn )
|
|||||||
{
|
{
|
||||||
if(!m_Menu.IsTransitioning())
|
if(!m_Menu.IsTransitioning())
|
||||||
{
|
{
|
||||||
SOUND->PlayOnce( THEME->GetPathToS("Common start") );
|
SCREENMAN->PlayStartSound();
|
||||||
m_Menu.StartTransitioning( SM_GoToPrevScreen );
|
m_Menu.StartTransitioning( SM_GoToPrevScreen );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -103,7 +103,7 @@ void ScreenTestLights::MenuBack( PlayerNumber pn )
|
|||||||
{
|
{
|
||||||
if(!m_Menu.IsTransitioning())
|
if(!m_Menu.IsTransitioning())
|
||||||
{
|
{
|
||||||
SOUND->PlayOnce( THEME->GetPathToS("Common start") );
|
SCREENMAN->PlayStartSound();
|
||||||
m_Menu.StartTransitioning( SM_GoToPrevScreen );
|
m_Menu.StartTransitioning( SM_GoToPrevScreen );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1146,11 +1146,11 @@ CString SaveScreenshot( CString sDir, bool bSaveCompressed, bool bMakeSignature,
|
|||||||
bool bResult = DISPLAY->SaveScreenshot( sPath, fmt );
|
bool bResult = DISPLAY->SaveScreenshot( sPath, fmt );
|
||||||
if( !bResult )
|
if( !bResult )
|
||||||
{
|
{
|
||||||
SOUND->PlayOnce( THEME->GetPathToS("Common invalid") );
|
SCREENMAN->PlayInvalidSound();
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
SOUND->PlayOnce( THEME->GetPathToS("Common screenshot") );
|
SCREENMAN->PlayScreenshotSound();
|
||||||
|
|
||||||
// We wrote a new file, and SignFile won't pick it up unless we invalidate
|
// 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
|
// 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);
|
LOG->Trace("%i coins inserted, %i needed to play", GAMESTATE->m_iCoins, PREFSMAN->m_iCoinsPerCredit);
|
||||||
BOOKKEEPER->CoinInserted();
|
BOOKKEEPER->CoinInserted();
|
||||||
SCREENMAN->RefreshCreditsMessages();
|
SCREENMAN->RefreshCreditsMessages();
|
||||||
SOUND->PlayOnce( THEME->GetPathToS("Common coin") );
|
SCREENMAN->PlayCoinSound();
|
||||||
return false; // Attract need to know because they go to TitleMenu on > 1 credit
|
return false; // Attract need to know because they go to TitleMenu on > 1 credit
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user