From d38897a6fd11fc5c97afd090b535de10277c715d Mon Sep 17 00:00:00 2001 From: Glenn Maynard Date: Sun, 15 Oct 2006 05:53:26 +0000 Subject: [PATCH] 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. --- .../life graph.lua | 8 +++----- stepmania/src/GraphDisplay.cpp | 20 +++++++++++++++---- 2 files changed, 19 insertions(+), 9 deletions(-) diff --git a/stepmania/Themes/default/BGAnimations/ScreenEvaluationStage overlay/life graph.lua b/stepmania/Themes/default/BGAnimations/ScreenEvaluationStage overlay/life graph.lua index 7d37ab2548..d26b97aee2 100644 --- a/stepmania/Themes/default/BGAnimations/ScreenEvaluationStage overlay/life graph.lua +++ b/stepmania/Themes/default/BGAnimations/ScreenEvaluationStage overlay/life graph.lua @@ -8,15 +8,13 @@ children = { local Stats = STATSMAN:GetCurStageStats(); self:LoadFromStats( Stats, Stats:GetPlayerStageStats(Player) ) end, - -- Input = { Name="Player" }, - Texture = Def.Layer { - File="LifeGraph p1", + Texture = LoadActor("LifeGraph p1")() .. { InitCommand=cmd(ztest,1;diffusealpha,0), OnCommand=cmd(linear,0.5;diffusealpha,1), OffCommand=cmd(linear,0.5;diffusealpha,0), }, - Line = Def.Layer { InitCommand=cmd(hidden,1) }, - Body = Def.Layer { InitCommand=cmd(zwrite,1;blend,"BlendMode_NoEffect") }, + Line = Def.GraphLine { InitCommand=cmd(hidden,1) }, + Body = Def.GraphBody { InitCommand=cmd(zwrite,1;blend,"BlendMode_NoEffect") }, SongBoundary = Def.Actor { InitCommand=cmd(hidden,1) }, Barely = Def.Actor { InitCommand=cmd(hidden,1) }, } diff --git a/stepmania/src/GraphDisplay.cpp b/stepmania/src/GraphDisplay.cpp index 73652a4a59..743ad44380 100644 --- a/stepmania/src/GraphDisplay.cpp +++ b/stepmania/src/GraphDisplay.cpp @@ -102,10 +102,13 @@ public: } + virtual Actor *Copy() const; + private: vector m_Quads; vector m_pCircles; }; +REGISTER_ACTOR_CLASS( GraphLine ) class GraphBody: public Actor { @@ -133,13 +136,16 @@ public: DISPLAY->DrawQuadStrip( m_Slices, ARRAYLEN(m_Slices) ); } + virtual Actor *Copy() const; + RageSpriteVertex m_Slices[2*VALUE_RESOLUTION]; }; +REGISTER_ACTOR_CLASS( GraphBody ) GraphDisplay::GraphDisplay() { - m_pGraphLine = new GraphLine; - m_pGraphBody = new GraphBody; + m_pGraphLine = NULL; + m_pGraphBody = NULL; } GraphDisplay::~GraphDisplay() @@ -158,7 +164,10 @@ void GraphDisplay::LoadFromNode( const XNode* pNode ) const XNode *pChild = pNode->GetChild( "Body" ); if( pChild == NULL ) 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(p); + if( m_pGraphBody == NULL ) + RageException::Throw( "%s: GraphDisplay: \"Body\" child is not a GraphBody", ActorUtil::GetWhere(pNode).c_str() ); this->AddChild( m_pGraphBody ); pChild = pNode->GetChild( "Texture" ); @@ -172,7 +181,10 @@ void GraphDisplay::LoadFromNode( const XNode* pNode ) pChild = pNode->GetChild( "Line" ); if( pChild == NULL ) 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(p); + if( m_pGraphLine == NULL ) + RageException::Throw( "%s: GraphDisplay: \"Body\" child is not a GraphLine", ActorUtil::GetWhere(pNode).c_str() ); this->AddChild( m_pGraphLine ); pChild = pNode->GetChild( "SongBoundary" );