2019-08-20 02:10:12 +08: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.
|
|
|
|
|
|
|
|
|
|
using NUnit.Framework;
|
|
|
|
|
using osu.Game.Rulesets.Judgements;
|
2020-01-09 12:43:44 +08:00
|
|
|
|
using osu.Framework.Utils;
|
2019-08-20 02:25:14 +08:00
|
|
|
|
using osu.Framework.Graphics;
|
2019-08-20 03:45:27 +08:00
|
|
|
|
using osu.Framework.Graphics.Containers;
|
2020-02-23 02:53:51 +08:00
|
|
|
|
using osu.Framework.Threading;
|
2019-11-25 10:30:55 +08:00
|
|
|
|
using osu.Game.Graphics.Sprites;
|
2019-09-06 14:24:00 +08:00
|
|
|
|
using osu.Game.Rulesets.Catch.Scoring;
|
|
|
|
|
using osu.Game.Rulesets.Mania.Scoring;
|
2020-02-25 18:07:15 +08:00
|
|
|
|
using osu.Game.Rulesets.Objects;
|
2019-09-06 14:24:00 +08:00
|
|
|
|
using osu.Game.Rulesets.Osu.Scoring;
|
|
|
|
|
using osu.Game.Rulesets.Scoring;
|
|
|
|
|
using osu.Game.Rulesets.Taiko.Scoring;
|
2019-08-30 17:46:42 +08:00
|
|
|
|
using osu.Game.Screens.Play.HUD.HitErrorMeters;
|
2019-08-20 02:10:12 +08:00
|
|
|
|
|
|
|
|
|
namespace osu.Game.Tests.Visual.Gameplay
|
|
|
|
|
{
|
2019-12-21 19:30:49 +08:00
|
|
|
|
public class TestSceneHitErrorMeter : OsuTestScene
|
2019-08-20 02:10:12 +08:00
|
|
|
|
{
|
2019-12-21 19:30:49 +08:00
|
|
|
|
private BarHitErrorMeter barMeter;
|
|
|
|
|
private BarHitErrorMeter barMeter2;
|
2020-10-15 18:11:40 +08:00
|
|
|
|
private BarHitErrorMeter barMeter3;
|
2019-12-21 19:30:49 +08:00
|
|
|
|
private ColourHitErrorMeter colourMeter;
|
|
|
|
|
private ColourHitErrorMeter colourMeter2;
|
2020-10-15 18:11:40 +08:00
|
|
|
|
private ColourHitErrorMeter colourMeter3;
|
2019-08-30 18:47:13 +08:00
|
|
|
|
private HitWindows hitWindows;
|
2019-08-20 02:10:12 +08:00
|
|
|
|
|
2019-12-21 19:30:49 +08:00
|
|
|
|
public TestSceneHitErrorMeter()
|
2019-08-20 02:10:12 +08:00
|
|
|
|
{
|
2019-08-30 18:47:13 +08:00
|
|
|
|
recreateDisplay(new OsuHitWindows(), 5);
|
2019-08-30 15:40:24 +08:00
|
|
|
|
|
|
|
|
|
AddRepeatStep("New random judgement", () => newJudgement(), 40);
|
|
|
|
|
|
2019-09-06 14:24:00 +08:00
|
|
|
|
AddRepeatStep("New max negative", () => newJudgement(-hitWindows.WindowFor(HitResult.Meh)), 20);
|
|
|
|
|
AddRepeatStep("New max positive", () => newJudgement(hitWindows.WindowFor(HitResult.Meh)), 20);
|
2019-08-20 02:10:12 +08:00
|
|
|
|
AddStep("New fixed judgement (50ms)", () => newJudgement(50));
|
2020-02-23 02:53:51 +08:00
|
|
|
|
|
|
|
|
|
AddStep("Judgement barrage", () =>
|
|
|
|
|
{
|
|
|
|
|
int runCount = 0;
|
|
|
|
|
|
|
|
|
|
ScheduledDelegate del = null;
|
|
|
|
|
|
|
|
|
|
del = Scheduler.AddDelayed(() =>
|
|
|
|
|
{
|
|
|
|
|
newJudgement(runCount++ / 10f);
|
|
|
|
|
|
|
|
|
|
if (runCount == 500)
|
|
|
|
|
// ReSharper disable once AccessToModifiedClosure
|
|
|
|
|
del?.Cancel();
|
|
|
|
|
}, 10, true);
|
|
|
|
|
});
|
2019-08-20 02:10:12 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void TestOsu()
|
|
|
|
|
{
|
|
|
|
|
AddStep("OD 1", () => recreateDisplay(new OsuHitWindows(), 1));
|
|
|
|
|
AddStep("OD 10", () => recreateDisplay(new OsuHitWindows(), 10));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void TestTaiko()
|
|
|
|
|
{
|
|
|
|
|
AddStep("OD 1", () => recreateDisplay(new TaikoHitWindows(), 1));
|
|
|
|
|
AddStep("OD 10", () => recreateDisplay(new TaikoHitWindows(), 10));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void TestMania()
|
|
|
|
|
{
|
|
|
|
|
AddStep("OD 1", () => recreateDisplay(new ManiaHitWindows(), 1));
|
|
|
|
|
AddStep("OD 10", () => recreateDisplay(new ManiaHitWindows(), 10));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void TestCatch()
|
|
|
|
|
{
|
|
|
|
|
AddStep("OD 1", () => recreateDisplay(new CatchHitWindows(), 1));
|
|
|
|
|
AddStep("OD 10", () => recreateDisplay(new CatchHitWindows(), 10));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void recreateDisplay(HitWindows hitWindows, float overallDifficulty)
|
|
|
|
|
{
|
2019-08-30 18:47:13 +08:00
|
|
|
|
this.hitWindows = hitWindows;
|
|
|
|
|
|
|
|
|
|
hitWindows?.SetDifficulty(overallDifficulty);
|
2019-08-20 03:45:27 +08:00
|
|
|
|
|
2019-08-20 02:10:12 +08:00
|
|
|
|
Clear();
|
2019-08-20 03:45:27 +08:00
|
|
|
|
|
|
|
|
|
Add(new FillFlowContainer
|
|
|
|
|
{
|
2019-08-30 16:06:23 +08:00
|
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
|
Origin = Anchor.Centre,
|
2019-08-20 03:45:27 +08:00
|
|
|
|
Direction = FillDirection.Vertical,
|
|
|
|
|
AutoSizeAxes = Axes.Both,
|
|
|
|
|
Children = new[]
|
|
|
|
|
{
|
2019-11-25 10:30:55 +08:00
|
|
|
|
new OsuSpriteText { Text = $@"Great: {hitWindows?.WindowFor(HitResult.Great)}" },
|
2020-09-29 16:16:55 +08:00
|
|
|
|
new OsuSpriteText { Text = $@"Good: {hitWindows?.WindowFor(HitResult.Ok)}" },
|
2019-11-25 10:30:55 +08:00
|
|
|
|
new OsuSpriteText { Text = $@"Meh: {hitWindows?.WindowFor(HitResult.Meh)}" },
|
2019-08-20 03:45:27 +08:00
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
2019-12-21 19:30:49 +08:00
|
|
|
|
Add(barMeter = new BarHitErrorMeter(hitWindows, true)
|
2019-08-20 02:25:14 +08:00
|
|
|
|
{
|
2019-08-30 16:06:23 +08:00
|
|
|
|
Anchor = Anchor.CentreRight,
|
|
|
|
|
Origin = Anchor.CentreRight,
|
|
|
|
|
});
|
|
|
|
|
|
2019-12-21 19:30:49 +08:00
|
|
|
|
Add(barMeter2 = new BarHitErrorMeter(hitWindows, false)
|
2019-08-30 16:06:23 +08:00
|
|
|
|
{
|
|
|
|
|
Anchor = Anchor.CentreLeft,
|
|
|
|
|
Origin = Anchor.CentreLeft,
|
2019-08-20 02:25:14 +08:00
|
|
|
|
});
|
2019-12-21 19:30:49 +08:00
|
|
|
|
|
2020-10-15 18:11:40 +08:00
|
|
|
|
Add(barMeter3 = new BarHitErrorMeter(hitWindows, true)
|
|
|
|
|
{
|
|
|
|
|
Anchor = Anchor.BottomCentre,
|
|
|
|
|
Origin = Anchor.CentreLeft,
|
|
|
|
|
Rotation = 270,
|
|
|
|
|
});
|
|
|
|
|
|
2019-12-21 19:30:49 +08:00
|
|
|
|
Add(colourMeter = new ColourHitErrorMeter(hitWindows)
|
|
|
|
|
{
|
|
|
|
|
Anchor = Anchor.CentreRight,
|
|
|
|
|
Origin = Anchor.CentreRight,
|
|
|
|
|
Margin = new MarginPadding { Right = 50 }
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
Add(colourMeter2 = new ColourHitErrorMeter(hitWindows)
|
|
|
|
|
{
|
|
|
|
|
Anchor = Anchor.CentreLeft,
|
|
|
|
|
Origin = Anchor.CentreLeft,
|
|
|
|
|
Margin = new MarginPadding { Left = 50 }
|
|
|
|
|
});
|
2020-10-15 18:11:40 +08:00
|
|
|
|
|
|
|
|
|
Add(colourMeter3 = new ColourHitErrorMeter(hitWindows)
|
|
|
|
|
{
|
|
|
|
|
Anchor = Anchor.BottomCentre,
|
|
|
|
|
Origin = Anchor.CentreLeft,
|
|
|
|
|
Rotation = 270,
|
|
|
|
|
Margin = new MarginPadding { Left = 50 }
|
|
|
|
|
});
|
2019-08-20 02:10:12 +08:00
|
|
|
|
}
|
|
|
|
|
|
2019-08-30 15:40:24 +08:00
|
|
|
|
private void newJudgement(double offset = 0)
|
2019-08-20 02:10:12 +08:00
|
|
|
|
{
|
2020-02-25 18:07:15 +08:00
|
|
|
|
var judgement = new JudgementResult(new HitObject(), new Judgement())
|
2019-08-20 02:10:12 +08:00
|
|
|
|
{
|
2019-08-30 15:40:24 +08:00
|
|
|
|
TimeOffset = offset == 0 ? RNG.Next(-150, 150) : offset,
|
2019-08-20 02:10:12 +08:00
|
|
|
|
Type = HitResult.Perfect,
|
2019-08-30 16:06:23 +08:00
|
|
|
|
};
|
|
|
|
|
|
2019-12-21 19:30:49 +08:00
|
|
|
|
barMeter.OnNewJudgement(judgement);
|
|
|
|
|
barMeter2.OnNewJudgement(judgement);
|
2020-10-15 18:11:40 +08:00
|
|
|
|
barMeter3.OnNewJudgement(judgement);
|
2019-12-21 19:30:49 +08:00
|
|
|
|
colourMeter.OnNewJudgement(judgement);
|
|
|
|
|
colourMeter2.OnNewJudgement(judgement);
|
2020-10-15 18:11:40 +08:00
|
|
|
|
colourMeter3.OnNewJudgement(judgement);
|
2019-08-20 02:10:12 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|