1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-18 11:02:57 +08:00

Move spinner approach circle to its own SkinnableDrawable

This commit is contained in:
Salman Ahmed 2021-06-18 20:33:50 +03:00
parent f7b5341663
commit 843c8bd7a4
6 changed files with 76 additions and 41 deletions

View File

@ -111,7 +111,7 @@ namespace osu.Game.Rulesets.Osu.Mods
// todo: hide background
using (spinner.BeginAbsoluteSequence(hitObject.StartTime - hitObject.TimePreempt))
spinner.HideApproachCircle();
spinner.ApproachCircle.Hide();
using (spinner.BeginAbsoluteSequence(fadeStartTime))
spinner.FadeOut(fadeDuration);

View File

@ -29,6 +29,8 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables
public new OsuSpinnerJudgementResult Result => (OsuSpinnerJudgementResult)base.Result;
public SkinnableDrawable ApproachCircle { get; private set; }
public SpinnerRotationTracker RotationTracker { get; private set; }
private SpinnerSpmCalculator spmCalculator;
@ -42,8 +44,6 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables
private const float spinning_sample_initial_frequency = 1.0f;
private const float spinning_sample_modulated_base_frequency = 0.5f;
internal readonly Bindable<Visibility> ApproachCircleVisibility = new Bindable<Visibility>(Visibility.Visible);
/// <summary>
/// The amount of bonus score gained from spinning after the required number of spins, for display purposes.
/// </summary>
@ -88,7 +88,8 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables
RelativeSizeAxes = Axes.Y,
Children = new Drawable[]
{
new SkinnableDrawable(new OsuSkinComponent(OsuSkinComponents.SpinnerBody), _ => new DefaultSpinner()),
ApproachCircle = new SkinnableDrawable(new OsuSkinComponent(OsuSkinComponents.SpinnerApproachCircle)),
new SkinnableSpinnerBody(ApproachCircle.CreateProxy(), _ => new DefaultSpinner()),
RotationTracker = new SpinnerRotationTracker(this)
}
},
@ -287,11 +288,6 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables
updateBonusScore();
}
/// <summary>
/// Hides the spinner's approach circle if it has one.
/// </summary>
public void HideApproachCircle() => this.TransformBindableTo(ApproachCircleVisibility, Visibility.Hidden);
private static readonly int score_per_tick = new SpinnerBonusTick.OsuSpinnerBonusTickJudgement().MaxNumericResult;
private int wholeSpins;

View File

@ -10,7 +10,6 @@ namespace osu.Game.Rulesets.Osu
Cursor,
CursorTrail,
SliderScorePoint,
ApproachCircle,
ReverseArrow,
HitCircleText,
SliderHeadHitCircle,
@ -19,5 +18,6 @@ namespace osu.Game.Rulesets.Osu
SliderBall,
SliderBody,
SpinnerBody,
SpinnerApproachCircle,
}
}

View File

@ -32,7 +32,6 @@ namespace osu.Game.Rulesets.Osu.Skinning.Legacy
protected DrawableSpinner DrawableSpinner { get; private set; }
private Drawable approachCircle;
private Sprite spin;
private Sprite clear;
@ -61,7 +60,6 @@ namespace osu.Game.Rulesets.Osu.Skinning.Legacy
RelativeSizeAxes = Axes.Both,
Children = new[]
{
approachCircle = getSpinnerApproachCircle(source),
spin = new Sprite
{
Anchor = Anchor.TopCentre,
@ -104,28 +102,8 @@ namespace osu.Game.Rulesets.Osu.Skinning.Legacy
}.With(s => s.Font = s.Font.With(fixedWidth: false)),
}
});
static Drawable getSpinnerApproachCircle(ISkinSource source)
{
var spinnerProvider = source.FindProvider(s =>
s.GetTexture("spinner-circle") != null ||
s.GetTexture("spinner-top") != null);
if (spinnerProvider is DefaultLegacySkin)
return Empty();
return new Sprite
{
Anchor = Anchor.TopCentre,
Origin = Anchor.Centre,
Texture = source.GetTexture("spinner-approachcircle"),
Scale = new Vector2(SPRITE_SCALE * 1.86f),
Y = SPINNER_Y_CENTRE,
};
}
}
private IBindable<Visibility> approachCircleVisibility;
private IBindable<double> gainedBonus;
private IBindable<double> spinsPerMinute;
@ -135,12 +113,6 @@ namespace osu.Game.Rulesets.Osu.Skinning.Legacy
{
base.LoadComplete();
approachCircleVisibility = DrawableSpinner.ApproachCircleVisibility.GetBoundCopy();
approachCircleVisibility.BindValueChanged(v =>
{
approachCircle.Alpha = v.NewValue == Visibility.Hidden ? 0 : 1;
}, true);
gainedBonus = DrawableSpinner.GainedBonus.GetBoundCopy();
gainedBonus.BindValueChanged(bonus =>
{
@ -204,9 +176,6 @@ namespace osu.Game.Rulesets.Osu.Skinning.Legacy
spmCounter.MoveToOffset(new Vector2(0, -spm_hide_offset), d.HitObject.TimeFadeIn, Easing.Out);
}
using (BeginAbsoluteSequence(d.HitObject.StartTime))
approachCircle.ScaleTo(SPRITE_SCALE * 1.86f).ScaleTo(SPRITE_SCALE * 0.1f, d.HitObject.Duration);
double spinFadeOutLength = Math.Min(400, d.HitObject.Duration);
using (BeginAbsoluteSequence(drawableHitObject.HitStateUpdateTime - spinFadeOutLength, true))

View File

@ -0,0 +1,64 @@
// 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 JetBrains.Annotations;
using osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Sprites;
using osu.Game.Rulesets.Objects.Drawables;
using osu.Game.Rulesets.Osu.Objects.Drawables;
using osu.Game.Skinning;
using osuTK;
using static osu.Game.Rulesets.Osu.Skinning.Legacy.LegacySpinner;
namespace osu.Game.Rulesets.Osu.Skinning.Legacy
{
public class LegacySpinnerApproachCircle : CompositeDrawable
{
private DrawableSpinner drawableSpinner;
[CanBeNull]
private Sprite sprite;
[BackgroundDependencyLoader]
private void load(DrawableHitObject drawableHitObject, ISkinSource source)
{
drawableSpinner = (DrawableSpinner)drawableHitObject;
AutoSizeAxes = Axes.Both;
var spinnerProvider = source.FindProvider(s =>
s.GetTexture("spinner-circle") != null ||
s.GetTexture("spinner-top") != null);
if (spinnerProvider is DefaultLegacySkin)
return;
InternalChild = sprite = new Sprite
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Texture = source.GetTexture("spinner-approachcircle"),
Scale = new Vector2(SPRITE_SCALE * 1.86f),
};
}
protected override void LoadComplete()
{
base.LoadComplete();
drawableSpinner.ApplyCustomUpdateState += updateStateTransforms;
updateStateTransforms(drawableSpinner, drawableSpinner.State.Value);
}
private void updateStateTransforms(DrawableHitObject drawableHitObject, ArmedState state)
{
if (!(drawableHitObject is DrawableSpinner spinner))
return;
using (BeginAbsoluteSequence(spinner.HitObject.StartTime))
sprite?.ScaleTo(SPRITE_SCALE * 0.1f, spinner.HitObject.Duration);
}
}
}

View File

@ -121,6 +121,12 @@ namespace osu.Game.Rulesets.Osu.Skinning.Legacy
return new LegacyOldStyleSpinner();
return null;
case OsuSkinComponents.SpinnerApproachCircle:
if (Source.GetTexture("spinner-approachcircle") != null)
return new LegacySpinnerApproachCircle();
return null;
}
}