2017-12-27 16:34:07 +08:00
|
|
|
|
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
|
|
|
|
|
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
|
|
|
|
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
2017-12-27 19:41:59 +08:00
|
|
|
|
using NUnit.Framework;
|
2017-12-27 16:34:07 +08:00
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
|
using osu.Framework.Graphics.Containers;
|
|
|
|
|
using osu.Game.Audio;
|
|
|
|
|
using osu.Game.Beatmaps;
|
|
|
|
|
using osu.Game.Beatmaps.ControlPoints;
|
|
|
|
|
using osu.Game.Rulesets.Osu.Objects;
|
|
|
|
|
using osu.Game.Rulesets.Osu.Objects.Drawables;
|
|
|
|
|
using osu.Game.Tests.Visual;
|
|
|
|
|
using OpenTK;
|
2017-12-29 01:09:35 +08:00
|
|
|
|
using osu.Game.Rulesets.Osu.Mods;
|
2017-12-30 00:56:48 +08:00
|
|
|
|
using OpenTK.Graphics;
|
2017-12-27 16:34:07 +08:00
|
|
|
|
|
|
|
|
|
namespace osu.Game.Rulesets.Osu.Tests
|
|
|
|
|
{
|
2017-12-27 19:41:59 +08:00
|
|
|
|
[Ignore("getting CI working")]
|
2017-12-27 16:34:07 +08:00
|
|
|
|
public class TestCaseSlider : OsuTestCase
|
|
|
|
|
{
|
2017-12-30 00:44:38 +08:00
|
|
|
|
public override IReadOnlyList<Type> RequiredTypes => new[]
|
|
|
|
|
{
|
|
|
|
|
typeof(Slider),
|
|
|
|
|
typeof(HitCircle),
|
|
|
|
|
typeof(OsuModHidden),
|
|
|
|
|
typeof(DrawableSlider),
|
2017-12-30 03:01:26 +08:00
|
|
|
|
typeof(DrawableHitCircle),
|
|
|
|
|
typeof(DrawableSliderTick),
|
|
|
|
|
typeof(DrawableRepeatPoint)
|
2017-12-30 00:44:38 +08:00
|
|
|
|
};
|
2017-12-27 16:34:07 +08:00
|
|
|
|
|
|
|
|
|
private readonly Container content;
|
|
|
|
|
protected override Container<Drawable> Content => content;
|
|
|
|
|
|
2017-12-29 01:09:35 +08:00
|
|
|
|
private bool hidden;
|
|
|
|
|
private int repeats;
|
|
|
|
|
private int depthIndex;
|
|
|
|
|
private int circleSize;
|
2017-12-29 01:21:08 +08:00
|
|
|
|
private float circleScale = 1;
|
2017-12-27 19:08:33 +08:00
|
|
|
|
private double speedMultiplier = 2;
|
|
|
|
|
private double sliderMultiplier = 2;
|
2017-12-27 18:47:42 +08:00
|
|
|
|
|
2017-12-27 16:34:07 +08:00
|
|
|
|
public TestCaseSlider()
|
|
|
|
|
{
|
|
|
|
|
base.Content.Add(content = new OsuInputManager(new RulesetInfo { ID = 0 }));
|
|
|
|
|
|
2017-12-29 01:09:35 +08:00
|
|
|
|
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);
|
2017-12-27 16:34:07 +08:00
|
|
|
|
}
|
|
|
|
|
|
2017-12-29 01:09:35 +08:00
|
|
|
|
private void testSingle(double timeOffset = 0, Vector2? positionOffset = null)
|
2017-12-27 16:34:07 +08:00
|
|
|
|
{
|
2017-12-27 18:47:42 +08:00
|
|
|
|
positionOffset = positionOffset ?? Vector2.Zero;
|
|
|
|
|
|
2017-12-27 16:34:07 +08:00
|
|
|
|
var slider = new Slider
|
|
|
|
|
{
|
2017-12-27 18:47:42 +08:00
|
|
|
|
StartTime = Time.Current + 1000 + timeOffset,
|
|
|
|
|
Position = new Vector2(-200, 0) + positionOffset.Value,
|
2017-12-30 00:56:48 +08:00
|
|
|
|
ComboColour = Color4.LightSeaGreen,
|
2017-12-27 16:34:07 +08:00
|
|
|
|
ControlPoints = new List<Vector2>
|
|
|
|
|
{
|
2017-12-27 18:47:42 +08:00
|
|
|
|
new Vector2(-200, 0) + positionOffset.Value,
|
|
|
|
|
new Vector2(400, 0) + positionOffset.Value,
|
2017-12-27 16:34:07 +08:00
|
|
|
|
},
|
2017-12-30 00:56:48 +08:00
|
|
|
|
Distance = 400
|
2017-12-27 16:34:07 +08:00
|
|
|
|
};
|
|
|
|
|
|
2017-12-29 01:09:35 +08:00
|
|
|
|
addSlider(slider);
|
2017-12-27 16:34:07 +08:00
|
|
|
|
}
|
|
|
|
|
|
2017-12-29 01:09:35 +08:00
|
|
|
|
private void testRepeated(int repeats)
|
2017-12-27 16:34:07 +08:00
|
|
|
|
{
|
2017-12-27 18:47:42 +08:00
|
|
|
|
// The first run through the slider is considered a repeat
|
|
|
|
|
repeats++;
|
|
|
|
|
|
|
|
|
|
var repeatSamples = new List<List<SampleInfo>>();
|
|
|
|
|
for (int i = 0; i < repeats; i++)
|
|
|
|
|
repeatSamples.Add(new List<SampleInfo>());
|
|
|
|
|
|
2017-12-27 16:34:07 +08:00
|
|
|
|
var slider = new Slider
|
|
|
|
|
{
|
|
|
|
|
StartTime = Time.Current + 1000,
|
|
|
|
|
Position = new Vector2(-200, 0),
|
2017-12-30 00:56:48 +08:00
|
|
|
|
ComboColour = Color4.LightSeaGreen,
|
2017-12-27 16:34:07 +08:00
|
|
|
|
ControlPoints = new List<Vector2>
|
|
|
|
|
{
|
|
|
|
|
new Vector2(-200, 0),
|
|
|
|
|
new Vector2(400, 0),
|
|
|
|
|
},
|
|
|
|
|
Distance = 400,
|
|
|
|
|
RepeatCount = repeats,
|
2017-12-27 18:47:42 +08:00
|
|
|
|
RepeatSamples = repeatSamples
|
2017-12-27 16:34:07 +08:00
|
|
|
|
};
|
|
|
|
|
|
2017-12-29 01:09:35 +08:00
|
|
|
|
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)
|
|
|
|
|
{
|
2017-12-27 18:47:42 +08:00
|
|
|
|
var cpi = new ControlPointInfo();
|
|
|
|
|
cpi.DifficultyPoints.Add(new DifficultyControlPoint { SpeedMultiplier = speedMultiplier });
|
2017-12-27 16:34:07 +08:00
|
|
|
|
|
2017-12-27 22:44:51 +08:00
|
|
|
|
var difficulty = new BeatmapDifficulty
|
|
|
|
|
{
|
|
|
|
|
SliderMultiplier = (float)sliderMultiplier,
|
2017-12-29 01:09:35 +08:00
|
|
|
|
CircleSize = circleSize
|
2017-12-27 22:44:51 +08:00
|
|
|
|
};
|
2017-12-27 18:47:42 +08:00
|
|
|
|
|
|
|
|
|
slider.ApplyDefaults(cpi, difficulty);
|
2017-12-29 01:09:35 +08:00
|
|
|
|
|
|
|
|
|
var drawable = new DrawableSlider(slider)
|
2017-12-27 18:47:42 +08:00
|
|
|
|
{
|
|
|
|
|
Anchor = Anchor.Centre,
|
2017-12-29 01:09:35 +08:00
|
|
|
|
Scale = new Vector2(circleScale),
|
2017-12-27 18:47:42 +08:00
|
|
|
|
Depth = depthIndex++
|
2017-12-29 01:09:35 +08:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
if (hidden)
|
2017-12-29 16:10:33 +08:00
|
|
|
|
new OsuModHidden().ApplyToDrawableHitObjects(new [] { drawable });
|
2017-12-29 01:09:35 +08:00
|
|
|
|
|
|
|
|
|
Add(drawable);
|
2017-12-27 16:34:07 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
2017-12-29 01:09:35 +08:00
|
|
|
|
|
2017-12-27 16:34:07 +08:00
|
|
|
|
}
|