public void loadTiles() { if (assetPath_Graphics == "" && Directory.Exists(assetPath_Graphics)) { MessageBox.Show("Please specify a path for graphics assets path"); assetFolderBrowser.ShowDialog(); assetPath_Graphics = assetFolderBrowser.SelectedPath; } DirectoryInfo di = new DirectoryInfo(assetPath_Graphics + "\\tileset\\"); FileInfo[] rgFiles = di.GetFiles("*.tile"); foreach (FileInfo fi in rgFiles) { int tileID = Convert.ToInt32(fi.Name.Replace(".tile", "")); string imagePath = assetPath_Graphics + "\\tileset\\" + tileID + ".png"; tileset newTileset = new mapEditor.tileset(); newTileset.imageData = new Bitmap(imagePath); //Load the tileset Image System.IO.FileStream FS = new FileStream(assetPath_Graphics + "\\tileset\\" + tileID + ".tile", FileMode.Open); //Open settings.dat file System.IO.BinaryReader BR = new BinaryReader(FS); //Create stream newTileset.tileWidth = BR.ReadInt16(); //Read tile width newTileset.tileHeight = BR.ReadInt16(); //Read tile width BR.Close(); FS.Close(); tilesetList.Add(tileID, newTileset); this.cmbTileSelection.Items.Add(fi.Name); } }
public void loadTiles() { if (assetPath_Graphics == "" && Directory.Exists(assetPath_Graphics)) { MessageBox.Show("Please specify a path for graphics assets path"); assetFolderBrowser.ShowDialog(); assetPath_Graphics = assetFolderBrowser.SelectedPath; } DirectoryInfo di = new DirectoryInfo(assetPath_Graphics+"\\tileset\\"); FileInfo[] rgFiles = di.GetFiles("*.tile"); foreach (FileInfo fi in rgFiles) { int tileID = Convert.ToInt32(fi.Name.Replace(".tile","")); string imagePath = assetPath_Graphics + "\\tileset\\" + tileID + ".png"; tileset newTileset = new mapEditor.tileset(); newTileset.imageData = new Bitmap(imagePath); //Load the tileset Image System.IO.FileStream FS = new FileStream(assetPath_Graphics + "\\tileset\\" + tileID + ".tile", FileMode.Open); //Open settings.dat file System.IO.BinaryReader BR = new BinaryReader(FS); //Create stream newTileset.tileWidth = BR.ReadInt16(); //Read tile width newTileset.tileHeight = BR.ReadInt16(); //Read tile width BR.Close(); FS.Close(); tilesetList.Add(tileID,newTileset); this.cmbTileSelection.Items.Add(fi.Name); } }