Beispiel #1
0
        public void LoadTextureDir(string path)
        {
            if (Directory.Exists(path)){
                foreach (string sheetDir in Directory.GetDirectories(path, "*")){
                    string sheetName = sheetDir.Substring(sheetDir.LastIndexOf(Path.DirectorySeparatorChar) + 1);
                    Console.WriteLine("Got sheet: {0}", sheetName);
                    if (!this.Sheets.ContainsKey(sheetName)){
                        this.Sheets.Add(sheetName, new Dictionary<string, MMTextureData>());
                    }

                    foreach (string textureFile in Directory.GetFiles(sheetDir, "*png")){
                        Image img = Image.FromFile(textureFile, true);
                        Bitmap bm = new Bitmap(img);
                        string textureName = textureFile.Substring(textureFile.LastIndexOf(Path.DirectorySeparatorChar) + 1);
                        textureName = (textureName.Split(new Char[] { '.' }))[0];
                        MMTextureData tex = new MMTextureData(0, 0, bm.Width, bm.Height, 0, 0, 0, 0, textureName);
                        tex.SetData(bm);

                        if (!this.Textures.ContainsKey(tex.name)){
                            this.Textures.Add(tex.name, tex);
                        }
                        if (!this.Sheets[sheetName].ContainsKey(tex.name))
                            this.Sheets[sheetName].Add(tex.name, tex);
                    }
                }
            } else {
                Console.WriteLine("Texture path does not exist: {0}", Path.GetFileName(path));
            }
        }
Beispiel #2
0
        public void LoadTextureDir(string path)
        {
            if (Directory.Exists(path))
            {
                foreach (string sheetDir in Directory.GetDirectories(path, "*"))
                {
                    string sheetName = sheetDir.Substring(sheetDir.LastIndexOf(Path.DirectorySeparatorChar) + 1);
                    Console.WriteLine("Got sheet: {0}", sheetName);
                    if (!this.Sheets.ContainsKey(sheetName))
                    {
                        this.Sheets.Add(sheetName, new Dictionary <string, MMTextureData>());
                    }

                    foreach (string textureFile in Directory.GetFiles(sheetDir, "*png"))
                    {
                        Image  img         = Image.FromFile(textureFile, true);
                        Bitmap bm          = new Bitmap(img);
                        string textureName = textureFile.Substring(textureFile.LastIndexOf(Path.DirectorySeparatorChar) + 1);
                        textureName = (textureName.Split(new Char[] { '.' }))[0];
                        MMTextureData tex = new MMTextureData(0, 0, bm.Width, bm.Height, 0, 0, 0, 0, textureName);
                        tex.SetData(bm);

                        if (!this.Textures.ContainsKey(tex.name))
                        {
                            this.Textures.Add(tex.name, tex);
                        }
                        if (!this.Sheets[sheetName].ContainsKey(tex.name))
                        {
                            this.Sheets[sheetName].Add(tex.name, tex);
                        }
                    }
                }
            }
            else
            {
                Console.WriteLine("Texture path does not exist: {0}", Path.GetFileName(path));
            }
        }