From c5086b20eba7bb29ad0451756bc891fa1793831d Mon Sep 17 00:00:00 2001 From: Glenn Maynard Date: Fri, 31 Oct 2003 00:50:06 +0000 Subject: [PATCH] Bump Util commands out of the header. --- stepmania/src/ActorUtil.cpp | 39 +++++++++++++++++++++++++++++++++++-- stepmania/src/ActorUtil.h | 32 ++++-------------------------- 2 files changed, 41 insertions(+), 30 deletions(-) diff --git a/stepmania/src/ActorUtil.cpp b/stepmania/src/ActorUtil.cpp index 3504b4a32e..ecd80c380e 100644 --- a/stepmania/src/ActorUtil.cpp +++ b/stepmania/src/ActorUtil.cpp @@ -15,6 +15,7 @@ #include "Sprite.h" #include "BitmapText.h" #include "Model.h" +#include "BGAnimation.h" #include "IniFile.h" #include "ThemeManager.h" #include "RageUtil_FileDB.h" @@ -90,7 +91,6 @@ Actor* MakeActor( RageTextureID ID ) CString sExt = GetExtension( ID.filename ); sExt.MakeLower(); - if( sExt=="actor" ) { return LoadActor( ID.filename ); @@ -114,7 +114,14 @@ Actor* MakeActor( RageTextureID ID ) pModel->LoadMilkshapeAscii( ID.filename ); return pModel; } - + /* Do this last, to avoid the IsADirectory in most cases. */ + else if( IsADirectory(ID.filename) ) + { + BGAnimation *pBGA = new BGAnimation; + pBGA->LoadFromAniDir( ID.filename ); + return pBGA; + } + else RageException::Throw("File \"%s\" has unknown type, \"%s\"", ID.filename.c_str(), sExt.c_str() ); } @@ -127,3 +134,31 @@ void IncorrectActorParametersWarning( const CStringArray &asTokens, int iMaxInde if( DISPLAY->IsWindowed() ) HOOKS->MessageBoxOK( sError ); } + +void UtilSetXY( Actor& actor, CString sClassName ) +{ + ASSERT( !actor.GetName().empty() ); + actor.SetXY( THEME->GetMetricF(sClassName,actor.GetName()+"X"), THEME->GetMetricF(sClassName,actor.GetName()+"Y") ); +} + +float UtilCommand( Actor& actor, CString sClassName, CString sCommandName ) +{ + ASSERT( !actor.GetName().empty() ); + return actor.Command( THEME->GetMetric(sClassName,actor.GetName()+sCommandName+"Command") ); +} + +float UtilOnCommand( Actor& actor, CString sClassName ) +{ + ASSERT( !actor.GetName().empty() ); + return actor.Command( THEME->GetMetric(sClassName,actor.GetName()+"OnCommand") ); +} + +float UtilOffCommand( Actor& actor, CString sClassName ) +{ + // HACK: It's very often that we command things to TweenOffScreen + // that we aren't drawing. We know that an Actor is not being + // used if it's name is blank. So, do nothing on Actors with a blank name. + if( actor.GetName().empty() ) + return 0; + return actor.Command( THEME->GetMetric(sClassName,actor.GetName()+"OffCommand") ); +} diff --git a/stepmania/src/ActorUtil.h b/stepmania/src/ActorUtil.h index 9555584ecb..193d08187a 100644 --- a/stepmania/src/ActorUtil.h +++ b/stepmania/src/ActorUtil.h @@ -12,7 +12,6 @@ */ #include "Actor.h" -#include "ThemeManager.h" #include "RageTexture.h" @@ -23,42 +22,19 @@ #define COMMAND( actor, command_name ) UtilCommand( actor, m_sName, command_name ) -inline void UtilSetXY( Actor& actor, CString sClassName ) -{ - ASSERT( !actor.GetName().empty() ); - actor.SetXY( THEME->GetMetricF(sClassName,actor.GetName()+"X"), THEME->GetMetricF(sClassName,actor.GetName()+"Y") ); -} +void UtilSetXY( Actor& actor, CString sClassName ); inline void UtilSetXY( Actor* pActor, CString sClassName ) { UtilSetXY( *pActor, sClassName ); } -inline float UtilOnCommand( Actor& actor, CString sClassName ) -{ - ASSERT( !actor.GetName().empty() ); - return actor.Command( THEME->GetMetric(sClassName,actor.GetName()+"OnCommand") ); -} +float UtilOnCommand( Actor& actor, CString sClassName ); inline float UtilOnCommand( Actor* pActor, CString sClassName ) { return UtilOnCommand( *pActor, sClassName ); } - -inline float UtilCommand( Actor& actor, CString sClassName, CString sCommandName ) -{ - ASSERT( !actor.GetName().empty() ); - return actor.Command( THEME->GetMetric(sClassName,actor.GetName()+sCommandName+"Command") ); -} +float UtilCommand( Actor& actor, CString sClassName, CString sCommandName ); inline float UtilCommand( Actor* pActor, CString sClassName, CString sCommandName ) { return UtilCommand( *pActor, sClassName, sCommandName ); } - -inline float UtilOffCommand( Actor& actor, CString sClassName ) -{ - // HACK: It's very often that we command things to TweenOffScreen - // that we aren't drawing. We know that an Actor is not being - // used if it's name is blank. So, do nothing on Actors with a blank name. - if( actor.GetName().empty() ) - return 0; - return actor.Command( THEME->GetMetric(sClassName,actor.GetName()+"OffCommand") ); -} +float UtilOffCommand( Actor& actor, CString sClassName ); inline float UtilOffCommand( Actor* pActor, CString sClassName ) { return UtilOffCommand( *pActor, sClassName ); } - inline float UtilSetXYAndOnCommand( Actor& actor, CString sClassName ) { UtilSetXY( actor, sClassName );