示例#1
0
CString Character::GetDanceAnimationPath() const { return DerefRedir(GetRandomFileInDir(m_sCharDir + "Dance/")); }
示例#2
0
/* Resolves actor paths a la LoadActor("..."), with autowildcarding and .redir
 * files.  Returns a path *within* the Rage filesystem, unlike the FILEMAN
 * function of the same name. */
bool ActorUtil::ResolvePath( RString &sPath, const RString &sName, bool optional )
{
	CollapsePath( sPath );

	// If we know this is an exact match, don't bother with the GetDirListing,
	// so "foo" doesn't partial match "foobar" if "foo" exists.
	RageFileManager::FileType ft = FILEMAN->GetFileType( sPath );
	if( ft != RageFileManager::TYPE_FILE && ft != RageFileManager::TYPE_DIR )
	{
		vector<RString> asPaths;
		GetDirListing( sPath + "*", asPaths, false, true );	// return path too

		if( asPaths.empty() )
		{
			if(optional)
			{
				return false;
			}
			RString sError = ssprintf( "%s: references a file \"%s\" which doesn't exist", sName.c_str(), sPath.c_str() );
			switch(LuaHelpers::ReportScriptError(sError, "BROKEN_FILE_REFERENCE", true))
			{
			case Dialog::abort:
				RageException::Throw( "%s", sError.c_str() ); 
				break;
			case Dialog::retry:
				FILEMAN->FlushDirCache();
				return ResolvePath( sPath, sName );
			case Dialog::ignore:
				return false;
			default:
				FAIL_M("Invalid response to Abort/Retry/Ignore dialog");
			}
		}

		THEME->FilterFileLanguages( asPaths );

		if( asPaths.size() > 1 )
		{
			RString sError = ssprintf( "%s: references a file \"%s\" which has multiple matches", sName.c_str(), sPath.c_str() );
			sError += "\n" + join( "\n", asPaths );
			switch(LuaHelpers::ReportScriptError(sError, "BROKEN_FILE_REFERENCE", true))
			{
			case Dialog::abort:
				RageException::Throw( "%s", sError.c_str() ); 
				break;
			case Dialog::retry:
				FILEMAN->FlushDirCache();
				return ResolvePath( sPath, sName );
			case Dialog::ignore:
				asPaths.erase( asPaths.begin()+1, asPaths.end() );
				break;
			default:
				FAIL_M("Invalid response to Abort/Retry/Ignore dialog");
			}
		}

		sPath = asPaths[0];
	}

	if( ft == RageFileManager::TYPE_DIR )
	{
		RString sLuaPath = sPath + "/default.lua";
		if( DoesFileExist(sLuaPath) )
		{
			sPath = sLuaPath;
			return true;
		}
	}

	sPath = DerefRedir( sPath );
	return true;
}
示例#3
0
CString Character::GetWarmUpAnimationPath() const { return DerefRedir(GetRandomFileInDir(m_sCharDir + "WarmUp/")); }