search redirs in note skins like we do in themes

This commit is contained in:
Glenn Maynard
2004-02-17 08:55:33 +00:00
parent 6c7f3fb898
commit a7d86a8e13
2 changed files with 55 additions and 42 deletions
+53 -41
View File
@@ -231,25 +231,29 @@ CString NoteSkinManager::GetPathToFromPlayerAndButton( PlayerNumber pn, CString
return GetPathToFromNoteSkinAndButton( sNoteSkinName, sButtonName, sElement, bOptional ); return GetPathToFromNoteSkinAndButton( sNoteSkinName, sButtonName, sElement, bOptional );
} }
CString NoteSkinManager::GetPathToFromNoteSkinAndButtonInternal( CString NoteSkin, CString sButtonName, CString sElement )
{
CString ret;
if( ret.empty() )
ret = GetPathToFromDir( GetNoteSkinDir(NoteSkin), sButtonName+" "+sElement );
if( ret.empty() ) // Search game default NoteSkin
ret = GetPathToFromDir( GetNoteSkinDir(GAME_BASE_NOTESKIN_NAME), sButtonName+" "+sElement );
if( ret.empty() ) // Search global default NoteSkin
ret = GetPathToFromDir( GLOBAL_BASE_NOTESKIN_DIR, "Fallback "+sElement );
return ret;
}
CString NoteSkinManager::GetPathToFromNoteSkinAndButton( CString NoteSkin, CString sButtonName, CString sElement, bool bOptional ) CString NoteSkinManager::GetPathToFromNoteSkinAndButton( CString NoteSkin, CString sButtonName, CString sElement, bool bOptional )
{ {
CString ret = GetPathToFromDir( GetNoteSkinDir(NoteSkin), sButtonName+" "+sElement ); CString sPath = GetPathToFromNoteSkinAndButtonInternal( NoteSkin, sButtonName, sElement );
if( !ret.empty() ) // we found something if( sPath == "" )
return ret; {
// Search game default NoteSkin
ret = GetPathToFromDir( GetNoteSkinDir(GAME_BASE_NOTESKIN_NAME), sButtonName+" "+sElement );
if( !ret.empty() ) // we found something
return ret;
// Search global default NoteSkin
ret = GetPathToFromDir( GLOBAL_BASE_NOTESKIN_DIR, "Fallback "+sElement );
if( !ret.empty() ) // we found something
return ret;
if( bOptional ) if( bOptional )
return ""; {
else g_Cache[CacheString] = sPath;
return sPath;
}
RageException::Throw( "The NoteSkin element '%s %s' could not be found in '%s', '%s', or '%s'.", RageException::Throw( "The NoteSkin element '%s %s' could not be found in '%s', '%s', or '%s'.",
sButtonName.c_str(), sElement.c_str(), sButtonName.c_str(), sElement.c_str(),
GetNoteSkinDir(NoteSkin).c_str(), GetNoteSkinDir(NoteSkin).c_str(),
@@ -257,6 +261,38 @@ CString NoteSkinManager::GetPathToFromNoteSkinAndButton( CString NoteSkin, CStri
GLOBAL_BASE_NOTESKIN_DIR.c_str() ); GLOBAL_BASE_NOTESKIN_DIR.c_str() );
} }
while( GetExtension(sPath) == "redir" )
{
CString sNewFileName = GetRedirContents(sPath);
CString sRealPath;
if( sRealPath == "" )
sRealPath = GetPathToFromDir( GetNoteSkinDir(NoteSkin), sNewFileName );
if( sRealPath == "" )
sRealPath = GetPathToFromDir( GetNoteSkinDir(GAME_BASE_NOTESKIN_NAME), sNewFileName );
if( sRealPath == "" )
sRealPath = GetPathToFromDir( GLOBAL_BASE_NOTESKIN_DIR, sNewFileName );
if( sRealPath == "" )
{
CString message = ssprintf(
"NoteSkinManager: The redirect '%s' points to the file '%s', which does not exist. "
"Verify that this redirect is correct.",
sPath.c_str(), sNewFileName.c_str());
if( ArchHooks::retry == HOOKS->MessageBoxAbortRetryIgnore(message) )
{
FlushDirCache();
continue;
}
RageException::Throw( "%s", message.c_str() );
}
sPath = sRealPath;
}
return sPath;
}
CString NoteSkinManager::GetPathToFromDir( CString sDir, CString sFileName ) CString NoteSkinManager::GetPathToFromDir( CString sDir, CString sFileName )
{ {
@@ -281,29 +317,5 @@ CString NoteSkinManager::GetPathToFromDir( CString sDir, CString sFileName )
HOOKS->MessageBoxOK( sError ); HOOKS->MessageBoxOK( sError );
} }
CString sPath = matches[0]; return matches[0];
bool bIsARedirect = GetExtension(sPath).CompareNoCase("redir")==0;
if( !bIsARedirect )
{
return sPath;
}
else // bIsARedirect
{
CString sNewFileName = GetRedirContents(sPath);
CString sNewPath = GetPathToFromDir(sDir, sNewFileName);
if( !sNewPath.empty() )
return sNewPath;
else
{
CString message = ssprintf(
"ThemeManager: The redirect '%s' points to the file '%s', which does not exist. "
"Verify that this redirect is correct.",
sPath.c_str(), sNewFileName.c_str());
RageException::Throw( "%s", message.c_str() );
}
}
} }
+1
View File
@@ -46,6 +46,7 @@ public:
protected: protected:
CString GetPathToFromDir( CString sDir, CString sFileName ); CString GetPathToFromDir( CString sDir, CString sFileName );
CString GetPathToFromNoteSkinAndButtonInternal( CString NoteSkin, CString sButtonName, CString sElement );
struct NoteSkinData struct NoteSkinData
{ {