private static bool IsTextureExist(DicoTexture texture) { foreach (DicoTexture txt in dico.Values) { if (txt.FullPath == texture.FullPath) { return(true); } } return(false); }
/// <summary> /// Add A Texture To The Texture Manager /// </summary> /// <param name="AssetName">The AssetName To Add</param> /// <param name="FullPath">The Path Of Texture To Matche With The AssetName</param> /// <param name="TCP">Texture Parameters</param> /// <param name="graphicsDevice">XNA GraphicsDevice Referenec</param> public static void Add(string AssetName, string FullPath, TextureCreationParameters TCP, GraphicsDevice graphicsDevice) { bool textureerreur = false; bool errload = true; try { DicoTexture texture = new DicoTexture(); texture.texture = Texture2D.FromFile(graphicsDevice, FullPath, TCP); errload = false; texture.FullPath = FullPath; if (!IsTextureExist(texture)) { dico.Add(AssetName, texture); } else { textureerreur = true; throw new System.Exception(); } } catch { if (textureerreur) { throw new Exception("Error This Texture Allready Exist"); } else { if (errload) { throw new Exception("Error This Asset filename Doesn't Exist"); } else { throw new Exception("Error This Asset Allready Exist"); } } } }