2018-06-08 13:28:27 +08:00
|
|
|
|
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
|
|
|
|
|
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
|
|
|
|
|
2018-06-11 14:43:15 +08:00
|
|
|
|
using System.Collections.Generic;
|
2018-08-08 11:21:44 +08:00
|
|
|
|
using System.Linq;
|
2018-06-08 13:28:27 +08:00
|
|
|
|
using NUnit.Framework;
|
|
|
|
|
using osu.Framework.Allocation;
|
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
|
using osu.Framework.Graphics.Containers;
|
2018-06-11 14:43:15 +08:00
|
|
|
|
using osu.Game.Beatmaps;
|
|
|
|
|
using osu.Game.Beatmaps.ControlPoints;
|
2018-06-08 13:28:27 +08:00
|
|
|
|
using osu.Game.Rulesets.Mania.Beatmaps;
|
2018-06-11 14:43:15 +08:00
|
|
|
|
using osu.Game.Rulesets.Mania.Objects;
|
|
|
|
|
using osu.Game.Rulesets.Mania.Objects.Drawables;
|
2018-06-08 13:28:27 +08:00
|
|
|
|
using osu.Game.Rulesets.Mania.UI;
|
|
|
|
|
using osu.Game.Rulesets.UI.Scrolling;
|
2018-11-06 14:46:36 +08:00
|
|
|
|
using osu.Game.Tests.Visual;
|
2018-11-20 15:51:59 +08:00
|
|
|
|
using osuTK;
|
2018-06-08 13:28:27 +08:00
|
|
|
|
|
|
|
|
|
namespace osu.Game.Rulesets.Mania.Tests
|
|
|
|
|
{
|
|
|
|
|
[TestFixture]
|
|
|
|
|
public class TestCaseStage : ManiaInputTestCase
|
|
|
|
|
{
|
2018-06-11 14:43:15 +08:00
|
|
|
|
private const int columns = 4;
|
|
|
|
|
|
|
|
|
|
private readonly List<ManiaStage> stages = new List<ManiaStage>();
|
|
|
|
|
|
2018-08-08 11:21:44 +08:00
|
|
|
|
private FillFlowContainer<ScrollingTestContainer> fill;
|
|
|
|
|
|
2018-06-08 13:28:27 +08:00
|
|
|
|
public TestCaseStage()
|
2018-06-11 14:43:15 +08:00
|
|
|
|
: base(columns)
|
2018-06-08 13:28:27 +08:00
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[BackgroundDependencyLoader]
|
|
|
|
|
private void load()
|
|
|
|
|
{
|
2018-08-08 11:21:44 +08:00
|
|
|
|
Child = fill = new FillFlowContainer<ScrollingTestContainer>
|
2018-06-08 13:28:27 +08: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 14:43:15 +08:00
|
|
|
|
protected override void LoadComplete()
|
|
|
|
|
{
|
|
|
|
|
base.LoadComplete();
|
|
|
|
|
|
|
|
|
|
AddStep("note", createNote);
|
|
|
|
|
AddStep("hold note", createHoldNote);
|
2018-06-11 15:12:52 +08:00
|
|
|
|
AddStep("minor bar line", () => createBarLine(false));
|
|
|
|
|
AddStep("major bar line", () => createBarLine(true));
|
2018-08-08 11:21:44 +08:00
|
|
|
|
|
|
|
|
|
AddAssert("check note anchors", () => notesInStageAreAnchored(stages[0], Anchor.TopCentre));
|
|
|
|
|
AddAssert("check note anchors", () => notesInStageAreAnchored(stages[1], Anchor.BottomCentre));
|
|
|
|
|
|
|
|
|
|
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));
|
2018-06-11 14:43:15 +08:00
|
|
|
|
}
|
|
|
|
|
|
2018-08-08 11:21:44 +08:00
|
|
|
|
private bool notesInStageAreAnchored(ManiaStage stage, Anchor anchor) => stage.Columns.SelectMany(c => c.AllHitObjects).All(o => o.Anchor == anchor);
|
|
|
|
|
|
2018-06-11 14:43:15 +08:00
|
|
|
|
private void createNote()
|
|
|
|
|
{
|
|
|
|
|
foreach (var stage in stages)
|
|
|
|
|
{
|
|
|
|
|
for (int i = 0; i < stage.Columns.Count; i++)
|
|
|
|
|
{
|
|
|
|
|
var obj = new Note { Column = i, StartTime = Time.Current + 2000 };
|
|
|
|
|
obj.ApplyDefaults(new ControlPointInfo(), new BeatmapDifficulty());
|
|
|
|
|
|
2018-07-02 11:31:41 +08:00
|
|
|
|
stage.Add(new DrawableNote(obj));
|
2018-06-11 14:43:15 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void createHoldNote()
|
|
|
|
|
{
|
|
|
|
|
foreach (var stage in stages)
|
|
|
|
|
{
|
|
|
|
|
for (int i = 0; i < stage.Columns.Count; i++)
|
|
|
|
|
{
|
|
|
|
|
var obj = new HoldNote { Column = i, StartTime = Time.Current + 2000, Duration = 500 };
|
|
|
|
|
obj.ApplyDefaults(new ControlPointInfo(), new BeatmapDifficulty());
|
|
|
|
|
|
2018-07-02 11:31:41 +08:00
|
|
|
|
stage.Add(new DrawableHoldNote(obj));
|
2018-06-11 14:43:15 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2018-06-11 15:12:52 +08:00
|
|
|
|
private void createBarLine(bool major)
|
2018-06-11 14:43:15 +08:00
|
|
|
|
{
|
|
|
|
|
foreach (var stage in stages)
|
|
|
|
|
{
|
2018-06-11 15:12:52 +08:00
|
|
|
|
var obj = new BarLine
|
|
|
|
|
{
|
|
|
|
|
StartTime = Time.Current + 2000,
|
|
|
|
|
ControlPoint = new TimingControlPoint(),
|
|
|
|
|
BeatIndex = major ? 0 : 1
|
|
|
|
|
};
|
|
|
|
|
|
2018-06-11 14:43:15 +08:00
|
|
|
|
obj.ApplyDefaults(new ControlPointInfo(), new BeatmapDifficulty());
|
|
|
|
|
|
|
|
|
|
stage.Add(obj);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2018-08-08 11:21:44 +08:00
|
|
|
|
private ScrollingTestContainer createStage(ScrollingDirection direction, ManiaAction action)
|
2018-06-08 13:28:27 +08:00
|
|
|
|
{
|
|
|
|
|
var specialAction = ManiaAction.Special1;
|
2018-06-08 19:13:24 +08:00
|
|
|
|
|
2018-11-07 16:24:05 +08:00
|
|
|
|
var stage = new ManiaStage(0, new StageDefinition { Columns = 2 }, ref action, ref specialAction);
|
2018-06-11 14:43:15 +08:00
|
|
|
|
stages.Add(stage);
|
|
|
|
|
|
2018-06-08 20:41:20 +08:00
|
|
|
|
return new ScrollingTestContainer(direction)
|
2018-06-08 19:13:24 +08:00
|
|
|
|
{
|
|
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
|
Origin = Anchor.Centre,
|
|
|
|
|
RelativeSizeAxes = Axes.Y,
|
|
|
|
|
AutoSizeAxes = Axes.X,
|
2018-11-07 16:24:05 +08:00
|
|
|
|
TimeRange = 2000,
|
2018-06-11 14:43:15 +08:00
|
|
|
|
Child = stage
|
2018-06-08 19:13:24 +08:00
|
|
|
|
};
|
2018-06-08 13:28:27 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|