public TexturePack(int imageNumber, string textureName, Texture2D texture2D) { nextTexturePack = null; this.imageNumber = imageNumber; this.texture2D = texture2D; this.textureName = textureName; }
static public int AddImage(string imageName, string imagePathAndFileName) { TexturePack stepPack = firstTexturePack; if (firstTexturePack != null) { // Find last texturepack while (stepPack.nextTexturePack != null) { if (stepPack.textureName == imageName) { return(stepPack.imageNumber); } stepPack = stepPack.nextTexturePack; } TexturePack newImage = new TexturePack(uniqueTextureId, imageName, Texture2D.FromStream(graphicsDevice, File.OpenRead(imagePathAndFileName))); uniqueTextureId++; stepPack.nextTexturePack = newImage; } else { TexturePack newImage = new TexturePack(uniqueTextureId, imageName, Texture2D.FromStream(graphicsDevice, File.OpenRead(imagePathAndFileName))); uniqueTextureId++; firstTexturePack = newImage; } return(uniqueTextureId); }
static public Texture2D GetImageWithId(int imageId) { TexturePack stepTexture = firstTexturePack; while (stepTexture != null) { if (stepTexture.imageNumber == imageId) { return(stepTexture.texture2D); } stepTexture = stepTexture.nextTexturePack; } return(null); }
static public void ClearAllImages() { firstTexturePack = null; GC.Collect(); }
static public void Initialize(GraphicsDevice currentGraphicsDevice) { firstTexturePack = null; graphicsDevice = currentGraphicsDevice; uniqueTextureId = 0; }