Exemple #1
0
 protected virtual void OnBeginPaint()
 {
     MainForm.Instance.EnableShortcuts = false;
     this.m_painting = (((Control.ModifierKeys & Keys.Control) == Keys.None) ? ToolPaint.PaintingMode.Plus : ToolPaint.PaintingMode.Minus);
     UndoManager.RecordUndo();
     this.CreateBrush();
 }
Exemple #2
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.m_cursorPos = cursorPos;
                        this.OnBeginPaint();
                    }
                }
                else
                {
                    this.m_painting = ToolPaint.PaintingMode.Shortcut;
                }
                if (this.m_painting != ToolPaint.PaintingMode.None)
                {
                    Editor.Viewport.CaptureMouse = true;
                    Editor.Viewport.CameraEnabled = false;
                }
                break;

            case Editor.MouseEvent.MouseUp:
                if (this.m_painting != ToolPaint.PaintingMode.None)
                {
                    switch (this.m_painting)
                    {
                    case ToolPaint.PaintingMode.Plus:
                    case ToolPaint.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 = ToolPaint.PaintingMode.None;
                }
                break;

            case Editor.MouseEvent.MouseMove:
                switch (this.m_painting)
                {
                case ToolPaint.PaintingMode.None:
                case ToolPaint.PaintingMode.Plus:
                case ToolPaint.PaintingMode.Minus:
                    this.m_cursorValid = Editor.RayCastTerrainFromMouse(out this.m_cursorPos);
                    break;
                }
                break;

            case Editor.MouseEvent.MouseMoveDelta:
                switch (this.m_painting)
                {
                case ToolPaint.PaintingMode.Plus:
                case ToolPaint.PaintingMode.Minus:
                    if (!this.m_grabMode.Value)
                    {
                        Editor.ApplyScreenDeltaToWorldPos(new Vec2((float)mouseEventArgs.X / (float)Editor.Viewport.Width, (float)mouseEventArgs.Y / (float)Editor.Viewport.Height), ref this.m_cursorPos);
                        this.m_cursorPos.Z = TerrainManager.GetHeightAtWithWater(this.m_cursorPos.XY);
                    }
                    else
                    {
                        this.OnPaintGrab((float)mouseEventArgs.X, (float)mouseEventArgs.Y);
                    }
                    break;

                case ToolPaint.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 #3
0
 protected virtual void OnBeginPaint()
 {
     MainForm.Instance.EnableShortcuts = false;
     this.m_painting = (((Control.ModifierKeys & Keys.Control) == Keys.None) ? ToolPaint.PaintingMode.Plus : ToolPaint.PaintingMode.Minus);
     UndoManager.RecordUndo();
     this.CreateBrush();
 }
Exemple #4
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.m_cursorPos = cursorPos;
                        this.OnBeginPaint();
                    }
                }
                else
                {
                    this.m_painting = ToolPaint.PaintingMode.Shortcut;
                }
                if (this.m_painting != ToolPaint.PaintingMode.None)
                {
                    Editor.Viewport.CaptureMouse  = true;
                    Editor.Viewport.CameraEnabled = false;
                }
                break;

            case Editor.MouseEvent.MouseUp:
                if (this.m_painting != ToolPaint.PaintingMode.None)
                {
                    switch (this.m_painting)
                    {
                    case ToolPaint.PaintingMode.Plus:
                    case ToolPaint.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 = ToolPaint.PaintingMode.None;
                }
                break;

            case Editor.MouseEvent.MouseMove:
                switch (this.m_painting)
                {
                case ToolPaint.PaintingMode.None:
                case ToolPaint.PaintingMode.Plus:
                case ToolPaint.PaintingMode.Minus:
                    this.m_cursorValid = Editor.RayCastTerrainFromMouse(out this.m_cursorPos);
                    break;
                }
                break;

            case Editor.MouseEvent.MouseMoveDelta:
                switch (this.m_painting)
                {
                case ToolPaint.PaintingMode.Plus:
                case ToolPaint.PaintingMode.Minus:
                    if (!this.m_grabMode.Value)
                    {
                        Editor.ApplyScreenDeltaToWorldPos(new Vec2((float)mouseEventArgs.X / (float)Editor.Viewport.Width, (float)mouseEventArgs.Y / (float)Editor.Viewport.Height), ref this.m_cursorPos);
                        this.m_cursorPos.Z = TerrainManager.GetHeightAtWithWater(this.m_cursorPos.XY);
                    }
                    else
                    {
                        this.OnPaintGrab((float)mouseEventArgs.X, (float)mouseEventArgs.Y);
                    }
                    break;

                case ToolPaint.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);
        }