Add mania stage test case

This commit is contained in:
smoogipoo 2018-06-08 14:28:27 +09:00
parent 32037701bf
commit ee64760406
5 changed files with 54 additions and 8 deletions

View File

@ -0,0 +1,46 @@
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using NUnit.Framework;
using osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Game.Rulesets.Mania.Beatmaps;
using osu.Game.Rulesets.Mania.UI;
using osu.Game.Rulesets.UI.Scrolling;
using OpenTK;
namespace osu.Game.Rulesets.Mania.Tests
{
[TestFixture]
public class TestCaseStage : ManiaInputTestCase
{
public TestCaseStage()
: base(4)
{
}
[BackgroundDependencyLoader]
private void load()
{
Child = new FillFlowContainer
{
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)
}
};
}
private ManiaStage createStage(ScrollingDirection direction, ManiaAction action)
{
var specialAction = ManiaAction.Special1;
return new ManiaStage(direction, 0, new StageDefinition { Columns = 2 }, ref action, ref specialAction);
}
}
}

View File

@ -44,7 +44,7 @@ public ManiaAction Action
protected override Container<Drawable> Content => hitObjectArea;
public Column(ScrollingDirection direction = ScrollingDirection.Up)
public Column(ScrollingDirection direction)
: base(direction)
{
RelativeSizeAxes = Axes.Y;

View File

@ -21,8 +21,8 @@ public class ManiaPlayfield : ScrollingPlayfield
public List<Column> Columns => stages.SelectMany(x => x.Columns).ToList();
private readonly List<ManiaStage> stages = new List<ManiaStage>();
public ManiaPlayfield(List<StageDefinition> stageDefinitions)
: base(ScrollingDirection.Up)
public ManiaPlayfield(ScrollingDirection direction, List<StageDefinition> stageDefinitions)
: base(direction)
{
if (stageDefinitions == null)
throw new ArgumentNullException(nameof(stageDefinitions));
@ -42,7 +42,7 @@ public ManiaPlayfield(List<StageDefinition> stageDefinitions)
int firstColumnIndex = 0;
for (int i = 0; i < stageDefinitions.Count; i++)
{
var newStage = new ManiaStage(firstColumnIndex, stageDefinitions[i], ref normalColumnAction, ref specialColumnAction);
var newStage = new ManiaStage(direction, firstColumnIndex, stageDefinitions[i], ref normalColumnAction, ref specialColumnAction);
newStage.VisibleTimeRange.BindTo(VisibleTimeRange);
playfieldGrid.Content[0][i] = newStage;

View File

@ -73,7 +73,7 @@ private void load()
BarLines.ForEach(Playfield.Add);
}
protected sealed override Playfield CreatePlayfield() => new ManiaPlayfield(Beatmap.Stages)
protected sealed override Playfield CreatePlayfield() => new ManiaPlayfield(ScrollingDirection.Up, Beatmap.Stages)
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,

View File

@ -43,8 +43,8 @@ internal class ManiaStage : ScrollingPlayfield
private readonly int firstColumnIndex;
public ManiaStage(int firstColumnIndex, StageDefinition definition, ref ManiaAction normalColumnStartAction, ref ManiaAction specialColumnStartAction)
: base(ScrollingDirection.Up)
public ManiaStage(ScrollingDirection direction, int firstColumnIndex, StageDefinition definition, ref ManiaAction normalColumnStartAction, ref ManiaAction specialColumnStartAction)
: base(direction)
{
this.firstColumnIndex = firstColumnIndex;
@ -125,7 +125,7 @@ public ManiaStage(int firstColumnIndex, StageDefinition definition, ref ManiaAct
for (int i = 0; i < definition.Columns; i++)
{
var isSpecial = definition.IsSpecialColumn(i);
var column = new Column
var column = new Column(direction)
{
IsSpecial = isSpecial,
Action = isSpecial ? specialColumnStartAction++ : normalColumnStartAction++