Example #1
0
        /// <summary>
        /// Loads a texture stack into memory from specified path
        /// using Loader.AutoTextureStack(name) and added to Atlas
        /// under specified name pattern resembling name_X where
        /// X = the textures index as found in the directory.
        ///
        /// Will throw error if true and the specified
        /// name is already occupied.
        /// </summary>
        public void LoadStack(string path, string name, bool throwException = true)
        {
            name = name.ToLower();

            var stack = Loader.AutoTextureStack(path);

            if (stack.Length < 1)
            {
                if (!throwException)
                {
                    return;
                }
                throw new InvalidOperationException("Texture stack not found!");
            }

            for (var i = 0; i < stack.Length; i++)
            {
                if (_textures.ContainsKey(name + "_" + i))
                {
                    if (!throwException)
                    {
                        return;
                    }
                    throw new InvalidOperationException("Key(s)? already exists with that name pattern!");
                }

                _textures.Add(name + "_" + i, stack[i]);
            }
        }