2019-12-17 18:29:27 +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.Game.Rulesets.Objects.Drawables;
|
|
|
|
using osu.Game.Rulesets.Osu.Configuration;
|
2020-12-04 19:21:53 +08:00
|
|
|
using osu.Game.Rulesets.Osu.Objects;
|
|
|
|
using osu.Game.Rulesets.Osu.Objects.Drawables;
|
2019-12-17 18:29:27 +08:00
|
|
|
using osu.Game.Skinning;
|
|
|
|
using osuTK.Graphics;
|
|
|
|
|
2020-12-04 19:21:53 +08:00
|
|
|
namespace osu.Game.Rulesets.Osu.Skinning.Default
|
2019-12-17 18:29:27 +08:00
|
|
|
{
|
|
|
|
public abstract class PlaySliderBody : SnakingSliderBody
|
|
|
|
{
|
|
|
|
private IBindable<float> scaleBindable;
|
|
|
|
private IBindable<int> pathVersion;
|
|
|
|
private IBindable<Color4> accentColour;
|
|
|
|
|
|
|
|
[Resolved(CanBeNull = true)]
|
|
|
|
private OsuRulesetConfigManager config { get; set; }
|
|
|
|
|
2021-02-05 14:56:13 +08:00
|
|
|
private readonly Bindable<bool> snakingOut = new Bindable<bool>();
|
|
|
|
|
2019-12-17 18:29:27 +08:00
|
|
|
[BackgroundDependencyLoader]
|
2020-11-05 13:40:48 +08:00
|
|
|
private void load(ISkinSource skin, DrawableHitObject drawableObject)
|
2019-12-17 18:29:27 +08:00
|
|
|
{
|
2020-11-05 13:40:48 +08:00
|
|
|
var drawableSlider = (DrawableSlider)drawableObject;
|
2019-12-17 18:29:27 +08:00
|
|
|
|
2020-11-05 13:40:48 +08:00
|
|
|
scaleBindable = drawableSlider.ScaleBindable.GetBoundCopy();
|
2019-12-18 12:37:37 +08:00
|
|
|
scaleBindable.BindValueChanged(scale => PathRadius = OsuHitObject.OBJECT_RADIUS * scale.NewValue, true);
|
2019-12-17 18:29:27 +08:00
|
|
|
|
2020-11-05 13:40:48 +08:00
|
|
|
pathVersion = drawableSlider.PathVersion.GetBoundCopy();
|
2019-12-17 18:29:27 +08:00
|
|
|
pathVersion.BindValueChanged(_ => Refresh());
|
|
|
|
|
|
|
|
accentColour = drawableObject.AccentColour.GetBoundCopy();
|
|
|
|
accentColour.BindValueChanged(accent => updateAccentColour(skin, accent.NewValue), true);
|
|
|
|
|
2021-02-05 14:56:13 +08:00
|
|
|
SnakingOut.BindTo(snakingOut);
|
2019-12-17 18:29:27 +08:00
|
|
|
config?.BindWith(OsuRulesetSetting.SnakingInSliders, SnakingIn);
|
2021-02-05 14:56:13 +08:00
|
|
|
config?.BindWith(OsuRulesetSetting.SnakingOutSliders, snakingOut);
|
2019-12-17 18:29:27 +08:00
|
|
|
|
|
|
|
BorderSize = skin.GetConfig<OsuSkinConfiguration, float>(OsuSkinConfiguration.SliderBorderSize)?.Value ?? 1;
|
|
|
|
BorderColour = skin.GetConfig<OsuSkinColour, Color4>(OsuSkinColour.SliderBorder)?.Value ?? Color4.White;
|
2021-02-05 14:56:13 +08:00
|
|
|
|
|
|
|
drawableObject.HitObjectApplied += onHitObjectApplied;
|
|
|
|
}
|
|
|
|
|
|
|
|
private void onHitObjectApplied(DrawableHitObject obj)
|
|
|
|
{
|
|
|
|
var drawableSlider = (DrawableSlider)obj;
|
|
|
|
if (drawableSlider.HitObject == null)
|
|
|
|
return;
|
|
|
|
|
2021-02-05 16:33:48 +08:00
|
|
|
if (!drawableSlider.HeadCircle.TrackFollowCircle)
|
2021-02-05 14:56:13 +08:00
|
|
|
{
|
|
|
|
// When not tracking the follow circle, force the path to not snake out as it looks better that way.
|
|
|
|
SnakingOut.UnbindFrom(snakingOut);
|
|
|
|
SnakingOut.Value = false;
|
|
|
|
}
|
2019-12-17 18:29:27 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
private void updateAccentColour(ISkinSource skin, Color4 defaultAccentColour)
|
|
|
|
=> AccentColour = skin.GetConfig<OsuSkinColour, Color4>(OsuSkinColour.SliderTrackOverride)?.Value ?? defaultAccentColour;
|
|
|
|
}
|
|
|
|
}
|