Skip to content

Fix cursor scale animation not matching stable on classic skins #26567

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion osu.Game.Rulesets.Osu/Skinning/Argon/ArgonCursor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

namespace osu.Game.Rulesets.Osu.Skinning.Argon
{
public partial class ArgonCursor : OsuCursorSprite
public partial class ArgonCursor : SkinnableCursor
{
public ArgonCursor()
{
Expand Down
16 changes: 15 additions & 1 deletion osu.Game.Rulesets.Osu/Skinning/Legacy/LegacyCursor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,11 @@

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;

Expand Down Expand Up @@ -51,5 +54,16 @@ protected override void LoadComplete()
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);
}
}
}
11 changes: 4 additions & 7 deletions osu.Game.Rulesets.Osu/UI/Cursor/OsuCursor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,12 @@ public partial class OsuCursor : SkinReloadableDrawable
{
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;

Expand Down Expand Up @@ -108,18 +105,18 @@ public void Expand()
{
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.
/// </summary>
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()
{
Expand Down
19 changes: 0 additions & 19 deletions osu.Game.Rulesets.Osu/UI/Cursor/OsuCursorSprite.cs

This file was deleted.

31 changes: 31 additions & 0 deletions osu.Game.Rulesets.Osu/UI/Cursor/SkinnableCursor.cs
Original file line number Diff line number Diff line change
@@ -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; }
}
}