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
|
|
|
|
|
|
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.Beatmaps;
|
|
|
|
|
using osu.Game.Beatmaps.ControlPoints;
|
2017-12-27 18:47:55 +08:00
|
|
|
|
using osu.Game.Rulesets.Objects.Drawables;
|
2017-12-27 16:34:07 +08:00
|
|
|
|
using osu.Game.Rulesets.Osu.Objects;
|
|
|
|
|
using osu.Game.Rulesets.Osu.Objects.Drawables;
|
|
|
|
|
using osu.Game.Tests.Visual;
|
|
|
|
|
using OpenTK;
|
2017-12-29 00:06:15 +08:00
|
|
|
|
using osu.Game.Rulesets.Osu.Mods;
|
|
|
|
|
using OpenTK.Graphics;
|
|
|
|
|
using osu.Game.Rulesets.Osu.Judgements;
|
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 TestCaseHitCircle : OsuTestCase
|
|
|
|
|
{
|
|
|
|
|
private readonly Container content;
|
|
|
|
|
protected override Container<Drawable> Content => content;
|
|
|
|
|
|
2017-12-27 18:47:55 +08:00
|
|
|
|
private bool auto;
|
2017-12-29 00:06:15 +08:00
|
|
|
|
private bool hidden;
|
2017-12-27 18:47:55 +08:00
|
|
|
|
private int depthIndex;
|
2017-12-29 00:06:15 +08:00
|
|
|
|
private int circleSize;
|
|
|
|
|
private float circleScale;
|
2017-12-27 18:47:55 +08:00
|
|
|
|
|
2017-12-27 16:34:07 +08:00
|
|
|
|
public TestCaseHitCircle()
|
|
|
|
|
{
|
|
|
|
|
base.Content.Add(content = new OsuInputManager(new RulesetInfo { ID = 0 }));
|
|
|
|
|
|
2017-12-27 18:47:55 +08:00
|
|
|
|
AddStep("Single", () => addSingle());
|
2017-12-27 16:34:07 +08:00
|
|
|
|
AddStep("Stream", addStream);
|
2017-12-27 18:47:55 +08:00
|
|
|
|
AddToggleStep("Auto", v => auto = v);
|
2017-12-29 00:06:15 +08:00
|
|
|
|
AddToggleStep("Hidden", v => hidden = v);
|
|
|
|
|
AddSliderStep("CircleSize", 0, 10, 0, s => circleSize = s);
|
|
|
|
|
AddSliderStep("CircleScale", 0.5f, 2, 1, s => circleScale = s);
|
2017-12-27 16:34:07 +08:00
|
|
|
|
}
|
|
|
|
|
|
2017-12-27 18:47:55 +08:00
|
|
|
|
private void addSingle(double timeOffset = 0, Vector2? positionOffset = null)
|
2017-12-27 16:34:07 +08:00
|
|
|
|
{
|
2017-12-27 18:47:55 +08:00
|
|
|
|
positionOffset = positionOffset ?? Vector2.Zero;
|
|
|
|
|
|
|
|
|
|
var circle = new HitCircle
|
|
|
|
|
{
|
|
|
|
|
StartTime = Time.Current + 1000 + timeOffset,
|
2017-12-29 00:06:15 +08:00
|
|
|
|
Position = positionOffset.Value,
|
|
|
|
|
ComboColour = Color4.LightSeaGreen
|
2017-12-27 18:47:55 +08:00
|
|
|
|
};
|
|
|
|
|
|
2017-12-29 00:06:15 +08:00
|
|
|
|
circle.ApplyDefaults(new ControlPointInfo(), new BeatmapDifficulty { CircleSize = circleSize });
|
2017-12-27 16:34:07 +08:00
|
|
|
|
|
2017-12-29 00:06:15 +08:00
|
|
|
|
var drawable = new TestDrawableHitCircle(circle, auto)
|
2017-12-27 18:47:55 +08:00
|
|
|
|
{
|
|
|
|
|
Anchor = Anchor.Centre,
|
2017-12-29 00:06:15 +08:00
|
|
|
|
Scale = new Vector2(circleScale),
|
2017-12-27 18:47:55 +08:00
|
|
|
|
Depth = depthIndex++
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
if (auto)
|
|
|
|
|
drawable.State.Value = ArmedState.Hit;
|
|
|
|
|
|
2017-12-29 00:06:15 +08:00
|
|
|
|
if (hidden)
|
|
|
|
|
drawable.ApplyCustomUpdateState += new TestOsuModHidden().CustomSequence;
|
|
|
|
|
|
2017-12-27 18:47:55 +08:00
|
|
|
|
Add(drawable);
|
2017-12-27 16:34:07 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void addStream()
|
|
|
|
|
{
|
|
|
|
|
Vector2 pos = Vector2.Zero;
|
|
|
|
|
|
2017-12-27 18:47:55 +08:00
|
|
|
|
for (int i = 0; i <= 1000; i += 100)
|
2017-12-27 16:34:07 +08:00
|
|
|
|
{
|
2017-12-27 18:47:55 +08:00
|
|
|
|
addSingle(i, pos);
|
2017-12-27 16:34:07 +08:00
|
|
|
|
pos += new Vector2(10);
|
|
|
|
|
}
|
|
|
|
|
}
|
2017-12-29 00:06:15 +08:00
|
|
|
|
|
|
|
|
|
private class TestOsuModHidden : OsuModHidden
|
|
|
|
|
{
|
|
|
|
|
public new void CustomSequence(DrawableHitObject drawable, ArmedState state) => base.CustomSequence(drawable, state);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private class TestDrawableHitCircle : DrawableHitCircle
|
|
|
|
|
{
|
|
|
|
|
private readonly bool auto;
|
|
|
|
|
|
|
|
|
|
public TestDrawableHitCircle(OsuHitObject h, bool auto) : base(h)
|
|
|
|
|
{
|
|
|
|
|
this.auto = auto;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void CheckForJudgements(bool userTriggered, double timeOffset)
|
|
|
|
|
{
|
|
|
|
|
if (auto && !userTriggered && timeOffset > 0)
|
|
|
|
|
{
|
|
|
|
|
// pretend we really hit it
|
|
|
|
|
AddJudgement(new OsuJudgement
|
|
|
|
|
{
|
|
|
|
|
Result = HitObject.ScoreResultForOffset(timeOffset)
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
base.CheckForJudgements(userTriggered, timeOffset);
|
|
|
|
|
}
|
|
|
|
|
}
|
2017-12-27 16:34:07 +08:00
|
|
|
|
}
|
|
|
|
|
}
|