예제 #1
0
파일: MenuCursor.cs 프로젝트: oscsan/osu
        protected override bool OnMouseMove(InputState state)
        {
            if (dragging)
            {
                Debug.Assert(state.Mouse.PositionMouseDown != null);

                // don't start rotating until we're moved a minimum distance away from the mouse down location,
                // else it can have an annoying effect.
                startRotation |= Vector2Extensions.Distance(state.Mouse.Position, state.Mouse.PositionMouseDown.Value) > 30;

                if (startRotation)
                {
                    Vector2 offset  = state.Mouse.Position - state.Mouse.PositionMouseDown.Value;
                    float   degrees = (float)MathHelper.RadiansToDegrees(Math.Atan2(-offset.X, offset.Y)) + 24.3f;

                    // Always rotate in the direction of least distance
                    float diff = (degrees - ActiveCursor.Rotation) % 360;
                    if (diff < -180)
                    {
                        diff += 360;
                    }
                    if (diff > 180)
                    {
                        diff -= 360;
                    }
                    degrees = ActiveCursor.Rotation + diff;

                    ActiveCursor.RotateTo(degrees, 600, Easing.OutQuint);
                }
            }

            return(base.OnMouseMove(state));
        }
예제 #2
0
        protected override bool OnMouseUp(InputState state, MouseUpEventArgs args)
        {
            if (!state.Mouse.HasMainButtonPressed)
            {
                ((Cursor)ActiveCursor).AdditiveLayer.FadeOut(500, EasingTypes.OutQuint);
                ActiveCursor.RotateTo(0, 600 * (1 + Math.Abs(ActiveCursor.Rotation / 720)), EasingTypes.OutElasticHalf);
                ActiveCursor.ScaleTo(1, 500, EasingTypes.OutElastic);
            }

            return(base.OnMouseUp(state, args));
        }
예제 #3
0
        protected override bool OnMouseUp(InputState state, MouseUpEventArgs args)
        {
            if (!state.Mouse.HasMainButtonPressed)
            {
                ((Cursor)ActiveCursor).AdditiveLayer.FadeOut(500, Easing.OutQuint);
                ActiveCursor.ScaleTo(1, 500, Easing.OutElastic);
            }

            if (args.Button == MouseButton.Left)
            {
                if (dragRotationState == DragRotationState.Rotating)
                {
                    ActiveCursor.RotateTo(0, 600 * (1 + Math.Abs(ActiveCursor.Rotation / 720)), Easing.OutElasticHalf);
                }
                dragRotationState = DragRotationState.NotDragging;
            }
            return(base.OnMouseUp(state, args));
        }
예제 #4
0
파일: MenuCursor.cs 프로젝트: Catzzye/osu
        protected override bool OnMouseMove(InputState state)
        {
            if (dragging)
            {
                Vector2 offset  = state.Mouse.Position - state.Mouse.PositionMouseDown ?? state.Mouse.Delta;
                float   degrees = (float)MathHelper.RadiansToDegrees(Math.Atan2(-offset.X, offset.Y)) + 24.3f;

                // Always rotate in the direction of least distance
                float diff = (degrees - ActiveCursor.Rotation) % 360;
                if (diff < -180)
                {
                    diff += 360;
                }
                if (diff > 180)
                {
                    diff -= 360;
                }
                degrees = ActiveCursor.Rotation + diff;

                ActiveCursor.RotateTo(degrees, 600, EasingTypes.OutQuint);
            }

            return(base.OnMouseMove(state));
        }
예제 #5
0
        protected override bool OnMouseMove(InputState state)
        {
            if (dragRotationState != DragRotationState.NotDragging)
            {
                var position = state.Mouse.Position;
                var distance = Vector2Extensions.Distance(position, positionMouseDown);
                // don't start rotating until we're moved a minimum distance away from the mouse down location,
                // else it can have an annoying effect.
                if (dragRotationState == DragRotationState.DragStarted && distance > 30)
                {
                    dragRotationState = DragRotationState.Rotating;
                }
                // don't rotate when distance is zero to avoid NaN
                if (dragRotationState == DragRotationState.Rotating && distance > 0)
                {
                    Vector2 offset  = state.Mouse.Position - positionMouseDown;
                    float   degrees = (float)MathHelper.RadiansToDegrees(Math.Atan2(-offset.X, offset.Y)) + 24.3f;

                    // Always rotate in the direction of least distance
                    float diff = (degrees - ActiveCursor.Rotation) % 360;
                    if (diff < -180)
                    {
                        diff += 360;
                    }
                    if (diff > 180)
                    {
                        diff -= 360;
                    }
                    degrees = ActiveCursor.Rotation + diff;

                    ActiveCursor.RotateTo(degrees, 600, Easing.OutQuint);
                }
            }

            return(base.OnMouseMove(state));
        }