public void onMouseDown(object sender, MouseEventArgs e) { if (e.Button == MouseButtons.Left) { action = new MultiAction("Logic Pencil"); temp = new MultiAction("customary rape action"); processDraw(e); } }
private void onMouseMove(object sender, MouseEventArgs e) { if (e.Button == MouseButtons.Left) { if (this.action == null) { this.action = new MultiAction("Eraser"); } 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) { int tilesetIndex = TileEditorState.Instance.SelectedTileset; MockupTile t = EditorEngine.Instance.CurrentMap.GetTile(xt, yt, EditorEngine.Instance.SelectedLayer); if (t != null) { SetTileAction tileAction = new SetTileAction(xt, yt, EditorEngine.Instance.SelectedLayer, tilesetIndex, -1); tileAction.Execute(); action.Actions.Add(tileAction); } } lxt = xt; lyt = yt; } }
public void onMouseUp(object sender, MouseEventArgs e) { if (e.Button == MouseButtons.Left) { //action.UnExecute(); temp.UnExecute(); EditorEngine.Instance.GetActionManager().Execute(action); foreach (SetTileAction a in action.Actions) { Map map = EditorEngine.Instance.CurrentMap; MockupTileBehavior b = map.GetBehavior(a.X, a.Y); b.BehaviorId = map.Tilesets[a.TilesetIndex].Tileset.Tiles[a.TileIndex].DefaultBehavior.BehaviorId; } action = null; temp = null; } }
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; }
public IAction Read() { IAction result = null; BinaryInput stream = _stream as BinaryInput; int i = stream.ReadInt32(); if (i == 1) { result = new SetTileAction(); } if (i == 2) { result = new MultiAction(); } if (i == 3) { result = new FillAction(); } if (i == 4) { result = new RectangleAction(); } if (i == 5) { result = new AddEntityAction(); } if (i == 6) { result = new RemoveEntityAction(); } IEncodable encodable = result as IEncodable; if (encodable != null) { encodable.Decode(stream); } return(result); }
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; }
public void OnMouseUp(object sender, MouseEventArgs e) { if (e.Button == MouseButtons.Left) { int xs = selection.Region.X; int ys = selection.Region.Y; int width = selection.Region.Width; int height = selection.Region.Height; EntityTemplate template = FrmEntitySelector.Instance.selectedEntity; int tx = Int32.MaxValue; int ty = Int32.MaxValue; int tw = -1; int th = -1; foreach (Rectangle rect in template.CollisionMap) { if (rect.X < tx) tx = rect.X; if (rect.Y < ty) ty = rect.Y; if (rect.Width > tw) tw = rect.Width; if (rect.Height > th) th = rect.Height; } if (tw != template.Texture.Texture.Width) tw += 1; //if (th != Template.Texture.Texture.Height) th += 1; Rectangle tbounds = new Rectangle(tx, ty, tw, th); int xCount = (int) Math.Ceiling(((double) width / tbounds.Width)); int yCount = (int) Math.Ceiling(((double) height / tbounds.Height)); MultiAction action = new MultiAction(Name); int xInc = 0; int yInc = 0; //if (tw != Template.Texture.Texture.Width) xInc -= 1; if (th != template.Texture.Texture.Height) yInc -= 1; for (int j = 0; j < yCount; j++, yInc += tbounds.Height, xInc = 0) { for (int i = 0; i < xCount; i++, xInc += tbounds.Width) { action.Actions.Add(new AddEntityAction(template, new Vector2(xs + xInc, ys + yInc))); } } EditorEngine.Instance.GetActionManager().Execute(action); } selection.Region = Rectangle.Empty; }
private void onMouseUp(object sender, MouseEventArgs e) { if (e.Button == MouseButtons.Left) { EditorEngine.Instance.GetActionManager().Execute(this.action); this.action = null; } }