2020-07-29 21:31:18 +08:00
|
|
|
// 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.Allocation;
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
using osu.Framework.Graphics.Containers;
|
|
|
|
using osu.Framework.Graphics.Sprites;
|
2020-07-30 11:05:19 +08:00
|
|
|
using osu.Framework.Utils;
|
2020-07-29 21:31:18 +08:00
|
|
|
using osu.Game.Rulesets.Objects.Drawables;
|
|
|
|
using osu.Game.Rulesets.Osu.Objects.Drawables;
|
|
|
|
using osu.Game.Skinning;
|
2020-07-30 11:05:19 +08:00
|
|
|
using osuTK;
|
|
|
|
using osuTK.Graphics;
|
2020-07-29 21:31:18 +08:00
|
|
|
|
|
|
|
namespace osu.Game.Rulesets.Osu.Skinning
|
|
|
|
{
|
2020-07-30 09:35:48 +08:00
|
|
|
/// <summary>
|
|
|
|
/// Legacy skinned spinner with two main spinning layers, one fixed overlay and one final spinning overlay.
|
|
|
|
/// No background layer.
|
|
|
|
/// </summary>
|
2020-07-29 21:31:18 +08:00
|
|
|
public class LegacyNewStyleSpinner : CompositeDrawable
|
|
|
|
{
|
|
|
|
private Sprite discBottom;
|
|
|
|
private Sprite discTop;
|
|
|
|
private Sprite spinningMiddle;
|
2020-07-30 11:05:19 +08:00
|
|
|
private Sprite fixedMiddle;
|
2020-07-29 21:31:18 +08:00
|
|
|
|
|
|
|
private DrawableSpinner drawableSpinner;
|
|
|
|
|
2020-07-30 11:05:19 +08:00
|
|
|
private const float final_scale = 0.625f;
|
|
|
|
|
2020-07-29 21:31:18 +08:00
|
|
|
[BackgroundDependencyLoader]
|
|
|
|
private void load(ISkinSource source, DrawableHitObject drawableObject)
|
|
|
|
{
|
|
|
|
drawableSpinner = (DrawableSpinner)drawableObject;
|
|
|
|
|
2020-07-30 11:05:19 +08:00
|
|
|
Scale = new Vector2(final_scale);
|
|
|
|
|
2020-07-29 21:31:18 +08:00
|
|
|
InternalChildren = new Drawable[]
|
|
|
|
{
|
|
|
|
discBottom = new Sprite
|
|
|
|
{
|
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
Origin = Anchor.Centre,
|
|
|
|
Texture = source.GetTexture("spinner-bottom")
|
|
|
|
},
|
|
|
|
discTop = new Sprite
|
|
|
|
{
|
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
Origin = Anchor.Centre,
|
|
|
|
Texture = source.GetTexture("spinner-top")
|
|
|
|
},
|
2020-07-30 11:05:19 +08:00
|
|
|
fixedMiddle = new Sprite
|
2020-07-29 21:31:18 +08:00
|
|
|
{
|
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
Origin = Anchor.Centre,
|
|
|
|
Texture = source.GetTexture("spinner-middle")
|
|
|
|
},
|
|
|
|
spinningMiddle = new Sprite
|
|
|
|
{
|
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
Origin = Anchor.Centre,
|
|
|
|
Texture = source.GetTexture("spinner-middle2")
|
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
protected override void LoadComplete()
|
|
|
|
{
|
|
|
|
base.LoadComplete();
|
|
|
|
|
2020-09-28 16:20:36 +08:00
|
|
|
drawableSpinner.ApplyCustomUpdateState += updateStateTransforms;
|
2020-10-01 19:38:47 +08:00
|
|
|
updateStateTransforms(drawableSpinner, drawableSpinner.State.Value);
|
2020-07-29 21:31:18 +08:00
|
|
|
}
|
|
|
|
|
2020-09-28 16:20:36 +08:00
|
|
|
private void updateStateTransforms(DrawableHitObject drawableHitObject, ArmedState state)
|
2020-07-29 21:31:18 +08:00
|
|
|
{
|
2020-10-01 19:38:47 +08:00
|
|
|
if (!(drawableHitObject is DrawableSpinner))
|
|
|
|
return;
|
|
|
|
|
2020-11-05 12:51:46 +08:00
|
|
|
var spinner = drawableSpinner.HitObject;
|
2020-07-29 21:31:18 +08:00
|
|
|
|
2020-10-02 15:17:57 +08:00
|
|
|
using (BeginAbsoluteSequence(spinner.StartTime - spinner.TimePreempt, true))
|
|
|
|
this.FadeOut();
|
|
|
|
|
2020-08-13 17:20:45 +08:00
|
|
|
using (BeginAbsoluteSequence(spinner.StartTime - spinner.TimeFadeIn / 2, true))
|
|
|
|
this.FadeInFromZero(spinner.TimeFadeIn / 2);
|
2020-07-30 11:05:19 +08:00
|
|
|
|
2020-10-02 15:17:57 +08:00
|
|
|
using (BeginAbsoluteSequence(spinner.StartTime - spinner.TimePreempt, true))
|
|
|
|
{
|
|
|
|
fixedMiddle.FadeColour(Color4.White);
|
|
|
|
|
|
|
|
using (BeginDelayedSequence(spinner.TimePreempt, true))
|
|
|
|
fixedMiddle.FadeColour(Color4.Red, spinner.Duration);
|
|
|
|
}
|
2020-07-29 21:31:18 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
protected override void Update()
|
|
|
|
{
|
|
|
|
base.Update();
|
|
|
|
spinningMiddle.Rotation = discTop.Rotation = drawableSpinner.RotationTracker.Rotation;
|
|
|
|
discBottom.Rotation = discTop.Rotation / 3;
|
2020-07-30 11:05:19 +08:00
|
|
|
|
2020-07-31 13:48:56 +08:00
|
|
|
Scale = new Vector2(final_scale * (0.8f + (float)Interpolation.ApplyEasing(Easing.Out, drawableSpinner.Progress) * 0.2f));
|
2020-07-29 21:31:18 +08:00
|
|
|
}
|
2020-09-28 16:41:10 +08:00
|
|
|
|
|
|
|
protected override void Dispose(bool isDisposing)
|
|
|
|
{
|
|
|
|
base.Dispose(isDisposing);
|
2020-09-28 16:46:22 +08:00
|
|
|
|
|
|
|
if (drawableSpinner != null)
|
|
|
|
drawableSpinner.ApplyCustomUpdateState -= updateStateTransforms;
|
2020-09-28 16:41:10 +08:00
|
|
|
}
|
2020-07-29 21:31:18 +08:00
|
|
|
}
|
|
|
|
}
|