public TileRepository(string filename) { isSolid[0] = false; LoadingScreenForm loadingScreen = new LoadingScreenForm(); loadingScreen.setSubject("tileset"); loadingScreen.setMax(100); loadingScreen.Show(); loadingScreen.Refresh(); if (!File.Exists(filename)) throw new ArgumentException("Tile file not found"); String basePath = System.IO.Path.GetDirectoryName(filename); tileset = new TileSet(); tileset.Parse(filename); // append a TileGroup (misc) with all tiles that are not yet in a TileGroup TileGroup miscTiles = new TileGroup(); foreach (Tile tile in tileset.Tiles) { if (tile == null) continue; bool found = false; foreach (TileGroup tileGroup in tileset.TileGroups) { if (tileGroup.Tiles.Contains(tile.ID)) found = true; } if (found) continue; miscTiles.Name = "(misc)"; miscTiles.Tiles.Add(tile.ID); } tileset.TileGroups.Add(miscTiles); loadingScreen.setMax(tileset.Tiles.Count); int progress = 0; foreach (Tile tile in tileset.Tiles) { progress++; if (tile == null) continue; addTile(tile, basePath); loadingScreen.setProgress(progress); } loadingScreen.Close(); }
public TileRepository(string filename) { isSolid[0] = false; LoadingScreenForm loadingScreen = new LoadingScreenForm(); loadingScreen.setSubject("tileset"); loadingScreen.setMax(100); loadingScreen.Show(); loadingScreen.Refresh(); if (!File.Exists(filename)) { throw new ArgumentException("Tile file not found"); } String basePath = System.IO.Path.GetDirectoryName(filename); tileset = new TileSet(); tileset.Parse(filename); // append a TileGroup (misc) with all tiles that are not yet in a TileGroup TileGroup miscTiles = new TileGroup(); foreach (Tile tile in tileset.Tiles) { if (tile == null) { continue; } bool found = false; foreach (TileGroup tileGroup in tileset.TileGroups) { if (tileGroup.Tiles.Contains(tile.ID)) { found = true; } } if (found) { continue; } miscTiles.Name = "(misc)"; miscTiles.Tiles.Add(tile.ID); } tileset.TileGroups.Add(miscTiles); loadingScreen.setMax(tileset.Tiles.Count); int progress = 0; foreach (Tile tile in tileset.Tiles) { progress++; if (tile == null) { continue; } addTile(tile, basePath); loadingScreen.setProgress(progress); } loadingScreen.Close(); }