Main Page | Namespace List | Class Hierarchy | Class List | File List | Namespace Members | Class Members | File Members

ActorUtil.h

Go to the documentation of this file.
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 /* convenience */ 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 // Return a Sprite, BitmapText, or Model depending on the file type 00037 Actor* LoadFromActorFile( const CString& sAniDir, const XNode* pNode ); 00038 Actor* MakeActor( const RageTextureID &ID ); 00039 }; 00040 00041 // creates the appropriate Actor derivitive on load and 00042 // automatically deletes Actor on deconstruction. 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 * (c) 2003-2004 Chris Danford 00065 * All rights reserved. 00066 * 00067 * Permission is hereby granted, free of charge, to any person obtaining a 00068 * copy of this software and associated documentation files (the 00069 * "Software"), to deal in the Software without restriction, including 00070 * without limitation the rights to use, copy, modify, merge, publish, 00071 * distribute, and/or sell copies of the Software, and to permit persons to 00072 * whom the Software is furnished to do so, provided that the above 00073 * copyright notice(s) and this permission notice appear in all copies of 00074 * the Software and that both the above copyright notice(s) and this 00075 * permission notice appear in supporting documentation. 00076 * 00077 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 00078 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 00079 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF 00080 * THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS 00081 * INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT 00082 * OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS 00083 * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR 00084 * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR 00085 * PERFORMANCE OF THIS SOFTWARE. 00086 */

Generated on Thu Jan 27 20:57:17 2005 for StepMania by doxygen 1.3.7