示例#1
0
		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;
				}*/
			}
		}
示例#2
0
		public void QueueBackgroundLoad(BackgroundDownload backgroundDownload)
		{
			_backgroundDownloads.Enqueue(backgroundDownload);

			// TODO: will we handle downloads differently to files?  they're all streams
			// at the end of the day.
			/*if ( bgl->opcode == DLTYPE_FILE ) {
				if ( dynamic_cast<idFile_Permanent *>(bgl->f) ) {
					// add the bgl to the background download list
					Sys_EnterCriticalSection();
					bgl->next = backgroundDownloads;
					backgroundDownloads = bgl;
					Sys_TriggerEvent();
					Sys_LeaveCriticalSection();
				} else {
					// read zipped file directly
					bgl->f->Seek( bgl->file.position, FS_SEEK_SET );
					bgl->f->Read( bgl->file.buffer, bgl->file.length );
					bgl->completed = true;
				}
			} else {
				Sys_EnterCriticalSection();
				bgl->next = backgroundDownloads;
				backgroundDownloads = bgl;
				Sys_TriggerEvent();
				Sys_LeaveCriticalSection();
			}*/
		}