1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-14 15:17:27 +08:00

Add ability to change spin speed in spinner test

This commit is contained in:
Dean Herbert 2023-10-20 16:10:50 +09:00
parent f16400929d
commit 0da0855692
No known key found for this signature in database

View File

@ -6,6 +6,7 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using NUnit.Framework; using NUnit.Framework;
using osu.Framework.Bindables;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Testing; using osu.Framework.Testing;
using osu.Game.Audio; using osu.Game.Audio;
@ -26,6 +27,15 @@ namespace osu.Game.Rulesets.Osu.Tests
private TestDrawableSpinner drawableSpinner; private TestDrawableSpinner drawableSpinner;
private readonly BindableDouble spinRate = new BindableDouble();
protected override void LoadComplete()
{
base.LoadComplete();
AddSliderStep("Spin rate", 0.5, 5, 1, val => spinRate.Value = val);
}
[TestCase(true)] [TestCase(true)]
[TestCase(false)] [TestCase(false)]
public void TestVariousSpinners(bool autoplay) public void TestVariousSpinners(bool autoplay)
@ -86,7 +96,7 @@ namespace osu.Game.Rulesets.Osu.Tests
spinner.ApplyDefaults(new ControlPointInfo(), new BeatmapDifficulty { OverallDifficulty = od }); spinner.ApplyDefaults(new ControlPointInfo(), new BeatmapDifficulty { OverallDifficulty = od });
return drawableSpinner = new TestDrawableSpinner(spinner, true) return drawableSpinner = new TestDrawableSpinner(spinner, true, spinRate)
{ {
Anchor = Anchor.Centre, Anchor = Anchor.Centre,
Depth = depthIndex++, Depth = depthIndex++,
@ -114,7 +124,7 @@ namespace osu.Game.Rulesets.Osu.Tests
spinner.ApplyDefaults(new ControlPointInfo(), new BeatmapDifficulty { CircleSize = circleSize }); spinner.ApplyDefaults(new ControlPointInfo(), new BeatmapDifficulty { CircleSize = circleSize });
drawableSpinner = new TestDrawableSpinner(spinner, auto) drawableSpinner = new TestDrawableSpinner(spinner, auto, spinRate)
{ {
Anchor = Anchor.Centre, Anchor = Anchor.Centre,
Depth = depthIndex++, Depth = depthIndex++,
@ -130,18 +140,20 @@ namespace osu.Game.Rulesets.Osu.Tests
private partial class TestDrawableSpinner : DrawableSpinner private partial class TestDrawableSpinner : DrawableSpinner
{ {
private readonly bool auto; private readonly bool auto;
private readonly BindableDouble spinRate;
public TestDrawableSpinner(Spinner s, bool auto) public TestDrawableSpinner(Spinner s, bool auto, BindableDouble spinRate)
: base(s) : base(s)
{ {
this.auto = auto; this.auto = auto;
this.spinRate = spinRate;
} }
protected override void Update() protected override void Update()
{ {
base.Update(); base.Update();
if (auto) if (auto)
RotationTracker.AddRotation((float)(Clock.ElapsedFrameTime * 2)); RotationTracker.AddRotation((float)(Clock.ElapsedFrameTime * spinRate.Value));
} }
} }
} }