Exemple #1
0
        public virtual bool OnMouseEvent(Editor.MouseEvent mouseEvent, MouseEventArgs mouseEventArgs)
        {
            switch (mouseEvent)
            {
            case Editor.MouseEvent.MouseDown:
                if ((Control.ModifierKeys & Keys.Shift) == Keys.None)
                {
                    Vec3 cursorPos;
                    if (Editor.RayCastTerrainFromMouse(out cursorPos))
                    {
                        this.UpdateCursorPos(cursorPos);
                        this.OnBeginPaint();
                    }
                }
                else
                {
                    this.m_painting = ToolPaintStrict.PaintingMode.Shortcut;
                }
                if (this.m_painting != ToolPaintStrict.PaintingMode.None)
                {
                    Editor.Viewport.CaptureMouse  = true;
                    Editor.Viewport.CameraEnabled = false;
                }
                break;

            case Editor.MouseEvent.MouseUp:
                if (this.m_painting != ToolPaintStrict.PaintingMode.None)
                {
                    switch (this.m_painting)
                    {
                    case ToolPaintStrict.PaintingMode.Plus:
                    case ToolPaintStrict.PaintingMode.Minus:
                        this.OnEndPaint();
                        break;
                    }
                    this.m_cursorPos.Z = TerrainManager.GetHeightAtWithWater(this.m_cursorPos.XY);
                    Vec2 captureMousePos;
                    if (Editor.GetScreenPointFromWorldPos(this.m_cursorPos, out captureMousePos, true))
                    {
                        Editor.Viewport.CaptureMousePos = captureMousePos;
                    }
                    Editor.Viewport.CaptureMouse  = false;
                    Editor.Viewport.CameraEnabled = true;
                    this.m_painting = ToolPaintStrict.PaintingMode.None;
                }
                break;

            case Editor.MouseEvent.MouseMove:
                switch (this.m_painting)
                {
                case ToolPaintStrict.PaintingMode.None:
                case ToolPaintStrict.PaintingMode.Plus:
                case ToolPaintStrict.PaintingMode.Minus:
                {
                    Vec3 cursorPos2;
                    this.m_cursorValid = Editor.RayCastTerrainFromMouse(out cursorPos2);
                    this.UpdateCursorPos(cursorPos2);
                    break;
                }
                }
                break;

            case Editor.MouseEvent.MouseMoveDelta:
                switch (this.m_painting)
                {
                case ToolPaintStrict.PaintingMode.Plus:
                case ToolPaintStrict.PaintingMode.Minus:
                {
                    Vec3 cursorPos3 = this.m_cursorPos;
                    Editor.ApplyScreenDeltaToWorldPos(new Vec2((float)mouseEventArgs.X / (float)Editor.Viewport.Width, (float)mouseEventArgs.Y / (float)Editor.Viewport.Height), ref cursorPos3);
                    cursorPos3.Z = TerrainManager.GetHeightAtWithWater(cursorPos3.XY);
                    this.UpdateCursorPos(cursorPos3);
                    break;
                }

                case ToolPaintStrict.PaintingMode.Shortcut:
                {
                    float delta;
                    if (Math.Abs(mouseEventArgs.X) > Math.Abs(mouseEventArgs.Y))
                    {
                        delta = (float)mouseEventArgs.X;
                    }
                    else
                    {
                        delta = (float)(-(float)mouseEventArgs.Y);
                    }
                    this.OnShortcutDelta(delta);
                    break;
                }
                }
                break;
            }
            return(false);
        }
Exemple #2
0
 protected virtual void OnBeginPaint()
 {
     MainForm.Instance.EnableShortcuts = false;
     this.m_painting = (((Control.ModifierKeys & Keys.Control) == Keys.None) ? ToolPaintStrict.PaintingMode.Plus : ToolPaintStrict.PaintingMode.Minus);
     UndoManager.RecordUndo();
 }