Add visual tests for timing based note coloring

This commit is contained in:
Justus Franklin Tumacder 2021-04-27 19:02:57 +08:00
parent 559d403abe
commit c4d28110d6
2 changed files with 89 additions and 1 deletions

View File

@ -0,0 +1,88 @@
// 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.
using NUnit.Framework;
using osu.Framework.Graphics;
using osu.Framework.Allocation;
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;
namespace osu.Game.Rulesets.Mania.Tests
{
[TestFixture]
public class TestSceneTimingBasedNoteColouring : OsuTestScene
{
[Resolved]
private RulesetConfigCache configCache { get; set; }
private readonly Bindable<bool> configTimingBasedNoteColouring = new Bindable<bool>();
protected override void LoadComplete()
{
const int beatLength = 500;
var ruleset = new ManiaRuleset();
var beatmap = new ManiaBeatmap(new StageDefinition { Columns = 1 })
{
HitObjects = {
new Note { StartTime = 0 },
new Note { StartTime = beatLength / 16 },
new Note { StartTime = beatLength / 12 },
new Note { StartTime = beatLength / 8 },
new Note { StartTime = beatLength / 6 },
new Note { StartTime = beatLength / 4 },
new Note { StartTime = beatLength / 3 },
new Note { StartTime = beatLength / 2 },
new Note { StartTime = beatLength }
},
ControlPointInfo = new ControlPointInfo(),
BeatmapInfo =
{
BaseDifficulty = new BeatmapDifficulty
{
SliderTickRate = 4,
OverallDifficulty = 10,
},
Ruleset = ruleset.RulesetInfo
},
};
foreach (var note in beatmap.HitObjects)
{
note.ApplyDefaults(new ControlPointInfo(), new BeatmapDifficulty());
}
beatmap.ControlPointInfo.Add(0, new TimingControlPoint()
{
TimeSignature = Game.Beatmaps.Timing.TimeSignatures.SimpleQuadruple,
BeatLength = beatLength
}
);
Child = new Container
{
Clock = new FramedClock(new ManualClock()),
RelativeSizeAxes = Axes.Both,
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Children = new[]
{
ruleset.CreateDrawableRulesetWith(beatmap)
}
};
var config = (ManiaRulesetConfigManager)configCache.GetConfigFor(Ruleset.Value.CreateInstance());
config.BindWith(ManiaRulesetSetting.TimingBasedNoteColouring, configTimingBasedNoteColouring);
AddStep("Enable", () => configTimingBasedNoteColouring.Value = true);
AddStep("Disable", () => configTimingBasedNoteColouring.Value = false);
}
}
}

View File

@ -26,7 +26,7 @@ public class DrawableNote : DrawableManiaHitObject<Note>, IKeyBindingHandler<Man
[Resolved]
private OsuColour colours { get; set; }
[Resolved]
[Resolved(canBeNull: true)]
private BeatDivisorFinder beatDivisorFinder { get; set; }
private readonly Bindable<bool> configTimingBasedNoteColouring = new Bindable<bool>();