コード例 #1
0
        private void Field_Click(object sender, EventArgs e)
        {
            NavigationFocus.Focus();
            if (View.Editor == null || View.Editor.ActiveTool == null)
            {
                return;
            }
            var      mE          = (MouseEventArgs)e;
            Vector2f pf          = ren.ImageToGame(mE.X, mE.Y - (Field.Height - Field.Image.Height) / 2);
            Position p           = new Position((int)Math.Round(pf.X), (int)Math.Round(pf.Y));
            int      actionIndex = 0;

            if (mE.Button == MouseButtons.Left)
            {
                actionIndex = 1;
            }
            if (mE.Button == MouseButtons.Right)
            {
                actionIndex = 2;
            }
            if (mE.Button == MouseButtons.Left && ModifierKeys == Keys.Shift)
            {
                actionIndex = 2;
            }
            if (mE.Button == MouseButtons.Middle)
            {
                actionIndex = 3;
            }
            if (mE.Button == MouseButtons.Left && ModifierKeys == Keys.Control)
            {
                actionIndex = 3;
            }
            if (actionIndex == 0)
            {
                return;
            }
            if (!Game.State.IsPositionValid(p))
            {
                return;
            }
            List <GameAction> actions = View.Editor.ActiveTool.Click(Game, actionIndex, p).ToList();

            View.Editor.AddActions(actions);
        }
コード例 #2
0
        private void GameTreePaintBox_Click(object sender, EventArgs e)
        {
            NavigationFocus.Focus();
            if (View.Editor == null)
            {
                return;
            }
            var   mE       = (MouseEventArgs)e;
            Point pixelPos = mE.Location;
            int   x        = (pixelPos.X - GameTreePaintBox.AutoScrollPosition.X) / TreeBlockSize;
            int   y        = (pixelPos.Y - GameTreePaintBox.AutoScrollPosition.Y) / TreeBlockSize;
            int?  node     = Game.Tree.NodeAtPosition(new Vector2i(x, y));

            if (node == null)
            {
                return;
            }
            View.Editor.AddActions(new GameAction[] { new SelectStateAction((int)node) });
        }