1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-11 15:47:26 +08:00

Implement legacy slider border shadow (#7255)

Implement legacy slider border shadow

Co-authored-by: Dean Herbert <pe@ppy.sh>
This commit is contained in:
Dean Herbert 2019-12-18 16:09:34 +09:00 committed by GitHub
commit 0ca241287c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 15 additions and 11 deletions

View File

@ -24,16 +24,14 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables.Pieces
private OsuRulesetConfigManager config { get; set; } private OsuRulesetConfigManager config { get; set; }
private Slider slider; private Slider slider;
private float defaultPathRadius;
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load(ISkinSource skin) private void load(ISkinSource skin)
{ {
slider = (Slider)drawableObject.HitObject; slider = (Slider)drawableObject.HitObject;
defaultPathRadius = skin.GetConfig<OsuSkinConfiguration, float>(OsuSkinConfiguration.SliderPathRadius)?.Value ?? OsuHitObject.OBJECT_RADIUS;
scaleBindable = slider.ScaleBindable.GetBoundCopy(); scaleBindable = slider.ScaleBindable.GetBoundCopy();
scaleBindable.BindValueChanged(_ => updatePathRadius(), true); scaleBindable.BindValueChanged(scale => PathRadius = OsuHitObject.OBJECT_RADIUS * scale.NewValue, true);
pathVersion = slider.Path.Version.GetBoundCopy(); pathVersion = slider.Path.Version.GetBoundCopy();
pathVersion.BindValueChanged(_ => Refresh()); pathVersion.BindValueChanged(_ => Refresh());
@ -48,9 +46,6 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables.Pieces
BorderColour = skin.GetConfig<OsuSkinColour, Color4>(OsuSkinColour.SliderBorder)?.Value ?? Color4.White; BorderColour = skin.GetConfig<OsuSkinColour, Color4>(OsuSkinColour.SliderBorder)?.Value ?? Color4.White;
} }
private void updatePathRadius()
=> PathRadius = defaultPathRadius * scaleBindable.Value;
private void updateAccentColour(ISkinSource skin, Color4 defaultAccentColour) private void updateAccentColour(ISkinSource skin, Color4 defaultAccentColour)
=> AccentColour = skin.GetConfig<OsuSkinColour, Color4>(OsuSkinColour.SliderTrackOverride)?.Value ?? defaultAccentColour; => AccentColour = skin.GetConfig<OsuSkinColour, Color4>(OsuSkinColour.SliderTrackOverride)?.Value ?? defaultAccentColour;
} }

View File

@ -4,6 +4,7 @@
using System; using System;
using osu.Framework.Extensions.Color4Extensions; using osu.Framework.Extensions.Color4Extensions;
using osu.Framework.MathUtils; using osu.Framework.MathUtils;
using osu.Game.Rulesets.Osu.Objects;
using osu.Game.Rulesets.Osu.Objects.Drawables.Pieces; using osu.Game.Rulesets.Osu.Objects.Drawables.Pieces;
using osuTK.Graphics; using osuTK.Graphics;
@ -15,19 +16,27 @@ namespace osu.Game.Rulesets.Osu.Skinning
private class LegacyDrawableSliderPath : DrawableSliderPath private class LegacyDrawableSliderPath : DrawableSliderPath
{ {
private const float shadow_portion = 1 - (OsuLegacySkinTransformer.LEGACY_CIRCLE_RADIUS / OsuHitObject.OBJECT_RADIUS);
public new Color4 AccentColour => new Color4(base.AccentColour.R, base.AccentColour.G, base.AccentColour.B, base.AccentColour.A * 0.70f); public new Color4 AccentColour => new Color4(base.AccentColour.R, base.AccentColour.G, base.AccentColour.B, base.AccentColour.A * 0.70f);
protected override Color4 ColourAt(float position) protected override Color4 ColourAt(float position)
{ {
if (CalculatedBorderPortion != 0f && position <= CalculatedBorderPortion) float realBorderPortion = shadow_portion + CalculatedBorderPortion;
float realGradientPortion = 1 - realBorderPortion;
if (position <= shadow_portion)
return new Color4(0f, 0f, 0f, 0.25f * position / shadow_portion);
if (position <= realBorderPortion)
return BorderColour; return BorderColour;
position -= BORDER_PORTION; position -= realBorderPortion;
Color4 outerColour = AccentColour.Darken(0.1f); Color4 outerColour = AccentColour.Darken(0.1f);
Color4 innerColour = lighten(AccentColour, 0.5f); Color4 innerColour = lighten(AccentColour, 0.5f);
return Interpolation.ValueAt(position / GRADIENT_PORTION, outerColour, innerColour, 0, 1); return Interpolation.ValueAt(position / realGradientPortion, outerColour, innerColour, 0, 1);
} }
/// <summary> /// <summary>

View File

@ -23,7 +23,7 @@ namespace osu.Game.Rulesets.Osu.Skinning
/// Their hittable area is 128px, but the actual circle portion is 118px. /// Their hittable area is 128px, but the actual circle portion is 118px.
/// We must account for some gameplay elements such as slider bodies, where this padding is not present. /// We must account for some gameplay elements such as slider bodies, where this padding is not present.
/// </summary> /// </summary>
private const float legacy_circle_radius = 64 - 5; public const float LEGACY_CIRCLE_RADIUS = 64 - 5;
public OsuLegacySkinTransformer(ISkinSource source) public OsuLegacySkinTransformer(ISkinSource source)
{ {
@ -130,7 +130,7 @@ namespace osu.Game.Rulesets.Osu.Skinning
{ {
case OsuSkinConfiguration.SliderPathRadius: case OsuSkinConfiguration.SliderPathRadius:
if (hasHitCircle.Value) if (hasHitCircle.Value)
return SkinUtils.As<TValue>(new BindableFloat(legacy_circle_radius)); return SkinUtils.As<TValue>(new BindableFloat(LEGACY_CIRCLE_RADIUS));
break; break;
} }