2019-01-24 08:43:03 +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.
|
2018-06-08 05:28:27 +00:00
|
|
|
|
|
2022-06-17 07:37:17 +00:00
|
|
|
|
#nullable disable
|
|
|
|
|
|
2019-04-10 08:54:57 +00:00
|
|
|
|
using System;
|
2018-06-11 06:43:15 +00:00
|
|
|
|
using System.Collections.Generic;
|
2018-08-08 03:21:44 +00:00
|
|
|
|
using System.Linq;
|
2018-06-08 05:28:27 +00:00
|
|
|
|
using NUnit.Framework;
|
|
|
|
|
using osu.Framework.Allocation;
|
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
|
using osu.Framework.Graphics.Containers;
|
2018-06-11 06:43:15 +00:00
|
|
|
|
using osu.Game.Beatmaps;
|
|
|
|
|
using osu.Game.Beatmaps.ControlPoints;
|
2018-06-08 05:28:27 +00:00
|
|
|
|
using osu.Game.Rulesets.Mania.Beatmaps;
|
2018-06-11 06:43:15 +00:00
|
|
|
|
using osu.Game.Rulesets.Mania.Objects;
|
|
|
|
|
using osu.Game.Rulesets.Mania.Objects.Drawables;
|
2018-06-08 05:28:27 +00:00
|
|
|
|
using osu.Game.Rulesets.Mania.UI;
|
2019-04-10 08:54:57 +00:00
|
|
|
|
using osu.Game.Rulesets.Mods;
|
2018-06-08 05:28:27 +00:00
|
|
|
|
using osu.Game.Rulesets.UI.Scrolling;
|
2018-11-06 06:46:36 +00:00
|
|
|
|
using osu.Game.Tests.Visual;
|
2018-11-20 07:51:59 +00:00
|
|
|
|
using osuTK;
|
2018-06-08 05:28:27 +00:00
|
|
|
|
|
|
|
|
|
namespace osu.Game.Rulesets.Mania.Tests
|
|
|
|
|
{
|
|
|
|
|
[TestFixture]
|
2019-05-14 19:37:25 +00:00
|
|
|
|
public partial class TestSceneStage : ManiaInputTestScene
|
2018-06-08 05:28:27 +00:00
|
|
|
|
{
|
2018-06-11 06:43:15 +00:00
|
|
|
|
private const int columns = 4;
|
|
|
|
|
|
2019-04-10 08:54:57 +00:00
|
|
|
|
[Cached(typeof(IReadOnlyList<Mod>))]
|
|
|
|
|
private IReadOnlyList<Mod> mods { get; set; } = Array.Empty<Mod>();
|
|
|
|
|
|
2020-04-08 05:08:34 +00:00
|
|
|
|
private readonly List<Stage> stages = new List<Stage>();
|
2018-06-11 06:43:15 +00:00
|
|
|
|
|
2018-08-08 03:21:44 +00:00
|
|
|
|
private FillFlowContainer<ScrollingTestContainer> fill;
|
|
|
|
|
|
2019-05-14 19:37:25 +00:00
|
|
|
|
public TestSceneStage()
|
2018-06-11 06:43:15 +00:00
|
|
|
|
: base(columns)
|
2018-06-08 05:28:27 +00:00
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[BackgroundDependencyLoader]
|
|
|
|
|
private void load()
|
|
|
|
|
{
|
2018-08-08 03:21:44 +00:00
|
|
|
|
Child = fill = new FillFlowContainer<ScrollingTestContainer>
|
2018-06-08 05:28:27 +00:00
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
|
Origin = Anchor.Centre,
|
|
|
|
|
Spacing = new Vector2(20, 0),
|
|
|
|
|
Children = new[]
|
|
|
|
|
{
|
|
|
|
|
createStage(ScrollingDirection.Up, ManiaAction.Key1),
|
|
|
|
|
createStage(ScrollingDirection.Down, ManiaAction.Key3)
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
2018-06-11 06:43:15 +00:00
|
|
|
|
protected override void LoadComplete()
|
|
|
|
|
{
|
|
|
|
|
base.LoadComplete();
|
|
|
|
|
|
|
|
|
|
AddStep("note", createNote);
|
|
|
|
|
AddStep("hold note", createHoldNote);
|
2018-06-11 07:12:52 +00:00
|
|
|
|
AddStep("minor bar line", () => createBarLine(false));
|
|
|
|
|
AddStep("major bar line", () => createBarLine(true));
|
2018-08-08 03:21:44 +00:00
|
|
|
|
|
|
|
|
|
AddAssert("check note anchors", () => notesInStageAreAnchored(stages[0], Anchor.TopCentre));
|
|
|
|
|
AddAssert("check note anchors", () => notesInStageAreAnchored(stages[1], Anchor.BottomCentre));
|
2019-09-24 18:34:09 +00:00
|
|
|
|
AddAssert("check bar anchors", () => barsInStageAreAnchored(stages[0], Anchor.TopCentre));
|
|
|
|
|
AddAssert("check bar anchors", () => barsInStageAreAnchored(stages[1], Anchor.BottomCentre));
|
2018-08-08 03:21:44 +00:00
|
|
|
|
|
|
|
|
|
AddStep("flip direction", () =>
|
|
|
|
|
{
|
|
|
|
|
foreach (var c in fill.Children)
|
|
|
|
|
c.Flip();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
AddAssert("check note anchors", () => notesInStageAreAnchored(stages[0], Anchor.BottomCentre));
|
|
|
|
|
AddAssert("check note anchors", () => notesInStageAreAnchored(stages[1], Anchor.TopCentre));
|
2019-09-24 18:34:09 +00:00
|
|
|
|
AddAssert("check bar anchors", () => barsInStageAreAnchored(stages[0], Anchor.BottomCentre));
|
|
|
|
|
AddAssert("check bar anchors", () => barsInStageAreAnchored(stages[1], Anchor.TopCentre));
|
2018-06-11 06:43:15 +00:00
|
|
|
|
}
|
|
|
|
|
|
2020-04-08 05:08:34 +00:00
|
|
|
|
private bool notesInStageAreAnchored(Stage stage, Anchor anchor) => stage.Columns.SelectMany(c => c.AllHitObjects).All(o => o.Anchor == anchor);
|
2018-08-08 03:21:44 +00:00
|
|
|
|
|
2020-04-08 05:08:34 +00:00
|
|
|
|
private bool barsInStageAreAnchored(Stage stage, Anchor anchor) => stage.AllHitObjects.Where(obj => obj is DrawableBarLine).All(o => o.Anchor == anchor);
|
2019-09-24 18:34:09 +00:00
|
|
|
|
|
2018-06-11 06:43:15 +00:00
|
|
|
|
private void createNote()
|
|
|
|
|
{
|
|
|
|
|
foreach (var stage in stages)
|
|
|
|
|
{
|
2024-01-30 00:07:37 +00:00
|
|
|
|
for (int i = 0; i < stage.Columns.Length; i++)
|
2018-06-11 06:43:15 +00:00
|
|
|
|
{
|
|
|
|
|
var obj = new Note { Column = i, StartTime = Time.Current + 2000 };
|
|
|
|
|
obj.ApplyDefaults(new ControlPointInfo(), new BeatmapDifficulty());
|
|
|
|
|
|
2018-07-02 03:31:41 +00:00
|
|
|
|
stage.Add(new DrawableNote(obj));
|
2018-06-11 06:43:15 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void createHoldNote()
|
|
|
|
|
{
|
|
|
|
|
foreach (var stage in stages)
|
|
|
|
|
{
|
2024-01-30 00:07:37 +00:00
|
|
|
|
for (int i = 0; i < stage.Columns.Length; i++)
|
2018-06-11 06:43:15 +00:00
|
|
|
|
{
|
|
|
|
|
var obj = new HoldNote { Column = i, StartTime = Time.Current + 2000, Duration = 500 };
|
|
|
|
|
obj.ApplyDefaults(new ControlPointInfo(), new BeatmapDifficulty());
|
|
|
|
|
|
2018-07-02 03:31:41 +00:00
|
|
|
|
stage.Add(new DrawableHoldNote(obj));
|
2018-06-11 06:43:15 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2018-06-11 07:12:52 +00:00
|
|
|
|
private void createBarLine(bool major)
|
2018-06-11 06:43:15 +00:00
|
|
|
|
{
|
2023-08-15 04:34:02 +00:00
|
|
|
|
var obj = new BarLine
|
2018-06-11 06:43:15 +00:00
|
|
|
|
{
|
2023-08-15 04:34:02 +00:00
|
|
|
|
StartTime = Time.Current + 2000,
|
|
|
|
|
Major = major,
|
|
|
|
|
};
|
2018-06-11 07:12:52 +00:00
|
|
|
|
|
2023-08-15 04:34:02 +00:00
|
|
|
|
obj.ApplyDefaults(new ControlPointInfo(), new BeatmapDifficulty());
|
2018-06-11 06:43:15 +00:00
|
|
|
|
|
2023-08-15 04:34:02 +00:00
|
|
|
|
foreach (var stage in stages)
|
2018-06-11 06:43:15 +00:00
|
|
|
|
stage.Add(obj);
|
|
|
|
|
}
|
|
|
|
|
|
2018-08-08 03:21:44 +00:00
|
|
|
|
private ScrollingTestContainer createStage(ScrollingDirection direction, ManiaAction action)
|
2018-06-08 05:28:27 +00:00
|
|
|
|
{
|
2024-08-07 21:36:04 +00:00
|
|
|
|
var stage = new Stage(0, new StageDefinition(2), ref action);
|
2018-06-11 06:43:15 +00:00
|
|
|
|
stages.Add(stage);
|
|
|
|
|
|
2018-06-08 12:41:20 +00:00
|
|
|
|
return new ScrollingTestContainer(direction)
|
2018-06-08 11:13:24 +00:00
|
|
|
|
{
|
|
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
|
Origin = Anchor.Centre,
|
|
|
|
|
RelativeSizeAxes = Axes.Y,
|
|
|
|
|
AutoSizeAxes = Axes.X,
|
2018-11-07 08:24:05 +00:00
|
|
|
|
TimeRange = 2000,
|
2018-06-11 06:43:15 +00:00
|
|
|
|
Child = stage
|
2018-06-08 11:13:24 +00:00
|
|
|
|
};
|
2018-06-08 05:28:27 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|