mirror of https://github.com/ppy/osu
Border size to float, add min and max size, other small changes
This commit is contained in:
parent
92595e43f6
commit
cbb7498a42
|
@ -160,7 +160,7 @@ protected override void SkinChanged(ISkinSource skin, bool allowFallback)
|
|||
{
|
||||
base.SkinChanged(skin, allowFallback);
|
||||
|
||||
Body.BorderSize = skin.GetValue<SkinConfiguration, int?>(s => s.SliderBorderSize) ?? Body.BorderSize;
|
||||
Body.BorderSize = skin.GetValue<SkinConfiguration, float?>(s => s.SliderBorderSize) ?? Body.BorderSize;
|
||||
Body.AccentColour = skin.GetValue<SkinConfiguration, Color4?>(s => s.CustomColours.ContainsKey("SliderTrackOverride") ? s.CustomColours["SliderTrackOverride"] : (Color4?)null) ?? Body.AccentColour;
|
||||
Body.BorderColour = skin.GetValue<SkinConfiguration, Color4?>(s => s.CustomColours.ContainsKey("SliderBorder") ? s.CustomColours["SliderBorder"] : (Color4?)null) ?? Body.BorderColour;
|
||||
Ball.AccentColour = skin.GetValue<SkinConfiguration, Color4?>(s => s.CustomColours.ContainsKey("SliderBall") ? s.CustomColours["SliderBall"] : (Color4?)null) ?? Ball.AccentColour;
|
||||
|
|
|
@ -67,7 +67,8 @@ public Color4 AccentColour
|
|||
/// <summary>
|
||||
/// Used to size the path border.
|
||||
/// </summary>
|
||||
public int BorderSize {
|
||||
public float BorderSize
|
||||
{
|
||||
get => path.BorderSize;
|
||||
set {
|
||||
if (path.BorderSize == value)
|
||||
|
@ -107,6 +108,9 @@ protected void SetVertices(IReadOnlyList<Vector2> vertices)
|
|||
|
||||
private class SliderPath : SmoothPath
|
||||
{
|
||||
private const float border_max_size = 10f;
|
||||
private const float border_min_size = 0f; // = no border
|
||||
|
||||
private const float border_portion = 0.128f;
|
||||
private const float gradient_portion = 1 - border_portion;
|
||||
|
||||
|
@ -145,28 +149,32 @@ public Color4 AccentColour
|
|||
}
|
||||
}
|
||||
|
||||
private int borderSize = 100;
|
||||
private float borderSize = 1f;
|
||||
|
||||
public int BorderSize {
|
||||
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 calucatedBorderPortion => BorderSize / 100f * border_portion;
|
||||
private float calculatedBorderPortion => BorderSize * border_portion;
|
||||
|
||||
protected override Color4 ColourAt(float position)
|
||||
{
|
||||
if (position <= calucatedBorderPortion)
|
||||
if (calculatedBorderPortion != 0f && position <= calculatedBorderPortion)
|
||||
return BorderColour;
|
||||
|
||||
position -= calucatedBorderPortion;
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,6 +2,8 @@
|
|||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using osu.Game.Beatmaps.Formats;
|
||||
using System;
|
||||
using System.Globalization;
|
||||
|
||||
namespace osu.Game.Skinning
|
||||
{
|
||||
|
@ -34,7 +36,7 @@ protected override void ParseLine(SkinConfiguration skin, Section section, strin
|
|||
skin.CursorExpand = pair.Value != "0";
|
||||
break;
|
||||
case @"SliderBorderSize":
|
||||
if (int.TryParse(pair.Value, out int size))
|
||||
if (Single.TryParse(pair.Value, NumberStyles.Number, CultureInfo.CreateSpecificCulture("en-US"), out float size))
|
||||
skin.SliderBorderSize = size;
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -25,7 +25,7 @@ public class SkinConfiguration : IHasComboColours, IHasCustomColours
|
|||
|
||||
public int HitCircleOverlap { get; set; }
|
||||
|
||||
public int? SliderBorderSize { get; set; }
|
||||
public float? SliderBorderSize { get; set; }
|
||||
|
||||
public bool? CursorExpand { get; set; } = true;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue