Merge pull request #2094 from smoogipoo/general-slider-improvements

Expose SliderBody's snaking and border colour
This commit is contained in:
Dean Herbert 2018-02-22 13:10:42 +09:00 committed by GitHub
commit cc3546f907
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 40 additions and 17 deletions

View File

@ -7,9 +7,11 @@
using osu.Game.Rulesets.Osu.Objects.Drawables.Pieces;
using System.Collections.Generic;
using System.Linq;
using osu.Framework.Allocation;
using osu.Framework.Graphics.Containers;
using osu.Game.Rulesets.Osu.Judgements;
using osu.Framework.Graphics.Primitives;
using osu.Game.Configuration;
using osu.Game.Rulesets.Scoring;
namespace osu.Game.Rulesets.Osu.Objects.Drawables
@ -86,6 +88,13 @@ public DrawableSlider(Slider s)
}
}
[BackgroundDependencyLoader]
private void load(OsuConfigManager config)
{
config.BindWith(OsuSetting.SnakingInSliders, Body.SnakingIn);
config.BindWith(OsuSetting.SnakingOutSliders, Body.SnakingOut);
}
public bool Tracking;
protected override void Update()

View File

@ -10,7 +10,6 @@
using osu.Framework.Graphics.OpenGL.Textures;
using osu.Framework.Graphics.Lines;
using osu.Framework.Graphics.Textures;
using osu.Game.Configuration;
using OpenTK;
using OpenTK.Graphics.ES30;
using OpenTK.Graphics;
@ -30,6 +29,9 @@ public float PathWidth
set { path.PathWidth = value; }
}
public readonly Bindable<bool> SnakingIn = new Bindable<bool>();
public readonly Bindable<bool> SnakingOut = new Bindable<bool>();
public double? SnakedStart { get; private set; }
public double? SnakedEnd { get; private set; }
@ -46,8 +48,26 @@ public Color4 AccentColour
return;
accentColour = value;
if (LoadState == LoadState.Ready)
Schedule(reloadTexture);
if (LoadState >= LoadState.Ready)
reloadTexture();
}
}
private Color4 borderColour = Color4.White;
/// <summary>
/// Used to colour the path border.
/// </summary>
public new Color4 BorderColour
{
get { return borderColour; }
set
{
if (borderColour == value)
return;
borderColour = value;
if (LoadState >= LoadState.Ready)
reloadTexture();
}
}
@ -97,15 +117,9 @@ public void SetRange(double p0, double p1)
}
}
private Bindable<bool> snakingIn;
private Bindable<bool> snakingOut;
[BackgroundDependencyLoader]
private void load(OsuConfigManager config)
private void load()
{
snakingIn = config.GetBindable<bool>(OsuSetting.SnakingInSliders);
snakingOut = config.GetBindable<bool>(OsuSetting.SnakingOutSliders);
reloadTexture();
}
@ -130,10 +144,10 @@ private void reloadTexture()
if (progress <= border_portion)
{
bytes[i * 4] = 255;
bytes[i * 4 + 1] = 255;
bytes[i * 4 + 2] = 255;
bytes[i * 4 + 3] = (byte)(Math.Min(progress / aa_portion, 1) * 255);
bytes[i * 4] = (byte)(BorderColour.R * 255);
bytes[i * 4 + 1] = (byte)(BorderColour.G * 255);
bytes[i * 4 + 2] = (byte)(BorderColour.B * 255);
bytes[i * 4 + 3] = (byte)(Math.Min(progress / aa_portion, 1) * (BorderColour.A * 255));
}
else
{
@ -173,18 +187,18 @@ public void UpdateProgress(double completionProgress)
var spanProgress = slider.ProgressAt(completionProgress);
double start = 0;
double end = snakingIn ? MathHelper.Clamp((Time.Current - (slider.StartTime - slider.TimePreempt)) / slider.TimeFadein, 0, 1) : 1;
double end = SnakingIn ? MathHelper.Clamp((Time.Current - (slider.StartTime - slider.TimePreempt)) / slider.TimeFadein, 0, 1) : 1;
if (span >= slider.SpanCount() - 1)
{
if (Math.Min(span, slider.SpanCount() - 1) % 2 == 1)
{
start = 0;
end = snakingOut ? spanProgress : 1;
end = SnakingOut ? spanProgress : 1;
}
else
{
start = snakingOut ? spanProgress : 0;
start = SnakingOut ? spanProgress : 0;
}
}