From 73167283a3b05176e1215e476399482c6404ede5 Mon Sep 17 00:00:00 2001 From: Chris Danford Date: Sun, 5 Jun 2005 02:23:15 +0000 Subject: [PATCH] fix random BGA placed on BPM change overrides scripted BG add SBE_UpperLeft for correct alignment of BGAs --- stepmania/src/Background.cpp | 24 +++++++++++++----------- stepmania/src/BackgroundUtil.h | 1 + 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/stepmania/src/Background.cpp b/stepmania/src/Background.cpp index fa82a1613a..41afecf3c5 100644 --- a/stepmania/src/Background.cpp +++ b/stepmania/src/Background.cpp @@ -86,7 +86,7 @@ protected: map m_mapNameToTransition; deque m_RandomBGAnimations; // random background to choose from. These may or may not be loaded into m_BGAnimations. - void LoadFromRandom( float fFirstBeat, float fLastBeat, const BackgroundChange &change ); + void LoadFromRandom( float fFirstBeat, float fEndBeat, const BackgroundChange &change ); bool IsDangerAllVisible(); class Layer @@ -372,7 +372,7 @@ bool BackgroundImpl::Layer::CreateBackground( const Song *pSong, const Backgroun case FT_Directory: case FT_Xml: case FT_Model: - sEffect = SBE_Centered; + sEffect = SBE_UpperLeft; break; } } @@ -422,12 +422,12 @@ BackgroundDef BackgroundImpl::Layer::CreateRandomBGA( const Song *pSong, const C return bd; } -void BackgroundImpl::LoadFromRandom( float fFirstBeat, float fLastBeat, const BackgroundChange &change ) +void BackgroundImpl::LoadFromRandom( float fFirstBeat, float fEndBeat, const BackgroundChange &change ) { const TimingData &timing = m_pSong->m_Timing; // change BG every 4 bars - for( float f=fFirstBeat; f iEndIndex ) + + // start so that we don't create a BGChange right on top of fEndBeat + bool bInRange = bpmseg.m_iStartIndex >= iStartIndex && bpmseg.m_iStartIndex < iEndIndex; + if( !bInRange ) continue; // skip BackgroundDef bd = m_Layer[0].CreateRandomBGA( m_pSong, change.m_def.m_sEffect, m_RandomBGAnimations ); @@ -536,7 +538,7 @@ void BackgroundImpl::LoadFromSong( const Song* pSong ) bool bIsAlreadyLoaded = layer.m_BGAnimations.find(bd) != layer.m_BGAnimations.end(); - if( bd.m_sFile1 != RANDOM_BACKGROUND_FILE && !bIsAlreadyLoaded ) + if( bd.m_sFile1 != RANDOM_BACKGROUND_FILE && !bIsAlreadyLoaded ) { if( layer.CreateBackground( m_pSong, bd ) ) { @@ -544,7 +546,7 @@ void BackgroundImpl::LoadFromSong( const Song* pSong ) } else { - if( i == 0 ) + if( i == BACKGROUND_LAYER_1 ) { // The background was not found. Try to use a random one instead. bd = layer.CreateRandomBGA( pSong, "", m_RandomBGAnimations ); @@ -627,12 +629,12 @@ void BackgroundImpl::LoadFromSong( const Song* pSong ) continue; const float fStartBeat = change.m_fStartBeat; - const float fLastBeat = (i+1 < mainlayer.m_aBGChanges.size())? mainlayer.m_aBGChanges[i+1].m_fStartBeat: FLT_MAX; + const float fEndBeat = (i+1 < mainlayer.m_aBGChanges.size())? mainlayer.m_aBGChanges[i+1].m_fStartBeat: FLT_MAX; mainlayer.m_aBGChanges.erase( mainlayer.m_aBGChanges.begin()+i ); --i; - LoadFromRandom( fStartBeat, fLastBeat, change ); + LoadFromRandom( fStartBeat, fEndBeat, change ); } // At this point, we shouldn't have any BGChanges to "". "" is an invalid name. diff --git a/stepmania/src/BackgroundUtil.h b/stepmania/src/BackgroundUtil.h index 4b5361e460..b3b6911f8a 100644 --- a/stepmania/src/BackgroundUtil.h +++ b/stepmania/src/BackgroundUtil.h @@ -5,6 +5,7 @@ class Song; +const CString SBE_UpperLeft = "UpperLeft"; const CString SBE_Centered = "Centered"; const CString SBE_StretchNormal = "StretchNormal"; const CString SBE_StretchNoLoop = "StretchNoLoop";