/// <summary> /// Draws the brush onto the given screen at the given tile location. /// Returns an "undo brush" - a brush of all tiles that were overwritten. /// Returns null if no tiles were changed. /// </summary> public ITileBrush DrawOn(ScreenDocument screen, int tile_x, int tile_y) { TileBrush undo = new TileBrush(Width, Height); bool changed = false; foreach (TileBrushCell[] col in cells) { foreach (TileBrushCell cell in col) { var old = screen.TileAt(cell.x + tile_x, cell.y + tile_y); if (old == null) { continue; } undo.AddTile(old, cell.x, cell.y); if (old.Id != cell.tile.Id) { changed = true; screen.ChangeTile(cell.x + tile_x, cell.y + tile_y, cell.tile.Id); } } } if (changed) { return(undo); } return(null); }
private void buttonNewBrush_Click(object sender, EventArgs e) { if (Tileset == null || brushes == null) { return; } creatingBrush = new TileBrush(2, 2); splitter.Panel1Collapsed = false; ResetNewBrush(2, 2); }
public void Copy() { if (ActiveSurface != null && ActiveSurface.Selection != null) { var selection = ActiveSurface.Selection.Value; copyBrush = new TileBrush(selection.Width, selection.Height); for (int ty = selection.Y; ty < selection.Bottom; ty++) { for (int tx = selection.X; tx < selection.Right; tx++) { copyBrush.AddTile(ActiveSurface.Screen.TileAt(tx, ty), tx - selection.X, ty - selection.Y); } } } }
public void Copy() { if (ActiveSurface != null && ActiveSurface.Selection != null) { var selection = ActiveSurface.Selection.Value; copyBrush = new TileBrush(selection.Width, selection.Height); for (int ty = selection.Y; ty < selection.Bottom; ty++) { for (int tx = selection.X; tx < selection.Right; tx++) { copyBrush.AddTile(ActiveSurface.Screen.TileAt(tx, ty), tx - selection.X, ty - selection.Y); } } } }
private void LoadBrushes() { string dir = System.IO.Path.GetDirectoryName(Tileset.FilePath.Absolute); string file = System.IO.Path.GetFileNameWithoutExtension(Tileset.FilePath.Absolute); string path = System.IO.Path.Combine(dir, file + "_brushes.xml"); if (!System.IO.File.Exists(path)) { return; } using (var stream = new System.IO.StreamReader(path)) { while (!stream.EndOfStream) { string line = stream.ReadLine(); if (line == null) { break; } string[] info = line.Split(' '); TileBrush brush = new TileBrush(int.Parse(info[0]), int.Parse(info[1])); int x = 0; int y = 0; for (int i = 2; i < info.Length; i++) { int id = int.Parse(info[i]); if (id >= 0) { brush.AddTile(Tileset[id], x, y); } y++; if (y >= brush.Height) { y = 0; x++; } } brushes.Add(brush); } } }
private void CancelNewBrush(object sender, EventArgs e) { creatingBrush = null; splitter.Panel1Collapsed = true; }
private void SaveNewBrush(object sender, EventArgs e) { AddBrush(creatingBrush); creatingBrush = null; splitter.Panel1Collapsed = true; }
private void SaveNewBrush(object sender, EventArgs e) { AddBrush(creatingBrush); creatingBrush = null; splitter.Panel1Collapsed = true; }
private void LoadBrushes() { string dir = System.IO.Path.GetDirectoryName(Tileset.FilePath.Absolute); string file = System.IO.Path.GetFileNameWithoutExtension(Tileset.FilePath.Absolute); string path = System.IO.Path.Combine(dir, file + "_brushes.xml"); if (!System.IO.File.Exists(path)) return; using (var stream = new System.IO.StreamReader(path)) { while (!stream.EndOfStream) { string line = stream.ReadLine(); if (line == null) break; string[] info = line.Split(' '); TileBrush brush = new TileBrush(int.Parse(info[0]), int.Parse(info[1])); int x = 0; int y = 0; for (int i = 2; i < info.Length; i++) { int id = int.Parse(info[i]); if (id >= 0) brush.AddTile(Tileset[id], x, y); y++; if (y >= brush.Height) { y = 0; x++; } } brushes.Add(brush); } } }
private void CancelNewBrush(object sender, EventArgs e) { creatingBrush = null; splitter.Panel1Collapsed = true; }
private void buttonNewBrush_Click(object sender, EventArgs e) { if (Tileset == null || brushes == null) return; creatingBrush = new TileBrush(2, 2); splitter.Panel1Collapsed = false; ResetNewBrush(2, 2); }
/// <summary> /// Draws the brush onto the given screen at the given tile location. /// Returns an "undo brush" - a brush of all tiles that were overwritten. /// Returns null if no tiles were changed. /// </summary> public ITileBrush DrawOn(ScreenDocument screen, int tile_x, int tile_y) { TileBrush undo = new TileBrush(Width, Height); bool changed = false; foreach (TileBrushCell[] col in cells) { foreach (TileBrushCell cell in col) { var old = screen.TileAt(cell.x + tile_x, cell.y + tile_y); if (old == null) continue; undo.AddTile(old, cell.x, cell.y); if (old.Id != cell.tile.Id) { changed = true; screen.ChangeTile(cell.x + tile_x, cell.y + tile_y, cell.tile.Id); } } } if (changed) return undo; return null; }