1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-13 08:32:57 +08:00

extend TestCaseSlider with new steps

- Hidden, Size and Scale
- made Repeats an SliderStep instead
This commit is contained in:
Aergwyn 2017-12-28 18:09:35 +01:00
parent cd237da6d3
commit 8d5f4d4f19
2 changed files with 53 additions and 43 deletions

View File

@ -33,15 +33,15 @@ namespace osu.Game.Rulesets.Osu.Tests
{
base.Content.Add(content = new OsuInputManager(new RulesetInfo { ID = 0 }));
AddStep("Single", () => addSingle());
AddStep("Stream", addStream);
AddStep("Single", () => testSingle());
AddStep("Stream", testStream);
AddToggleStep("Auto", v => auto = v);
AddToggleStep("Hidden", v => hidden = v);
AddSliderStep("CircleSize", 0, 10, 0, s => circleSize = s);
AddSliderStep("CircleScale", 0.5f, 2, 1, s => circleScale = s);
}
private void addSingle(double timeOffset = 0, Vector2? positionOffset = null)
private void testSingle(double timeOffset = 0, Vector2? positionOffset = null)
{
positionOffset = positionOffset ?? Vector2.Zero;
@ -70,13 +70,13 @@ namespace osu.Game.Rulesets.Osu.Tests
Add(drawable);
}
private void addStream()
private void testStream()
{
Vector2 pos = Vector2.Zero;
for (int i = 0; i <= 1000; i += 100)
{
addSingle(i, pos);
testSingle(i, pos);
pos += new Vector2(10);
}
}

View File

@ -13,6 +13,8 @@ using osu.Game.Rulesets.Osu.Objects;
using osu.Game.Rulesets.Osu.Objects.Drawables;
using osu.Game.Tests.Visual;
using OpenTK;
using osu.Game.Rulesets.Osu.Mods;
using osu.Game.Rulesets.Objects.Drawables;
namespace osu.Game.Rulesets.Osu.Tests
{
@ -24,26 +26,30 @@ namespace osu.Game.Rulesets.Osu.Tests
private readonly Container content;
protected override Container<Drawable> Content => content;
private bool hidden;
private int repeats;
private int depthIndex;
private int circleSize;
private float circleScale;
private double speedMultiplier = 2;
private double sliderMultiplier = 2;
private int depthIndex;
public TestCaseSlider()
{
base.Content.Add(content = new OsuInputManager(new RulesetInfo { ID = 0 }));
AddStep("Single", () => addSingle());
AddStep("Repeated (1)", () => addRepeated(1));
AddStep("Repeated (2)", () => addRepeated(2));
AddStep("Repeated (3)", () => addRepeated(3));
AddStep("Repeated (4)", () => addRepeated(4));
AddStep("Stream", addStream);
AddSliderStep("SpeedMultiplier", 0.01, 10, 2, s => speedMultiplier = s);
AddSliderStep("SliderMultiplier", 0.01, 10, 2, s => sliderMultiplier = s);
AddStep("Single", () => testSingle());
AddStep("Stream", testStream);
AddStep("Repeated", () => testRepeated(repeats));
AddToggleStep("Hidden", v => hidden = v);
AddSliderStep("Repeats", 1, 10, 1, s => repeats = s);
AddSliderStep("CircleSize", 0, 10, 0, s => circleSize = s);
AddSliderStep("CircleScale", 0.5f, 2, 1, s => circleScale = s);
AddSliderStep("SpeedMultiplier", 0.1, 10, 2, s => speedMultiplier = s);
AddSliderStep("SliderMultiplier", 0.1, 10, 2, s => sliderMultiplier = s);
}
private void addSingle(double timeOffset = 0, Vector2? positionOffset = null)
private void testSingle(double timeOffset = 0, Vector2? positionOffset = null)
{
positionOffset = positionOffset ?? Vector2.Zero;
@ -59,24 +65,10 @@ namespace osu.Game.Rulesets.Osu.Tests
Distance = 400,
};
var cpi = new ControlPointInfo();
cpi.DifficultyPoints.Add(new DifficultyControlPoint { SpeedMultiplier = speedMultiplier });
var difficulty = new BeatmapDifficulty
{
SliderMultiplier = (float)sliderMultiplier,
CircleSize = 0
};
slider.ApplyDefaults(cpi, difficulty);
Add(new DrawableSlider(slider)
{
Anchor = Anchor.Centre,
Depth = depthIndex++
});
addSlider(slider);
}
private void addRepeated(int repeats)
private void testRepeated(int repeats)
{
// The first run through the slider is considered a repeat
repeats++;
@ -99,32 +91,50 @@ namespace osu.Game.Rulesets.Osu.Tests
RepeatSamples = repeatSamples
};
addSlider(slider);
}
private void testStream()
{
Vector2 pos = Vector2.Zero;
for (int i = 0; i <= 1000; i += 100)
{
testSingle(i, pos);
pos += new Vector2(10);
}
}
private void addSlider(Slider slider)
{
var cpi = new ControlPointInfo();
cpi.DifficultyPoints.Add(new DifficultyControlPoint { SpeedMultiplier = speedMultiplier });
var difficulty = new BeatmapDifficulty
{
SliderMultiplier = (float)sliderMultiplier,
CircleSize = 0
CircleSize = circleSize
};
slider.ApplyDefaults(cpi, difficulty);
Add(new DrawableSlider(slider)
var drawable = new DrawableSlider(slider)
{
Anchor = Anchor.Centre,
Scale = new Vector2(circleScale),
Depth = depthIndex++
});
};
if (hidden)
drawable.ApplyCustomUpdateState += new TestOsuModHidden().CustomSequence;
Add(drawable);
}
private void addStream()
private class TestOsuModHidden : OsuModHidden
{
Vector2 pos = Vector2.Zero;
for (int i = 0; i <= 1000; i += 100)
{
addSingle(i, pos);
pos += new Vector2(10);
}
public new void CustomSequence(DrawableHitObject drawable, ArmedState state) => base.CustomSequence(drawable, state);
}
}
}