iterate over each Attrib only one, not 8 times while searching for name matches
This commit is contained in:
+28
-36
@@ -190,17 +190,19 @@ Actor::Actor( const Actor &cpy )
|
|||||||
|
|
||||||
void Actor::LoadFromNode( const CString& sDir, const XNode* pNode )
|
void Actor::LoadFromNode( const CString& sDir, const XNode* pNode )
|
||||||
{
|
{
|
||||||
// Load Name, if any.
|
FOREACH_CONST_Attr( pNode, pAttr )
|
||||||
pNode->GetAttrValue( "Name", m_sName );
|
|
||||||
|
|
||||||
FOREACH_CONST_Attr( pNode, pChild )
|
|
||||||
{
|
{
|
||||||
if( pChild->m_sName == "Input" )
|
// Load Name, if any.
|
||||||
|
if( pAttr->m_sName == "Name" )
|
||||||
|
{
|
||||||
|
m_sName = pAttr->m_sValue;
|
||||||
|
}
|
||||||
|
else if( pAttr->m_sName == "Input" )
|
||||||
{
|
{
|
||||||
/* Parameters are set as globals by ActorUtil::LoadFromActorFile.
|
/* Parameters are set as globals by ActorUtil::LoadFromActorFile.
|
||||||
* If parameters are specified here, save them to the actor. Accessing
|
* If parameters are specified here, save them to the actor. Accessing
|
||||||
* parameters as globals directly is deprecated. */
|
* parameters as globals directly is deprecated. */
|
||||||
const CString &sName = pChild->m_sValue;
|
const CString &sName = pAttr->m_sValue;
|
||||||
|
|
||||||
Lua *L = LUA->Get();
|
Lua *L = LUA->Get();
|
||||||
this->PushSelf( L );
|
this->PushSelf( L );
|
||||||
@@ -214,38 +216,28 @@ void Actor::LoadFromNode( const CString& sDir, const XNode* pNode )
|
|||||||
lua_pop( L, 1 );
|
lua_pop( L, 1 );
|
||||||
LUA->Release( L );
|
LUA->Release( L );
|
||||||
}
|
}
|
||||||
}
|
else if( pAttr->m_sName == "BaseRotationXDegrees" ) SetBaseRotationX( atof( pAttr->m_sValue ) );
|
||||||
|
else if( pAttr->m_sName == "BaseRotationYDegrees" ) SetBaseRotationY( atof( pAttr->m_sValue ) );
|
||||||
|
else if( pAttr->m_sName == "BaseRotationZDegrees" ) SetBaseRotationZ( atof( pAttr->m_sValue ) );
|
||||||
|
else if( pAttr->m_sName == "BaseZoomX" ) SetBaseZoomX( atof( pAttr->m_sValue ) );
|
||||||
|
else if( pAttr->m_sName == "BaseZoomY" ) SetBaseZoomY( atof( pAttr->m_sValue ) );
|
||||||
|
else if( pAttr->m_sName == "BaseZoomZ" ) SetBaseZoomZ( atof( pAttr->m_sValue ) );
|
||||||
|
else if( EndsWith(pAttr->m_sName,"Command") )
|
||||||
|
{
|
||||||
|
CString sKeyName = pAttr->m_sName; /* "OnCommand" */
|
||||||
|
|
||||||
float f;
|
CString sValue = pAttr->m_sValue;
|
||||||
if( pNode->GetAttrValue( "BaseRotationXDegrees", f ) ) SetBaseRotationX( f );
|
THEME->EvaluateString( sValue );
|
||||||
if( pNode->GetAttrValue( "BaseRotationYDegrees", f ) ) SetBaseRotationY( f );
|
apActorCommands apac( new ActorCommands( sValue ) );
|
||||||
if( pNode->GetAttrValue( "BaseRotationZDegrees", f ) ) SetBaseRotationZ( f );
|
|
||||||
if( pNode->GetAttrValue( "BaseZoomX", f ) ) SetBaseZoomX( f );
|
|
||||||
if( pNode->GetAttrValue( "BaseZoomY", f ) ) SetBaseZoomY( f );
|
|
||||||
if( pNode->GetAttrValue( "BaseZoomZ", f ) ) SetBaseZoomZ( f );
|
|
||||||
|
|
||||||
|
CString sCmdName;
|
||||||
//
|
/* Special case: "Command=foo" -> "OnCommand=foo" */
|
||||||
// Load command attributes
|
if( sKeyName.size() == 7 )
|
||||||
//
|
sCmdName="On";
|
||||||
FOREACH_CONST_Attr( pNode, a )
|
else
|
||||||
{
|
sCmdName = sKeyName.Left( sKeyName.size()-7 );
|
||||||
CString sKeyName = a->m_sName; /* "OnCommand" */
|
AddCommand( sCmdName, apac );
|
||||||
|
}
|
||||||
if( sKeyName.Right(7).CompareNoCase("Command") != 0 )
|
|
||||||
continue; /* not a command */
|
|
||||||
|
|
||||||
CString sValue = a->m_sValue;
|
|
||||||
THEME->EvaluateString( sValue );
|
|
||||||
apActorCommands apac( new ActorCommands( sValue ) );
|
|
||||||
|
|
||||||
CString sCmdName;
|
|
||||||
/* Special case: "Command=foo" -> "OnCommand=foo" */
|
|
||||||
if( sKeyName.size() == 7 )
|
|
||||||
sCmdName="On";
|
|
||||||
else
|
|
||||||
sCmdName = sKeyName.Left( sKeyName.size()-7 );
|
|
||||||
AddCommand( sCmdName, apac );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
|
|||||||
Reference in New Issue
Block a user