2019-01-24 08:43:03 +00:00
|
|
|
|
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
|
|
|
|
// See the LICENCE file in the repository root for full licence text.
|
2018-04-13 09:19:50 +00:00
|
|
|
|
|
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
|
using osu.Framework.Graphics.Containers;
|
|
|
|
|
using osu.Game.Beatmaps;
|
|
|
|
|
using osu.Game.Beatmaps.ControlPoints;
|
|
|
|
|
using osu.Game.Rulesets.Osu.Objects;
|
|
|
|
|
using osu.Game.Rulesets.Osu.Objects.Drawables;
|
2018-11-20 07:51:59 +00:00
|
|
|
|
using osuTK;
|
2018-04-13 09:19:50 +00:00
|
|
|
|
using osu.Game.Rulesets.Mods;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using NUnit.Framework;
|
|
|
|
|
using osu.Game.Rulesets.Scoring;
|
|
|
|
|
|
|
|
|
|
namespace osu.Game.Rulesets.Osu.Tests
|
|
|
|
|
{
|
|
|
|
|
[TestFixture]
|
2020-04-07 06:38:29 +00:00
|
|
|
|
public class TestSceneHitCircle : OsuSkinnableTestScene
|
2018-04-13 09:19:50 +00:00
|
|
|
|
{
|
|
|
|
|
private int depthIndex;
|
|
|
|
|
|
2019-05-14 19:37:25 +00:00
|
|
|
|
public TestSceneHitCircle()
|
2018-04-13 09:19:50 +00:00
|
|
|
|
{
|
2019-07-26 10:29:06 +00:00
|
|
|
|
AddStep("Miss Big Single", () => SetContents(() => testSingle(2)));
|
|
|
|
|
AddStep("Miss Medium Single", () => SetContents(() => testSingle(5)));
|
|
|
|
|
AddStep("Miss Small Single", () => SetContents(() => testSingle(7)));
|
|
|
|
|
AddStep("Hit Big Single", () => SetContents(() => testSingle(2, true)));
|
|
|
|
|
AddStep("Hit Medium Single", () => SetContents(() => testSingle(5, true)));
|
|
|
|
|
AddStep("Hit Small Single", () => SetContents(() => testSingle(7, true)));
|
|
|
|
|
AddStep("Miss Big Stream", () => SetContents(() => testStream(2)));
|
|
|
|
|
AddStep("Miss Medium Stream", () => SetContents(() => testStream(5)));
|
|
|
|
|
AddStep("Miss Small Stream", () => SetContents(() => testStream(7)));
|
|
|
|
|
AddStep("Hit Big Stream", () => SetContents(() => testStream(2, true)));
|
|
|
|
|
AddStep("Hit Medium Stream", () => SetContents(() => testStream(5, true)));
|
|
|
|
|
AddStep("Hit Small Stream", () => SetContents(() => testStream(7, true)));
|
2018-04-13 09:19:50 +00:00
|
|
|
|
}
|
|
|
|
|
|
2019-07-26 10:29:06 +00:00
|
|
|
|
private Drawable testSingle(float circleSize, bool auto = false, double timeOffset = 0, Vector2? positionOffset = null)
|
2018-04-13 09:19:50 +00:00
|
|
|
|
{
|
2019-11-12 10:35:08 +00:00
|
|
|
|
positionOffset ??= Vector2.Zero;
|
2018-04-13 09:19:50 +00:00
|
|
|
|
|
|
|
|
|
var circle = new HitCircle
|
|
|
|
|
{
|
|
|
|
|
StartTime = Time.Current + 1000 + timeOffset,
|
|
|
|
|
Position = positionOffset.Value,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
circle.ApplyDefaults(new ControlPointInfo(), new BeatmapDifficulty { CircleSize = circleSize });
|
|
|
|
|
|
2019-07-29 08:05:13 +00:00
|
|
|
|
var drawable = CreateDrawableHitCircle(circle, auto);
|
2018-04-13 09:19:50 +00:00
|
|
|
|
|
2019-12-13 12:45:38 +00:00
|
|
|
|
foreach (var mod in SelectedMods.Value.OfType<IApplicableToDrawableHitObjects>())
|
2018-04-13 09:19:50 +00:00
|
|
|
|
mod.ApplyToDrawableHitObjects(new[] { drawable });
|
|
|
|
|
|
2019-07-26 10:29:06 +00:00
|
|
|
|
return drawable;
|
2018-04-13 09:19:50 +00:00
|
|
|
|
}
|
|
|
|
|
|
2019-07-29 08:05:13 +00:00
|
|
|
|
protected virtual TestDrawableHitCircle CreateDrawableHitCircle(HitCircle circle, bool auto) => new TestDrawableHitCircle(circle, auto)
|
|
|
|
|
{
|
|
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
|
Depth = depthIndex++
|
|
|
|
|
};
|
|
|
|
|
|
2019-07-26 10:29:06 +00:00
|
|
|
|
private Drawable testStream(float circleSize, bool auto = false)
|
2018-04-13 09:19:50 +00:00
|
|
|
|
{
|
2019-07-26 10:29:06 +00:00
|
|
|
|
var container = new Container { RelativeSizeAxes = Axes.Both };
|
|
|
|
|
|
2018-04-13 09:19:50 +00:00
|
|
|
|
Vector2 pos = new Vector2(-250, 0);
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i <= 1000; i += 100)
|
|
|
|
|
{
|
2019-07-26 10:29:06 +00:00
|
|
|
|
container.Add(testSingle(circleSize, auto, i, pos));
|
2018-04-13 09:19:50 +00:00
|
|
|
|
pos.X += 50;
|
|
|
|
|
}
|
2019-07-26 10:29:06 +00:00
|
|
|
|
|
|
|
|
|
return container;
|
2018-04-13 09:19:50 +00:00
|
|
|
|
}
|
|
|
|
|
|
2018-07-06 08:38:58 +00:00
|
|
|
|
protected class TestDrawableHitCircle : DrawableHitCircle
|
2018-04-13 09:19:50 +00:00
|
|
|
|
{
|
|
|
|
|
private readonly bool auto;
|
|
|
|
|
|
2019-02-28 04:31:40 +00:00
|
|
|
|
public TestDrawableHitCircle(HitCircle h, bool auto)
|
|
|
|
|
: base(h)
|
2018-04-13 09:19:50 +00:00
|
|
|
|
{
|
|
|
|
|
this.auto = auto;
|
|
|
|
|
}
|
|
|
|
|
|
2018-08-24 06:26:36 +00:00
|
|
|
|
public void TriggerJudgement() => UpdateResult(true);
|
2018-07-06 08:38:58 +00:00
|
|
|
|
|
2018-08-06 02:31:46 +00:00
|
|
|
|
protected override void CheckForResult(bool userTriggered, double timeOffset)
|
2018-04-13 09:19:50 +00:00
|
|
|
|
{
|
|
|
|
|
if (auto && !userTriggered && timeOffset > 0)
|
|
|
|
|
{
|
|
|
|
|
// force success
|
2018-08-03 06:38:48 +00:00
|
|
|
|
ApplyResult(r => r.Type = HitResult.Great);
|
2018-04-13 09:19:50 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
2018-08-06 02:31:46 +00:00
|
|
|
|
base.CheckForResult(userTriggered, timeOffset);
|
2018-04-13 09:19:50 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|