
#include "CD3DImageManager.h"
#include "D3DStructs.h"
#include "CD3DManager.h"
#include "Assert.h"

CD3DImageManager::CD3DImageManager()
{


}


CD3DImageManager::~CD3DImageManager()
{


}


CD3DTexture* CD3DImageManager::getTexture(STRINGC fileName)
{
	CD3DTexture* texture=NULL;
	
	
	for(ImageListIterator itor=Images.begin(); itor!= Images.end();++itor)
	{
		
		if((*itor)->fileName==fileName)
		{

	//		g_Console.AddMessage(STRINGC("Image Found: ") + fileName,3);
			texture = (*itor);
			
						
		}
		

	}

	return texture;


}

void CD3DImageManager::insertTexture(CD3DTexture* texture)
{
	Images.push_front(texture);
}


void CD3DImageManager::releaseTextures()
{

	for(ImageListIterator itor=Images.begin(); itor!= Images.end();++itor)
	{
		
//		SAFE_RELEASE((*itor)->lpD3DTexture);

		(*itor)->lpD3DTexture->Release();
		//(*itor)->lpD3DTexture->OnLostDevice();

		
	}	

}


void CD3DImageManager::restoreTextures()
{
	for(ImageListIterator itor=Images.begin(); itor!= Images.end();++itor)
	{
		//CD3DManager* d3d = (CD3DManager*)&g_GraphicSystem;		
		//d3d->loadTexture((*itor)->fileName,(*itor)->lpD3DTexture);		
		(*itor)->reloadTexture();
		
	}



}