2022-12-11 22:47:17 +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 System;
|
|
|
|
using System.Diagnostics;
|
|
|
|
using System.Linq;
|
|
|
|
using NUnit.Framework;
|
|
|
|
using osu.Framework.Bindables;
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
using osu.Framework.Graphics.Containers;
|
|
|
|
using osu.Framework.Testing;
|
|
|
|
using osu.Game.Rulesets;
|
|
|
|
using osu.Game.Rulesets.Judgements;
|
|
|
|
using osu.Game.Rulesets.Mania;
|
|
|
|
using osu.Game.Rulesets.Objects;
|
|
|
|
using osu.Game.Rulesets.Osu.Judgements;
|
|
|
|
using osu.Game.Rulesets.Scoring;
|
|
|
|
using osu.Game.Screens.Play.HUD.JudgementCounter;
|
|
|
|
|
|
|
|
namespace osu.Game.Tests.Visual.Gameplay
|
|
|
|
{
|
|
|
|
public partial class TestSceneJudgementCounter : OsuTestScene
|
|
|
|
{
|
|
|
|
private ScoreProcessor scoreProcessor = null!;
|
|
|
|
private JudgementTally judgementTally = null!;
|
|
|
|
private TestJudgementCounterDisplay counter = null!;
|
|
|
|
|
|
|
|
private readonly Bindable<JudgementResult> lastJudgementResult = new Bindable<JudgementResult>();
|
|
|
|
|
|
|
|
private int iteration;
|
|
|
|
|
|
|
|
[SetUpSteps]
|
|
|
|
public void SetupSteps() => AddStep("Create components", () =>
|
|
|
|
{
|
|
|
|
var ruleset = CreateRuleset();
|
|
|
|
|
2022-12-12 10:53:07 +00:00
|
|
|
var r = ruleset.CreateBeatmapConverter(Beatmap.Value.Beatmap);
|
|
|
|
|
|
|
|
var n = r.Convert().BeatmapInfo.Ruleset.CreateInstance();
|
2022-12-11 22:47:17 +00:00
|
|
|
Debug.Assert(ruleset != null);
|
|
|
|
|
2022-12-12 10:53:07 +00:00
|
|
|
scoreProcessor = new ScoreProcessor(n);
|
2022-12-11 22:47:17 +00:00
|
|
|
Child = new DependencyProvidingContainer
|
|
|
|
{
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
2022-12-12 10:53:07 +00:00
|
|
|
CachedDependencies = new (Type, object)[] { (typeof(ScoreProcessor), scoreProcessor), (typeof(Ruleset), n) },
|
2022-12-11 22:47:17 +00:00
|
|
|
Children = new Drawable[]
|
|
|
|
{
|
|
|
|
judgementTally = new JudgementTally(),
|
|
|
|
new DependencyProvidingContainer
|
|
|
|
{
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
CachedDependencies = new (Type, object)[] { (typeof(JudgementTally), judgementTally) },
|
|
|
|
Child = counter = new TestJudgementCounterDisplay
|
|
|
|
{
|
|
|
|
Margin = new MarginPadding { Top = 100 },
|
|
|
|
Anchor = Anchor.TopCentre,
|
|
|
|
Origin = Anchor.TopCentre
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
};
|
|
|
|
});
|
|
|
|
|
|
|
|
protected override Ruleset CreateRuleset() => new ManiaRuleset();
|
|
|
|
|
|
|
|
private void applyOneJudgement(HitResult result)
|
|
|
|
{
|
|
|
|
lastJudgementResult.Value = new OsuJudgementResult(new HitObject
|
|
|
|
{
|
|
|
|
StartTime = iteration * 10000
|
|
|
|
}, new OsuJudgement())
|
|
|
|
{
|
|
|
|
Type = result,
|
|
|
|
};
|
|
|
|
scoreProcessor.ApplyResult(lastJudgementResult.Value);
|
|
|
|
|
|
|
|
iteration++;
|
|
|
|
}
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
public void TestAddJudgementsToCounters()
|
|
|
|
{
|
|
|
|
AddRepeatStep("Add judgement", () => applyOneJudgement(HitResult.Great), 2);
|
|
|
|
AddRepeatStep("Add judgement", () => applyOneJudgement(HitResult.Miss), 2);
|
|
|
|
AddRepeatStep("Add judgement", () => applyOneJudgement(HitResult.Meh), 2);
|
|
|
|
AddRepeatStep("Add judgement", () => applyOneJudgement(HitResult.LargeTickHit), 2);
|
|
|
|
AddStep("Show all judgements", () => counter.Mode.Value = JudgementCounterDisplay.DisplayMode.All);
|
|
|
|
AddAssert("Check value added whilst hidden", () => hiddenCount() == 2);
|
|
|
|
}
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
public void TestAddWhilstHidden()
|
|
|
|
{
|
|
|
|
AddRepeatStep("Add judgement", () => applyOneJudgement(HitResult.LargeTickHit), 2);
|
|
|
|
AddAssert("Check value added whilst hidden", () => hiddenCount() == 2);
|
|
|
|
AddStep("Show all judgements", () => counter.Mode.Value = JudgementCounterDisplay.DisplayMode.All);
|
|
|
|
}
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
public void TestChangeFlowDirection()
|
|
|
|
{
|
2022-12-11 23:33:28 +00:00
|
|
|
AddStep("Set direction vertical", () => counter.FlowDirection.Value = JudgementCounterDisplay.Flow.Vertical);
|
2022-12-12 09:52:55 +00:00
|
|
|
AddStep("Set direction horizontal", () => counter.FlowDirection.Value = JudgementCounterDisplay.Flow.Horizontal);
|
2022-12-11 22:47:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
[Test]
|
2022-12-11 22:58:10 +00:00
|
|
|
public void TestToggleJudgementNames()
|
2022-12-11 22:47:17 +00:00
|
|
|
{
|
|
|
|
AddStep("Hide judgement names", () => counter.ShowName.Value = false);
|
2022-12-11 22:58:10 +00:00
|
|
|
AddAssert("Assert hidden", () => counter.JudgementContainer.Children.OfType<JudgementCounter>().First().ResultName.Alpha == 0);
|
|
|
|
AddStep("Hide judgement names", () => counter.ShowName.Value = true);
|
|
|
|
AddAssert("Assert shown", () => counter.JudgementContainer.Children.OfType<JudgementCounter>().First().ResultName.Alpha == 1);
|
2022-12-11 22:47:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
public void TestHideMaxValue()
|
|
|
|
{
|
|
|
|
AddStep("Hide max judgement", () => counter.ShowMax.Value = false);
|
|
|
|
AddStep("Show max judgement", () => counter.ShowMax.Value = true);
|
|
|
|
}
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
public void TestCycleDisplayModes()
|
|
|
|
{
|
|
|
|
AddStep("Show all judgements", () => counter.Mode.Value = JudgementCounterDisplay.DisplayMode.All);
|
|
|
|
AddStep("Show normal judgements", () => counter.Mode.Value = JudgementCounterDisplay.DisplayMode.Normal);
|
|
|
|
AddStep("Show basic judgements", () => counter.Mode.Value = JudgementCounterDisplay.DisplayMode.Simple);
|
|
|
|
}
|
|
|
|
|
|
|
|
private int hiddenCount()
|
|
|
|
{
|
|
|
|
var num = counter.JudgementContainer.Children.OfType<JudgementCounter>().First(child => child.Result.ResultInfo.Type == HitResult.LargeTickHit);
|
|
|
|
return num.Result.ResultCount.Value;
|
|
|
|
}
|
|
|
|
|
|
|
|
private partial class TestJudgementCounterDisplay : JudgementCounterDisplay
|
|
|
|
{
|
|
|
|
public new FillFlowContainer JudgementContainer => base.JudgementContainer;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|