mirror of
https://github.com/ppy/osu.git
synced 2024-12-14 10:12:54 +08:00
Implement skinning for slider border thickness (#4471)
Implement skinning for slider border thickness Co-authored-by: Dean Herbert <pe@ppy.sh>
This commit is contained in:
commit
dc486579fb
@ -160,6 +160,7 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables
|
||||
{
|
||||
base.SkinChanged(skin, allowFallback);
|
||||
|
||||
Body.BorderSize = skin.GetValue<SkinConfiguration, float?>(s => s.SliderBorderSize) ?? SliderBody.DEFAULT_BORDER_SIZE;
|
||||
Body.AccentColour = skin.GetValue<SkinConfiguration, Color4?>(s => s.CustomColours.ContainsKey("SliderTrackOverride") ? s.CustomColours["SliderTrackOverride"] : (Color4?)null) ?? AccentColour;
|
||||
Body.BorderColour = skin.GetValue<SkinConfiguration, Color4?>(s => s.CustomColours.ContainsKey("SliderBorder") ? s.CustomColours["SliderBorder"] : (Color4?)null) ?? Color4.White;
|
||||
Ball.AccentColour = skin.GetValue<SkinConfiguration, Color4?>(s => s.CustomColours.ContainsKey("SliderBall") ? s.CustomColours["SliderBall"] : (Color4?)null) ?? AccentColour;
|
||||
|
@ -14,6 +14,8 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables.Pieces
|
||||
{
|
||||
public abstract class SliderBody : CompositeDrawable
|
||||
{
|
||||
public const float DEFAULT_BORDER_SIZE = 1;
|
||||
|
||||
private readonly SliderPath path;
|
||||
protected Path Path => path;
|
||||
|
||||
@ -64,6 +66,23 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables.Pieces
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Used to size the path border.
|
||||
/// </summary>
|
||||
public float BorderSize
|
||||
{
|
||||
get => path.BorderSize;
|
||||
set
|
||||
{
|
||||
if (path.BorderSize == value)
|
||||
return;
|
||||
|
||||
path.BorderSize = value;
|
||||
|
||||
container.ForceRedraw();
|
||||
}
|
||||
}
|
||||
|
||||
public Quad PathDrawQuad => container.ScreenSpaceDrawQuad;
|
||||
|
||||
protected SliderBody()
|
||||
@ -92,6 +111,9 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables.Pieces
|
||||
|
||||
private class SliderPath : SmoothPath
|
||||
{
|
||||
private const float border_max_size = 8f;
|
||||
private const float border_min_size = 0f;
|
||||
|
||||
private const float border_portion = 0.128f;
|
||||
private const float gradient_portion = 1 - border_portion;
|
||||
|
||||
@ -130,12 +152,33 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables.Pieces
|
||||
}
|
||||
}
|
||||
|
||||
private float borderSize = DEFAULT_BORDER_SIZE;
|
||||
|
||||
public float BorderSize
|
||||
{
|
||||
get => borderSize;
|
||||
set
|
||||
{
|
||||
if (borderSize == value)
|
||||
return;
|
||||
|
||||
if (value < border_min_size || value > border_max_size)
|
||||
return;
|
||||
|
||||
borderSize = value;
|
||||
|
||||
InvalidateTexture();
|
||||
}
|
||||
}
|
||||
|
||||
private float calculatedBorderPortion => BorderSize * border_portion;
|
||||
|
||||
protected override Color4 ColourAt(float position)
|
||||
{
|
||||
if (position <= border_portion)
|
||||
if (calculatedBorderPortion != 0f && position <= calculatedBorderPortion)
|
||||
return BorderColour;
|
||||
|
||||
position -= border_portion;
|
||||
position -= calculatedBorderPortion;
|
||||
return new Color4(AccentColour.R, AccentColour.G, AccentColour.B, (opacity_at_edge - (opacity_at_edge - opacity_at_centre) * position / gradient_portion) * AccentColour.A);
|
||||
}
|
||||
}
|
||||
|
@ -34,6 +34,10 @@ namespace osu.Game.Skinning
|
||||
case @"CursorExpand":
|
||||
skin.CursorExpand = pair.Value != "0";
|
||||
break;
|
||||
|
||||
case @"SliderBorderSize":
|
||||
skin.SliderBorderSize = Parsing.ParseFloat(pair.Value);
|
||||
break;
|
||||
}
|
||||
|
||||
break;
|
||||
|
@ -25,6 +25,8 @@ namespace osu.Game.Skinning
|
||||
|
||||
public int HitCircleOverlap { get; set; }
|
||||
|
||||
public float? SliderBorderSize { get; set; }
|
||||
|
||||
public bool? CursorExpand { get; set; } = true;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user