sType -> sMetricsGroup, add binding for LoadAllCommandsAndSetXY
This commit is contained in:
+19
-12
@@ -308,7 +308,7 @@ apActorCommands ActorUtil::ParseActorCommands( const RString &sCommands, const R
|
||||
return apActorCommands( pRet );
|
||||
}
|
||||
|
||||
void ActorUtil::SetXY( Actor& actor, const RString &sType )
|
||||
void ActorUtil::SetXY( Actor& actor, const RString &sMetricsGroup )
|
||||
{
|
||||
ASSERT( !actor.GetName().empty() );
|
||||
|
||||
@@ -317,31 +317,31 @@ void ActorUtil::SetXY( Actor& actor, const RString &sType )
|
||||
* these are both 0, leave the actor where it is. If InitCommand doesn't,
|
||||
* then 0,0 is the default, anyway.
|
||||
*/
|
||||
float fX = THEME->GetMetricF(sType,actor.GetName()+"X");
|
||||
float fY = THEME->GetMetricF(sType,actor.GetName()+"Y");
|
||||
float fX = THEME->GetMetricF(sMetricsGroup,actor.GetName()+"X");
|
||||
float fY = THEME->GetMetricF(sMetricsGroup,actor.GetName()+"Y");
|
||||
if( fX != 0 || fY != 0 )
|
||||
actor.SetXY( fX, fY );
|
||||
}
|
||||
|
||||
void ActorUtil::LoadCommand( Actor& actor, const RString &sType, const RString &sCommandName )
|
||||
void ActorUtil::LoadCommand( Actor& actor, const RString &sMetricsGroup, const RString &sCommandName )
|
||||
{
|
||||
ActorUtil::LoadCommandFromName( actor, sType, sCommandName, actor.GetName() );
|
||||
ActorUtil::LoadCommandFromName( actor, sMetricsGroup, sCommandName, actor.GetName() );
|
||||
}
|
||||
|
||||
void ActorUtil::LoadCommandFromName( Actor& actor, const RString &sType, const RString &sCommandName, const RString &sName )
|
||||
void ActorUtil::LoadCommandFromName( Actor& actor, const RString &sMetricsGroup, const RString &sCommandName, const RString &sName )
|
||||
{
|
||||
actor.AddCommand( sCommandName, THEME->GetMetricA(sType,sName+sCommandName+"Command") );
|
||||
actor.AddCommand( sCommandName, THEME->GetMetricA(sMetricsGroup,sName+sCommandName+"Command") );
|
||||
}
|
||||
|
||||
void ActorUtil::LoadAllCommands( Actor& actor, const RString &sType )
|
||||
void ActorUtil::LoadAllCommands( Actor& actor, const RString &sMetricsGroup )
|
||||
{
|
||||
LoadAllCommandsFromName( actor, sType, actor.GetName() );
|
||||
LoadAllCommandsFromName( actor, sMetricsGroup, actor.GetName() );
|
||||
}
|
||||
|
||||
void ActorUtil::LoadAllCommandsFromName( Actor& actor, const RString &sType, const RString &sName )
|
||||
void ActorUtil::LoadAllCommandsFromName( Actor& actor, const RString &sMetricsGroup, const RString &sName )
|
||||
{
|
||||
set<RString> vsValueNames;
|
||||
THEME->GetMetricsThatBeginWith( sType, sName, vsValueNames );
|
||||
THEME->GetMetricsThatBeginWith( sMetricsGroup, sName, vsValueNames );
|
||||
|
||||
FOREACHS_CONST( RString, vsValueNames, v )
|
||||
{
|
||||
@@ -350,7 +350,7 @@ void ActorUtil::LoadAllCommandsFromName( Actor& actor, const RString &sType, con
|
||||
if( EndsWith(sv,sEnding) )
|
||||
{
|
||||
RString sCommandName( sv.begin()+sName.size(), sv.end()-sEnding.size() );
|
||||
LoadCommandFromName( actor, sType, sCommandName, sName );
|
||||
LoadCommandFromName( actor, sMetricsGroup, sCommandName, sName );
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -435,12 +435,19 @@ namespace
|
||||
lua_pushboolean( L, IsRegistered(SArg(1)) );
|
||||
return 1;
|
||||
}
|
||||
static int LoadAllCommandsAndSetXY( lua_State *L )
|
||||
{
|
||||
Actor *p = Luna<Actor>::check( L, 1 );
|
||||
ActorUtil::LoadAllCommandsAndSetXY( p, SArg(2) );
|
||||
return 0;
|
||||
}
|
||||
|
||||
const luaL_Reg ActorUtilTable[] =
|
||||
{
|
||||
LIST_METHOD( GetFileType ),
|
||||
LIST_METHOD( ResolvePath ),
|
||||
LIST_METHOD( IsRegisteredClass ),
|
||||
LIST_METHOD( LoadAllCommandsAndSetXY ),
|
||||
{ NULL, NULL }
|
||||
};
|
||||
}
|
||||
|
||||
+21
-21
@@ -42,7 +42,7 @@ namespace ActorUtil
|
||||
void Register( const RString& sClassName, CreateActorFn pfn );
|
||||
|
||||
apActorCommands ParseActorCommands( const RString &sCommands, const RString &sName = "" );
|
||||
void SetXY( Actor& actor, const RString &sType );
|
||||
void SetXY( Actor& actor, const RString &sMetricsGroup );
|
||||
inline void PlayCommand( Actor& actor, const RString &sCommandName ) { actor.PlayCommand( sCommandName ); }
|
||||
inline void OnCommand( Actor& actor )
|
||||
{
|
||||
@@ -61,45 +61,45 @@ namespace ActorUtil
|
||||
actor.PlayCommand("Off");
|
||||
}
|
||||
|
||||
void LoadCommand( Actor& actor, const RString &sType, const RString &sCommandName );
|
||||
void LoadCommandFromName( Actor& actor, const RString &sType, const RString &sCommandName, const RString &sName );
|
||||
void LoadAllCommands( Actor& actor, const RString &sType );
|
||||
void LoadAllCommandsFromName( Actor& actor, const RString &sType, const RString &sName );
|
||||
void LoadCommand( Actor& actor, const RString &sMetricsGroup, const RString &sCommandName );
|
||||
void LoadCommandFromName( Actor& actor, const RString &sMetricsGroup, const RString &sCommandName, const RString &sName );
|
||||
void LoadAllCommands( Actor& actor, const RString &sMetricsGroup );
|
||||
void LoadAllCommandsFromName( Actor& actor, const RString &sMetricsGroup, const RString &sName );
|
||||
|
||||
inline void LoadAllCommandsAndSetXY( Actor& actor, const RString &sType )
|
||||
inline void LoadAllCommandsAndSetXY( Actor& actor, const RString &sMetricsGroup )
|
||||
{
|
||||
LoadAllCommands( actor, sType );
|
||||
SetXY( actor, sType );
|
||||
LoadAllCommands( actor, sMetricsGroup );
|
||||
SetXY( actor, sMetricsGroup );
|
||||
}
|
||||
inline void LoadAllCommandsAndOnCommand( Actor& actor, const RString &sType )
|
||||
inline void LoadAllCommandsAndOnCommand( Actor& actor, const RString &sMetricsGroup )
|
||||
{
|
||||
LoadAllCommands( actor, sType );
|
||||
LoadAllCommands( actor, sMetricsGroup );
|
||||
OnCommand( actor );
|
||||
}
|
||||
inline void SetXYAndOnCommand( Actor& actor, const RString &sType )
|
||||
inline void SetXYAndOnCommand( Actor& actor, const RString &sMetricsGroup )
|
||||
{
|
||||
SetXY( actor, sType );
|
||||
SetXY( actor, sMetricsGroup );
|
||||
OnCommand( actor );
|
||||
}
|
||||
inline void LoadAllCommandsAndSetXYAndOnCommand( Actor& actor, const RString &sType )
|
||||
inline void LoadAllCommandsAndSetXYAndOnCommand( Actor& actor, const RString &sMetricsGroup )
|
||||
{
|
||||
LoadAllCommands( actor, sType );
|
||||
SetXY( actor, sType );
|
||||
LoadAllCommands( actor, sMetricsGroup );
|
||||
SetXY( actor, sMetricsGroup );
|
||||
OnCommand( actor );
|
||||
}
|
||||
|
||||
/* convenience */
|
||||
inline void SetXY( Actor* pActor, const RString &sType ) { SetXY( *pActor, sType ); }
|
||||
inline void SetXY( Actor* pActor, const RString &sMetricsGroup ) { SetXY( *pActor, sMetricsGroup ); }
|
||||
inline void PlayCommand( Actor* pActor, const RString &sCommandName ) { if(pActor) pActor->PlayCommand( sCommandName ); }
|
||||
inline void OnCommand( Actor* pActor ) { if(pActor) ActorUtil::OnCommand( *pActor ); }
|
||||
inline void OffCommand( Actor* pActor ) { if(pActor) ActorUtil::OffCommand( *pActor ); }
|
||||
|
||||
inline void LoadAllCommands( Actor* pActor, const RString &sType ) { if(pActor) LoadAllCommands( *pActor, sType ); }
|
||||
inline void LoadAllCommands( Actor* pActor, const RString &sMetricsGroup ) { if(pActor) LoadAllCommands( *pActor, sMetricsGroup ); }
|
||||
|
||||
inline void LoadAllCommandsAndSetXY( Actor* pActor, const RString &sType ) { if(pActor) LoadAllCommandsAndSetXY( *pActor, sType ); }
|
||||
inline void LoadAllCommandsAndOnCommand( Actor* pActor, const RString &sType ) { if(pActor) LoadAllCommandsAndOnCommand( *pActor, sType ); }
|
||||
inline void SetXYAndOnCommand( Actor* pActor, const RString &sType ) { if(pActor) SetXYAndOnCommand( *pActor, sType ); }
|
||||
inline void LoadAllCommandsAndSetXYAndOnCommand( Actor* pActor, const RString &sType ) { if(pActor) LoadAllCommandsAndSetXYAndOnCommand( *pActor, sType ); }
|
||||
inline void LoadAllCommandsAndSetXY( Actor* pActor, const RString &sMetricsGroup ) { if(pActor) LoadAllCommandsAndSetXY( *pActor, sMetricsGroup ); }
|
||||
inline void LoadAllCommandsAndOnCommand( Actor* pActor, const RString &sMetricsGroup ) { if(pActor) LoadAllCommandsAndOnCommand( *pActor, sMetricsGroup ); }
|
||||
inline void SetXYAndOnCommand( Actor* pActor, const RString &sMetricsGroup ) { if(pActor) SetXYAndOnCommand( *pActor, sMetricsGroup ); }
|
||||
inline void LoadAllCommandsAndSetXYAndOnCommand( Actor* pActor, const RString &sMetricsGroup ) { if(pActor) LoadAllCommandsAndSetXYAndOnCommand( *pActor, sMetricsGroup ); }
|
||||
|
||||
// Return a Sprite, BitmapText, or Model depending on the file type
|
||||
Actor* LoadFromNode( const XNode* pNode, Actor *pParentActor = NULL );
|
||||
|
||||
Reference in New Issue
Block a user