From 987c51c0b62332f847206222be131889c71aa624 Mon Sep 17 00:00:00 2001 From: Chris Danford Date: Sat, 5 Jul 2003 05:28:23 +0000 Subject: [PATCH] add global offset setting (remove when we add timestamped input) --- stepmania/src/PrefsManager.cpp | 3 +++ stepmania/src/PrefsManager.h | 1 + stepmania/src/Song.cpp | 9 +++++++-- 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/stepmania/src/PrefsManager.cpp b/stepmania/src/PrefsManager.cpp index 9f4d728537..215147eb0e 100644 --- a/stepmania/src/PrefsManager.cpp +++ b/stepmania/src/PrefsManager.cpp @@ -97,6 +97,7 @@ PrefsManager::PrefsManager() m_bUseUnlockSystem = false; m_bFirstRun = true; m_bAutoMapJoysticks = true; + m_fGlobalOffsetSeconds = 0; /* DDR Extreme-style extra stage support. * Default off so people used to the current behavior (or those with extra @@ -213,6 +214,7 @@ void PrefsManager::ReadGlobalPrefsFromDisk( bool bSwitchToLastPlayedGame ) ini.GetValue ( "Options", "LastSeenMemory", m_iLastSeenMemory ); #endif ini.GetValueB( "Options", "AntiAliasing", m_bAntiAliasing ); + ini.GetValueF( "Options", "GlobalOffsetSeconds", m_fGlobalOffsetSeconds ); m_asAdditionalSongFolders.clear(); CString sAdditionalSongFolders; @@ -304,6 +306,7 @@ void PrefsManager::SaveGlobalPrefsToDisk() ini.SetValue ( "Options", "LastSeenMemory", m_iLastSeenMemory ); #endif ini.SetValueB( "Options", "AntiAliasing", m_bAntiAliasing ); + ini.SetValueF( "Options", "GlobalOffsetSeconds", m_fGlobalOffsetSeconds ); /* Only write these if they aren't the default. This ensures that we can change * the default and have it take effect for everyone (except people who diff --git a/stepmania/src/PrefsManager.h b/stepmania/src/PrefsManager.h index 9b3bdd098e..45976f28b9 100644 --- a/stepmania/src/PrefsManager.h +++ b/stepmania/src/PrefsManager.h @@ -80,6 +80,7 @@ public: bool m_bUseUnlockSystem; bool m_bFirstRun; bool m_bAutoMapJoysticks; + float m_fGlobalOffsetSeconds; /* 0 = no; 1 = yes; -1 = auto (do whatever is appropriate for the arch). */ int m_iBoostAppPriority; diff --git a/stepmania/src/Song.cpp b/stepmania/src/Song.cpp index 27789b495e..9eb55766fe 100644 --- a/stepmania/src/Song.cpp +++ b/stepmania/src/Song.cpp @@ -28,6 +28,7 @@ #include "TitleSubstitution.h" #include "BannerCache.h" #include "Sprite.h" +#include "PrefsManager.h" #include "NotesLoaderSM.h" #include "NotesLoaderDWI.h" @@ -148,7 +149,7 @@ void Song::AddLyricSegment( LyricSegment seg ) float Song::GetMusicStartBeat() const { float fBPS = m_BPMSegments[0].m_fBPM / 60.0f; - return -m_fBeat0OffsetInSeconds*fBPS; + return -(PREFSMAN->m_fGlobalOffsetSeconds+m_fBeat0OffsetInSeconds)*fBPS; }; void Song::GetBeatAndBPSFromElapsedTime( float fElapsedTime, float &fBeatOut, float &fBPSOut, bool &bFreezeOut ) const @@ -156,6 +157,8 @@ void Song::GetBeatAndBPSFromElapsedTime( float fElapsedTime, float &fBeatOut, fl // LOG->Trace( "GetBeatAndBPSFromElapsedTime( fElapsedTime = %f )", fElapsedTime ); // This function is a nightmare. Don't even try to understand it. :-) + fElapsedTime += PREFSMAN->m_fGlobalOffsetSeconds; + fElapsedTime += m_fBeat0OffsetInSeconds; @@ -225,7 +228,9 @@ void Song::GetBeatAndBPSFromElapsedTime( float fElapsedTime, float &fBeatOut, fl float Song::GetElapsedTimeFromBeat( float fBeat ) const { - float fElapsedTime = -m_fBeat0OffsetInSeconds; + float fElapsedTime = 0; + fElapsedTime -= PREFSMAN->m_fGlobalOffsetSeconds; + fElapsedTime -= m_fBeat0OffsetInSeconds; for( unsigned j=0; j