2003-02-16 04:01:45 +00:00
|
|
|
#include "global.h" // testing updates
|
2001-12-11 11:44:26 +00:00
|
|
|
/*
|
|
|
|
|
-----------------------------------------------------------------------------
|
2002-07-23 01:41:40 +00:00
|
|
|
Class: ActorFrame
|
2001-12-11 11:44:26 +00:00
|
|
|
|
2002-07-23 01:41:40 +00:00
|
|
|
Desc: See header.
|
2001-12-11 11:44:26 +00:00
|
|
|
|
2002-05-19 01:59:48 +00:00
|
|
|
Copyright (c) 2001-2002 by the person(s) listed below. All rights reserved.
|
2002-07-23 01:41:40 +00:00
|
|
|
Chris Danford
|
2001-12-11 11:44:26 +00:00
|
|
|
-----------------------------------------------------------------------------
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include "ActorFrame.h"
|
2004-01-07 04:37:00 +00:00
|
|
|
#include "arch/ArchHooks/ArchHooks.h"
|
|
|
|
|
#include "RageUtil.h"
|
2001-12-11 11:44:26 +00:00
|
|
|
|
2003-01-11 08:55:21 +00:00
|
|
|
void ActorFrame::AddChild( Actor* pActor )
|
2002-06-14 22:25:22 +00:00
|
|
|
{
|
2003-08-23 22:04:57 +00:00
|
|
|
#if _DEBUG
|
|
|
|
|
// check that this Actor isn't already added.
|
|
|
|
|
vector<Actor*>::iterator iter = find( m_SubActors.begin(), m_SubActors.end(), pActor );
|
2003-10-10 23:42:02 +00:00
|
|
|
if( iter != m_SubActors.end() )
|
2004-01-07 04:37:00 +00:00
|
|
|
HOOKS->MessageBoxOK( ssprintf("Actor \"%s\" adds child \"%s\" more than once", m_sName.c_str(), pActor->m_sName.c_str()) );
|
2003-08-23 22:04:57 +00:00
|
|
|
#endif
|
|
|
|
|
|
2002-07-23 01:41:40 +00:00
|
|
|
ASSERT( pActor );
|
|
|
|
|
ASSERT( (void*)pActor != (void*)0xC0000005 );
|
2002-10-31 04:23:39 +00:00
|
|
|
m_SubActors.push_back( pActor );
|
2002-06-14 22:25:22 +00:00
|
|
|
}
|
2001-12-11 11:44:26 +00:00
|
|
|
|
2003-01-20 05:08:35 +00:00
|
|
|
void ActorFrame::MoveToTail( Actor* pActor )
|
2003-01-11 08:55:21 +00:00
|
|
|
{
|
|
|
|
|
vector<Actor*>::iterator iter = find( m_SubActors.begin(), m_SubActors.end(), pActor );
|
|
|
|
|
if( iter == m_SubActors.end() ) // didn't find
|
|
|
|
|
{
|
|
|
|
|
ASSERT(0); // called with a pActor that doesn't exist
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
m_SubActors.erase( iter );
|
|
|
|
|
m_SubActors.push_back( pActor );
|
|
|
|
|
}
|
|
|
|
|
|
2003-01-20 05:08:35 +00:00
|
|
|
void ActorFrame::MoveToHead( Actor* pActor )
|
2003-01-11 08:55:21 +00:00
|
|
|
{
|
|
|
|
|
vector<Actor*>::iterator iter = find( m_SubActors.begin(), m_SubActors.end(), pActor );
|
|
|
|
|
if( iter == m_SubActors.end() ) // didn't find
|
|
|
|
|
{
|
|
|
|
|
ASSERT(0); // called with a pActor that doesn't exist
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
m_SubActors.erase( iter );
|
|
|
|
|
m_SubActors.insert( m_SubActors.begin(), pActor );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2002-05-19 01:59:48 +00:00
|
|
|
void ActorFrame::DrawPrimitives()
|
2001-12-11 11:44:26 +00:00
|
|
|
{
|
2003-05-15 06:09:19 +00:00
|
|
|
// Don't set Actor-defined render states because we won't be drawing
|
|
|
|
|
// any geometry that belongs to this object.
|
|
|
|
|
// Actor::DrawPrimitives();
|
|
|
|
|
|
2002-01-16 10:01:32 +00:00
|
|
|
// draw all sub-ActorFrames while we're in the ActorFrame's local coordinate space
|
2004-01-11 07:12:13 +00:00
|
|
|
for( unsigned i=0; i<m_SubActors.size(); i++ )
|
2001-12-11 11:44:26 +00:00
|
|
|
m_SubActors[i]->Draw();
|
|
|
|
|
}
|
|
|
|
|
|
2004-01-11 07:12:13 +00:00
|
|
|
void ActorFrame::RunCommandOnChildren( const CString &cmd )
|
|
|
|
|
{
|
|
|
|
|
for( unsigned i=0; i<m_SubActors.size(); i++ )
|
|
|
|
|
m_SubActors[i]->Command( cmd );
|
|
|
|
|
}
|
2001-12-11 11:44:26 +00:00
|
|
|
|
|
|
|
|
void ActorFrame::Update( float fDeltaTime )
|
|
|
|
|
{
|
2002-07-31 19:40:40 +00:00
|
|
|
// LOG->Trace( "ActorFrame::Update( %f )", fDeltaTime );
|
2002-01-16 10:01:32 +00:00
|
|
|
Actor::Update( fDeltaTime );
|
2001-12-11 11:44:26 +00:00
|
|
|
|
2002-01-16 10:01:32 +00:00
|
|
|
// update all sub-Actors
|
2003-10-07 06:00:33 +00:00
|
|
|
for( vector<Actor*>::iterator it=m_SubActors.begin(); it!=m_SubActors.end(); it++ )
|
|
|
|
|
(*it)->Update(fDeltaTime);
|
2001-12-11 11:44:26 +00:00
|
|
|
}
|
|
|
|
|
|
2004-01-11 05:33:24 +00:00
|
|
|
#define PropagateActorFrameCommand( cmd, type ) \
|
|
|
|
|
void ActorFrame::cmd( type f ) \
|
|
|
|
|
{ \
|
|
|
|
|
Actor::cmd( f ); \
|
|
|
|
|
\
|
|
|
|
|
/* set all sub-Actors */ \
|
|
|
|
|
for( unsigned i=0; i<m_SubActors.size(); i++ ) \
|
|
|
|
|
m_SubActors[i]->cmd( f ); \
|
|
|
|
|
}
|
2001-12-11 11:44:26 +00:00
|
|
|
|
2004-01-11 05:33:24 +00:00
|
|
|
PropagateActorFrameCommand( SetDiffuse, RageColor )
|
|
|
|
|
PropagateActorFrameCommand( SetZTest, bool )
|
|
|
|
|
PropagateActorFrameCommand( SetZWrite, bool )
|
|
|
|
|
PropagateActorFrameCommand( HurryTweening, float )
|
2003-05-15 06:09:19 +00:00
|
|
|
|
2004-02-01 04:41:48 +00:00
|
|
|
void ActorFrame::SetDiffuseAlpha( float f )
|
|
|
|
|
{
|
|
|
|
|
Actor::SetDiffuseAlpha( f );
|
|
|
|
|
|
|
|
|
|
/* set all sub-Actors */
|
|
|
|
|
for( unsigned i=0; i<m_SubActors.size(); i++ )
|
|
|
|
|
m_SubActors[i]->SetDiffuseAlpha( f );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2003-07-20 01:32:42 +00:00
|
|
|
void ActorFrame::FinishTweening()
|
|
|
|
|
{
|
|
|
|
|
Actor::FinishTweening();
|
|
|
|
|
|
|
|
|
|
// set all sub-Actors
|
|
|
|
|
for( unsigned i=0; i<m_SubActors.size(); i++ )
|
|
|
|
|
m_SubActors[i]->FinishTweening();
|
|
|
|
|
}
|
|
|
|
|
|
2003-03-02 01:43:33 +00:00
|
|
|
float ActorFrame::GetTweenTimeLeft() const
|
2003-01-01 09:05:21 +00:00
|
|
|
{
|
2003-03-02 01:43:33 +00:00
|
|
|
float m = Actor::GetTweenTimeLeft();
|
2003-01-01 09:05:21 +00:00
|
|
|
|
|
|
|
|
for( unsigned i=0; i<m_SubActors.size(); i++ )
|
2003-03-02 01:43:33 +00:00
|
|
|
m = max(m, m_SubActors[i]->GetTweenTimeLeft());
|
2003-01-01 09:05:21 +00:00
|
|
|
|
|
|
|
|
return m;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
2003-06-20 23:07:45 +00:00
|
|
|
bool CompareActorsByZDesc(const Actor *p1, const Actor *p2)
|
2003-06-19 18:05:52 +00:00
|
|
|
{
|
2003-06-20 23:07:45 +00:00
|
|
|
return p1->GetZ() > p2->GetZ();
|
|
|
|
|
}
|
2003-06-19 18:05:52 +00:00
|
|
|
|
2003-06-20 23:07:45 +00:00
|
|
|
void ActorFrame::SortByZ()
|
|
|
|
|
{
|
|
|
|
|
// Preserve ordering of Actors with equal Z values.
|
|
|
|
|
stable_sort( m_SubActors.begin(), m_SubActors.end(), CompareActorsByZDesc );
|
2003-06-19 18:05:52 +00:00
|
|
|
}
|
2004-01-17 23:14:56 +00:00
|
|
|
|
|
|
|
|
void ActorFrame::DeleteAllChildren()
|
|
|
|
|
{
|
|
|
|
|
for( unsigned i=0; i<m_SubActors.size(); i++ )
|
|
|
|
|
delete m_SubActors[i];
|
|
|
|
|
m_SubActors.clear();
|
|
|
|
|
}
|
|
|
|
|
|
2004-01-20 03:31:08 +00:00
|
|
|
void ActorFrame::HandleCommand( const ParsedCommand &command )
|
|
|
|
|
{
|
|
|
|
|
Actor::HandleCommand( command );
|
|
|
|
|
}
|
2004-02-01 03:14:37 +00:00
|
|
|
|
|
|
|
|
void ActorFrame::GainingFocus( float fRate, bool bRewindMovie, bool bLoop )
|
|
|
|
|
{
|
|
|
|
|
for( unsigned i=0; i<m_SubActors.size(); i++ )
|
|
|
|
|
m_SubActors[i]->GainingFocus( fRate, bRewindMovie, bLoop );
|
|
|
|
|
|
|
|
|
|
SetDiffuse( RageColor(1,1,1,1) );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ActorFrame::LosingFocus()
|
|
|
|
|
{
|
|
|
|
|
for( unsigned i=0; i<m_SubActors.size(); i++ )
|
|
|
|
|
m_SubActors[i]->LosingFocus();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ActorFrame::PlayCommand( const CString &sCommandName )
|
|
|
|
|
{
|
|
|
|
|
for( unsigned i=0; i<m_SubActors.size(); i++ )
|
|
|
|
|
m_SubActors[i]->PlayCommand( sCommandName );
|
|
|
|
|
}
|