2021-04-27 11:02:57 +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.
|
|
|
|
|
|
2022-06-17 07:37:17 +00:00
|
|
|
|
#nullable disable
|
|
|
|
|
|
2021-09-12 15:48:08 +00:00
|
|
|
|
using System.Linq;
|
2021-04-27 11:02:57 +00:00
|
|
|
|
using NUnit.Framework;
|
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
|
using osu.Framework.Graphics.Containers;
|
|
|
|
|
using osu.Game.Beatmaps;
|
|
|
|
|
using osu.Game.Beatmaps.ControlPoints;
|
|
|
|
|
using osu.Game.Tests.Visual;
|
|
|
|
|
using osu.Framework.Timing;
|
|
|
|
|
using osu.Game.Rulesets.Mania.Objects;
|
|
|
|
|
using osu.Game.Rulesets.Mania.Beatmaps;
|
|
|
|
|
using osu.Game.Rulesets.Mania.Configuration;
|
|
|
|
|
using osu.Framework.Bindables;
|
2021-12-23 18:02:10 +00:00
|
|
|
|
using osu.Framework.Extensions.ObjectExtensions;
|
2021-09-12 15:41:50 +00:00
|
|
|
|
using osu.Framework.Testing;
|
2021-09-12 15:48:08 +00:00
|
|
|
|
using osu.Framework.Utils;
|
|
|
|
|
using osu.Game.Rulesets.Mania.Objects.Drawables;
|
|
|
|
|
using osu.Game.Rulesets.Mania.UI;
|
2021-04-27 11:02:57 +00:00
|
|
|
|
|
|
|
|
|
namespace osu.Game.Rulesets.Mania.Tests
|
|
|
|
|
{
|
|
|
|
|
[TestFixture]
|
2022-11-24 05:32:20 +00:00
|
|
|
|
public partial class TestSceneTimingBasedNoteColouring : OsuTestScene
|
2021-04-27 11:02:57 +00:00
|
|
|
|
{
|
2021-09-12 15:41:50 +00:00
|
|
|
|
private Bindable<bool> configTimingBasedNoteColouring;
|
2021-04-27 11:02:57 +00:00
|
|
|
|
|
2021-09-12 15:41:50 +00:00
|
|
|
|
private ManualClock clock;
|
2021-09-12 15:48:08 +00:00
|
|
|
|
private DrawableManiaRuleset drawableRuleset;
|
2021-09-12 15:41:50 +00:00
|
|
|
|
|
|
|
|
|
[SetUpSteps]
|
|
|
|
|
public void SetUpSteps()
|
2021-04-27 11:02:57 +00:00
|
|
|
|
{
|
2021-09-12 15:41:50 +00:00
|
|
|
|
AddStep("setup hierarchy", () => Child = new Container
|
|
|
|
|
{
|
|
|
|
|
Clock = new FramedClock(clock = new ManualClock()),
|
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
|
Origin = Anchor.Centre,
|
|
|
|
|
Children = new[]
|
|
|
|
|
{
|
2021-09-12 15:48:08 +00:00
|
|
|
|
drawableRuleset = (DrawableManiaRuleset)Ruleset.Value.CreateInstance().CreateDrawableRulesetWith(createTestBeatmap())
|
2021-09-12 15:41:50 +00:00
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
AddStep("retrieve config bindable", () =>
|
|
|
|
|
{
|
2021-12-23 18:34:41 +00:00
|
|
|
|
var config = (ManiaRulesetConfigManager)RulesetConfigs.GetConfigFor(Ruleset.Value.CreateInstance()).AsNonNull();
|
2021-09-12 15:41:50 +00:00
|
|
|
|
configTimingBasedNoteColouring = config.GetBindable<bool>(ManiaRulesetSetting.TimingBasedNoteColouring);
|
|
|
|
|
});
|
|
|
|
|
}
|
2021-04-27 11:02:57 +00:00
|
|
|
|
|
2021-09-12 15:41:50 +00:00
|
|
|
|
[Test]
|
|
|
|
|
public void TestSimple()
|
|
|
|
|
{
|
|
|
|
|
AddStep("enable", () => configTimingBasedNoteColouring.Value = true);
|
|
|
|
|
AddStep("disable", () => configTimingBasedNoteColouring.Value = false);
|
|
|
|
|
}
|
|
|
|
|
|
2021-09-12 15:48:08 +00:00
|
|
|
|
[Test]
|
|
|
|
|
public void TestToggleOffScreen()
|
|
|
|
|
{
|
|
|
|
|
AddStep("enable", () => configTimingBasedNoteColouring.Value = true);
|
|
|
|
|
|
|
|
|
|
seekTo(10000);
|
|
|
|
|
AddStep("disable", () => configTimingBasedNoteColouring.Value = false);
|
|
|
|
|
seekTo(0);
|
|
|
|
|
AddAssert("all notes not coloured", () => this.ChildrenOfType<DrawableNote>().All(note => note.Colour == Colour4.White));
|
|
|
|
|
|
|
|
|
|
seekTo(10000);
|
|
|
|
|
AddStep("enable again", () => configTimingBasedNoteColouring.Value = true);
|
|
|
|
|
seekTo(0);
|
|
|
|
|
AddAssert("some notes coloured", () => this.ChildrenOfType<DrawableNote>().Any(note => note.Colour != Colour4.White));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void seekTo(double time)
|
|
|
|
|
{
|
|
|
|
|
AddStep($"seek to {time}", () => clock.CurrentTime = time);
|
|
|
|
|
AddUntilStep("wait for seek", () => Precision.AlmostEquals(drawableRuleset.FrameStableClock.CurrentTime, time, 1));
|
|
|
|
|
}
|
|
|
|
|
|
2021-09-12 15:41:50 +00:00
|
|
|
|
private ManiaBeatmap createTestBeatmap()
|
|
|
|
|
{
|
|
|
|
|
const double beat_length = 500;
|
2021-04-27 11:02:57 +00:00
|
|
|
|
|
2022-10-05 10:14:31 +00:00
|
|
|
|
var beatmap = new ManiaBeatmap(new StageDefinition(1))
|
2021-04-27 11:02:57 +00:00
|
|
|
|
{
|
2021-04-27 11:25:46 +00:00
|
|
|
|
HitObjects =
|
|
|
|
|
{
|
2021-04-27 11:02:57 +00:00
|
|
|
|
new Note { StartTime = 0 },
|
2021-04-27 11:25:46 +00:00
|
|
|
|
new Note { StartTime = beat_length / 16 },
|
|
|
|
|
new Note { StartTime = beat_length / 12 },
|
|
|
|
|
new Note { StartTime = beat_length / 8 },
|
|
|
|
|
new Note { StartTime = beat_length / 6 },
|
|
|
|
|
new Note { StartTime = beat_length / 4 },
|
|
|
|
|
new Note { StartTime = beat_length / 3 },
|
|
|
|
|
new Note { StartTime = beat_length / 2 },
|
|
|
|
|
new Note { StartTime = beat_length }
|
2021-04-27 11:02:57 +00:00
|
|
|
|
},
|
|
|
|
|
ControlPointInfo = new ControlPointInfo(),
|
2021-09-12 15:41:50 +00:00
|
|
|
|
BeatmapInfo = { Ruleset = Ruleset.Value },
|
2021-04-27 11:02:57 +00:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
foreach (var note in beatmap.HitObjects)
|
|
|
|
|
{
|
|
|
|
|
note.ApplyDefaults(new ControlPointInfo(), new BeatmapDifficulty());
|
|
|
|
|
}
|
|
|
|
|
|
2021-04-27 11:25:46 +00:00
|
|
|
|
beatmap.ControlPointInfo.Add(0, new TimingControlPoint
|
2021-05-01 07:00:18 +00:00
|
|
|
|
{
|
|
|
|
|
BeatLength = beat_length
|
|
|
|
|
});
|
2021-09-12 15:41:50 +00:00
|
|
|
|
return beatmap;
|
2021-04-27 11:02:57 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|