2017-05-01 16:00:41 +08:00
|
|
|
|
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
|
|
|
|
|
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
|
|
|
|
|
2017-05-03 11:58:46 +08:00
|
|
|
|
using osu.Framework.Input;
|
|
|
|
|
using osu.Framework.Testing;
|
|
|
|
|
using osu.Framework.Graphics;
|
2017-05-03 11:37:47 +08:00
|
|
|
|
using osu.Game.Rulesets.Mania.UI;
|
2017-05-04 14:12:32 +08:00
|
|
|
|
using System;
|
2017-05-11 11:33:19 +08:00
|
|
|
|
using System.Collections.Generic;
|
2017-05-16 17:02:54 +08:00
|
|
|
|
using OpenTK;
|
2017-05-16 17:27:33 +08:00
|
|
|
|
using osu.Game.Rulesets.Mania.Objects.Drawables;
|
|
|
|
|
using osu.Game.Rulesets.Mania.Objects;
|
2017-05-23 12:55:18 +08:00
|
|
|
|
using osu.Game.Rulesets.Mania.Timing;
|
2017-05-24 19:45:01 +08:00
|
|
|
|
using osu.Framework.Configuration;
|
|
|
|
|
using OpenTK.Input;
|
|
|
|
|
using osu.Framework.Timing;
|
2017-05-01 16:00:41 +08:00
|
|
|
|
|
|
|
|
|
namespace osu.Desktop.VisualTests.Tests
|
|
|
|
|
{
|
|
|
|
|
internal class TestCaseManiaPlayfield : TestCase
|
|
|
|
|
{
|
|
|
|
|
public override string Description => @"Mania playfield";
|
|
|
|
|
|
2017-05-03 11:30:03 +08:00
|
|
|
|
protected override double TimePerAction => 200;
|
2017-05-01 16:24:35 +08:00
|
|
|
|
|
2017-05-01 16:00:41 +08:00
|
|
|
|
public override void Reset()
|
|
|
|
|
{
|
|
|
|
|
base.Reset();
|
|
|
|
|
|
2017-05-04 14:12:32 +08:00
|
|
|
|
Action<int, SpecialColumnPosition> createPlayfield = (cols, pos) =>
|
|
|
|
|
{
|
|
|
|
|
Clear();
|
2017-05-23 12:55:18 +08:00
|
|
|
|
Add(new ManiaPlayfield(cols, new List<TimingChange>())
|
2017-05-04 14:12:32 +08:00
|
|
|
|
{
|
|
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
|
Origin = Anchor.Centre,
|
2017-05-16 17:02:54 +08:00
|
|
|
|
SpecialColumnPosition = pos,
|
|
|
|
|
Scale = new Vector2(1, -1)
|
2017-05-04 14:12:32 +08:00
|
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
|
2017-05-16 17:27:33 +08:00
|
|
|
|
Action<int, SpecialColumnPosition> createPlayfieldWithNotes = (cols, pos) =>
|
2017-05-01 16:00:41 +08:00
|
|
|
|
{
|
2017-05-16 17:27:33 +08:00
|
|
|
|
Clear();
|
2017-05-03 11:30:03 +08:00
|
|
|
|
|
2017-05-16 17:27:33 +08:00
|
|
|
|
ManiaPlayfield playField;
|
2017-05-23 17:06:31 +08:00
|
|
|
|
Add(playField = new ManiaPlayfield(cols, new List<TimingChange> { new TimingChange { BeatLength = 200 } })
|
2017-05-16 17:27:33 +08:00
|
|
|
|
{
|
|
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
|
Origin = Anchor.Centre,
|
|
|
|
|
SpecialColumnPosition = pos,
|
|
|
|
|
Scale = new Vector2(1, -1)
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < cols; i++)
|
|
|
|
|
{
|
|
|
|
|
playField.Add(new DrawableNote(new Note
|
|
|
|
|
{
|
|
|
|
|
StartTime = Time.Current + 1000,
|
|
|
|
|
Column = i
|
|
|
|
|
}));
|
|
|
|
|
}
|
|
|
|
|
};
|
2017-05-03 11:30:03 +08:00
|
|
|
|
|
2017-05-24 19:45:01 +08:00
|
|
|
|
Action createPlayfieldWithNotesAcceptingInput = () =>
|
|
|
|
|
{
|
|
|
|
|
Clear();
|
|
|
|
|
|
|
|
|
|
var rateAdjustClock = new StopwatchClock(true) { Rate = 0.2 };
|
|
|
|
|
|
|
|
|
|
ManiaPlayfield playField;
|
|
|
|
|
Add(playField = new ManiaPlayfield(4, new List<TimingChange> { new TimingChange { BeatLength = 200 } })
|
|
|
|
|
{
|
|
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
|
Origin = Anchor.Centre,
|
|
|
|
|
Scale = new Vector2(1, -1),
|
|
|
|
|
Clock = new FramedClock(rateAdjustClock)
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
playField.Add(new DrawableNote(new Note
|
|
|
|
|
{
|
|
|
|
|
StartTime = 1000,
|
|
|
|
|
Column = 0
|
|
|
|
|
}, new Bindable<Key>(Key.D)));
|
|
|
|
|
|
|
|
|
|
playField.Add(new DrawableHoldNote(new HoldNote
|
|
|
|
|
{
|
|
|
|
|
StartTime = 1000,
|
|
|
|
|
Duration = 2000,
|
|
|
|
|
Column = 1
|
|
|
|
|
}, new Bindable<Key>(Key.F)));
|
|
|
|
|
|
|
|
|
|
playField.Add(new DrawableHoldNote(new HoldNote
|
|
|
|
|
{
|
|
|
|
|
StartTime = 1000,
|
|
|
|
|
Duration = 2000,
|
|
|
|
|
Column = 2
|
|
|
|
|
}, new Bindable<Key>(Key.J)));
|
|
|
|
|
|
|
|
|
|
playField.Add(new DrawableNote(new Note
|
|
|
|
|
{
|
|
|
|
|
StartTime = 1000,
|
|
|
|
|
Column = 3
|
|
|
|
|
}, new Bindable<Key>(Key.K)));
|
|
|
|
|
};
|
|
|
|
|
|
2017-05-16 17:27:33 +08:00
|
|
|
|
AddStep("1 column", () => createPlayfield(1, SpecialColumnPosition.Normal));
|
|
|
|
|
AddStep("4 columns", () => createPlayfield(4, SpecialColumnPosition.Normal));
|
|
|
|
|
AddStep("Left special style", () => createPlayfield(4, SpecialColumnPosition.Left));
|
|
|
|
|
AddStep("Right special style", () => createPlayfield(4, SpecialColumnPosition.Right));
|
|
|
|
|
AddStep("5 columns", () => createPlayfield(5, SpecialColumnPosition.Normal));
|
|
|
|
|
AddStep("8 columns", () => createPlayfield(8, SpecialColumnPosition.Normal));
|
|
|
|
|
AddStep("Left special style", () => createPlayfield(8, SpecialColumnPosition.Left));
|
|
|
|
|
AddStep("Right special style", () => createPlayfield(8, SpecialColumnPosition.Right));
|
2017-05-04 14:12:32 +08:00
|
|
|
|
|
2017-05-16 17:27:33 +08:00
|
|
|
|
AddStep("Normal special style", () => createPlayfield(4, SpecialColumnPosition.Normal));
|
2017-05-03 18:38:27 +08:00
|
|
|
|
|
2017-05-16 17:27:33 +08:00
|
|
|
|
AddStep("Notes", () => createPlayfieldWithNotes(4, SpecialColumnPosition.Normal));
|
|
|
|
|
AddWaitStep(10);
|
|
|
|
|
AddStep("Left special style", () => createPlayfieldWithNotes(4, SpecialColumnPosition.Left));
|
|
|
|
|
AddWaitStep(10);
|
|
|
|
|
AddStep("Right special style", () => createPlayfieldWithNotes(4, SpecialColumnPosition.Right));
|
|
|
|
|
AddWaitStep(10);
|
2017-05-24 19:45:01 +08:00
|
|
|
|
|
|
|
|
|
AddStep("Test", () => createPlayfieldWithNotesAcceptingInput());
|
2017-05-03 11:30:03 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void triggerKeyDown(Column column)
|
|
|
|
|
{
|
|
|
|
|
column.TriggerKeyDown(new InputState(), new KeyDownEventArgs
|
|
|
|
|
{
|
|
|
|
|
Key = column.Key,
|
|
|
|
|
Repeat = false
|
2017-05-01 16:00:41 +08:00
|
|
|
|
});
|
2017-05-03 11:30:03 +08:00
|
|
|
|
}
|
2017-05-01 16:24:35 +08:00
|
|
|
|
|
2017-05-03 11:30:03 +08:00
|
|
|
|
private void triggerKeyUp(Column column)
|
|
|
|
|
{
|
|
|
|
|
column.TriggerKeyUp(new InputState(), new KeyUpEventArgs
|
2017-05-01 16:24:35 +08:00
|
|
|
|
{
|
2017-05-03 11:30:03 +08:00
|
|
|
|
Key = column.Key
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
2017-05-01 16:00:41 +08:00
|
|
|
|
}
|