WHITEBOX_BEGIN

IResource*	IScriptResourceSerializer::Load( CDataStream& dataStream, const CResourceDescriptor& descriptor )
{
	CScriptStreamReader scriptStreamReader;
	SScriptNodePtr pScriptNode = scriptStreamReader.Parse( dataStream );
	
	CScriptNodeReader scriptNodeReader( pScriptNode );
	return Load( scriptNodeReader, descriptor );
}
Exemplo n.º 2
0
void CResourceManager::ParseResources( const String& resourceFolder )
{
	String resourceFolderFormat = resourceFolder;
	if ( !resourceFolderFormat.empty() && (resourceFolderFormat.c_str()[ resourceFolderFormat.length()-1 ] != '/') )
	{
		resourceFolderFormat = resourceFolderFormat + "/";
	}

	m_resourceRootDir = resourceFolderFormat + "Resources/";

	CDataStream dataStream;
	gVars->pOperatingSystem->GetDataStream( resourceFolderFormat + "Resources.list", dataStream );

	CScriptStreamReader scriptStreamReader;
	SScriptNodePtr pScriptNode = scriptStreamReader.Parse( dataStream );
	
	CScriptNodeReader scriptNodeReader( pScriptNode );
	
	if ( scriptNodeReader.BeginGroup( "Resources" ) )
	{
		while ( scriptNodeReader.BeginGroup( "Resource" ) )
		{		
			String path;
			int size = 0;
			
			scriptNodeReader.Value( "path", path );
			scriptNodeReader.Value( "size", size );
			
			CResourceDescriptor* pDescriptor = AddResource( path, size );
			if ( pDescriptor != nullptr )
			{
				std::vector< String >& dependencies = pDescriptor->GetDependencies();
				
				while ( scriptNodeReader.BeginGroup( "Dependency" ) )
				{
					String dependency;
					scriptNodeReader.Value( "path", dependency );

					dependencies.push_back( dependency );

					scriptNodeReader.EndGroup();
				}
			}
			scriptNodeReader.EndGroup();
		}
	
		scriptNodeReader.EndGroup();
	}
}