From 025ef162692b697128274b7a5f1e3cb9a8279acb Mon Sep 17 00:00:00 2001 From: Chris Danford Date: Thu, 27 Mar 2008 10:11:07 +0000 Subject: [PATCH] remove LoadFromNode, add PlayerState param --- stepmania/src/DifficultyDisplay.cpp | 22 ++++++++++------------ stepmania/src/DifficultyDisplay.h | 4 ++-- stepmania/src/DifficultyList.cpp | 2 +- 3 files changed, 13 insertions(+), 15 deletions(-) diff --git a/stepmania/src/DifficultyDisplay.cpp b/stepmania/src/DifficultyDisplay.cpp index 421efef687..1e70611939 100644 --- a/stepmania/src/DifficultyDisplay.cpp +++ b/stepmania/src/DifficultyDisplay.cpp @@ -12,6 +12,7 @@ #include "XmlFile.h" #include "LuaBinding.h" #include "GameManager.h" +#include "PlayerState.h" REGISTER_ACTOR_CLASS( DifficultyDisplay ); @@ -42,7 +43,7 @@ DifficultyDisplay::DifficultyDisplay() * so I'm trying it first in only this object. */ -void DifficultyDisplay::Load( const RString &sMetricsGroup ) +void DifficultyDisplay::Load( const RString &sMetricsGroup, const PlayerState *pPlayerState ) { m_sMetricsGroup = sMetricsGroup; @@ -106,19 +107,16 @@ void DifficultyDisplay::Load( const RString &sMetricsGroup ) this->AddChild( &m_sprStepsType ); } + // Play Load Command + PlayerState* pPlayerState_ = const_cast(pPlayerState); + Message msg("Load"); + if( pPlayerState_ ) + msg.SetParam( "PlayerState", LuaReference::CreateFromPush(*pPlayerState_) ); + this->HandleMessage( msg ); + Unset(); } -void DifficultyDisplay::LoadFromNode( const XNode* pNode ) -{ - ActorFrame::LoadFromNode( pNode ); - - RString s; - if( !pNode->GetAttrValue("Type", s) ) - RageException::Throw( "%s: DifficultyDisplay: missing the \"Type\" attribute", ActorUtil::GetWhere(pNode).c_str() ); - Load( s ); -} - void DifficultyDisplay::SetFromGameState( PlayerNumber pn ) { if( GAMESTATE->IsCourseMode() ) @@ -278,7 +276,7 @@ void DifficultyDisplay::SetInternal( const SetParams ¶ms ) class LunaDifficultyDisplay: public Luna { public: - static int Load( T* p, lua_State *L ) { p->Load( SArg(1) ); return 0; } + static int Load( T* p, lua_State *L ) { p->Load( SArg(1), NULL ); return 0; } static int SetFromStepsTypeAndMeterAndDifficulty( T* p, lua_State *L ) { p->SetFromStepsTypeAndMeterAndDifficulty( Enum::Check(L, 1), IArg(2), Enum::Check(L, 3) ); return 0; } static int SetFromSteps( T* p, lua_State *L ) { diff --git a/stepmania/src/DifficultyDisplay.h b/stepmania/src/DifficultyDisplay.h index 3444d3209b..3d26813b02 100644 --- a/stepmania/src/DifficultyDisplay.h +++ b/stepmania/src/DifficultyDisplay.h @@ -15,14 +15,14 @@ class Steps; class Trail; +class PlayerState; class DifficultyDisplay : public ActorFrame { public: DifficultyDisplay(); - void Load( const RString &sMetricsGroup ); - void LoadFromNode( const XNode* pNode ); + void Load( const RString &sMetricsGroup, const PlayerState *pPlayerState ); virtual DifficultyDisplay *Copy() const; diff --git a/stepmania/src/DifficultyList.cpp b/stepmania/src/DifficultyList.cpp index 218825bc0f..e77f484cda 100644 --- a/stepmania/src/DifficultyList.cpp +++ b/stepmania/src/DifficultyList.cpp @@ -68,7 +68,7 @@ void DifficultyList::LoadFromNode( const XNode* pNode ) for( unsigned m = 0; m < m_Lines.size(); ++m ) { m_Lines[m].m_Meter.SetName( "Row" ); - m_Lines[m].m_Meter.Load( "DifficultyDisplayListRow" ); + m_Lines[m].m_Meter.Load( "DifficultyDisplayListRow", NULL ); this->AddChild( &m_Lines[m].m_Meter ); }