From c4d28110d641c9d121d88e4559c783cfc2094218 Mon Sep 17 00:00:00 2001 From: Justus Franklin Tumacder Date: Tue, 27 Apr 2021 19:02:57 +0800 Subject: [PATCH] Add visual tests for timing based note coloring --- .../TestSceneTimingBasedNoteColouring.cs | 88 +++++++++++++++++++ .../Objects/Drawables/DrawableNote.cs | 2 +- 2 files changed, 89 insertions(+), 1 deletion(-) create mode 100644 osu.Game.Rulesets.Mania.Tests/TestSceneTimingBasedNoteColouring.cs diff --git a/osu.Game.Rulesets.Mania.Tests/TestSceneTimingBasedNoteColouring.cs b/osu.Game.Rulesets.Mania.Tests/TestSceneTimingBasedNoteColouring.cs new file mode 100644 index 0000000000..3a9ddb6a9d --- /dev/null +++ b/osu.Game.Rulesets.Mania.Tests/TestSceneTimingBasedNoteColouring.cs @@ -0,0 +1,88 @@ +// Copyright (c) ppy Pty Ltd . 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 configTimingBasedNoteColouring = new Bindable(); + + 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); + } + } +} diff --git a/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableNote.cs b/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableNote.cs index 102cd485dc..942a32936c 100644 --- a/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableNote.cs +++ b/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableNote.cs @@ -26,7 +26,7 @@ namespace osu.Game.Rulesets.Mania.Objects.Drawables [Resolved] private OsuColour colours { get; set; } - [Resolved] + [Resolved(canBeNull: true)] private BeatDivisorFinder beatDivisorFinder { get; set; } private readonly Bindable configTimingBasedNoteColouring = new Bindable();