_Source, for real source paths in error messages

This commit is contained in:
Glenn Maynard
2006-10-09 07:42:18 +00:00
parent 0c74193c2c
commit 7477cd1e4f
2 changed files with 17 additions and 2 deletions
+16 -2
View File
@@ -242,8 +242,8 @@ Actor* ActorUtil::LoadFromNode( const RString& sDir, const XNode* pNode, Actor *
* loading the layer we're in. */
if( sFile == "" )
{
RString sError = ssprintf( "An xml file in '%s' is missing the File attribute or has an invalid Class \"%s\"",
sDir.c_str(), sClass.c_str() );
RString sError = ssprintf( "The file \"%s\" is missing the File attribute or has an invalid Class \"%s\"",
ActorUtil::GetSourcePath(pNode).c_str(), sClass.c_str() );
Dialog::OK( sError );
pReturn = new Actor; // Return a dummy object so that we don't crash in AutoActor later.
goto all_done;
@@ -329,6 +329,10 @@ namespace
FOREACH_Child( pNode, pChild )
queue.push_back( pChild );
/* Source file, for error messages: */
pNode->AppendAttr( "_Source", sFile );
/* Directory of caller, for relative paths: */
pNode->AppendAttr( "_Dir", sDir );
}
@@ -459,6 +463,16 @@ Actor* ActorUtil::MakeActor( const RString &sPath_, const XNode *pParent, Actor
}
}
RString ActorUtil::GetSourcePath( const XNode *pNode )
{
RString sRet;
pNode->GetAttrValue( "_Source", sRet );
if( sRet.substr(0, 1) == "@" )
sRet.erase( 0, 1 );
return sRet;
}
bool ActorUtil::GetAttrPath( const XNode *pNode, const RString &sName, RString &sOut )
{
if( !pNode->GetAttrValue(sName, sOut) )
+1
View File
@@ -71,6 +71,7 @@ namespace ActorUtil
// Return a Sprite, BitmapText, or Model depending on the file type
Actor* LoadFromNode( const RString& sAniDir, const XNode* pNode, Actor *pParentActor = NULL );
Actor* MakeActor( const RString &sPath, const XNode *pParent = NULL, Actor *pParentActor = NULL );
RString GetSourcePath( const XNode *pNode );
bool GetAttrPath( const XNode *pNode, const RString &sName, RString &sOut );
void ResolvePath( RString &sPath, const RString &sName );