2022-06-29 16:23:35 +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.
|
|
|
|
|
|
2022-07-04 04:51:30 +08:00
|
|
|
|
using System.Diagnostics;
|
|
|
|
|
using osu.Framework.Allocation;
|
|
|
|
|
using osu.Framework.Bindables;
|
2022-06-29 16:23:35 +08:00
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
|
using osu.Framework.Graphics.Containers;
|
2022-07-04 04:51:30 +08:00
|
|
|
|
using osu.Game.Rulesets.Objects.Drawables;
|
|
|
|
|
using osu.Game.Rulesets.Osu.Objects.Drawables;
|
2022-06-29 16:23:35 +08:00
|
|
|
|
|
|
|
|
|
namespace osu.Game.Rulesets.Osu.Skinning.Legacy
|
|
|
|
|
{
|
|
|
|
|
public class LegacyFollowCircle : CompositeDrawable
|
|
|
|
|
{
|
2022-07-04 04:51:30 +08:00
|
|
|
|
[Resolved(canBeNull: true)]
|
|
|
|
|
private DrawableHitObject? parentObject { get; set; }
|
|
|
|
|
|
2022-06-29 16:23:35 +08:00
|
|
|
|
public LegacyFollowCircle(Drawable animationContent)
|
|
|
|
|
{
|
|
|
|
|
// follow circles are 2x the hitcircle resolution in legacy skins (since they are scaled down from >1x
|
|
|
|
|
animationContent.Scale *= 0.5f;
|
|
|
|
|
animationContent.Anchor = Anchor.Centre;
|
|
|
|
|
animationContent.Origin = Anchor.Centre;
|
|
|
|
|
|
2022-07-04 04:51:30 +08:00
|
|
|
|
Alpha = 0f;
|
2022-06-29 16:23:35 +08:00
|
|
|
|
RelativeSizeAxes = Axes.Both;
|
|
|
|
|
InternalChild = animationContent;
|
|
|
|
|
}
|
2022-07-04 04:51:30 +08:00
|
|
|
|
|
|
|
|
|
[BackgroundDependencyLoader]
|
|
|
|
|
private void load()
|
|
|
|
|
{
|
|
|
|
|
if (parentObject != null)
|
|
|
|
|
{
|
|
|
|
|
var slider = (DrawableSlider)parentObject;
|
|
|
|
|
slider.Tracking.BindValueChanged(trackingChanged, true);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void LoadComplete()
|
|
|
|
|
{
|
|
|
|
|
base.LoadComplete();
|
|
|
|
|
|
|
|
|
|
if (parentObject != null)
|
|
|
|
|
{
|
|
|
|
|
parentObject.ApplyCustomUpdateState += updateStateTransforms;
|
|
|
|
|
updateStateTransforms(parentObject, parentObject.State.Value);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void trackingChanged(ValueChangedEvent<bool> tracking)
|
|
|
|
|
{
|
|
|
|
|
Debug.Assert(parentObject != null);
|
|
|
|
|
|
|
|
|
|
if (parentObject.Judged)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
const float scale_duration = 180f;
|
|
|
|
|
const float fade_duration = 90f;
|
|
|
|
|
|
|
|
|
|
double maxScaleDuration = parentObject.HitStateUpdateTime - Time.Current;
|
|
|
|
|
double realScaleDuration = scale_duration;
|
|
|
|
|
if (tracking.NewValue && maxScaleDuration < realScaleDuration)
|
|
|
|
|
realScaleDuration = maxScaleDuration;
|
|
|
|
|
double realFadeDuration = fade_duration * realScaleDuration / fade_duration;
|
|
|
|
|
|
|
|
|
|
this.ScaleTo(tracking.NewValue ? DrawableSliderBall.FOLLOW_AREA : 1f, realScaleDuration, Easing.OutQuad)
|
|
|
|
|
.FadeTo(tracking.NewValue ? 1f : 0f, realFadeDuration, Easing.OutQuad);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void updateStateTransforms(DrawableHitObject drawableObject, ArmedState state)
|
|
|
|
|
{
|
|
|
|
|
if (drawableObject is not DrawableSlider)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
const float shrink_duration = 200f;
|
|
|
|
|
const float fade_duration = 240f;
|
|
|
|
|
|
|
|
|
|
using (BeginAbsoluteSequence(drawableObject.HitStateUpdateTime))
|
|
|
|
|
{
|
|
|
|
|
this.ScaleTo(DrawableSliderBall.FOLLOW_AREA * 0.8f, shrink_duration, Easing.OutQuint)
|
|
|
|
|
.FadeOut(fade_duration, Easing.InQuint);
|
|
|
|
|
}
|
|
|
|
|
}
|
2022-06-29 16:23:35 +08:00
|
|
|
|
}
|
|
|
|
|
}
|