mirror of
https://github.com/ppy/osu.git
synced 2024-11-13 16:13:34 +08:00
Fix cursor scale animation not matching stable on classic skins
This commit is contained in:
parent
24a06e1d65
commit
c45daa373e
@ -13,7 +13,7 @@ using osuTK.Graphics;
|
||||
|
||||
namespace osu.Game.Rulesets.Osu.Skinning.Argon
|
||||
{
|
||||
public partial class ArgonCursor : OsuCursorSprite
|
||||
public partial class ArgonCursor : SkinnableCursor
|
||||
{
|
||||
public ArgonCursor()
|
||||
{
|
||||
|
@ -9,8 +9,11 @@ using osuTK;
|
||||
|
||||
namespace osu.Game.Rulesets.Osu.Skinning.Legacy
|
||||
{
|
||||
public partial class LegacyCursor : OsuCursorSprite
|
||||
public partial class LegacyCursor : SkinnableCursor
|
||||
{
|
||||
private const float pressed_scale = 1.3f;
|
||||
private const float released_scale = 1f;
|
||||
|
||||
private readonly ISkin skin;
|
||||
private bool spin;
|
||||
|
||||
@ -51,5 +54,16 @@ namespace osu.Game.Rulesets.Osu.Skinning.Legacy
|
||||
if (spin)
|
||||
ExpandTarget.Spin(10000, RotationDirection.Clockwise);
|
||||
}
|
||||
|
||||
public override void Expand()
|
||||
{
|
||||
ExpandTarget?.ScaleTo(released_scale)
|
||||
.ScaleTo(pressed_scale, 100, Easing.Out);
|
||||
}
|
||||
|
||||
public override void Contract()
|
||||
{
|
||||
ExpandTarget?.ScaleTo(released_scale, 100, Easing.Out);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -24,15 +24,12 @@ namespace osu.Game.Rulesets.Osu.UI.Cursor
|
||||
{
|
||||
public const float SIZE = 28;
|
||||
|
||||
private const float pressed_scale = 1.2f;
|
||||
private const float released_scale = 1f;
|
||||
|
||||
private bool cursorExpand;
|
||||
|
||||
private SkinnableDrawable cursorSprite;
|
||||
private Container cursorScaleContainer = null!;
|
||||
|
||||
private Drawable expandTarget => (cursorSprite.Drawable as OsuCursorSprite)?.ExpandTarget ?? cursorSprite;
|
||||
private SkinnableCursor skinnableCursor => (SkinnableCursor)cursorSprite.Drawable;
|
||||
|
||||
public IBindable<float> CursorScale => cursorScale;
|
||||
|
||||
@ -108,10 +105,10 @@ namespace osu.Game.Rulesets.Osu.UI.Cursor
|
||||
{
|
||||
if (!cursorExpand) return;
|
||||
|
||||
expandTarget.ScaleTo(released_scale).ScaleTo(pressed_scale, 400, Easing.OutElasticHalf);
|
||||
skinnableCursor.Expand();
|
||||
}
|
||||
|
||||
public void Contract() => expandTarget.ScaleTo(released_scale, 400, Easing.OutQuad);
|
||||
public void Contract() => skinnableCursor.Contract();
|
||||
|
||||
/// <summary>
|
||||
/// Get the scale applicable to the ActiveCursor based on a beatmap's circle size.
|
||||
@ -119,7 +116,7 @@ namespace osu.Game.Rulesets.Osu.UI.Cursor
|
||||
public static float GetScaleForCircleSize(float circleSize) =>
|
||||
1f - 0.7f * (1f + circleSize - BeatmapDifficulty.DEFAULT_DIFFICULTY) / BeatmapDifficulty.DEFAULT_DIFFICULTY;
|
||||
|
||||
private partial class DefaultCursor : OsuCursorSprite
|
||||
private partial class DefaultCursor : SkinnableCursor
|
||||
{
|
||||
public DefaultCursor()
|
||||
{
|
||||
|
@ -1,19 +0,0 @@
|
||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
#nullable disable
|
||||
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
|
||||
namespace osu.Game.Rulesets.Osu.UI.Cursor
|
||||
{
|
||||
public abstract partial class OsuCursorSprite : CompositeDrawable
|
||||
{
|
||||
/// <summary>
|
||||
/// The an optional piece of the cursor to expand when in a clicked state.
|
||||
/// If null, the whole cursor will be affected by expansion.
|
||||
/// </summary>
|
||||
public Drawable ExpandTarget { get; protected set; }
|
||||
}
|
||||
}
|
31
osu.Game.Rulesets.Osu/UI/Cursor/SkinnableCursor.cs
Normal file
31
osu.Game.Rulesets.Osu/UI/Cursor/SkinnableCursor.cs
Normal file
@ -0,0 +1,31 @@
|
||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
|
||||
namespace osu.Game.Rulesets.Osu.UI.Cursor
|
||||
{
|
||||
public abstract partial class SkinnableCursor : CompositeDrawable
|
||||
{
|
||||
private const float pressed_scale = 1.2f;
|
||||
private const float released_scale = 1f;
|
||||
|
||||
public virtual void Expand()
|
||||
{
|
||||
ExpandTarget?.ScaleTo(released_scale)
|
||||
.ScaleTo(pressed_scale, 400, Easing.OutElasticHalf);
|
||||
}
|
||||
|
||||
public virtual void Contract()
|
||||
{
|
||||
ExpandTarget?.ScaleTo(released_scale, 400, Easing.OutQuad);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The an optional piece of the cursor to expand when in a clicked state.
|
||||
/// If null, the whole cursor will be affected by expansion.
|
||||
/// </summary>
|
||||
public Drawable? ExpandTarget { get; protected set; }
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user