Add support for SpinnerNoBlink in legacy spinner

This commit is contained in:
Max Hübner 2020-09-26 16:25:57 +02:00
parent e7d0456454
commit 33d000e532

View File

@ -12,6 +12,7 @@ using osu.Game.Rulesets.Objects.Drawables;
using osu.Game.Rulesets.Osu.Objects.Drawables;
using osu.Game.Skinning;
using osuTK;
using static osu.Game.Skinning.LegacySkinConfiguration;
namespace osu.Game.Rulesets.Osu.Skinning
{
@ -25,12 +26,16 @@ namespace osu.Game.Rulesets.Osu.Skinning
private Sprite metreSprite;
private Container metre;
private bool spinnerNoBlink;
private const float sprite_scale = 1 / 1.6f;
private const float final_metre_height = 692 * sprite_scale;
[BackgroundDependencyLoader]
private void load(ISkinSource source, DrawableHitObject drawableObject)
{
spinnerNoBlink = source.GetConfig<LegacySetting, bool>(LegacySetting.SpinnerNoBlink)?.Value ?? false;
drawableSpinner = (DrawableSpinner)drawableObject;
RelativeSizeAxes = Axes.Both;
@ -117,12 +122,15 @@ namespace osu.Game.Rulesets.Osu.Skinning
private float getMetreHeight(float progress)
{
progress = Math.Min(99, progress * 100);
progress *= 100;
// the spinner should still blink at 100% progress.
if (!spinnerNoBlink)
progress = Math.Min(99, progress);
int barCount = (int)progress / 10;
// todo: add SpinnerNoBlink support
if (RNG.NextBool(((int)progress % 10) / 10f))
if (!spinnerNoBlink && RNG.NextBool(((int)progress % 10) / 10f))
barCount++;
return (float)barCount / total_bars * final_metre_height;