1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-11 15:47:26 +08:00

Add method for any mouse button pressed.

This commit is contained in:
Power Maker 2020-06-03 20:43:47 +02:00
parent 89d973416a
commit 3fa02a5782

View File

@ -15,6 +15,7 @@ using osu.Framework.Graphics.Textures;
using osu.Framework.Input.Events;
using osuTK.Input;
using osu.Framework.Utils;
using osu.Game.Screens.Multi.Components;
namespace osu.Game.Graphics.Cursor
{
@ -83,7 +84,7 @@ namespace osu.Game.Graphics.Cursor
activeCursor.AdditiveLayer.FadeInFromZero(800, Easing.OutQuint);
}
if (shouldRotate(e) && cursorRotate.Value)
if (shouldRotateCursor(e) && cursorRotate.Value)
{
// if cursor is already rotating don't reset its rotate origin
if (!(dragRotationState == DragRotationState.Rotating))
@ -99,13 +100,13 @@ namespace osu.Game.Graphics.Cursor
protected override void OnMouseUp(MouseUpEvent e)
{
// 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)))
if (!anyMouseButtonPressed(e))
{
activeCursor.AdditiveLayer.FadeOutFromOne(500, Easing.OutQuint);
activeCursor.ScaleTo(1, 500, Easing.OutElastic);
}
if (!shouldRotate(e))
if (!shouldRotateCursor(e))
{
if (dragRotationState == DragRotationState.Rotating)
activeCursor.RotateTo(0, 600 * (1 + Math.Abs(activeCursor.Rotation / 720)), Easing.OutElasticHalf);
@ -127,7 +128,9 @@ namespace osu.Game.Graphics.Cursor
activeCursor.ScaleTo(0.6f, 250, Easing.In);
}
private static bool shouldRotate(MouseEvent e) => e.IsPressed(MouseButton.Left) || e.IsPressed(MouseButton.Right);
private static bool shouldRotateCursor(MouseEvent e) => e.IsPressed(MouseButton.Left) || e.IsPressed(MouseButton.Right);
private static bool anyMouseButtonPressed(MouseEvent e) => e.IsPressed(MouseButton.Left) || e.IsPressed(MouseButton.Middle) || e.IsPressed(MouseButton.Right);
public class Cursor : Container
{