remove dupe effect timer code

fix movie bugs
This commit is contained in:
Glenn Maynard
2004-10-18 04:20:44 +00:00
parent 1e7e57a1c8
commit e48459c7ae
2 changed files with 25 additions and 24 deletions
+22 -23
View File
@@ -18,8 +18,9 @@ Sprite::Sprite()
m_pTexture = NULL; m_pTexture = NULL;
m_bDrawIfTextureNull = false; m_bDrawIfTextureNull = false;
m_iCurState = 0; m_iCurState = 0;
m_fSecsIntoState = m_fLastTime = 0.0f; m_fSecsIntoState = 0.0f;
m_bUsingCustomTexCoords = false; m_bUsingCustomTexCoords = false;
m_bSkipNextUpdate = false;
m_fRememberedClipWidth = -1; m_fRememberedClipWidth = -1;
m_fRememberedClipHeight = -1; m_fRememberedClipHeight = -1;
@@ -257,6 +258,19 @@ bool Sprite::LoadFromTexture( RageTextureID ID )
return true; return true;
} }
void Sprite::GainFocus( float fRate, bool bRewindMovie, bool bLoop )
{
/*
* When we lose focus, we don't receive updates. When we regain focus,
* we'll receive an update, and if we're in CLOCK_BGM_TIME or CLOCK_BGM_BEAT,
* m_fSecsIntoEffect will be much higher than it was at our last update.
* We don't want to send that big jump on to the texture (don't animate
* when we don't have focus). This is particularly important for movies.
*
* However, we havn't received that time yet; we won't until the next Update().
*/
m_bSkipNextUpdate = true;
}
void Sprite::UpdateAnimationState() void Sprite::UpdateAnimationState()
{ {
@@ -277,31 +291,16 @@ void Sprite::Update( float fDelta )
{ {
Actor::Update( fDelta ); // do tweening Actor::Update( fDelta ); // do tweening
if( !m_bIsAnimating ) if( !m_bIsAnimating || m_bSkipNextUpdate )
return; {
m_bSkipNextUpdate = false;
return;
}
if( !m_pTexture ) // no texture, nothing to animate if( !m_pTexture ) // no texture, nothing to animate
return; return;
float fTimePassed = 0; float fTimePassed = GetEffectDeltaTime();
switch( m_EffectClock )
{
case CLOCK_TIMER:
fTimePassed = fDelta;
break;
case CLOCK_BGM_BEAT:
fTimePassed = g_fCurrentBGMBeat - m_fLastTime;
m_fLastTime = g_fCurrentBGMBeat;
break;
case CLOCK_BGM_TIME:
fTimePassed = g_fCurrentBGMTime - m_fLastTime;
m_fLastTime = g_fCurrentBGMTime;
break;
default: FAIL_M( ssprintf("%i",m_EffectClock) );
}
m_fSecsIntoState += fTimePassed; m_fSecsIntoState += fTimePassed;
UpdateAnimationState(); UpdateAnimationState();
@@ -649,7 +648,7 @@ void Sprite::SetState( int iNewState )
CLAMP(iNewState, 0, (int)m_States.size()-1); CLAMP(iNewState, 0, (int)m_States.size()-1);
m_iCurState = iNewState; m_iCurState = iNewState;
m_fSecsIntoState = m_fLastTime = 0.0f; m_fSecsIntoState = 0.0f;
} }
float Sprite::GetAnimationLengthSeconds() const float Sprite::GetAnimationLengthSeconds() const
+3 -1
View File
@@ -17,6 +17,8 @@ public:
virtual bool EarlyAbortDraw(); virtual bool EarlyAbortDraw();
virtual void DrawPrimitives(); virtual void DrawPrimitives();
virtual void Update( float fDeltaTime ); virtual void Update( float fDeltaTime );
virtual void GainFocus( float fRate, bool bRewindMovie, bool bLoop );
void UpdateAnimationState(); // take m_fSecondsIntoState, and move to a new state void UpdateAnimationState(); // take m_fSecondsIntoState, and move to a new state
/* Adjust texture properties for song backgrounds. */ /* Adjust texture properties for song backgrounds. */
@@ -79,9 +81,9 @@ protected:
vector<State> m_States; vector<State> m_States;
int m_iCurState; int m_iCurState;
float m_fSecsIntoState; // number of seconds that have elapsed since we switched to this frame float m_fSecsIntoState; // number of seconds that have elapsed since we switched to this frame
float m_fLastTime;
bool m_bUsingCustomTexCoords; bool m_bUsingCustomTexCoords;
bool m_bSkipNextUpdate;
float m_CustomTexCoords[8]; // (x,y) * 4: top left, bottom left, bottom right, top right float m_CustomTexCoords[8]; // (x,y) * 4: top left, bottom left, bottom right, top right
// Remembered clipped dimensions are applied on Load(). // Remembered clipped dimensions are applied on Load().