Ejemplo n.º 1
0
        private void SetFreeLook()
        {
            if (!Viewport.IsUnlocked(this))
            {
                return;
            }
            FreeLook = false;

            if (FreeLookToggle)
            {
                FreeLook = true;
            }
            else
            {
                var left  = Control.MouseButtons.HasFlag(MouseButtons.Left);
                var right = Control.MouseButtons.HasFlag(MouseButtons.Right);

                if (ToolManager.ActiveTool is CameraTool)
                {
                    FreeLook = left || right;
                }
                else
                {
                    var space = KeyboardState.IsKeyDown(Keys.Space);
                    var req   = Sledge.Settings.View.Camera3DPanRequiresMouseClick;
                    FreeLook = space && (!req || left || right);
                }
            }

            if (FreeLook && CursorVisible)
            {
                CursorClip       = Cursor.Clip;
                Cursor.Clip      = Viewport.RectangleToScreen(new Rectangle(0, 0, Viewport.Width, Viewport.Height));
                Viewport.Capture = true;
                CursorVisible    = false;
                Cursor.Hide();
                Viewport.AquireInputLock(this);
            }
            else if (!FreeLook && !CursorVisible)
            {
                Cursor.Clip      = CursorClip;
                CursorClip       = Rectangle.Empty;
                Viewport.Capture = false;
                CursorVisible    = true;
                Cursor.Show();
                Viewport.ReleaseInputLock(this);
            }
        }
Ejemplo n.º 2
0
        private void SetFreeLook()
        {
            if (!Viewport.IsUnlocked(this))
            {
                return;
            }
            FreeLook = false;

            if (FreeLookToggle)
            {
                FreeLook = true;
            }
            else
            {
                var left  = Control.MouseButtons.HasFlag(MouseButtons.Left);
                var right = Control.MouseButtons.HasFlag(MouseButtons.Right);

                var activeTool = _context.Get <ITool>("ActiveTool");
                if (activeTool != null && activeTool.GetType().Name == "CameraTool")
                {
                    FreeLook = left || right;
                }
                else
                {
                    var space = KeyboardState.IsKeyDown(Keys.Space);
                    var req   = CameraNavigationViewportSettings.Camera3DPanRequiresMouseClick;
                    FreeLook = space && (!req || left || right);
                }
            }

            if (FreeLook && CursorVisible)
            {
                CursorClip  = Cursor.Clip;
                Cursor.Clip = Viewport.Control.RectangleToScreen(new Rectangle(0, 0, Viewport.Width, Viewport.Height));
                SetCapture(true);
                Viewport.AquireInputLock(this);
            }
            else if (!FreeLook && !CursorVisible)
            {
                Cursor.Clip = CursorClip;
                CursorClip  = Rectangle.Empty;
                SetCapture(false);
                Viewport.ReleaseInputLock(this);
            }
        }