1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-14 03:25:11 +08:00

Add method for checking if cursor should rotate

This commit is contained in:
Power Maker 2020-06-03 10:03:39 +02:00
parent fa4d13a22b
commit 86a4664d9b

View File

@ -83,8 +83,9 @@ namespace osu.Game.Graphics.Cursor
activeCursor.AdditiveLayer.FadeInFromZero(800, Easing.OutQuint); activeCursor.AdditiveLayer.FadeInFromZero(800, Easing.OutQuint);
} }
if ((e.Button == MouseButton.Left || e.Button == MouseButton.Right) && cursorRotate.Value) if (shouldRotate(e) && cursorRotate.Value)
{ {
// if cursor is already rotating don't reset its rotate origin
if (!(dragRotationState == DragRotationState.Rotating)) if (!(dragRotationState == DragRotationState.Rotating))
{ {
dragRotationState = DragRotationState.DragStarted; dragRotationState = DragRotationState.DragStarted;
@ -97,13 +98,14 @@ namespace osu.Game.Graphics.Cursor
protected override void OnMouseUp(MouseUpEvent e) protected override void OnMouseUp(MouseUpEvent e)
{ {
if (!e.IsPressed(MouseButton.Left) && !e.IsPressed(MouseButton.Middle) && !e.IsPressed(MouseButton.Right)) // cursor should go back to original size when none of main buttons are pressed
if (!(e.IsPressed(MouseButton.Left) || e.IsPressed(MouseButton.Middle) || e.IsPressed(MouseButton.Right)))
{ {
activeCursor.AdditiveLayer.FadeOutFromOne(500, Easing.OutQuint); activeCursor.AdditiveLayer.FadeOutFromOne(500, Easing.OutQuint);
activeCursor.ScaleTo(1, 500, Easing.OutElastic); activeCursor.ScaleTo(1, 500, Easing.OutElastic);
} }
if (!e.IsPressed(MouseButton.Left) && !e.IsPressed(MouseButton.Right)) if (!shouldRotate(e))
{ {
if (dragRotationState == DragRotationState.Rotating) if (dragRotationState == DragRotationState.Rotating)
activeCursor.RotateTo(0, 600 * (1 + Math.Abs(activeCursor.Rotation / 720)), Easing.OutElasticHalf); activeCursor.RotateTo(0, 600 * (1 + Math.Abs(activeCursor.Rotation / 720)), Easing.OutElasticHalf);
@ -125,6 +127,14 @@ namespace osu.Game.Graphics.Cursor
activeCursor.ScaleTo(0.6f, 250, Easing.In); activeCursor.ScaleTo(0.6f, 250, Easing.In);
} }
private static bool shouldRotate(MouseEvent e)
{
if (e.IsPressed(MouseButton.Left) || e.IsPressed(MouseButton.Right))
return true;
else
return false;
}
public class Cursor : Container public class Cursor : Container
{ {
private Container cursorContainer; private Container cursorContainer;