From 78800818e3174f568a72774b95887100ee9367f8 Mon Sep 17 00:00:00 2001 From: Glenn Maynard Date: Sat, 15 Jan 2005 18:31:14 +0000 Subject: [PATCH] Remove BGAnimation::GetLengthSeconds; use GetTweenTimeLeft instead. --- stepmania/src/BGAnimation.cpp | 14 ++++++++------ stepmania/src/BGAnimation.h | 3 --- stepmania/src/Foreground.cpp | 2 +- stepmania/src/ScreenAttract.cpp | 4 ++-- stepmania/src/ScreenEnding.cpp | 4 ++-- stepmania/src/ScreenStage.cpp | 2 +- stepmania/src/Transition.cpp | 5 +++-- stepmania/src/Transition.h | 1 + 8 files changed, 18 insertions(+), 17 deletions(-) diff --git a/stepmania/src/BGAnimation.cpp b/stepmania/src/BGAnimation.cpp index 9d4b440698..2610730b7c 100644 --- a/stepmania/src/BGAnimation.cpp +++ b/stepmania/src/BGAnimation.cpp @@ -17,7 +17,6 @@ BGAnimation::BGAnimation( bool Generic ) { /* See BGAnimationLayer::BGAnimationLayer for explanation. */ m_bGeneric = Generic; - m_fLengthSeconds = 10; } BGAnimation::~BGAnimation() @@ -242,12 +241,15 @@ void BGAnimation::LoadFromNode( const CString &sDir, const XNode& node ) if( !m_bGeneric ) PlayCommand( "On" ); - - if( !node.GetAttrValue( "LengthSeconds", m_fLengthSeconds ) ) + /* Backwards-compatibility: if a "LengthSeconds" value is present, create a dummy + * actor that sleeps for the given length of time. This will extend GetTweenTimeLeft. */ + float fLengthSeconds = 0; + if( node.GetAttrValue( "LengthSeconds", fLengthSeconds ) ) { - /* XXX: if m_bGeneric, simply constructing the BG layer won't run "On", - * so at this point GetMaxTweenTimeLeft is probably 0 */ - m_fLengthSeconds = this->GetTweenTimeLeft(); + Actor *pActor = new Actor; + pActor->SetHidden( true ); + pActor->BeginTweening( fLengthSeconds ); + AddChild( pActor ); } } diff --git a/stepmania/src/BGAnimation.h b/stepmania/src/BGAnimation.h index 6f8c6edde7..cd2d8173cd 100644 --- a/stepmania/src/BGAnimation.h +++ b/stepmania/src/BGAnimation.h @@ -23,10 +23,7 @@ public: void LoadFromVisualization( const CString &sMoviePath ); void LoadFromNode( const CString &sDir, const XNode& node ); - float GetLengthSeconds() const { return m_fLengthSeconds; } - protected: - float m_fLengthSeconds; bool m_bGeneric; }; diff --git a/stepmania/src/Foreground.cpp b/stepmania/src/Foreground.cpp index 1e9567564a..7fe4458861 100644 --- a/stepmania/src/Foreground.cpp +++ b/stepmania/src/Foreground.cpp @@ -43,7 +43,7 @@ void Foreground::LoadFromSong( const Song *pSong ) bga.m_fStartBeat = change.m_fStartBeat; const float fStartSecond = pSong->m_Timing.GetElapsedTimeFromBeat( bga.m_fStartBeat ); - const float fStopSecond = fStartSecond + bga.m_bga->GetLengthSeconds(); + const float fStopSecond = fStartSecond + bga.m_bga->GetTweenTimeLeft(); bga.m_fStopBeat = pSong->m_Timing.GetBeatFromElapsedTime( fStopSecond ); bga.m_bga->SetHidden( true ); diff --git a/stepmania/src/ScreenAttract.cpp b/stepmania/src/ScreenAttract.cpp index f850fb97de..58c24b35c6 100644 --- a/stepmania/src/ScreenAttract.cpp +++ b/stepmania/src/ScreenAttract.cpp @@ -122,11 +122,11 @@ void ScreenAttract::Update( float fDelta ) // The shared background isn't loaded until the screen is actually // showing. The background is loaded by the time of the first update. BGAnimation &background = *SCREENMAN->m_pSharedBGA; - float fTimeUntilBeginFadingOut = background.GetLengthSeconds() - m_Out.GetLengthSeconds(); + float fTimeUntilBeginFadingOut = background.GetTweenTimeLeft() - m_Out.GetTweenTimeLeft(); if( fTimeUntilBeginFadingOut < 0 ) { LOG->Warn( "Screen '%s' Out BGAnimation (%f seconds) is longer than Background BGAnimation (%f seconds); background BGA will be truncated", - m_sName.c_str(), m_Out.GetLengthSeconds(), background.GetLengthSeconds() ); + m_sName.c_str(), m_Out.GetTweenTimeLeft(), background.GetTweenTimeLeft() ); fTimeUntilBeginFadingOut = 0; } this->PostScreenMessage( SM_BeginFadingOut, fTimeUntilBeginFadingOut ); diff --git a/stepmania/src/ScreenEnding.cpp b/stepmania/src/ScreenEnding.cpp index 88759916dd..511a6c9a59 100644 --- a/stepmania/src/ScreenEnding.cpp +++ b/stepmania/src/ScreenEnding.cpp @@ -260,11 +260,11 @@ void ScreenEnding::Update( float fDeltaTime ) if( IsFirstUpdate() ) { BGAnimation &background = *SCREENMAN->m_pSharedBGA; - float fSecsUntilBeginFadingOut = background.GetLengthSeconds() - m_Out.GetLengthSeconds(); + float fSecsUntilBeginFadingOut = background.GetTweenTimeLeft() - m_Out.GetTweenTimeLeft(); if( fSecsUntilBeginFadingOut < 0 ) { LOG->Warn( "Screen '%s' Out BGAnimation (%f seconds) is longer than Background BGAnimation (%f seconds); background BGA will be truncated", - m_sName.c_str(), m_Out.GetLengthSeconds(), background.GetLengthSeconds() ); + m_sName.c_str(), m_Out.GetTweenTimeLeft(), background.GetTweenTimeLeft() ); fSecsUntilBeginFadingOut = 0; } this->PostScreenMessage( SM_BeginFadingOut, fSecsUntilBeginFadingOut ); diff --git a/stepmania/src/ScreenStage.cpp b/stepmania/src/ScreenStage.cpp index d3861cdda9..e7ce28e08d 100644 --- a/stepmania/src/ScreenStage.cpp +++ b/stepmania/src/ScreenStage.cpp @@ -53,7 +53,7 @@ ScreenStage::ScreenStage( CString sClassName ) : Screen( sClassName ) this->AddChild( &m_Back ); /* Prep the new screen once m_In is complete. */ - this->PostScreenMessage( SM_PrepScreen, m_Background.GetLengthSeconds() ); + this->PostScreenMessage( SM_PrepScreen, m_Background.GetTweenTimeLeft() ); FOREACH_PlayerNumber(p) { diff --git a/stepmania/src/Transition.cpp b/stepmania/src/Transition.cpp index 5241dc735b..ccbc9259eb 100644 --- a/stepmania/src/Transition.cpp +++ b/stepmania/src/Transition.cpp @@ -18,6 +18,7 @@ void Transition::Load( CString sBGAniDir ) sBGAniDir += "/"; m_BGAnimation.LoadFromAniDir( sBGAniDir ); + m_fLengthSeconds = m_BGAnimation.GetTweenTimeLeft(); m_State = waiting; m_fSecsIntoTransition = 0.0f; @@ -58,7 +59,7 @@ void Transition::Update( float fDeltaTime ) } m_BGAnimation.Update( fDeltaTime ); - if( m_fSecsIntoTransition > m_BGAnimation.GetLengthSeconds() ) // over + if( m_fSecsIntoTransition > m_fLengthSeconds ) // over { SCREENMAN->SendMessageToTopScreen( m_MessageToSendWhenDone ); m_fSecsIntoTransition = 0.0; @@ -91,7 +92,7 @@ void Transition::StartTransitioning( ScreenMessage send_when_done ) float Transition::GetLengthSeconds() const { - return m_BGAnimation.GetLengthSeconds(); + return m_fLengthSeconds; } float Transition::GetTweenTimeLeft() const diff --git a/stepmania/src/Transition.h b/stepmania/src/Transition.h index a93baaa689..64c5e95903 100644 --- a/stepmania/src/Transition.h +++ b/stepmania/src/Transition.h @@ -38,6 +38,7 @@ protected: BGAnimation m_BGAnimation; + float m_fLengthSeconds; RandomSample m_sound; ScreenMessage m_MessageToSendWhenDone;