1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-27 11:52:54 +08:00

Border size to float, add min and max size, other small changes

This commit is contained in:
Santeri Nogelainen 2019-03-16 12:41:03 +02:00
parent 92595e43f6
commit cbb7498a42
4 changed files with 19 additions and 9 deletions

View File

@ -160,7 +160,7 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables
{ {
base.SkinChanged(skin, 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.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; 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; Ball.AccentColour = skin.GetValue<SkinConfiguration, Color4?>(s => s.CustomColours.ContainsKey("SliderBall") ? s.CustomColours["SliderBall"] : (Color4?)null) ?? Ball.AccentColour;

View File

@ -67,7 +67,8 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables.Pieces
/// <summary> /// <summary>
/// Used to size the path border. /// Used to size the path border.
/// </summary> /// </summary>
public int BorderSize { public float BorderSize
{
get => path.BorderSize; get => path.BorderSize;
set { set {
if (path.BorderSize == value) if (path.BorderSize == value)
@ -107,6 +108,9 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables.Pieces
private class SliderPath : SmoothPath 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 border_portion = 0.128f;
private const float gradient_portion = 1 - border_portion; private const float gradient_portion = 1 - border_portion;
@ -145,28 +149,32 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables.Pieces
} }
} }
private int borderSize = 100; private float borderSize = 1f;
public int BorderSize { public float BorderSize
{
get => borderSize; get => borderSize;
set { set {
if (borderSize == value) if (borderSize == value)
return; return;
if (value < border_min_size || value > border_max_size)
return;
borderSize = value; borderSize = value;
InvalidateTexture(); InvalidateTexture();
} }
} }
private float calucatedBorderPortion => BorderSize / 100f * border_portion; private float calculatedBorderPortion => BorderSize * border_portion;
protected override Color4 ColourAt(float position) protected override Color4 ColourAt(float position)
{ {
if (position <= calucatedBorderPortion) if (calculatedBorderPortion != 0f && position <= calculatedBorderPortion)
return BorderColour; 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); return new Color4(AccentColour.R, AccentColour.G, AccentColour.B, (opacity_at_edge - (opacity_at_edge - opacity_at_centre) * position / gradient_portion) * AccentColour.A);
} }
} }

View File

@ -2,6 +2,8 @@
// See the LICENCE file in the repository root for full licence text. // See the LICENCE file in the repository root for full licence text.
using osu.Game.Beatmaps.Formats; using osu.Game.Beatmaps.Formats;
using System;
using System.Globalization;
namespace osu.Game.Skinning namespace osu.Game.Skinning
{ {
@ -34,7 +36,7 @@ namespace osu.Game.Skinning
skin.CursorExpand = pair.Value != "0"; skin.CursorExpand = pair.Value != "0";
break; break;
case @"SliderBorderSize": 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; skin.SliderBorderSize = size;
break; break;
} }

View File

@ -25,7 +25,7 @@ namespace osu.Game.Skinning
public int HitCircleOverlap { get; set; } public int HitCircleOverlap { get; set; }
public int? SliderBorderSize { get; set; } public float? SliderBorderSize { get; set; }
public bool? CursorExpand { get; set; } = true; public bool? CursorExpand { get; set; } = true;
} }