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.
|
|
|
|
|
|
|
|
|
|
using osu.Framework.Allocation;
|
|
|
|
|
using osu.Framework.Bindables;
|
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
|
using osu.Framework.Graphics.Containers;
|
|
|
|
|
using osu.Framework.Graphics.Shapes;
|
|
|
|
|
using osu.Game.Rulesets.Objects.Drawables;
|
|
|
|
|
using osu.Game.Rulesets.Osu.Objects;
|
|
|
|
|
using osu.Game.Rulesets.Osu.Objects.Drawables;
|
|
|
|
|
using osu.Game.Skinning;
|
|
|
|
|
using osuTK;
|
|
|
|
|
using osuTK.Graphics;
|
|
|
|
|
|
|
|
|
|
namespace osu.Game.Rulesets.Osu.Skinning.Default
|
|
|
|
|
{
|
|
|
|
|
public class DefaultSliderBall : CompositeDrawable
|
|
|
|
|
{
|
2022-07-04 04:51:30 +08:00
|
|
|
|
private Box box = null!;
|
|
|
|
|
|
|
|
|
|
[Resolved(canBeNull: true)]
|
|
|
|
|
private DrawableHitObject? parentObject { get; set; }
|
2022-06-29 16:23:35 +08:00
|
|
|
|
|
|
|
|
|
[BackgroundDependencyLoader]
|
2022-07-04 04:51:30 +08:00
|
|
|
|
private void load(ISkinSource skin)
|
2022-06-29 16:23:35 +08:00
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.Both;
|
|
|
|
|
|
|
|
|
|
float radius = skin.GetConfig<OsuSkinConfiguration, float>(OsuSkinConfiguration.SliderPathRadius)?.Value ?? OsuHitObject.OBJECT_RADIUS;
|
|
|
|
|
|
|
|
|
|
InternalChild = new CircularContainer
|
|
|
|
|
{
|
|
|
|
|
Masking = true,
|
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
|
Scale = new Vector2(radius / OsuHitObject.OBJECT_RADIUS),
|
|
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
|
Origin = Anchor.Centre,
|
|
|
|
|
Blending = BlendingParameters.Additive,
|
|
|
|
|
BorderThickness = 10,
|
|
|
|
|
BorderColour = Color4.White,
|
|
|
|
|
Alpha = 1,
|
|
|
|
|
Child = box = new Box
|
|
|
|
|
{
|
|
|
|
|
Blending = BlendingParameters.Additive,
|
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
|
Colour = Color4.White,
|
|
|
|
|
AlwaysPresent = true,
|
|
|
|
|
Alpha = 0
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
2022-07-04 04:51:30 +08:00
|
|
|
|
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);
|
|
|
|
|
}
|
2022-06-29 16:23:35 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void trackingChanged(ValueChangedEvent<bool> tracking) =>
|
|
|
|
|
box.FadeTo(tracking.NewValue ? 0.3f : 0.05f, 200, Easing.OutQuint);
|
2022-07-04 04:51:30 +08:00
|
|
|
|
|
|
|
|
|
private void updateStateTransforms(DrawableHitObject drawableObject, ArmedState state)
|
|
|
|
|
{
|
2022-07-15 07:53:51 +08:00
|
|
|
|
// Gets called by slider ticks, tails, etc., leading to duplicated
|
|
|
|
|
// animations which may negatively affect performance
|
2022-07-04 04:51:30 +08:00
|
|
|
|
if (drawableObject is not DrawableSlider)
|
|
|
|
|
return;
|
|
|
|
|
|
2022-07-06 12:04:13 +08:00
|
|
|
|
const float fade_duration = 450f;
|
2022-07-04 04:51:30 +08:00
|
|
|
|
|
|
|
|
|
using (BeginAbsoluteSequence(drawableObject.StateUpdateTime))
|
|
|
|
|
{
|
2022-07-06 12:04:13 +08:00
|
|
|
|
this.FadeIn()
|
|
|
|
|
.ScaleTo(1f);
|
2022-07-04 04:51:30 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
using (BeginAbsoluteSequence(drawableObject.HitStateUpdateTime))
|
|
|
|
|
{
|
|
|
|
|
// intentionally pile on an extra FadeOut to make it happen much faster
|
2022-07-06 12:04:13 +08:00
|
|
|
|
this.FadeOut(fade_duration / 4, Easing.Out);
|
2022-07-04 04:51:30 +08:00
|
|
|
|
|
|
|
|
|
switch (state)
|
|
|
|
|
{
|
|
|
|
|
case ArmedState.Hit:
|
2022-07-06 12:04:13 +08:00
|
|
|
|
this.ScaleTo(1.4f, fade_duration, Easing.Out);
|
2022-07-04 04:51:30 +08:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void Dispose(bool isDisposing)
|
|
|
|
|
{
|
|
|
|
|
base.Dispose(isDisposing);
|
|
|
|
|
|
|
|
|
|
if (parentObject != null)
|
|
|
|
|
parentObject.ApplyCustomUpdateState -= updateStateTransforms;
|
|
|
|
|
}
|
2022-06-29 16:23:35 +08:00
|
|
|
|
}
|
|
|
|
|
}
|