From 7477cd1e4ffc0ef6ce194a39f97e99e8c8bfdf3a Mon Sep 17 00:00:00 2001 From: Glenn Maynard Date: Mon, 9 Oct 2006 07:42:18 +0000 Subject: [PATCH] _Source, for real source paths in error messages --- stepmania/src/ActorUtil.cpp | 18 ++++++++++++++++-- stepmania/src/ActorUtil.h | 1 + 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/stepmania/src/ActorUtil.cpp b/stepmania/src/ActorUtil.cpp index 9bebe8efbb..26fee22047 100644 --- a/stepmania/src/ActorUtil.cpp +++ b/stepmania/src/ActorUtil.cpp @@ -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) ) diff --git a/stepmania/src/ActorUtil.h b/stepmania/src/ActorUtil.h index 90789270c0..88fa40e2e8 100644 --- a/stepmania/src/ActorUtil.h +++ b/stepmania/src/ActorUtil.h @@ -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 );