From d59595cd938fca249948f81e75fb166e0cc46662 Mon Sep 17 00:00:00 2001 From: Glenn Maynard Date: Fri, 23 Jan 2004 03:53:23 +0000 Subject: [PATCH] move Background::LoadFromRandom out --- stepmania/src/Background.cpp | 66 +++++++++++++++++++----------------- stepmania/src/Background.h | 2 ++ 2 files changed, 36 insertions(+), 32 deletions(-) diff --git a/stepmania/src/Background.cpp b/stepmania/src/Background.cpp index a5e64f9b19..552eea4488 100644 --- a/stepmania/src/Background.cpp +++ b/stepmania/src/Background.cpp @@ -272,6 +272,39 @@ CString Background::CreateRandomBGA() return file; } +void Background::LoadFromRandom( float fFirstBeat, float fLastBeat, const TimingData &timing ) +{ + // change BG every 4 bars + for( float f=fFirstBeat; fm_BackgroundMode==PrefsManager::BGMODE_RANDOMMOVIES || + // PREFSMAN->m_BackgroundMode==PrefsManager::BGMODE_MOVIEVIS; + + CString sBGName = CreateRandomBGA(); + if( sBGName != "" ) + m_aBGChanges.push_back( BackgroundChange(f,sBGName,1.f,bFade) ); + } + + // change BG every BPM change that is at the beginning of a measure + for( unsigned i=0; i fLastBeat ) + continue; // skip + + CString sBGName = CreateRandomBGA(); + if( sBGName != "" ) + m_aBGChanges.push_back( BackgroundChange(bpmseg.m_fStartBeat,sBGName) ); + } +} + void Background::LoadFromSong( Song* pSong ) { Unload(); @@ -326,38 +359,7 @@ void Background::LoadFromSong( Song* pSong ) } else // pSong doesn't have an animation plan { - const float fFirstBeat = pSong->m_fFirstBeat; - const float fLastBeat = pSong->m_fLastBeat; - - // change BG every 4 bars - for( float f=fFirstBeat; fm_BackgroundMode==PrefsManager::BGMODE_RANDOMMOVIES || - // PREFSMAN->m_BackgroundMode==PrefsManager::BGMODE_MOVIEVIS; - - CString sBGName = CreateRandomBGA(); - if( sBGName != "" ) - m_aBGChanges.push_back( BackgroundChange(f,sBGName,1.f,bFade) ); - } - - // change BG every BPM change that is at the beginning of a measure - for( unsigned i=0; im_Timing.m_BPMSegments.size(); i++ ) - { - const BPMSegment& bpmseg = pSong->m_Timing.m_BPMSegments[i]; - - if( fmodf(bpmseg.m_fStartBeat, (float)BEATS_PER_MEASURE) != 0 ) - continue; // skip - - if( bpmseg.m_fStartBeat < fFirstBeat || bpmseg.m_fStartBeat > fLastBeat ) - continue; // skip - - CString sBGName = CreateRandomBGA(); - if( sBGName != "" ) - m_aBGChanges.push_back( BackgroundChange(bpmseg.m_fStartBeat,sBGName) ); - } + LoadFromRandom( pSong->m_fFirstBeat, pSong->m_fLastBeat, pSong->m_Timing ); } diff --git a/stepmania/src/Background.h b/stepmania/src/Background.h index 594b426832..57dd8fe7d2 100644 --- a/stepmania/src/Background.h +++ b/stepmania/src/Background.h @@ -40,6 +40,8 @@ public: DancingCharacters* GetDancingCharacters() { return m_pDancingCharacters; }; protected: + void LoadFromRandom( float fFirstBeat, float fLastBeat, const TimingData &timing ); + bool IsDangerPlayerVisible( PlayerNumber pn ); bool IsDangerAllVisible(); bool IsDeadPlayerVisible( PlayerNumber pn );