Split Update into Update and UpdateInternal so that every class doesn't need to early abort in Update when hibernating
This commit is contained in:
+15
-3
@@ -486,9 +486,6 @@ void Actor::Update( float fDeltaTime )
|
|||||||
// LOG->Trace( "Actor::Update( %f )", fDeltaTime );
|
// LOG->Trace( "Actor::Update( %f )", fDeltaTime );
|
||||||
ASSERT_M( fDeltaTime >= 0, ssprintf("%f",fDeltaTime) );
|
ASSERT_M( fDeltaTime >= 0, ssprintf("%f",fDeltaTime) );
|
||||||
|
|
||||||
if( m_bFirstUpdate )
|
|
||||||
m_bFirstUpdate = false;
|
|
||||||
|
|
||||||
if( m_fHibernateSecondsLeft > 0 )
|
if( m_fHibernateSecondsLeft > 0 )
|
||||||
{
|
{
|
||||||
m_fHibernateSecondsLeft -= fDeltaTime;
|
m_fHibernateSecondsLeft -= fDeltaTime;
|
||||||
@@ -500,6 +497,14 @@ void Actor::Update( float fDeltaTime )
|
|||||||
m_fHibernateSecondsLeft = 0;
|
m_fHibernateSecondsLeft = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this->UpdateInternal( fDeltaTime );
|
||||||
|
}
|
||||||
|
|
||||||
|
void Actor::UpdateInternal( float fDeltaTime )
|
||||||
|
{
|
||||||
|
if( m_bFirstUpdate )
|
||||||
|
m_bFirstUpdate = false;
|
||||||
|
|
||||||
switch( m_EffectClock )
|
switch( m_EffectClock )
|
||||||
{
|
{
|
||||||
case CLOCK_TIMER:
|
case CLOCK_TIMER:
|
||||||
@@ -1052,6 +1057,13 @@ bool Actor::HasCommand( const CString &sCmdName )
|
|||||||
return it != m_mapNameToCommands.end();
|
return it != m_mapNameToCommands.end();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const apActorCommands& Actor::GetCommand( const CString &sCommandName ) const
|
||||||
|
{
|
||||||
|
map<CString, apActorCommands>::const_iterator it = m_mapNameToCommands.find( sCommandName );
|
||||||
|
ASSERT( it != m_mapNameToCommands.end() );
|
||||||
|
return it->second;
|
||||||
|
}
|
||||||
|
|
||||||
void Actor::PlayCommand( const CString &sCommandName )
|
void Actor::PlayCommand( const CString &sCommandName )
|
||||||
{
|
{
|
||||||
PlayCommand2( sCommandName, NULL );
|
PlayCommand2( sCommandName, NULL );
|
||||||
|
|||||||
@@ -87,8 +87,11 @@ public:
|
|||||||
virtual void DrawPrimitives() {}; // Derivitives should override
|
virtual void DrawPrimitives() {}; // Derivitives should override
|
||||||
virtual void EndDraw(); // pops transform from world matrix stack
|
virtual void EndDraw(); // pops transform from world matrix stack
|
||||||
|
|
||||||
|
// TODO: make Update non virtual and change all classes to override UpdateInternal
|
||||||
|
// instead.
|
||||||
bool IsFirstUpdate() const;
|
bool IsFirstUpdate() const;
|
||||||
virtual void Update( float fDeltaTime );
|
virtual void Update( float fDeltaTime ); // this can short circuit UpdateInternal
|
||||||
|
virtual void UpdateInternal( float fDeltaTime ); // override this
|
||||||
void UpdateTweening( float fDeltaTime );
|
void UpdateTweening( float fDeltaTime );
|
||||||
void CopyTweening( const Actor &from );
|
void CopyTweening( const Actor &from );
|
||||||
|
|
||||||
@@ -333,6 +336,7 @@ public:
|
|||||||
virtual void PushSelf( lua_State *L );
|
virtual void PushSelf( lua_State *L );
|
||||||
void AddCommand( const CString &sCmdName, apActorCommands apac );
|
void AddCommand( const CString &sCmdName, apActorCommands apac );
|
||||||
bool HasCommand( const CString &sCmdName );
|
bool HasCommand( const CString &sCmdName );
|
||||||
|
const apActorCommands& GetCommand( const CString &sCommandName ) const;
|
||||||
virtual void PlayCommand( const CString &sCommandName );
|
virtual void PlayCommand( const CString &sCommandName );
|
||||||
virtual void PlayCommand2( const CString &sCommandName, Actor *pParent );
|
virtual void PlayCommand2( const CString &sCommandName, Actor *pParent );
|
||||||
virtual void RunCommands( const LuaReference& cmds );
|
virtual void RunCommands( const LuaReference& cmds );
|
||||||
|
|||||||
@@ -216,16 +216,13 @@ void ActorFrame::RunCommandsOnLeaves( const LuaReference& cmds )
|
|||||||
m_SubActors[i]->RunCommandsOnLeaves( cmds );
|
m_SubActors[i]->RunCommandsOnLeaves( cmds );
|
||||||
}
|
}
|
||||||
|
|
||||||
void ActorFrame::Update( float fDeltaTime )
|
void ActorFrame::UpdateInternal( float fDeltaTime )
|
||||||
{
|
{
|
||||||
// LOG->Trace( "ActorFrame::Update( %f )", fDeltaTime );
|
// LOG->Trace( "ActorFrame::Update( %f )", fDeltaTime );
|
||||||
|
|
||||||
fDeltaTime *= m_fUpdateRate;
|
fDeltaTime *= m_fUpdateRate;
|
||||||
|
|
||||||
Actor::Update( fDeltaTime );
|
Actor::UpdateInternal( fDeltaTime );
|
||||||
|
|
||||||
if( m_fHibernateSecondsLeft > 0 )
|
|
||||||
return;
|
|
||||||
|
|
||||||
// update all sub-Actors
|
// update all sub-Actors
|
||||||
for( vector<Actor*>::iterator it=m_SubActors.begin(); it!=m_SubActors.end(); it++ )
|
for( vector<Actor*>::iterator it=m_SubActors.begin(); it!=m_SubActors.end(); it++ )
|
||||||
|
|||||||
@@ -71,7 +71,7 @@ public:
|
|||||||
virtual void RunCommandsOnChildren( const apActorCommands& cmds ) { RunCommandsOnChildren( *cmds ); } // convenience
|
virtual void RunCommandsOnChildren( const apActorCommands& cmds ) { RunCommandsOnChildren( *cmds ); } // convenience
|
||||||
virtual void RunCommandsOnLeaves( const LuaReference& cmds ); /* but not on self */
|
virtual void RunCommandsOnLeaves( const LuaReference& cmds ); /* but not on self */
|
||||||
|
|
||||||
virtual void Update( float fDeltaTime );
|
virtual void UpdateInternal( float fDeltaTime );
|
||||||
virtual void DrawPrimitives();
|
virtual void DrawPrimitives();
|
||||||
|
|
||||||
// propagated commands
|
// propagated commands
|
||||||
|
|||||||
@@ -153,12 +153,9 @@ void ActorScroller::LoadFromNode( const CString &sDir, const XNode *pNode )
|
|||||||
pNode->GetAttrValue( "QuantizePixels", m_fQuantizePixels );
|
pNode->GetAttrValue( "QuantizePixels", m_fQuantizePixels );
|
||||||
}
|
}
|
||||||
|
|
||||||
void ActorScroller::Update( float fDeltaTime )
|
void ActorScroller::UpdateInternal( float fDeltaTime )
|
||||||
{
|
{
|
||||||
ActorFrame::Update( fDeltaTime );
|
ActorFrame::UpdateInternal( fDeltaTime );
|
||||||
|
|
||||||
if( m_fHibernateSecondsLeft > 0 )
|
|
||||||
return; // early abort
|
|
||||||
|
|
||||||
/* If we have no children, the code below will busy loop. */
|
/* If we have no children, the code below will busy loop. */
|
||||||
if( !m_SubActors.size() )
|
if( !m_SubActors.size() )
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ public:
|
|||||||
const CString &sTransformFunction,
|
const CString &sTransformFunction,
|
||||||
bool bUseMask );
|
bool bUseMask );
|
||||||
|
|
||||||
virtual void Update( float fDelta );
|
virtual void UpdateInternal( float fDelta );
|
||||||
virtual void DrawPrimitives(); // DOES draw
|
virtual void DrawPrimitives(); // DOES draw
|
||||||
|
|
||||||
void LoadFromNode( const CString &sDir, const XNode *pNode );
|
void LoadFromNode( const CString &sDir, const XNode *pNode );
|
||||||
|
|||||||
@@ -556,12 +556,9 @@ void BGAnimationLayer::LoadFromNode( const CString& sDir, const XNode* pNode )
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void BGAnimationLayer::Update( float fDeltaTime )
|
void BGAnimationLayer::UpdateInternal( float fDeltaTime )
|
||||||
{
|
{
|
||||||
if( m_fHibernateSecondsLeft > 0 )
|
ActorFrame::UpdateInternal( fDeltaTime );
|
||||||
return;
|
|
||||||
|
|
||||||
ActorFrame::Update( fDeltaTime );
|
|
||||||
|
|
||||||
fDeltaTime *= m_fUpdateRate;
|
fDeltaTime *= m_fUpdateRate;
|
||||||
|
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ public:
|
|||||||
void LoadFromAniLayerFile( const CString& sPath );
|
void LoadFromAniLayerFile( const CString& sPath );
|
||||||
void LoadFromNode( const CString& sDir, const XNode* pNode );
|
void LoadFromNode( const CString& sDir, const XNode* pNode );
|
||||||
|
|
||||||
void Update( float fDeltaTime );
|
void UpdateInternal( float fDeltaTime );
|
||||||
void DrawPrimitives();
|
void DrawPrimitives();
|
||||||
bool EarlyAbortDraw();
|
bool EarlyAbortDraw();
|
||||||
|
|
||||||
|
|||||||
@@ -629,9 +629,7 @@ bool ThemeManager::GetMetricRaw( const CString &sClassName, const CString &sValu
|
|||||||
|
|
||||||
CString sFallback;
|
CString sFallback;
|
||||||
|
|
||||||
for( deque<Theme>::const_iterator iter = g_vThemes.begin();
|
FOREACHD_CONST( Theme, g_vThemes, iter )
|
||||||
iter != g_vThemes.end();
|
|
||||||
iter++ )
|
|
||||||
{
|
{
|
||||||
if( iter->iniMetrics->GetValue(sClassName,sValueName,ret) )
|
if( iter->iniMetrics->GetValue(sClassName,sValueName,ret) )
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -65,7 +65,7 @@ void Transition::Load( CString sBGAniDir )
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Transition::Update( float fDeltaTime )
|
void Transition::UpdateInternal( float fDeltaTime )
|
||||||
{
|
{
|
||||||
if( m_State != transitioning )
|
if( m_State != transitioning )
|
||||||
return;
|
return;
|
||||||
@@ -83,7 +83,7 @@ void Transition::Update( float fDeltaTime )
|
|||||||
SCREENMAN->SendMessageToTopScreen( m_MessageToSendWhenDone );
|
SCREENMAN->SendMessageToTopScreen( m_MessageToSendWhenDone );
|
||||||
}
|
}
|
||||||
|
|
||||||
ActorFrame::Update( fDeltaTime );
|
ActorFrame::UpdateInternal( fDeltaTime );
|
||||||
}
|
}
|
||||||
|
|
||||||
void Transition::Reset()
|
void Transition::Reset()
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ public:
|
|||||||
|
|
||||||
void Load( CString sBGAniDir );
|
void Load( CString sBGAniDir );
|
||||||
|
|
||||||
virtual void Update( float fDeltaTime );
|
virtual void UpdateInternal( float fDeltaTime );
|
||||||
|
|
||||||
virtual void StartTransitioning( ScreenMessage send_when_done = SM_None );
|
virtual void StartTransitioning( ScreenMessage send_when_done = SM_None );
|
||||||
virtual bool EarlyAbortDraw();
|
virtual bool EarlyAbortDraw();
|
||||||
|
|||||||
Reference in New Issue
Block a user