put ActorUtil functions in a namespace

This commit is contained in:
Chris Danford
2005-01-17 05:42:52 +00:00
parent cda4c3b04a
commit 5d6eb1d236
9 changed files with 45 additions and 44 deletions
+1 -1
View File
@@ -29,7 +29,7 @@ void ActorFrame::LoadFromNode( const CString& sDir, const XNode* pNode )
{ {
FOREACH_CONST_Child( pChildren, pChild ) FOREACH_CONST_Child( pChildren, pChild )
{ {
Actor* pChildActor = LoadFromActorFile( sDir, pChild ); Actor* pChildActor = ActorUtil::LoadFromActorFile( sDir, pChild );
if( pChildActor ) if( pChildActor )
AddChild( pChildActor ); AddChild( pChildActor );
} }
+6 -6
View File
@@ -19,7 +19,7 @@
#include "arch/Dialog/Dialog.h" #include "arch/Dialog/Dialog.h"
Actor* LoadFromActorFile( const CString& sAniDir, const XNode* pNode ) Actor* ActorUtil::LoadFromActorFile( const CString& sAniDir, const XNode* pNode )
{ {
ASSERT( pNode ); ASSERT( pNode );
@@ -246,7 +246,7 @@ retry:
sNewPath = DerefRedir( sNewPath ); sNewPath = DerefRedir( sNewPath );
pActor = MakeActor( sNewPath ); pActor = ActorUtil::MakeActor( sNewPath );
if( pActor == NULL ) if( pActor == NULL )
return NULL; return NULL;
} }
@@ -259,7 +259,7 @@ retry:
return pActor; return pActor;
} }
Actor* MakeActor( const RageTextureID &ID ) Actor* ActorUtil::MakeActor( const RageTextureID &ID )
{ {
CString sExt = GetExtension( ID.filename ); CString sExt = GetExtension( ID.filename );
sExt.MakeLower(); sExt.MakeLower();
@@ -335,13 +335,13 @@ Actor* MakeActor( const RageTextureID &ID )
} }
} }
void UtilSetXY( Actor& actor, const CString &sScreenName ) void ActorUtil::SetXY( Actor& actor, const CString &sScreenName )
{ {
ASSERT( !actor.GetID().empty() ); ASSERT( !actor.GetID().empty() );
actor.SetXY( THEME->GetMetricF(sScreenName,actor.GetID()+"X"), THEME->GetMetricF(sScreenName,actor.GetID()+"Y") ); actor.SetXY( THEME->GetMetricF(sScreenName,actor.GetID()+"X"), THEME->GetMetricF(sScreenName,actor.GetID()+"Y") );
} }
void UtilCommand( Actor& actor, const CString &sScreenName, const CString &sCommandName ) void ActorUtil::Command( Actor& actor, const CString &sScreenName, const CString &sCommandName )
{ {
actor.PlayCommand( sCommandName ); actor.PlayCommand( sCommandName );
@@ -366,7 +366,7 @@ void UtilCommand( Actor& actor, const CString &sScreenName, const CString &sComm
void AutoActor::Load( const CString &sPath ) void AutoActor::Load( const CString &sPath )
{ {
Unload(); Unload();
m_pActor = MakeActor( sPath ); m_pActor = ActorUtil::MakeActor( sPath );
} }
void AutoActor::LoadAndSetName( const CString &sScreenName, const CString &sActorName ) void AutoActor::LoadAndSetName( const CString &sScreenName, const CString &sActorName )
+26 -25
View File
@@ -6,36 +6,37 @@
struct XNode; struct XNode;
#define SET_XY( actor ) UtilSetXY( actor, m_sName ) #define SET_XY( actor ) ActorUtil::SetXY( actor, m_sName )
#define ON_COMMAND( actor ) UtilOnCommand( actor, m_sName ) #define ON_COMMAND( actor ) ActorUtil::OnCommand( actor, m_sName )
#define OFF_COMMAND( actor ) UtilOffCommand( actor, m_sName ) #define OFF_COMMAND( actor ) ActorUtil::OffCommand( actor, m_sName )
#define SET_XY_AND_ON_COMMAND( actor ) UtilSetXYAndOnCommand( actor, m_sName ) #define SET_XY_AND_ON_COMMAND( actor ) ActorUtil::SetXYAndOnCommand( actor, m_sName )
#define COMMAND( actor, command_name ) UtilCommand( actor, m_sName, command_name ) #define COMMAND( actor, command_name ) ActorUtil::Command( actor, m_sName, command_name )
void UtilSetXY( Actor& actor, const CString &sScreenName ); namespace ActorUtil
inline void UtilSetXY( Actor* pActor, const CString &sScreenName ) { UtilSetXY( *pActor, sScreenName ); }
void UtilCommand( Actor& actor, const CString &sScreenName, const CString &sCommandName );
inline void UtilOnCommand( Actor& actor, const CString &sScreenName ) { UtilCommand( actor, sScreenName, "On" ); }
inline void UtilOffCommand( Actor& actor, const CString &sScreenName ) { UtilCommand( actor, sScreenName, "Off" ); }
inline void UtilSetXYAndOnCommand( Actor& actor, const CString &sScreenName )
{ {
UtilSetXY( actor, sScreenName ); void SetXY( Actor& actor, const CString &sScreenName );
UtilOnCommand( actor, sScreenName ); inline void SetXY( Actor* pActor, const CString &sScreenName ) { SetXY( *pActor, sScreenName ); }
}
/* convenience */ void Command( Actor& actor, const CString &sScreenName, const CString &sCommandName );
inline void UtilCommand( Actor* pActor, const CString &sScreenName, const CString &sCommandName ) { if(pActor) UtilCommand( *pActor, sScreenName, sCommandName ); }
inline void UtilOnCommand( Actor* pActor, const CString &sScreenName ) { if(pActor) UtilOnCommand( *pActor, sScreenName ); }
inline void UtilOffCommand( Actor* pActor, const CString &sScreenName ) { if(pActor) UtilOffCommand( *pActor, sScreenName ); }
inline void UtilSetXYAndOnCommand( Actor* pActor, const CString &sScreenName ) { if(pActor) UtilSetXYAndOnCommand( *pActor, sScreenName ); }
// Return a Sprite, BitmapText, or Model depending on the file type inline void OnCommand( Actor& actor, const CString &sScreenName ) { Command( actor, sScreenName, "On" ); }
Actor* LoadFromActorFile( const CString& sAniDir, const XNode* pNode ); inline void OffCommand( Actor& actor, const CString &sScreenName ) { Command( actor, sScreenName, "Off" ); }
Actor* MakeActor( const RageTextureID &ID ); inline void SetXYAndOnCommand( Actor& actor, const CString &sScreenName )
{
SetXY( actor, sScreenName );
OnCommand( actor, sScreenName );
}
/* convenience */
inline void Command( Actor* pActor, const CString &sScreenName, const CString &sCommandName ) { if(pActor) Command( *pActor, sScreenName, sCommandName ); }
inline void OnCommand( Actor* pActor, const CString &sScreenName ) { if(pActor) OnCommand( *pActor, sScreenName ); }
inline void OffCommand( Actor* pActor, const CString &sScreenName ) { if(pActor) OffCommand( *pActor, sScreenName ); }
inline void SetXYAndOnCommand( Actor* pActor, const CString &sScreenName ) { if(pActor) SetXYAndOnCommand( *pActor, sScreenName ); }
// Return a Sprite, BitmapText, or Model depending on the file type
Actor* LoadFromActorFile( const CString& sAniDir, const XNode* pNode );
Actor* MakeActor( const RageTextureID &ID );
};
// creates the appropriate Actor derivitive on load and // creates the appropriate Actor derivitive on load and
// automatically deletes Actor on deconstruction. // automatically deletes Actor on deconstruction.
+2 -2
View File
@@ -469,7 +469,7 @@ void BGAnimationLayer::LoadFromNode( const CString& sDir, const XNode* pNode )
{ {
case TYPE_SPRITE: case TYPE_SPRITE:
{ {
Actor* pActor = LoadFromActorFile( sAniDir, pNode ); Actor* pActor = ActorUtil::LoadFromActorFile( sAniDir, pNode );
this->AddChild( pActor ); this->AddChild( pActor );
if( bStretch ) if( bStretch )
pActor->StretchTo( FullScreenRectF ); pActor->StretchTo( FullScreenRectF );
@@ -494,7 +494,7 @@ void BGAnimationLayer::LoadFromNode( const CString& sDir, const XNode* pNode )
for( int i=0; i<iNumParticles; i++ ) for( int i=0; i<iNumParticles; i++ )
{ {
Actor* pActor = MakeActor( sPath ); Actor* pActor = ActorUtil::MakeActor( sPath );
if( pActor == NULL ) if( pActor == NULL )
continue; continue;
this->AddChild( pActor ); this->AddChild( pActor );
+1 -1
View File
@@ -99,7 +99,7 @@ void MusicWheel::Load()
m_sprHighlight.Load( THEME->GetPathToG("MusicWheel highlight") ); m_sprHighlight.Load( THEME->GetPathToG("MusicWheel highlight") );
m_sprHighlight->SetName( "Highlight" ); m_sprHighlight->SetName( "Highlight" );
this->AddChild( m_sprHighlight ); this->AddChild( m_sprHighlight );
UtilOnCommand( m_sprHighlight, "MusicWheel" ); ActorUtil::OnCommand( m_sprHighlight, "MusicWheel" );
m_ScrollBar.SetX( SCROLL_BAR_X ); m_ScrollBar.SetX( SCROLL_BAR_X );
m_ScrollBar.SetBarHeight( SCROLL_BAR_HEIGHT ); m_ScrollBar.SetBarHeight( SCROLL_BAR_HEIGHT );
+1 -1
View File
@@ -129,7 +129,7 @@ static NoteResource *MakeNoteResource( const CString &sPath, bool bSpriteOnly )
} }
else else
{ {
pRes->m_pActor = MakeActor( sPath ); pRes->m_pActor = ActorUtil::MakeActor( sPath );
ASSERT( pRes->m_pActor ); ASSERT( pRes->m_pActor );
} }
+1 -1
View File
@@ -260,7 +260,7 @@ void ScreenNetSelectBase::UpdateUsers()
void UtilSetQuadInit( Actor& actor, const CString &sClassName ) void UtilSetQuadInit( Actor& actor, const CString &sClassName )
{ {
UtilSetXYAndOnCommand( actor, sClassName ); ActorUtil::SetXYAndOnCommand( actor, sClassName );
actor.SetDiffuse( THEME->GetMetricC( sClassName, actor.m_sName + "Color" ) ); actor.SetDiffuse( THEME->GetMetricC( sClassName, actor.m_sName + "Color" ) );
actor.SetWidth( THEME->GetMetricF( sClassName, actor.m_sName + "Width" ) ); actor.SetWidth( THEME->GetMetricF( sClassName, actor.m_sName + "Width" ) );
actor.SetHeight( THEME->GetMetricF( sClassName, actor.m_sName + "Height" ) ); actor.SetHeight( THEME->GetMetricF( sClassName, actor.m_sName + "Height" ) );
+1 -1
View File
@@ -127,7 +127,7 @@ void ScreenPlayerOptions::Input( const DeviceInput& DeviceI, const InputEventTyp
GAMESTATE->m_pPlayerState[pn]->m_PlayerOptions.Init(); GAMESTATE->m_pPlayerState[pn]->m_PlayerOptions.Init();
GAMESTATE->m_pPlayerState[pn]->m_PlayerOptions.FromString( PREFSMAN->m_sDefaultModifiers ); GAMESTATE->m_pPlayerState[pn]->m_PlayerOptions.FromString( PREFSMAN->m_sDefaultModifiers );
UtilCommand( m_sprCancelAll[pn], m_sName, "Show" ); ActorUtil::Command( m_sprCancelAll[pn], m_sName, "Show" );
this->ImportOptionsForPlayer( pn ); this->ImportOptionsForPlayer( pn );
this->PositionUnderlines(); this->PositionUnderlines();
+6 -6
View File
@@ -126,15 +126,15 @@ void ScreenWithMenuElements::StartTransitioning( ScreenMessage smSendWhenDone )
{ {
m_MenuTimer->SetSeconds( 0 ); m_MenuTimer->SetSeconds( 0 );
m_MenuTimer->Stop(); m_MenuTimer->Stop();
UtilOffCommand( m_MenuTimer, m_sName ); ActorUtil::OffCommand( m_MenuTimer, m_sName );
} }
UtilOffCommand( m_autoHeader, m_sName ); ActorUtil::OffCommand( m_autoHeader, m_sName );
UtilOffCommand( m_sprStyleIcon, m_sName ); ActorUtil::OffCommand( m_sprStyleIcon, m_sName );
FOREACH_PlayerNumber( p ) FOREACH_PlayerNumber( p )
UtilOffCommand( m_MemoryCardDisplay[p], m_sName ); ActorUtil::OffCommand( m_MemoryCardDisplay[p], m_sName );
UtilOffCommand( m_autoFooter, m_sName ); ActorUtil::OffCommand( m_autoFooter, m_sName );
UtilOffCommand( m_textHelp, m_sName ); ActorUtil::OffCommand( m_textHelp, m_sName );
OFF_COMMAND( m_sprOverlay ); OFF_COMMAND( m_sprOverlay );
SCREENMAN->PlaySharedBackgroundOffCommand(); SCREENMAN->PlaySharedBackgroundOffCommand();