00001
#ifndef ActorUtil_H
00002
#define ActorUtil_H
00003
00004
#include "Actor.h"
00005
#include "RageTexture.h"
00006
00007
struct XNode;
00008
00009 #define SET_XY( actor ) ActorUtil::SetXY( actor, m_sName )
00010 #define ON_COMMAND( actor ) ActorUtil::OnCommand( actor, m_sName )
00011 #define OFF_COMMAND( actor ) ActorUtil::OffCommand( actor, m_sName )
00012 #define SET_XY_AND_ON_COMMAND( actor ) ActorUtil::SetXYAndOnCommand( actor, m_sName )
00013 #define COMMAND( actor, command_name ) ActorUtil::RunCommand( actor, m_sName, command_name )
00014
00015 namespace ActorUtil
00016 {
00017
void SetXY(
Actor& actor,
const CString &sScreenName );
00018 inline void SetXY(
Actor* pActor,
const CString &sScreenName ) {
SetXY( *pActor, sScreenName ); }
00019
00020
void RunCommand(
Actor& actor,
const CString &sScreenName,
const CString &sCommandName );
00021
00022 inline void OnCommand(
Actor& actor,
const CString &sScreenName ) {
RunCommand( actor, sScreenName,
"On" ); }
00023 inline void OffCommand(
Actor& actor,
const CString &sScreenName ) {
RunCommand( actor, sScreenName,
"Off" ); }
00024 inline void SetXYAndOnCommand(
Actor& actor,
const CString &sScreenName )
00025 {
00026
SetXY( actor, sScreenName );
00027
OnCommand( actor, sScreenName );
00028 }
00029
00030
00031 inline void RunCommand(
Actor* pActor,
const CString &sScreenName,
const CString &sCommandName ) {
if(pActor)
RunCommand( *pActor, sScreenName, sCommandName ); }
00032 inline void OnCommand(
Actor* pActor,
const CString &sScreenName ) {
if(pActor)
OnCommand( *pActor, sScreenName ); }
00033 inline void OffCommand(
Actor* pActor,
const CString &sScreenName ) {
if(pActor)
OffCommand( *pActor, sScreenName ); }
00034 inline void SetXYAndOnCommand(
Actor* pActor,
const CString &sScreenName ) {
if(pActor)
SetXYAndOnCommand( *pActor, sScreenName ); }
00035
00036
00037
Actor*
LoadFromActorFile(
const CString& sAniDir,
const XNode* pNode );
00038
Actor*
MakeActor(
const RageTextureID &ID );
00039 };
00040
00041
00042
00043 class AutoActor
00044 {
00045
public:
00046 AutoActor() {
m_pActor = NULL; }
00047 ~AutoActor() {
Unload(); }
00048 operator const Actor* ()
const {
return m_pActor; }
00049 operator Actor* () {
return m_pActor; }
00050 const Actor *
operator->()
const {
return m_pActor; }
00051 Actor *
operator->() {
return m_pActor; }
00052 void Unload() {
if(
m_pActor) {
delete m_pActor;
m_pActor=NULL; } }
00053 bool IsLoaded()
const {
return m_pActor != NULL; }
00054
void Load(
const CString &sPath );
00055
void LoadAndSetName(
const CString &sScreenName,
const CString &sActorName );
00056
00057
protected:
00058 Actor*
m_pActor;
00059 };
00060
00061
#endif
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086