mirror of
https://github.com/ppy/osu.git
synced 2025-02-14 06:33:17 +08:00
Merge pull request #10701 from peppy/add-spinner-clear
This commit is contained in:
commit
d66ac33032
@ -3,6 +3,7 @@
|
|||||||
|
|
||||||
using System;
|
using System;
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
|
using osu.Framework.Bindables;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
using osu.Framework.Graphics.Sprites;
|
using osu.Framework.Graphics.Sprites;
|
||||||
@ -20,6 +21,7 @@ namespace osu.Game.Rulesets.Osu.Skinning
|
|||||||
protected DrawableSpinner DrawableSpinner { get; private set; }
|
protected DrawableSpinner DrawableSpinner { get; private set; }
|
||||||
|
|
||||||
private Sprite spin;
|
private Sprite spin;
|
||||||
|
private Sprite clear;
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
private void load(DrawableHitObject drawableHitObject, ISkinSource source)
|
private void load(DrawableHitObject drawableHitObject, ISkinSource source)
|
||||||
@ -39,17 +41,58 @@ namespace osu.Game.Rulesets.Osu.Skinning
|
|||||||
Scale = new Vector2(SPRITE_SCALE),
|
Scale = new Vector2(SPRITE_SCALE),
|
||||||
Y = 120 - 45 // offset temporarily to avoid overlapping default spin counter
|
Y = 120 - 45 // offset temporarily to avoid overlapping default spin counter
|
||||||
},
|
},
|
||||||
|
clear = new Sprite
|
||||||
|
{
|
||||||
|
Anchor = Anchor.Centre,
|
||||||
|
Origin = Anchor.Centre,
|
||||||
|
Depth = float.MinValue,
|
||||||
|
Alpha = 0,
|
||||||
|
Texture = source.GetTexture("spinner-clear"),
|
||||||
|
Scale = new Vector2(SPRITE_SCALE),
|
||||||
|
Y = -60
|
||||||
|
},
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private readonly Bindable<bool> completed = new Bindable<bool>();
|
||||||
|
|
||||||
protected override void LoadComplete()
|
protected override void LoadComplete()
|
||||||
{
|
{
|
||||||
base.LoadComplete();
|
base.LoadComplete();
|
||||||
|
|
||||||
|
completed.BindTo(DrawableSpinner.RotationTracker.Complete);
|
||||||
|
completed.BindValueChanged(onCompletedChanged, true);
|
||||||
|
|
||||||
DrawableSpinner.ApplyCustomUpdateState += UpdateStateTransforms;
|
DrawableSpinner.ApplyCustomUpdateState += UpdateStateTransforms;
|
||||||
UpdateStateTransforms(DrawableSpinner, DrawableSpinner.State.Value);
|
UpdateStateTransforms(DrawableSpinner, DrawableSpinner.State.Value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void onCompletedChanged(ValueChangedEvent<bool> completed)
|
||||||
|
{
|
||||||
|
if (completed.NewValue)
|
||||||
|
{
|
||||||
|
double startTime = Math.Min(Time.Current, DrawableSpinner.HitStateUpdateTime - 400);
|
||||||
|
|
||||||
|
using (BeginAbsoluteSequence(startTime, true))
|
||||||
|
{
|
||||||
|
clear.FadeInFromZero(400, Easing.Out);
|
||||||
|
|
||||||
|
clear.ScaleTo(SPRITE_SCALE * 2)
|
||||||
|
.Then().ScaleTo(SPRITE_SCALE * 0.8f, 240, Easing.Out)
|
||||||
|
.Then().ScaleTo(SPRITE_SCALE, 160);
|
||||||
|
}
|
||||||
|
|
||||||
|
const double fade_out_duration = 50;
|
||||||
|
using (BeginAbsoluteSequence(DrawableSpinner.HitStateUpdateTime - fade_out_duration, true))
|
||||||
|
clear.FadeOut(fade_out_duration);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
clear.ClearTransforms();
|
||||||
|
clear.Alpha = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
protected virtual void UpdateStateTransforms(DrawableHitObject drawableHitObject, ArmedState state)
|
protected virtual void UpdateStateTransforms(DrawableHitObject drawableHitObject, ArmedState state)
|
||||||
{
|
{
|
||||||
switch (drawableHitObject)
|
switch (drawableHitObject)
|
||||||
@ -59,7 +102,6 @@ namespace osu.Game.Rulesets.Osu.Skinning
|
|||||||
|
|
||||||
using (BeginAbsoluteSequence(drawableHitObject.HitStateUpdateTime - fadeOutLength, true))
|
using (BeginAbsoluteSequence(drawableHitObject.HitStateUpdateTime - fadeOutLength, true))
|
||||||
spin.FadeOutFromOne(fadeOutLength);
|
spin.FadeOutFromOne(fadeOutLength);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case DrawableSpinnerTick d:
|
case DrawableSpinnerTick d:
|
||||||
|
Loading…
Reference in New Issue
Block a user