This code creates actors, then loads nodes with their parameters

later.  Make this less of a special case: load the node normally,
and check that the resulting actor is the wanted type.
This commit is contained in:
Glenn Maynard
2006-10-15 05:53:26 +00:00
parent 116db99a92
commit d38897a6fd
2 changed files with 19 additions and 9 deletions
@@ -8,15 +8,13 @@ children = {
local Stats = STATSMAN:GetCurStageStats(); local Stats = STATSMAN:GetCurStageStats();
self:LoadFromStats( Stats, Stats:GetPlayerStageStats(Player) ) self:LoadFromStats( Stats, Stats:GetPlayerStageStats(Player) )
end, end,
-- Input = { Name="Player" }, Texture = LoadActor("LifeGraph p1")() .. {
Texture = Def.Layer {
File="LifeGraph p1",
InitCommand=cmd(ztest,1;diffusealpha,0), InitCommand=cmd(ztest,1;diffusealpha,0),
OnCommand=cmd(linear,0.5;diffusealpha,1), OnCommand=cmd(linear,0.5;diffusealpha,1),
OffCommand=cmd(linear,0.5;diffusealpha,0), OffCommand=cmd(linear,0.5;diffusealpha,0),
}, },
Line = Def.Layer { InitCommand=cmd(hidden,1) }, Line = Def.GraphLine { InitCommand=cmd(hidden,1) },
Body = Def.Layer { InitCommand=cmd(zwrite,1;blend,"BlendMode_NoEffect") }, Body = Def.GraphBody { InitCommand=cmd(zwrite,1;blend,"BlendMode_NoEffect") },
SongBoundary = Def.Actor { InitCommand=cmd(hidden,1) }, SongBoundary = Def.Actor { InitCommand=cmd(hidden,1) },
Barely = Def.Actor { InitCommand=cmd(hidden,1) }, Barely = Def.Actor { InitCommand=cmd(hidden,1) },
} }
+16 -4
View File
@@ -102,10 +102,13 @@ public:
} }
virtual Actor *Copy() const;
private: private:
vector<RageSpriteVertex> m_Quads; vector<RageSpriteVertex> m_Quads;
vector<RageSpriteVertex> m_pCircles; vector<RageSpriteVertex> m_pCircles;
}; };
REGISTER_ACTOR_CLASS( GraphLine )
class GraphBody: public Actor class GraphBody: public Actor
{ {
@@ -133,13 +136,16 @@ public:
DISPLAY->DrawQuadStrip( m_Slices, ARRAYLEN(m_Slices) ); DISPLAY->DrawQuadStrip( m_Slices, ARRAYLEN(m_Slices) );
} }
virtual Actor *Copy() const;
RageSpriteVertex m_Slices[2*VALUE_RESOLUTION]; RageSpriteVertex m_Slices[2*VALUE_RESOLUTION];
}; };
REGISTER_ACTOR_CLASS( GraphBody )
GraphDisplay::GraphDisplay() GraphDisplay::GraphDisplay()
{ {
m_pGraphLine = new GraphLine; m_pGraphLine = NULL;
m_pGraphBody = new GraphBody; m_pGraphBody = NULL;
} }
GraphDisplay::~GraphDisplay() GraphDisplay::~GraphDisplay()
@@ -158,7 +164,10 @@ void GraphDisplay::LoadFromNode( const XNode* pNode )
const XNode *pChild = pNode->GetChild( "Body" ); const XNode *pChild = pNode->GetChild( "Body" );
if( pChild == NULL ) if( pChild == NULL )
RageException::Throw( "%s: GraphDisplay: missing the node \"Body\"", ActorUtil::GetWhere(pNode).c_str() ); RageException::Throw( "%s: GraphDisplay: missing the node \"Body\"", ActorUtil::GetWhere(pNode).c_str() );
m_pGraphBody->LoadFromNode( pChild ); Actor *p = ActorUtil::LoadFromNode( pChild, this );
m_pGraphBody = dynamic_cast<GraphBody *>(p);
if( m_pGraphBody == NULL )
RageException::Throw( "%s: GraphDisplay: \"Body\" child is not a GraphBody", ActorUtil::GetWhere(pNode).c_str() );
this->AddChild( m_pGraphBody ); this->AddChild( m_pGraphBody );
pChild = pNode->GetChild( "Texture" ); pChild = pNode->GetChild( "Texture" );
@@ -172,7 +181,10 @@ void GraphDisplay::LoadFromNode( const XNode* pNode )
pChild = pNode->GetChild( "Line" ); pChild = pNode->GetChild( "Line" );
if( pChild == NULL ) if( pChild == NULL )
RageException::Throw( "%s: GraphDisplay: missing the node \"Line\"", ActorUtil::GetWhere(pNode).c_str() ); RageException::Throw( "%s: GraphDisplay: missing the node \"Line\"", ActorUtil::GetWhere(pNode).c_str() );
m_pGraphLine->LoadFromNode( pChild ); p = ActorUtil::LoadFromNode( pChild, this );
m_pGraphLine = dynamic_cast<GraphLine *>(p);
if( m_pGraphLine == NULL )
RageException::Throw( "%s: GraphDisplay: \"Body\" child is not a GraphLine", ActorUtil::GetWhere(pNode).c_str() );
this->AddChild( m_pGraphLine ); this->AddChild( m_pGraphLine );
pChild = pNode->GetChild( "SongBoundary" ); pChild = pNode->GetChild( "SongBoundary" );