diff --git a/stepmania/Themes/default/metrics.ini b/stepmania/Themes/default/metrics.ini index 86f97ea178..d0f8457ab5 100644 --- a/stepmania/Themes/default/metrics.ini +++ b/stepmania/Themes/default/metrics.ini @@ -3542,12 +3542,11 @@ TimerSeconds=0 PrevScreen=ScreenOptionsMenu@ScreenOptionsMaster NextScreen=ScreenOptionsMenu@ScreenOptionsMaster -OptionMenuFlags=rows,5;together;explanations +OptionMenuFlags=rows,4;together;explanations Line1=conf,PreloadSounds Line2=conf,ResamplingQuality -Line3=conf,AttractSound -Line4=conf,DemonstrationSound -Line5=conf,SoundVolume +Line3=conf,AttractSoundFrequency +Line4=conf,SoundVolume [ScreenIntroMovie] NextScreen=ScreenDemonstration diff --git a/stepmania/src/GameState.cpp b/stepmania/src/GameState.cpp index 7b11d391b7..d7a5523430 100644 --- a/stepmania/src/GameState.cpp +++ b/stepmania/src/GameState.cpp @@ -56,6 +56,8 @@ GameState::GameState() m_pUnlockingSys = new UnlockSystem; ReloadCharacters(); + + m_iNumTimesThroughAttract = -1; // initial screen will bump this up to 0 } GameState::~GameState() @@ -161,6 +163,8 @@ void GameState::BeginGame() m_timeGameStarted = time(NULL); m_vpsNamesThatWereFilled.clear(); + + m_iNumTimesThroughAttract = 0; } void GameState::EndGame() @@ -1210,3 +1214,11 @@ bool GameState::OneIsHot() const return true; return false; } + +bool GameState::IsTimeToPlayAttractSounds() +{ + if( PREFSMAN->m_iAttractSoundFrequency == 0 ) // never + return false; + m_iNumTimesThroughAttract %= PREFSMAN->m_iAttractSoundFrequency; + return m_iNumTimesThroughAttract==0; +} \ No newline at end of file diff --git a/stepmania/src/GameState.h b/stepmania/src/GameState.h index 03b9396266..db74097faa 100644 --- a/stepmania/src/GameState.h +++ b/stepmania/src/GameState.h @@ -254,6 +254,12 @@ public: // Arrow positioning // NoteFieldPositioning *m_pPosition; + + // + // Attract stuff + // + int m_iNumTimesThroughAttract; + bool IsTimeToPlayAttractSounds(); }; diff --git a/stepmania/src/PrefsManager.cpp b/stepmania/src/PrefsManager.cpp index b97bda16da..8054cb51aa 100644 --- a/stepmania/src/PrefsManager.cpp +++ b/stepmania/src/PrefsManager.cpp @@ -155,8 +155,7 @@ PrefsManager::PrefsManager() m_fCenterImageScaleX = 1; m_fCenterImageScaleY = 1; - m_bAttractSound = true; - m_bDemonstrationSound = true; + m_iAttractSoundFrequency = 4; m_bAllowExtraStage = true; g_bAutoRestart = false; @@ -376,8 +375,7 @@ void PrefsManager::ReadGlobalPrefsFromDisk() ini.GetValue( "Options", "CenterImageTranslateY", m_iCenterImageTranslateY ); ini.GetValue( "Options", "CenterImageScaleX", m_fCenterImageScaleX ); ini.GetValue( "Options", "CenterImageScaleY", m_fCenterImageScaleY ); - ini.GetValue( "Options", "AttractSound", m_bAttractSound ); - ini.GetValue( "Options", "DemonstrationSound", m_bDemonstrationSound ); + ini.GetValue( "Options", "AttractSoundFrequency", m_iAttractSoundFrequency ); ini.GetValue( "Options", "AllowExtraStage", m_bAllowExtraStage ); ini.GetValue( "Options", "AutoRestart", g_bAutoRestart ); @@ -534,8 +532,7 @@ void PrefsManager::SaveGlobalPrefsToDisk() const ini.SetValue( "Options", "CenterImageTranslateY", m_iCenterImageTranslateY ); ini.SetValue( "Options", "CenterImageScaleX", m_fCenterImageScaleX ); ini.SetValue( "Options", "CenterImageScaleY", m_fCenterImageScaleY ); - ini.SetValue( "Options", "AttractSound", m_bAttractSound ); - ini.SetValue( "Options", "DemonstrationSound", m_bDemonstrationSound ); + ini.SetValue( "Options", "AttractSoundFrequency", m_iAttractSoundFrequency ); ini.SetValue( "Options", "AllowExtraStage", m_bAllowExtraStage ); ini.SetValue( "Options", "AutoRestart", g_bAutoRestart ); ini.SetValue( "Options", "SoundWriteAhead", m_iSoundWriteAhead ); diff --git a/stepmania/src/PrefsManager.h b/stepmania/src/PrefsManager.h index a49f023a3f..5f5f335282 100644 --- a/stepmania/src/PrefsManager.h +++ b/stepmania/src/PrefsManager.h @@ -128,8 +128,7 @@ public: int m_iCenterImageTranslateY; float m_fCenterImageScaleX; float m_fCenterImageScaleY; - bool m_bAttractSound; - bool m_bDemonstrationSound; + int m_iAttractSoundFrequency; // 0 = never, 1 = every time bool m_bAllowExtraStage; // course ranking diff --git a/stepmania/src/ScreenAttract.cpp b/stepmania/src/ScreenAttract.cpp index 9b35bc4105..0c6938d614 100644 --- a/stepmania/src/ScreenAttract.cpp +++ b/stepmania/src/ScreenAttract.cpp @@ -26,13 +26,18 @@ #include "SDL_utils.h" #include "RageSounds.h" -#define NEXT_SCREEN THEME->GetMetric(m_sName,"NextScreen") +#define NEXT_SCREEN THEME->GetMetric(m_sName,"NextScreen") +#define INITIAL_SCREEN THEME->GetMetric("Common","InitialScreen") ScreenAttract::ScreenAttract( CString sClassName ) : Screen( sClassName ) { LOG->Trace( "ScreenAttract::ScreenAttract(%s)", sClassName.c_str() ); + // increment times through attract count + if( sClassName == INITIAL_SCREEN ) + GAMESTATE->m_iNumTimesThroughAttract++; + GAMESTATE->Reset(); // We have to do initialization in the first update because this->GetElementName() won't @@ -51,7 +56,7 @@ ScreenAttract::ScreenAttract( CString sClassName ) : Screen( sClassName ) m_soundStart.Load( THEME->GetPathToS("Common start") ); - if( PREFSMAN->m_bAttractSound ) + if( GAMESTATE->IsTimeToPlayAttractSounds() ) SOUND->PlayMusic( THEME->GetPathToS(m_sName + " music") ); else SOUND->PlayMusic( "" ); // stop music diff --git a/stepmania/src/ScreenDemonstration.cpp b/stepmania/src/ScreenDemonstration.cpp index d4bab61967..d5b02c8367 100644 --- a/stepmania/src/ScreenDemonstration.cpp +++ b/stepmania/src/ScreenDemonstration.cpp @@ -73,7 +73,7 @@ ScreenDemonstration::ScreenDemonstration( CString sName ) : ScreenJukebox( sName m_DancingState = STATE_DANCING; this->PostScreenMessage( SM_BeginFadingOut, SECONDS_TO_SHOW ); - if( !PREFSMAN->m_bDemonstrationSound ) + if( !GAMESTATE->IsTimeToPlayAttractSounds() ) SOUNDMAN->SetPrefs( 0 ); // slient } @@ -103,7 +103,7 @@ void ScreenDemonstration::Input( const DeviceInput& DeviceI, const InputEventTyp break; // don't fall through m_soundMusic.Stop(); - if( !PREFSMAN->m_bDemonstrationSound ) + if( !GAMESTATE->IsTimeToPlayAttractSounds() ) SOUNDMAN->SetPrefs( PREFSMAN->m_fSoundVolume ); // turn volume back on break; @@ -124,7 +124,7 @@ void ScreenDemonstration::HandleScreenMessage( const ScreenMessage SM ) return; case SM_GoToNextScreen: m_soundMusic.Stop(); - if( !PREFSMAN->m_bDemonstrationSound ) + if( !GAMESTATE->IsTimeToPlayAttractSounds() ) SOUNDMAN->SetPrefs( PREFSMAN->m_fSoundVolume ); // turn volume back on GAMESTATE->Reset(); diff --git a/stepmania/src/ScreenOptionsMasterPrefs.cpp b/stepmania/src/ScreenOptionsMasterPrefs.cpp index 521de13e3c..8c7e5e5330 100644 --- a/stepmania/src/ScreenOptionsMasterPrefs.cpp +++ b/stepmania/src/ScreenOptionsMasterPrefs.cpp @@ -391,8 +391,7 @@ static void RefreshRate( int &sel, bool ToSel, const CStringArray &choices ) /* Sound options */ MOVE( PreloadSounds, PREFSMAN->m_bSoundPreloadAll ); MOVE( ResamplingQuality, PREFSMAN->m_iSoundResampleQuality ); -MOVE( AttractSound, PREFSMAN->m_bAttractSound ); -MOVE( DemonstrationSound, PREFSMAN->m_bDemonstrationSound ); +MOVE( AttractSoundFrequency,PREFSMAN->m_iAttractSoundFrequency ); static void SoundVolume( int &sel, bool ToSel, const CStringArray &choices ) { @@ -484,8 +483,7 @@ static const ConfOption g_ConfOptions[] = /* Sound options */ ConfOption( "Preload\nSounds", PreloadSounds, "NO","YES" ), ConfOption( "Resampling\nQuality", ResamplingQuality, "FAST","NORMAL","HIGH QUALITY" ), - ConfOption( "Attract\nSound", AttractSound, "OFF","ON" ), - ConfOption( "Demonstration\nSound", DemonstrationSound, "OFF","ON" ), + ConfOption( "Attract\nSound Frequency", AttractSoundFrequency, "NEVER","ALWAYS","2 TIMES","3 TIMES","4 TIMES","5 TIMES" ), ConfOption( "Sound\nVolume", SoundVolume, "0%","10%","20%","30%","40%","50%","60%","70%","80%","90%","100%","10%" ), ConfOption( "", NULL ) // end marker };