1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-13 13:32:54 +08:00

Fix LegacyCursor's cursormiddle expanding

This commit is contained in:
mcendu 2019-12-09 17:53:16 +08:00
parent 1e49078c52
commit 22f2a4bed2
No known key found for this signature in database
GPG Key ID: FBCD5D45163D6364
2 changed files with 15 additions and 11 deletions

View File

@ -5,13 +5,13 @@ using osu.Framework.Allocation;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Containers;
using osu.Game.Skinning; using osu.Game.Skinning;
using osu.Game.Rulesets.Osu.UI.Cursor;
using osuTK; using osuTK;
namespace osu.Game.Rulesets.Osu.Skinning namespace osu.Game.Rulesets.Osu.Skinning
{ {
public class LegacyCursor : CompositeDrawable public class LegacyCursor : OsuCursorSprite
{ {
private NonPlayfieldSprite cursor;
private bool spin; private bool spin;
public LegacyCursor() public LegacyCursor()
@ -35,7 +35,7 @@ namespace osu.Game.Rulesets.Osu.Skinning
Anchor = Anchor.Centre, Anchor = Anchor.Centre,
Origin = Anchor.Centre, Origin = Anchor.Centre,
}, },
cursor = new NonPlayfieldSprite ExpandTarget = new NonPlayfieldSprite
{ {
Texture = skin.GetTexture("cursor"), Texture = skin.GetTexture("cursor"),
Anchor = Anchor.Centre, Anchor = Anchor.Centre,
@ -47,7 +47,7 @@ namespace osu.Game.Rulesets.Osu.Skinning
protected override void LoadComplete() protected override void LoadComplete()
{ {
if (spin) if (spin)
cursor.Spin(10000, RotationDirection.Clockwise); ExpandTarget.Spin(10000, RotationDirection.Clockwise);
} }
} }
} }

View File

@ -20,7 +20,7 @@ namespace osu.Game.Rulesets.Osu.UI.Cursor
private bool cursorExpand; private bool cursorExpand;
private Container expandTarget; private OsuCursorSprite cursorSprite;
public OsuCursor() public OsuCursor()
{ {
@ -37,17 +37,19 @@ namespace osu.Game.Rulesets.Osu.UI.Cursor
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load() private void load()
{ {
InternalChild = expandTarget = new Container SkinnableDrawable cursor;
InternalChild = new Container
{ {
RelativeSizeAxes = Axes.Both, RelativeSizeAxes = Axes.Both,
Origin = Anchor.Centre, Origin = Anchor.Centre,
Anchor = Anchor.Centre, Anchor = Anchor.Centre,
Child = new SkinnableDrawable(new OsuSkinComponent(OsuSkinComponents.Cursor), _ => new DefaultCursor(), confineMode: ConfineMode.NoScaling) Child = cursor = new SkinnableDrawable(new OsuSkinComponent(OsuSkinComponents.Cursor), _ => new DefaultCursor(), confineMode: ConfineMode.NoScaling)
{ {
Origin = Anchor.Centre, Origin = Anchor.Centre,
Anchor = Anchor.Centre, Anchor = Anchor.Centre,
} }
}; };
cursorSprite = cursor.Drawable as OsuCursorSprite;
} }
private const float pressed_scale = 1.2f; private const float pressed_scale = 1.2f;
@ -57,12 +59,12 @@ namespace osu.Game.Rulesets.Osu.UI.Cursor
{ {
if (!cursorExpand) return; if (!cursorExpand) return;
expandTarget.ScaleTo(released_scale).ScaleTo(pressed_scale, 100, Easing.OutQuad); cursorSprite.ExpandTarget.ScaleTo(released_scale).ScaleTo(pressed_scale, 100, Easing.OutQuad);
} }
public void Contract() => expandTarget.ScaleTo(released_scale, 100, Easing.OutQuad); public void Contract() => cursorSprite.ExpandTarget.ScaleTo(released_scale, 100, Easing.OutQuad);
private class DefaultCursor : CompositeDrawable private class DefaultCursor : OsuCursorSprite
{ {
public DefaultCursor() public DefaultCursor()
{ {
@ -73,8 +75,10 @@ namespace osu.Game.Rulesets.Osu.UI.Cursor
InternalChildren = new Drawable[] InternalChildren = new Drawable[]
{ {
new CircularContainer ExpandTarget = new CircularContainer
{ {
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
RelativeSizeAxes = Axes.Both, RelativeSizeAxes = Axes.Both,
Masking = true, Masking = true,
BorderThickness = size / 6, BorderThickness = size / 6,