ActorUtil::GetWhere

This commit is contained in:
Glenn Maynard
2006-10-09 08:08:17 +00:00
parent bf8ded44c6
commit 8e8a10f56c
2 changed files with 15 additions and 4 deletions
+14 -4
View File
@@ -194,11 +194,11 @@ Actor* ActorUtil::LoadFromNode( const RString& sDir, const XNode* pNode, Actor *
{ {
RString sName; RString sName;
if( !pChild->GetAttrValue( "Name", sName ) ) if( !pChild->GetAttrValue( "Name", sName ) )
Dialog::OK( ssprintf("Param node in '%s' is missing the attribute \"Name\"", sDir.c_str()), "MISSING_ATTRIBUTE" ); Dialog::OK( ssprintf("%s: Param: missing the attribute \"Name\"", ActorUtil::GetWhere(pNode).c_str()), "MISSING_ATTRIBUTE" );
Lua *L = LUA->Get(); Lua *L = LUA->Get();
if( !pChild->PushAttrValue( L, "Value" ) ) if( !pChild->PushAttrValue( L, "Value" ) )
Dialog::OK( ssprintf("Param node in '%s' is missing the attribute \"Value\"", sDir.c_str()), "MISSING_ATTRIBUTE" ); Dialog::OK( ssprintf("%s: Param: missing the attribute \"Value\"", ActorUtil::GetWhere(pNode).c_str()), "MISSING_ATTRIBUTE" );
SetParamFromStack( L, sName, &setOldParams[sName] ); SetParamFromStack( L, sName, &setOldParams[sName] );
LUA->Release(L); LUA->Release(L);
@@ -241,8 +241,8 @@ Actor* ActorUtil::LoadFromNode( const RString& sDir, const XNode* pNode, Actor *
* loading the layer we're in. */ * loading the layer we're in. */
if( sFile == "" ) if( sFile == "" )
{ {
RString sError = ssprintf( "The file \"%s\" is missing the File attribute or has an invalid Class \"%s\"", RString sError = ssprintf( "%s: missing the File attribute or has an invalid Class \"%s\"",
ActorUtil::GetSourcePath(pNode).c_str(), sClass.c_str() ); ActorUtil::GetWhere(pNode).c_str(), sClass.c_str() );
Dialog::OK( sError ); Dialog::OK( sError );
pReturn = new Actor; // Return a dummy object so that we don't crash in AutoActor later. pReturn = new Actor; // Return a dummy object so that we don't crash in AutoActor later.
goto all_done; goto all_done;
@@ -470,6 +470,16 @@ RString ActorUtil::GetSourcePath( const XNode *pNode )
return sRet; return sRet;
} }
RString ActorUtil::GetWhere( const XNode *pNode )
{
RString sPath = GetSourcePath( pNode );
int iLine;
if( pNode->GetAttrValue("_Line", iLine) )
sPath += ssprintf( ":%i", iLine );
return sPath;
}
bool ActorUtil::GetAttrPath( const XNode *pNode, const RString &sName, RString &sOut ) bool ActorUtil::GetAttrPath( const XNode *pNode, const RString &sName, RString &sOut )
{ {
if( !pNode->GetAttrValue(sName, sOut) ) if( !pNode->GetAttrValue(sName, sOut) )
+1
View File
@@ -72,6 +72,7 @@ namespace ActorUtil
Actor* LoadFromNode( const RString& sAniDir, const XNode* pNode, Actor *pParentActor = NULL ); Actor* LoadFromNode( const RString& sAniDir, const XNode* pNode, Actor *pParentActor = NULL );
Actor* MakeActor( const RString &sPath, const XNode *pParent = NULL, Actor *pParentActor = NULL ); Actor* MakeActor( const RString &sPath, const XNode *pParent = NULL, Actor *pParentActor = NULL );
RString GetSourcePath( const XNode *pNode ); RString GetSourcePath( const XNode *pNode );
RString GetWhere( const XNode *pNode );
bool GetAttrPath( const XNode *pNode, const RString &sName, RString &sOut ); bool GetAttrPath( const XNode *pNode, const RString &sName, RString &sOut );
void ResolvePath( RString &sPath, const RString &sName ); void ResolvePath( RString &sPath, const RString &sName );