public void Click(ScreenDrawingSurface surface, Point location) { var selection = surface.Selection; if (selection != null) { // only paint inside selection if (!selection.Value.Contains(location)) { return; } } int tile_x = location.X / surface.Screen.Tileset.TileSize; int tile_y = location.Y / surface.Screen.Tileset.TileSize; var old = surface.Screen.TileAt(tile_x, tile_y); Flood(surface, tile_x, tile_y, old.Id, 0, 0); // need to manually inform the screen surface that I messed with it if (changes.Count > 0) { surface.EditedWithAction(new DrawAction("Fill", changes, surface)); surface.ReDrawTiles(); } changes.Clear(); }
private void Draw(ScreenDrawingSurface surface, int tile_x, int tile_y) { // first track the changes i'm going to make for undo purposes foreach (TileBrushCell cell in brush.Cells()) { int tx = cell.x + tile_x; int ty = cell.y + tile_y; if (tx < 0 || tx >= surface.Screen.Width || ty < 0 || ty >= surface.Screen.Height) { continue; } if (startTiles[tx, ty] == null) // don't overwrite existing data { startTiles[tx, ty] = surface.Screen.TileAt(tx, ty).Id; } endTiles[tx, ty] = cell.tile.Id; } brush.DrawOn(surface.Screen, tile_x, tile_y); surface.ReDrawTiles(); }
public void Run() { foreach (TileChange change in changes) { change.ApplyToSurface(surface); } surface.ReDrawTiles(); }
private void Draw(ScreenDrawingSurface surface, int tile_x, int tile_y) { var selection = surface.Selection; if (selection != null) { // only paint inside selection if (!selection.Value.Contains(tile_x, tile_y)) return; } // first track the changes i'm going to make for undo purposes foreach (TileBrushCell cell in brush.Cells()) { int tx = cell.x + tile_x; int ty = cell.y + tile_y; if (tx < 0 || tx >= surface.Screen.Width || ty < 0 || ty >= surface.Screen.Height) continue; if (startTiles[tx, ty] == null) // don't overwrite existing data { startTiles[tx, ty] = surface.Screen.TileAt(tx, ty).Id; } endTiles[tx, ty] = cell.tile.Id; } brush.DrawOn(surface.Screen, tile_x, tile_y); surface.ReDrawTiles(); }