Beispiel #1
0
        /// <summary>
        /// Gets a texture object from our manager list
        /// </summary>
        /// <param name="name">Name of texture</param>
        /// <returns>Returns the Texture Object, null if not found</returns>
        public static InfTexture GetTextureObj(string name)
        {
            InfTexture texture = null;

            if (!String.IsNullOrEmpty(name) &&
                _textures.TryGetValue(name, out texture))
            {
                return(texture);
            }

            return(null);
        }
Beispiel #2
0
 /// <summary>
 /// Adds a texture to our texture manager list
 /// </summary>
 /// <param name="name">Name of the texture</param>
 /// <param name="texture">The actual texture</param>
 public static void AddTexture(string name, InfTexture texture)
 {
     if (!String.IsNullOrWhiteSpace(name) &&
         !_textures.ContainsKey(name))
     {
         _textures.Add(name, texture);
         if (_initialized)
         {
             texture.LoadContent();
             _texturesLoaded++;
         }
     }
 }
Beispiel #3
0
        /// <summary>
        /// Removes a texture from our manager list
        /// </summary>
        /// <param name="name">The texture name</param>
        public static void RemoveTexture(string name)
        {
            InfTexture texture = null;

            if (!String.IsNullOrEmpty(name))
            {
                if (_textures.TryGetValue(name, out texture))
                {
                    texture.UnloadContent();
                    _textures.Remove(name);
                    _texturesLoaded--;
                }
            }
        }
Beispiel #4
0
        /// <summary>
        /// Gets a texture object from our list then gets the base texture
        /// </summary>
        /// <param name="name">Name of texture</param>
        /// <returns>Returns the base texture in our inf object, null if not found</returns>
        public static Texture2D GetTexture(string name)
        {
            InfTexture texture = null;

            if (!String.IsNullOrEmpty(name) &&
                _textures.TryGetValue(name, out texture))
            {
                if (texture.BaseTexture != null)
                {
                    return(texture.BaseTexture);
                }
            }

            return(null);
        }
Beispiel #5
0
 /// <summary>
 /// Removes a texture from our manager list
 /// </summary>
 /// <param name="texture">Our Texture Object</param>
 public static void RemoveTexture(InfTexture texture)
 {
     if (_textures.ContainsValue(texture))
     {
         foreach (InfTexture text in _textures.Values)
         {
             if (text == texture)
             {
                 string filename = text.FileName;
                 texture.UnloadContent();
                 _textures.Remove(filename);
                 _texturesLoaded--;
             }
         }
     }
 }
Beispiel #6
0
        /// <summary>
        /// Creates an InfTexture object then adds it to our texture manager list
        /// </summary>
        /// <param name="name">Name of the texture</param>
        /// <param name="path">The file path</param>
        public static void AddTexture(string name, string path)
        {
            InfTexture texture = null;

            if (!String.IsNullOrEmpty(name) && !_textures.ContainsKey(name))
            {
                //Are we using a set path?
                if (!String.IsNullOrEmpty(path))
                {
                    texture = new InfTexture(name, path);
                }
                else
                {
                    //We arent, use root content directory
                    texture = new InfTexture(name, GameManager.Contents.RootDirectory);
                }
                AddTexture(name, texture);
            }
        }
Beispiel #7
0
        /// <summary>
        /// Is our texture ready to render?
        /// </summary>
        /// <param name="name">Our texture name</param>
        /// <returns>Returns true if it is, false if not</returns>
        public static bool RenderReady(string name)
        {
            InfTexture obj = GetTextureObj(name);

            return(obj != null ? obj.RenderReady : false);
        }