1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-16 23:02:56 +08:00
osu-lazer/osu.Game.Rulesets.Mania.Tests/Skinning/TestSceneComboCounter.cs

96 lines
3.6 KiB
C#
Raw Normal View History

2023-12-30 10:21:10 +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.
2024-08-20 11:28:36 +08:00
using NUnit.Framework;
2023-12-30 10:21:10 +08:00
using osu.Framework.Allocation;
2024-08-20 11:28:36 +08:00
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
2023-12-30 10:21:10 +08:00
using osu.Framework.Testing;
using osu.Game.Rulesets.Judgements;
using osu.Game.Rulesets.Mania.Skinning.Argon;
using osu.Game.Rulesets.Mania.Skinning.Legacy;
using osu.Game.Rulesets.Objects;
using osu.Game.Rulesets.Scoring;
2024-08-20 11:28:36 +08:00
using osu.Game.Rulesets.UI.Scrolling;
2023-12-30 10:21:10 +08:00
using osu.Game.Skinning;
namespace osu.Game.Rulesets.Mania.Tests.Skinning
{
public partial class TestSceneComboCounter : ManiaSkinnableTestScene
{
[Cached]
private ScoreProcessor scoreProcessor = new ScoreProcessor(new ManiaRuleset());
2024-08-20 11:28:36 +08:00
[Test]
public void TestDisplay()
2023-12-30 10:21:10 +08:00
{
2024-08-20 11:28:36 +08:00
setup(Anchor.Centre);
AddRepeatStep("perform hit", () => scoreProcessor.ApplyResult(new JudgementResult(new HitObject(), new Judgement()) { Type = HitResult.Great }), 20);
AddStep("perform miss", () => scoreProcessor.ApplyResult(new JudgementResult(new HitObject(), new Judgement()) { Type = HitResult.Miss }));
}
[Test]
public void TestAnchorOrigin()
{
AddStep("set direction down", () => ScrollingInfo.Direction.Value = ScrollingDirection.Down);
setup(Anchor.TopCentre, 20);
AddStep("set direction up", () => ScrollingInfo.Direction.Value = ScrollingDirection.Up);
check(Anchor.BottomCentre, -20);
AddStep("set direction up", () => ScrollingInfo.Direction.Value = ScrollingDirection.Up);
setup(Anchor.BottomCentre, -20);
AddStep("set direction down", () => ScrollingInfo.Direction.Value = ScrollingDirection.Down);
check(Anchor.TopCentre, 20);
AddStep("set direction down", () => ScrollingInfo.Direction.Value = ScrollingDirection.Down);
setup(Anchor.Centre, 20);
AddStep("set direction up", () => ScrollingInfo.Direction.Value = ScrollingDirection.Up);
check(Anchor.Centre, 20);
AddStep("set direction up", () => ScrollingInfo.Direction.Value = ScrollingDirection.Up);
setup(Anchor.Centre, -20);
AddStep("set direction down", () => ScrollingInfo.Direction.Value = ScrollingDirection.Down);
check(Anchor.Centre, -20);
}
private void setup(Anchor anchor, float y = 0)
{
AddStep($"setup {anchor} {y}", () => SetContents(s =>
2023-12-30 10:21:10 +08:00
{
2024-08-20 11:28:36 +08:00
var container = new Container
{
RelativeSizeAxes = Axes.Both,
};
2023-12-30 10:21:10 +08:00
if (s is ArgonSkin)
2024-08-20 11:28:36 +08:00
container.Add(new ArgonManiaComboCounter());
else if (s is LegacySkin)
container.Add(new LegacyManiaComboCounter());
else
container.Add(new LegacyManiaComboCounter());
2023-12-30 10:21:10 +08:00
2024-08-20 11:28:36 +08:00
container.Child.Anchor = anchor;
container.Child.Origin = Anchor.Centre;
container.Child.Y = y;
2023-12-30 10:21:10 +08:00
2024-08-20 11:28:36 +08:00
return container;
2023-12-30 10:21:10 +08:00
}));
2024-08-20 11:28:36 +08:00
}
2023-12-30 10:21:10 +08:00
2024-08-20 11:28:36 +08:00
private void check(Anchor anchor, float y)
{
AddAssert($"check {anchor} {y}", () =>
{
foreach (var combo in this.ChildrenOfType<ISerialisableDrawable>())
{
var drawableCombo = (Drawable)combo;
if (drawableCombo.Anchor != anchor || drawableCombo.Y != y)
return false;
}
return true;
});
2023-12-30 10:21:10 +08:00
}
}
}