2019-08-19 18:10:12 +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.
|
|
|
|
|
|
|
|
|
|
using NUnit.Framework;
|
|
|
|
|
using osu.Game.Rulesets.Objects;
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using osu.Game.Rulesets.Judgements;
|
|
|
|
|
using osu.Framework.MathUtils;
|
2019-08-19 18:25:14 +00:00
|
|
|
|
using osu.Framework.Graphics;
|
2019-08-19 19:45:27 +00:00
|
|
|
|
using osu.Framework.Graphics.Containers;
|
2019-11-25 02:30:55 +00:00
|
|
|
|
using osu.Game.Graphics.Sprites;
|
2019-09-06 06:24:00 +00:00
|
|
|
|
using osu.Game.Rulesets.Catch.Scoring;
|
|
|
|
|
using osu.Game.Rulesets.Mania.Scoring;
|
|
|
|
|
using osu.Game.Rulesets.Osu.Scoring;
|
|
|
|
|
using osu.Game.Rulesets.Scoring;
|
|
|
|
|
using osu.Game.Rulesets.Taiko.Scoring;
|
2019-08-30 09:46:42 +00:00
|
|
|
|
using osu.Game.Screens.Play.HUD.HitErrorMeters;
|
2019-08-19 18:10:12 +00:00
|
|
|
|
|
|
|
|
|
namespace osu.Game.Tests.Visual.Gameplay
|
|
|
|
|
{
|
2019-08-30 06:32:47 +00:00
|
|
|
|
public class TestSceneBarHitErrorMeter : OsuTestScene
|
2019-08-19 18:10:12 +00:00
|
|
|
|
{
|
|
|
|
|
public override IReadOnlyList<Type> RequiredTypes => new[]
|
|
|
|
|
{
|
2019-08-30 06:32:47 +00:00
|
|
|
|
typeof(HitErrorMeter),
|
2019-08-19 18:10:12 +00:00
|
|
|
|
};
|
|
|
|
|
|
2019-08-30 06:32:47 +00:00
|
|
|
|
private HitErrorMeter meter;
|
2019-08-30 08:06:23 +00:00
|
|
|
|
private HitErrorMeter meter2;
|
2019-08-30 10:47:13 +00:00
|
|
|
|
private HitWindows hitWindows;
|
2019-08-19 18:10:12 +00:00
|
|
|
|
|
2019-08-30 06:32:47 +00:00
|
|
|
|
public TestSceneBarHitErrorMeter()
|
2019-08-19 18:10:12 +00:00
|
|
|
|
{
|
2019-08-30 10:47:13 +00:00
|
|
|
|
recreateDisplay(new OsuHitWindows(), 5);
|
2019-08-30 07:40:24 +00:00
|
|
|
|
|
|
|
|
|
AddRepeatStep("New random judgement", () => newJudgement(), 40);
|
|
|
|
|
|
2019-09-06 06:24:00 +00:00
|
|
|
|
AddRepeatStep("New max negative", () => newJudgement(-hitWindows.WindowFor(HitResult.Meh)), 20);
|
|
|
|
|
AddRepeatStep("New max positive", () => newJudgement(hitWindows.WindowFor(HitResult.Meh)), 20);
|
2019-08-19 18:10:12 +00:00
|
|
|
|
AddStep("New fixed judgement (50ms)", () => newJudgement(50));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[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 10:47:13 +00:00
|
|
|
|
this.hitWindows = hitWindows;
|
|
|
|
|
|
|
|
|
|
hitWindows?.SetDifficulty(overallDifficulty);
|
2019-08-19 19:45:27 +00:00
|
|
|
|
|
2019-08-19 18:10:12 +00:00
|
|
|
|
Clear();
|
2019-08-19 19:45:27 +00:00
|
|
|
|
|
|
|
|
|
Add(new FillFlowContainer
|
|
|
|
|
{
|
2019-08-30 08:06:23 +00:00
|
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
|
Origin = Anchor.Centre,
|
2019-08-19 19:45:27 +00:00
|
|
|
|
Direction = FillDirection.Vertical,
|
|
|
|
|
AutoSizeAxes = Axes.Both,
|
|
|
|
|
Children = new[]
|
|
|
|
|
{
|
2019-11-25 02:30:55 +00:00
|
|
|
|
new OsuSpriteText { Text = $@"Great: {hitWindows?.WindowFor(HitResult.Great)}" },
|
|
|
|
|
new OsuSpriteText { Text = $@"Good: {hitWindows?.WindowFor(HitResult.Good)}" },
|
|
|
|
|
new OsuSpriteText { Text = $@"Meh: {hitWindows?.WindowFor(HitResult.Meh)}" },
|
2019-08-19 19:45:27 +00:00
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
2019-08-30 08:06:23 +00:00
|
|
|
|
Add(meter = new BarHitErrorMeter(hitWindows, true)
|
2019-08-19 18:25:14 +00:00
|
|
|
|
{
|
2019-08-30 08:06:23 +00:00
|
|
|
|
Anchor = Anchor.CentreRight,
|
|
|
|
|
Origin = Anchor.CentreRight,
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
Add(meter2 = new BarHitErrorMeter(hitWindows, false)
|
|
|
|
|
{
|
|
|
|
|
Anchor = Anchor.CentreLeft,
|
|
|
|
|
Origin = Anchor.CentreLeft,
|
2019-08-19 18:25:14 +00:00
|
|
|
|
});
|
2019-08-19 18:10:12 +00:00
|
|
|
|
}
|
|
|
|
|
|
2019-08-30 07:40:24 +00:00
|
|
|
|
private void newJudgement(double offset = 0)
|
2019-08-19 18:10:12 +00:00
|
|
|
|
{
|
2019-09-02 08:14:40 +00:00
|
|
|
|
var judgement = new JudgementResult(new HitObject(), new Judgement())
|
2019-08-19 18:10:12 +00:00
|
|
|
|
{
|
2019-08-30 07:40:24 +00:00
|
|
|
|
TimeOffset = offset == 0 ? RNG.Next(-150, 150) : offset,
|
2019-08-19 18:10:12 +00:00
|
|
|
|
Type = HitResult.Perfect,
|
2019-08-30 08:06:23 +00:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
meter.OnNewJudgement(judgement);
|
|
|
|
|
meter2.OnNewJudgement(judgement);
|
2019-08-19 18:10:12 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|