예제 #1
0
        public EditMapForm(EditorForm editor, Genus2D.GameData.MapData mapData)
        {
            InitializeComponent();
            _editor  = editor;
            _mapData = mapData;

            NameField.Text           = mapData.GetMapName();
            WidthField.Value         = mapData.GetWidth();
            HeightField.Value        = mapData.GetHeight();
            PvpCheck.Checked         = mapData.PvpEnabled;
            MultiCombatCheck.Checked = mapData.MultiCombat;
        }
예제 #2
0
 public void SetMapData(Genus2D.GameData.MapData data, int mapID)
 {
     MapData = data;
     MapID   = mapID;
     if (data != null)
     {
         this.AutoScrollMinSize = new Size(data.GetWidth() * 32, data.GetHeight() * 32);
     }
     else
     {
         this.AutoScrollMinSize = new Size(0, 0);
     }
 }
예제 #3
0
        protected override void OnMouseDown(MouseEventArgs e)
        {
            base.OnClick(e);
            if (MapData == null)
            {
                return;
            }

            if (_leftGrabbed || _rightGrabbed)
            {
                return;
            }

            if (e.Button == MouseButtons.Left || e.Button == MouseButtons.Right)
            {
                Point mouse = this.PointToClient(Cursor.Position);
                if (mouse.X < MapData.GetWidth() * 32 && mouse.Y < MapData.GetHeight() * 32)
                {
                    int tileX = (mouse.X + HorizontalScroll.Value) / 32;
                    int tileY = (mouse.Y + VerticalScroll.Value) / 32;
                    _lastX = tileX;
                    _lastY = tileY;

                    if (e.Button == MouseButtons.Left)
                    {
                        _leftGrabbed = true;
                        EditorForm.MapTool tool = EditorForm.Instance.GetMapTool();
                        if (tool == EditorForm.MapTool.Rectangle)
                        {
                            _startX = tileX;
                            _startY = tileY;
                            _endX   = tileX;
                            _endY   = tileY;
                            this.Refresh();
                        }
                        else if (tool == EditorForm.MapTool.Pencil)
                        {
                            PaintSelection(tool);
                            this.Refresh();
                        }
                    }
                    else
                    {
                        _rightGrabbed = true;
                    }
                }
            }
        }