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-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-24 19:45:01 +08:00
|
|
|
|
using osu.Framework.Configuration;
|
|
|
|
|
using OpenTK.Input;
|
|
|
|
|
using osu.Framework.Timing;
|
2017-06-01 13:26:21 +08:00
|
|
|
|
using osu.Framework.Extensions.IEnumerableExtensions;
|
2017-06-01 14:13:52 +08:00
|
|
|
|
using osu.Game.Rulesets.Mania.Timing.Drawables;
|
2017-06-02 10:35:51 +08:00
|
|
|
|
using System.Linq;
|
2017-06-02 19:17:44 +08:00
|
|
|
|
using osu.Game.Rulesets.Timing;
|
|
|
|
|
using osu.Game.Rulesets.Timing.Drawables;
|
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-06-01 13:26:21 +08:00
|
|
|
|
Add(new ManiaPlayfield(cols)
|
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-06-02 17:02:05 +08:00
|
|
|
|
const double start_time = 500;
|
2017-06-02 17:11:06 +08:00
|
|
|
|
const double duration = 500;
|
2017-06-01 13:26:21 +08:00
|
|
|
|
|
2017-06-08 22:40:24 +08:00
|
|
|
|
Func<double, bool, DrawableTimingSection> createTimingChange = (time, gravity) =>
|
2017-06-02 17:02:05 +08:00
|
|
|
|
{
|
|
|
|
|
if (gravity)
|
2017-05-16 17:27:33 +08:00
|
|
|
|
{
|
2017-06-08 22:40:24 +08:00
|
|
|
|
return new DrawableManiaGravityTimingChange(new TimingSection
|
2017-05-16 17:27:33 +08:00
|
|
|
|
{
|
2017-06-02 17:02:05 +08:00
|
|
|
|
BeatLength = 1000,
|
|
|
|
|
Time = time
|
|
|
|
|
});
|
2017-05-16 17:27:33 +08:00
|
|
|
|
}
|
2017-06-02 17:02:05 +08:00
|
|
|
|
|
2017-06-08 22:40:24 +08:00
|
|
|
|
return new DrawableManiaScrollingTimingChange(new TimingSection
|
2017-06-02 17:02:05 +08:00
|
|
|
|
{
|
|
|
|
|
BeatLength = 1000,
|
|
|
|
|
Time = time
|
|
|
|
|
});
|
2017-05-16 17:27:33 +08:00
|
|
|
|
};
|
2017-05-03 11:30:03 +08:00
|
|
|
|
|
2017-06-07 18:20:01 +08:00
|
|
|
|
Action<bool> createPlayfieldWithNotes = gravity =>
|
2017-05-24 19:45:01 +08:00
|
|
|
|
{
|
|
|
|
|
Clear();
|
|
|
|
|
|
2017-06-02 17:11:06 +08:00
|
|
|
|
var rateAdjustClock = new StopwatchClock(true) { Rate = 1 };
|
2017-05-24 19:45:01 +08:00
|
|
|
|
|
|
|
|
|
ManiaPlayfield playField;
|
2017-06-01 13:26:21 +08:00
|
|
|
|
Add(playField = new ManiaPlayfield(4)
|
2017-05-24 19:45:01 +08:00
|
|
|
|
{
|
|
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
|
Origin = Anchor.Centre,
|
|
|
|
|
Scale = new Vector2(1, -1),
|
|
|
|
|
Clock = new FramedClock(rateAdjustClock)
|
|
|
|
|
});
|
|
|
|
|
|
2017-06-07 18:20:01 +08:00
|
|
|
|
if (!gravity)
|
2017-06-02 17:02:05 +08:00
|
|
|
|
playField.Columns.ForEach(c => c.Add(createTimingChange(0, false)));
|
|
|
|
|
|
|
|
|
|
for (double t = start_time; t <= start_time + duration; t += 100)
|
2017-05-24 19:45:01 +08:00
|
|
|
|
{
|
2017-06-07 18:20:01 +08:00
|
|
|
|
if (gravity)
|
2017-06-02 17:02:05 +08:00
|
|
|
|
playField.Columns.ElementAt(0).Add(createTimingChange(t, true));
|
2017-06-02 10:35:51 +08:00
|
|
|
|
|
2017-05-24 19:54:01 +08:00
|
|
|
|
playField.Add(new DrawableNote(new Note
|
|
|
|
|
{
|
|
|
|
|
StartTime = t,
|
|
|
|
|
Column = 0
|
2017-05-24 20:57:38 +08:00
|
|
|
|
}, new Bindable<Key>(Key.D)));
|
2017-05-24 19:54:01 +08:00
|
|
|
|
|
2017-06-07 18:20:01 +08:00
|
|
|
|
if (gravity)
|
2017-06-02 17:02:05 +08:00
|
|
|
|
playField.Columns.ElementAt(3).Add(createTimingChange(t, true));
|
2017-06-02 10:35:51 +08:00
|
|
|
|
|
2017-05-24 19:54:01 +08:00
|
|
|
|
playField.Add(new DrawableNote(new Note
|
|
|
|
|
{
|
|
|
|
|
StartTime = t,
|
|
|
|
|
Column = 3
|
|
|
|
|
}, new Bindable<Key>(Key.K)));
|
|
|
|
|
}
|
2017-05-24 19:45:01 +08:00
|
|
|
|
|
2017-06-07 18:20:01 +08:00
|
|
|
|
if (gravity)
|
2017-06-02 17:02:05 +08:00
|
|
|
|
playField.Columns.ElementAt(1).Add(createTimingChange(start_time, true));
|
2017-06-02 10:35:51 +08:00
|
|
|
|
|
2017-05-24 19:45:01 +08:00
|
|
|
|
playField.Add(new DrawableHoldNote(new HoldNote
|
|
|
|
|
{
|
2017-06-02 17:02:05 +08:00
|
|
|
|
StartTime = start_time,
|
|
|
|
|
Duration = duration,
|
2017-05-24 19:45:01 +08:00
|
|
|
|
Column = 1
|
|
|
|
|
}, new Bindable<Key>(Key.F)));
|
|
|
|
|
|
2017-06-07 18:20:01 +08:00
|
|
|
|
if (gravity)
|
2017-06-02 17:02:05 +08:00
|
|
|
|
playField.Columns.ElementAt(2).Add(createTimingChange(start_time, true));
|
2017-06-02 10:35:51 +08:00
|
|
|
|
|
2017-05-24 19:45:01 +08:00
|
|
|
|
playField.Add(new DrawableHoldNote(new HoldNote
|
|
|
|
|
{
|
2017-06-02 17:02:05 +08:00
|
|
|
|
StartTime = start_time,
|
|
|
|
|
Duration = duration,
|
2017-05-24 19:45:01 +08:00
|
|
|
|
Column = 2
|
|
|
|
|
}, new Bindable<Key>(Key.J)));
|
|
|
|
|
};
|
|
|
|
|
|
2017-06-02 17:02:05 +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));
|
|
|
|
|
|
|
|
|
|
AddStep("Notes with input", () => createPlayfieldWithNotes(false));
|
2017-06-02 17:11:06 +08:00
|
|
|
|
AddWaitStep((int)Math.Ceiling((start_time + duration) / TimePerAction));
|
2017-06-02 17:02:05 +08:00
|
|
|
|
|
|
|
|
|
AddStep("Notes with gravity", () => createPlayfieldWithNotes(true));
|
2017-06-02 17:11:06 +08:00
|
|
|
|
AddWaitStep((int)Math.Ceiling((start_time + duration) / TimePerAction));
|
2017-05-03 11:30:03 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void triggerKeyDown(Column column)
|
|
|
|
|
{
|
2017-05-28 17:34:12 +08:00
|
|
|
|
column.TriggerOnKeyDown(new InputState(), new KeyDownEventArgs
|
2017-05-03 11:30:03 +08:00
|
|
|
|
{
|
|
|
|
|
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)
|
|
|
|
|
{
|
2017-05-28 17:34:12 +08:00
|
|
|
|
column.TriggerOnKeyUp(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
|
|
|
|
}
|