private void processDraw(MouseEventArgs e) { if (e.Button == MouseButtons.Left) { int _size = FrmLogicTileSelector.Instance.size; bool odd = _size % 2 == 0; int xt = (int) ((e.X - EditorEngine.Instance.xCam) / EditorEngine.Instance.World.Camera.Scale / 16); int yt = (int) ((e.Y - EditorEngine.Instance.yCam) / EditorEngine.Instance.World.Camera.Scale / 16); if (xt != lxt || yt != lyt) { changed = true; } lxt = xt; lyt = yt; if (changed) { int l_index = FrmLogicTileSelector.Instance.CurrentLogicIndex; int x0 = xt - (int) Math.Floor((double) _size / 2); int y0 = yt - (int) Math.Floor((double) _size / 2); int x1 = xt + (int) Math.Floor((double) _size / 2); int y1 = yt + (int) Math.Floor((double) _size / 2); MultiAction act = new MultiAction(); for (int y = y0; !odd ? (y <= y1) : (y < y1); y++) { for (int x = x0; !odd ? (x <= x1) : (x < x1); x++) { act.Actions.Add(new LogicSetAction(x, y, l_index)); } } act.Execute(); temp.Actions.Add(act); foreach (IAction ia in act.Actions) { LogicSetAction i = ia as LogicSetAction; i.FillList(); foreach (IAction ia2 in i.Actions) { action.Actions.Add(ia2); } } } } changed = false; }
private void onMouseMove(object sender, MouseEventArgs e) { if (e.Button != MouseButtons.Left) return; if (action == null) action = new MultiAction("Tile Update"); int xt = (int) ((e.X - EditorEngine.Instance.xCam) / EditorEngine.Instance.World.Camera.Scale / 16); int yt = (int) ((e.Y - EditorEngine.Instance.yCam) / EditorEngine.Instance.World.Camera.Scale / 16); if (xt != lxt || yt != lyt) { if (TileEditorState.Instance.SelectedRegion != Rectangle.Empty) { MultiAction multiAction = new MultiAction("Tile Update"); Rectangle selection = TileEditorState.Instance.SelectedRegion; for (int x = 0; x < selection.Width; x++) { for (int y = 0; y < selection.Height; y++) { int currentX = selection.X + x; int currentY = selection.Y + y; int tilesetIndex = TileEditorState.Instance.SelectedTileset; Tileset tilesheet = EditorEngine.Instance.CurrentMap.Tilesets[tilesetIndex].Tileset; int tileIndex = tilesheet.Texture.GetIndex(currentX, currentY); int zt = EditorEngine.Instance.SelectedLayer; MockupTile t = EditorEngine.Instance.CurrentMap.GetTile(xt + x, yt + y, zt); if (t == null) continue; SetTileAction tileAction = new SetTileAction( xt + x, yt + y, zt, tilesetIndex, tileIndex); multiAction.Actions.Add(tileAction); } } multiAction.Execute(); action.Actions.Add(multiAction); } } lxt = xt; lyt = yt; }