public void QueueBackgroundLoad(idImage image)
{
string fileName = idE.ImageManager.ImageProgramStringToCompressedFileName(image.Name);
BackgroundDownload backgroundDownload = new BackgroundDownload();
backgroundDownload.Stream = idE.FileSystem.OpenFileRead(fileName);
if(backgroundDownload.Stream == null)
{
idConsole.Warning("idImageManager.StartBackgroundLoad: Couldn't load {0}", image.Name);
}
else
{
idE.FileSystem.QueueBackgroundLoad(backgroundDownload);
_backgroundImageLoads.Add(image, backgroundDownload);
// TODO: purge image cache
/*// purge some images if necessary
int totalSize = 0;
for ( idImage *check = globalImages->cacheLRU.cacheUsageNext ; check != &globalImages->cacheLRU ; check = check->cacheUsageNext ) {
totalSize += check->StorageSize();
}
int needed = this->StorageSize();
while ( ( totalSize + needed ) > globalImages->image_cacheMegs.GetFloat() * 1024 * 1024 ) {
// purge the least recently used
idImage *check = globalImages->cacheLRU.cacheUsagePrev;
if ( check->texnum != TEXTURE_NOT_LOADED ) {
totalSize -= check->StorageSize();
if ( globalImages->image_showBackgroundLoads.GetBool() ) {
common->Printf( "purging %s\n", check->imgName.c_str() );
}
check->PurgeImage();
}
// remove it from the cached list
check->cacheUsageNext->cacheUsagePrev = check->cacheUsagePrev;
check->cacheUsagePrev->cacheUsageNext = check->cacheUsageNext;
check->cacheUsageNext = NULL;
check->cacheUsagePrev = NULL;
}*/
}
}