public override void OnMouseLeftDown(Point location) { Point node = LayerEditor.MouseSnapPosition; if (Ogmo.EntitySelectionWindow.Selected.Count == 1) { Entity e = Ogmo.EntitySelectionWindow.Selected[0]; if (e.Definition.NodesDefinition.Enabled) { if (e.Nodes.Contains(node)) { moving = true; moveEntity = e; moveIndex = e.Nodes.FindIndex(p => p == node); } else if (e.Nodes.Count != e.Definition.NodesDefinition.Limit) { LevelEditor.Perform(new EntityAddNodeAction(LayerEditor.Layer, e, node)); } } } else { LevelEditor.StartBatch(); foreach (var e in Ogmo.EntitySelectionWindow.Selected) { if (e.Definition.NodesDefinition.Enabled && e.Nodes.Count != e.Definition.NodesDefinition.Limit && !e.Nodes.Contains(node)) { LevelEditor.BatchPerform(new EntityAddNodeAction(LayerEditor.Layer, e, node)); } } LevelEditor.EndBatch(); } }
public override void OnMouseRightUp(Point location) { if (drawing && !drawMode) { drawing = false; LevelEditor.StartBatch(); List <Point> pts = getPoints(drawStart, LayerEditor.Layer.Definition.ConvertToGrid(location)); foreach (var p in pts) { LevelEditor.BatchPerform(new TileDrawAction(LayerEditor.Layer, p, -1)); } LevelEditor.EndBatch(); } }
public override void Paste(LevelEditor editor, Layer layer) { List <Entity> created = new List <Entity>(); editor.StartBatch(); foreach (var e in entities) { Entity ee = e.Clone(); created.Add(ee); editor.BatchPerform(new EntityAddAction(layer as EntityLayer, ee)); } editor.EndBatch(); Ogmo.EntitySelectionWindow.SetSelection(created); }
public override void OnMouseMove(Point location) { if (moving) { Point move = new Point(location.X - mouseStart.X, location.Y - mouseStart.Y); move = LayerEditor.Layer.Definition.ConvertToGrid(move); move.X -= moved.X; move.Y -= moved.Y; if (move.X != 0 || move.Y != 0) { LevelEditor.BatchPerform(LayerEditor.Layer.Selection.GetMoveAction(move)); moved = new Point(move.X + moved.X, move.Y + moved.Y); } } }
public override void OnMouseLeftUp(Point location) { if (drawing && drawMode) { drawing = false; LevelEditor.StartBatch(); List <Point> pts = getPoints(drawStart, LayerEditor.Layer.Definition.ConvertToGrid(location)); foreach (var p in pts) { if (!LayerEditor.Layer.Grid[p.X, p.Y]) { LevelEditor.BatchPerform(new GridDrawAction(LayerEditor.Layer, p, true)); } } LevelEditor.EndBatch(); } }
public override void OnMouseLeftUp(Point location) { if (drawing && drawMode) { drawing = false; LevelEditor.StartBatch(); List <Point> pts = getPoints(drawStart, LayerEditor.Layer.Definition.ConvertToGrid(location)); foreach (var p in pts) { int id = -1; if (selection.HasValue) { id = LayerEditor.Layer.Tileset.GetIDFromSelectionRectPoint(selection.Value, drawStart, p); } LevelEditor.BatchPerform(new TileDrawAction(LayerEditor.Layer, p, id)); } LevelEditor.EndBatch(); } }
public override void OnMouseRightClick(Point location) { if (moving) { return; } Point node = LayerEditor.MouseSnapPosition; LevelEditor.StartBatch(); foreach (var e in Ogmo.EntitySelectionWindow.Selected) { if (e.Definition.NodesDefinition.Enabled) { int index = e.Nodes.IndexOf(node); if (index != -1) { LevelEditor.BatchPerform(new EntityRemoveNodeAction(LayerEditor.Layer, e, index)); } } } LevelEditor.EndBatch(); }