merge ActorUtil::Create into ActorUtil::LoadFromNode
This commit is contained in:
+10
-17
@@ -32,21 +32,6 @@ void ActorUtil::Register( const RString& sClassName, CreateActorFn pfn )
|
|||||||
(*g_pmapRegistrees)[sClassName] = pfn;
|
(*g_pmapRegistrees)[sClassName] = pfn;
|
||||||
}
|
}
|
||||||
|
|
||||||
Actor* ActorUtil::Create( const RString& sClassName, const XNode* pNode, Actor *pParentActor )
|
|
||||||
{
|
|
||||||
map<RString,CreateActorFn>::iterator iter = g_pmapRegistrees->find( sClassName );
|
|
||||||
ASSERT_M( iter != g_pmapRegistrees->end(), ssprintf("Actor '%s' is not registered.",sClassName.c_str()) );
|
|
||||||
|
|
||||||
const CreateActorFn &pfn = iter->second;
|
|
||||||
Actor *pRet = pfn();
|
|
||||||
|
|
||||||
if( pParentActor )
|
|
||||||
pRet->SetParent( pParentActor );
|
|
||||||
|
|
||||||
pRet->LoadFromNode( pNode );
|
|
||||||
return pRet;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool ActorUtil::ResolvePath( RString &sPath, const RString &sName )
|
bool ActorUtil::ResolvePath( RString &sPath, const RString &sName )
|
||||||
{
|
{
|
||||||
retry:
|
retry:
|
||||||
@@ -130,7 +115,8 @@ Actor* ActorUtil::LoadFromNode( const XNode* pNode, Actor *pParentActor )
|
|||||||
RString sClass;
|
RString sClass;
|
||||||
pNode->GetAttrValue( "Class", sClass );
|
pNode->GetAttrValue( "Class", sClass );
|
||||||
|
|
||||||
if( !IsRegistered(sClass) )
|
map<RString,CreateActorFn>::iterator iter = g_pmapRegistrees->find( sClass );
|
||||||
|
if( iter == g_pmapRegistrees->end() )
|
||||||
{
|
{
|
||||||
// sClass is invalid
|
// sClass is invalid
|
||||||
RString sError = ssprintf( "%s: invalid Class \"%s\"",
|
RString sError = ssprintf( "%s: invalid Class \"%s\"",
|
||||||
@@ -139,7 +125,14 @@ Actor* ActorUtil::LoadFromNode( const XNode* pNode, Actor *pParentActor )
|
|||||||
return new Actor; // Return a dummy object so that we don't crash in AutoActor later.
|
return new Actor; // Return a dummy object so that we don't crash in AutoActor later.
|
||||||
}
|
}
|
||||||
|
|
||||||
return ActorUtil::Create( sClass, pNode, pParentActor );
|
const CreateActorFn &pfn = iter->second;
|
||||||
|
Actor *pRet = pfn();
|
||||||
|
|
||||||
|
if( pParentActor )
|
||||||
|
pRet->SetParent( pParentActor );
|
||||||
|
|
||||||
|
pRet->LoadFromNode( pNode );
|
||||||
|
return pRet;
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace
|
namespace
|
||||||
|
|||||||
@@ -40,7 +40,6 @@ namespace ActorUtil
|
|||||||
{
|
{
|
||||||
// Every screen should register its class at program initialization.
|
// Every screen should register its class at program initialization.
|
||||||
void Register( const RString& sClassName, CreateActorFn pfn );
|
void Register( const RString& sClassName, CreateActorFn pfn );
|
||||||
Actor* Create( const RString& sClassName, const XNode* pNode, Actor *pParentActor );
|
|
||||||
|
|
||||||
apActorCommands ParseActorCommands( const RString &sCommands, const RString &sName = "" );
|
apActorCommands ParseActorCommands( const RString &sCommands, const RString &sName = "" );
|
||||||
void SetXY( Actor& actor, const RString &sType );
|
void SetXY( Actor& actor, const RString &sType );
|
||||||
|
|||||||
Reference in New Issue
Block a user