mirror of
https://github.com/ppy/osu
synced 2025-01-09 23:59:44 +00:00
Nicer cursor orientation when dragging
This commit is contained in:
parent
9af0104e3e
commit
f636f59289
@ -20,6 +20,26 @@ namespace osu.Game.Graphics.Cursor
|
|||||||
{
|
{
|
||||||
protected override Drawable CreateCursor() => new Cursor();
|
protected override Drawable CreateCursor() => new Cursor();
|
||||||
|
|
||||||
|
protected override bool OnMouseMove(InputState state)
|
||||||
|
{
|
||||||
|
if (state.Mouse.HasMainButtonPressed)
|
||||||
|
{
|
||||||
|
Vector2 offset = state.Mouse.Delta;
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
protected override bool OnMouseDown(InputState state, MouseDownEventArgs args)
|
protected override bool OnMouseDown(InputState state, MouseDownEventArgs args)
|
||||||
{
|
{
|
||||||
ActiveCursor.Scale = new Vector2(1);
|
ActiveCursor.Scale = new Vector2(1);
|
||||||
@ -35,7 +55,7 @@ namespace osu.Game.Graphics.Cursor
|
|||||||
if (!state.Mouse.HasMainButtonPressed)
|
if (!state.Mouse.HasMainButtonPressed)
|
||||||
{
|
{
|
||||||
((Cursor)ActiveCursor).AdditiveLayer.FadeOut(500, EasingTypes.OutQuint);
|
((Cursor)ActiveCursor).AdditiveLayer.FadeOut(500, EasingTypes.OutQuint);
|
||||||
ActiveCursor.RotateTo(0, 200, EasingTypes.OutQuint);
|
ActiveCursor.RotateTo(0, 600, EasingTypes.OutElasticHalf);
|
||||||
ActiveCursor.ScaleTo(1, 500, EasingTypes.OutElastic);
|
ActiveCursor.ScaleTo(1, 500, EasingTypes.OutElastic);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -49,12 +69,6 @@ namespace osu.Game.Graphics.Cursor
|
|||||||
return base.OnClick(state);
|
return base.OnClick(state);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override bool OnDragStart(InputState state)
|
|
||||||
{
|
|
||||||
ActiveCursor.RotateTo(-30, 600, EasingTypes.OutElastic);
|
|
||||||
return base.OnDragStart(state);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override void PopIn()
|
protected override void PopIn()
|
||||||
{
|
{
|
||||||
ActiveCursor.FadeTo(1, 250, EasingTypes.OutQuint);
|
ActiveCursor.FadeTo(1, 250, EasingTypes.OutQuint);
|
||||||
|
Loading…
Reference in New Issue
Block a user