void autoTile94_Click(object sender, EventArgs e) { if (selectedBasicTile != null) { Tile autotile = selectedBasicTile; AutoTile94 at = new AutoTile94(); AddAutotile94(autotile, at); } }
private void btn_loadtiles_Click(object sender, EventArgs e) { OpenFileDialog ofd = new OpenFileDialog(); ofd.ShowDialog(); if (string.IsNullOrEmpty(ofd.FileName)) { return; } string basename = Path.Combine(Path.GetDirectoryName(ofd.FileName), Path.GetFileNameWithoutExtension(ofd.FileName)); string basictilesname = basename + ".basictiles"; string tilesname = basename + ".tiles"; string pngname = basename + ".png"; if (!File.Exists(basictilesname) || !File.Exists(tilesname)) { return; } using (Bitmap bmp = new Bitmap(pngname)) { using (FormattedReader tiles = new FormattedReader(tilesname)) using (FormattedReader basictiles = new FormattedReader(basictilesname)) { var btff = basictiles.Read<BasicTilesFileFormat>(); var simpletiles = btff.tiles.Select(x => new SimpleTile(x, bmp)).ToArray(); //foreach (var st in simpletiles) //{ // AddBasicTile(st); //} var tff = tiles.Read<TilesFileFormat>(); foreach (var tile in tff.tiles) { if (tile.type == TileType.SIMPLE) { AddSimpleTile(simpletiles[tile.simp[0].basictile]); } else if (tile.type == TileType.AUTOTILE12) { AutoTile12 at = new AutoTile12(simpletiles, tile.auto[0].basictiles); AddAutotile12(at, at); } else if (tile.type == TileType.AUTOTILE94) { AutoTile94 at = new AutoTile94(simpletiles, tile.auto[0].basictiles); AddAutotile94(at, at); } } } } }
private void AddAutotile94(Tile autotile, AutoTile94 at) { RadioButton btn = new RadioButton(); btn.Appearance = Appearance.Button; btn.Size = new System.Drawing.Size(40, 40); btn.Image = autotile.GetBitmap(0, 0); int t = Tile.tilesize; var nine = new Bitmap(t * 3, t * 3); var four = new Bitmap(t * 2, t * 2); using (Graphics g = Graphics.FromImage(nine)) { for (int x = 0; x < 3; x++) { for (int y = 0; y < 3; y++) { g.DrawImage(autotile.GetBitmap(0, 0), t * x, t * y); } } } using (Graphics g = Graphics.FromImage(four)) { for (int x = 0; x < 2; x++) { for (int y = 0; y < 2; y++) { g.DrawImage(autotile.GetBitmap(0, 0), t * x, t * y); } } } btn.Tag = at; btn.Click += new EventHandler((o, evt) => { paintTile = (Tile)((RadioButton)o).Tag; populatePanel2WithTileEditor(); }); flow_tiles.Controls.Add(btn); }