Esempio n. 1
0
        public override void OnMouseLeftUp(Point location)
        {
            if (drawing)
            {
                drawing = false;

                int       x = Math.Min(mouseStart.X, LevelEditor.MousePosition.X);
                int       y = Math.Min(mouseStart.Y, LevelEditor.MousePosition.Y);
                int       w = Math.Max(mouseStart.X, LevelEditor.MousePosition.X) - x;
                int       h = Math.Max(mouseStart.Y, LevelEditor.MousePosition.Y) - y;
                Rectangle r = new Rectangle(x, y, w, h);

                List <Entity> hit = LayerEditor.Layer.Entities.FindAll(e => e.Bounds.IntersectsWith(r));

                if (Util.Ctrl)
                {
                    Ogmo.EntitySelectionWindow.ToggleSelection(hit);
                }
                else
                {
                    Ogmo.EntitySelectionWindow.SetSelection(hit);
                }
            }

            if (moving)
            {
                moving     = false;
                moveAction = null;
            }
        }
Esempio n. 2
0
        public override void OnMouseMove(Point location)
        {
            if (moving)
            {
                Point move = new Point(location.X - mouseStart.X, location.Y - mouseStart.Y);
                if (!Util.Ctrl)
                {
                    move = LayerEditor.Layer.Definition.SnapToGrid(move);
                }

                move = new Point(move.X - moved.X, move.Y - moved.Y);
                if (move.X != 0 || move.Y != 0)
                {
                    if (moveAction != null)
                    {
                        moveAction.DoAgain(move);
                    }
                    else
                    {
                        LevelEditor.Perform(moveAction = new EntityMoveAction(LayerEditor.Layer, Ogmo.EntitySelectionWindow.Selected, move));
                    }
                    moved = new Point(move.X + moved.X, move.Y + moved.Y);
                    Ogmo.EntitySelectionWindow.RefreshPosition();
                }
            }
        }
Esempio n. 3
0
 public override void OnMouseLeftUp(Point location)
 {
     if (moving)
     {
         moving     = false;
         moveAction = null;
     }
 }
Esempio n. 4
0
 public EntitySelectionTool()
     : base("Select / Move", "selection.png")
 {
     moveAction = null;
 }
Esempio n. 5
0
 public EntityMoveTool()
     : base("Move", "move.png")
 {
     moving     = false;
     moveAction = null;
 }