_Source, for real source paths in error messages
This commit is contained in:
@@ -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) )
|
||||
|
||||
@@ -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 );
|
||||
|
||||
Reference in New Issue
Block a user