From 8a6f6a71249f142e4e7b4411a5df6df59189c515 Mon Sep 17 00:00:00 2001 From: Kyzentun Date: Mon, 14 Jul 2014 18:02:28 -0600 Subject: [PATCH] ActorUtil::ResolvePath updated for error reporting. Changed BitmapText to work with either a font name or a path. ThemeManager::GetPathInfoRaw fixed to use correct error dialog. ThemeManager::GetPathInfo fixed to report correct error for missing theme elements. --- src/ActorUtil.cpp | 4 ++-- src/BitmapText.cpp | 28 +++++++++++++++------------- src/ThemeManager.cpp | 11 ++++++----- 3 files changed, 23 insertions(+), 20 deletions(-) diff --git a/src/ActorUtil.cpp b/src/ActorUtil.cpp index a8a50dd550..3d48573c6c 100644 --- a/src/ActorUtil.cpp +++ b/src/ActorUtil.cpp @@ -55,7 +55,7 @@ bool ActorUtil::ResolvePath( RString &sPath, const RString &sName ) if( asPaths.empty() ) { RString sError = ssprintf( "%s: references a file \"%s\" which doesn't exist", sName.c_str(), sPath.c_str() ); - switch( Dialog::AbortRetryIgnore( sError, "BROKEN_FILE_REFERENCE" ) ) + switch(LuaHelpers::ReportScriptError(sError, "BROKEN_FILE_REFERENCE", true)) { case Dialog::abort: RageException::Throw( "%s", sError.c_str() ); @@ -76,7 +76,7 @@ bool ActorUtil::ResolvePath( RString &sPath, const RString &sName ) { RString sError = ssprintf( "%s: references a file \"%s\" which has multiple matches", sName.c_str(), sPath.c_str() ); sError += "\n" + join( "\n", asPaths ); - switch( Dialog::AbortRetryIgnore( sError, "BROKEN_FILE_REFERENCE" ) ) + switch(LuaHelpers::ReportScriptError(sError, "BROKEN_FILE_REFERENCE", true)) { case Dialog::abort: RageException::Throw( "%s", sError.c_str() ); diff --git a/src/BitmapText.cpp b/src/BitmapText.cpp index 3fc7525637..fd55c067d2 100644 --- a/src/BitmapText.cpp +++ b/src/BitmapText.cpp @@ -126,21 +126,23 @@ void BitmapText::LoadFromNode( const XNode* pNode ) ThemeManager::EvaluateString( sAltText ); RString sFont; - // The short circuiting loading condition that was here before wasn't short circuiting correctly on all platforms. - if(!ActorUtil::GetAttrPath(pNode, "Font", sFont)) + // Allow the Font attribute to be either a path or simply the name of a font. + // If it's a path, it will have a slash in it. + // Also allow it to be set through either "Font" or through "File". + if(!pNode->GetAttrValue("Font", sFont) && !pNode->GetAttrValue("File", sFont)) { - if(!ActorUtil::GetAttrPath(pNode, "File", sFont)) - { - if( !pNode->GetAttrValue("Font", sFont) && - !pNode->GetAttrValue("File", sFont) ) // accept "File" for backward compatibility - { - LuaHelpers::ReportScriptErrorFmt( "%s: BitmapText: Font or File attribute not found", - ActorUtil::GetWhere(pNode).c_str() ); - sFont = "Common Normal"; - } - } + LuaHelpers::ReportScriptErrorFmt("%s: BitmapText: Font or File attribute not found", + ActorUtil::GetWhere(pNode).c_str()); + sFont = "Common Normal"; + } + if(sFont.find("/") == RString::npos) + { + sFont= THEME->GetPathF("", sFont); + } + else if(!ActorUtil::ResolvePath(sFont, ActorUtil::GetWhere(pNode))) + { + sFont= THEME->GetPathF("", "Common Normal"); } - sFont = THEME->GetPathF( "", sFont ); LoadFromFont( sFont ); diff --git a/src/ThemeManager.cpp b/src/ThemeManager.cpp index b8adc806b5..fbf70293a6 100644 --- a/src/ThemeManager.cpp +++ b/src/ThemeManager.cpp @@ -722,7 +722,7 @@ bool ThemeManager::GetPathInfoToRaw( PathInfo &out, const RString &sThemeName_, "Verify that this redirect is correct.", sPath.c_str(), sNewFileName.c_str()); - switch( LuaHelpers::ReportScriptError(sMessage) ) + switch(LuaHelpers::ReportScriptError(sMessage, "", true)) { case Dialog::retry: ReloadMetrics(); @@ -815,11 +815,12 @@ try_element_again: goto try_element_again; case Dialog::ignore: { - RString error= ssprintf(sCategory + '/' + sFileName, - "could not be found in \"%s\" or \"%s\".", - GetThemeDirFromName(m_sCurThemeName).c_str(), - GetThemeDirFromName(SpecialFiles::BASE_THEME_NAME).c_str() ); + RString error= sCategory + '/' + sFileName + + " could not be found in \"" + + GetThemeDirFromName(m_sCurThemeName).c_str() + "\" or \"" + + GetThemeDirFromName(SpecialFiles::BASE_THEME_NAME).c_str() + "\"."; LOG->UserLog("Theme element", "%s", error.c_str()); + LOG->Warn(error.c_str()); LuaHelpers::ScriptErrorMessage(error); }