diff --git a/osu.Game.Rulesets.Mania.Tests/Editor/ManiaPlacementBlueprintTestScene.cs b/osu.Game.Rulesets.Mania.Tests/Editor/ManiaPlacementBlueprintTestScene.cs index ece523e84c..8e94d6bbb6 100644 --- a/osu.Game.Rulesets.Mania.Tests/Editor/ManiaPlacementBlueprintTestScene.cs +++ b/osu.Game.Rulesets.Mania.Tests/Editor/ManiaPlacementBlueprintTestScene.cs @@ -4,10 +4,12 @@ using System; using System.Collections.Generic; using osu.Framework.Allocation; +using osu.Framework.Bindables; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Timing; using osu.Game.Rulesets.Edit; +using osu.Game.Rulesets.Mania.Configuration; using osu.Game.Rulesets.Mania.Objects.Drawables; using osu.Game.Rulesets.Mania.UI; using osu.Game.Rulesets.Mods; @@ -28,6 +30,9 @@ namespace osu.Game.Rulesets.Mania.Tests.Editor [Cached(typeof(IScrollingInfo))] private IScrollingInfo scrollingInfo; + [Cached] + protected readonly Bindable configColourCode = new Bindable(); + protected ManiaPlacementBlueprintTestScene() { scrollingInfo = ((ScrollingTestContainer)HitObjectContainer).ScrollingInfo; @@ -41,6 +46,13 @@ namespace osu.Game.Rulesets.Mania.Tests.Editor }); } + [BackgroundDependencyLoader] + private void load(RulesetConfigCache configCache) + { + var config = (ManiaRulesetConfigManager)configCache.GetConfigFor(Ruleset.Value.CreateInstance()); + config.BindWith(ManiaRulesetSetting.ColourCode, configColourCode); + } + protected override SnapResult SnapForBlueprint(PlacementBlueprint blueprint) { var time = column.TimeAtScreenSpacePosition(InputManager.CurrentState.Mouse.Position); diff --git a/osu.Game.Rulesets.Mania.Tests/Editor/ManiaSelectionBlueprintTestScene.cs b/osu.Game.Rulesets.Mania.Tests/Editor/ManiaSelectionBlueprintTestScene.cs index 176fbba921..453f8e36e6 100644 --- a/osu.Game.Rulesets.Mania.Tests/Editor/ManiaSelectionBlueprintTestScene.cs +++ b/osu.Game.Rulesets.Mania.Tests/Editor/ManiaSelectionBlueprintTestScene.cs @@ -2,8 +2,10 @@ // See the LICENCE file in the repository root for full licence text. using osu.Framework.Allocation; +using osu.Framework.Bindables; using osu.Framework.Graphics; using osu.Framework.Timing; +using osu.Game.Rulesets.Mania.Configuration; using osu.Game.Rulesets.Mania.UI; using osu.Game.Tests.Visual; using osuTK.Graphics; @@ -15,6 +17,9 @@ namespace osu.Game.Rulesets.Mania.Tests.Editor [Cached(Type = typeof(IAdjustableClock))] private readonly IAdjustableClock clock = new StopwatchClock(); + [Cached] + protected readonly Bindable configColourCode = new Bindable(); + protected ManiaSelectionBlueprintTestScene() { Add(new Column(0) @@ -26,6 +31,13 @@ namespace osu.Game.Rulesets.Mania.Tests.Editor }); } + [BackgroundDependencyLoader] + private void load(RulesetConfigCache configCache) + { + var config = (ManiaRulesetConfigManager)configCache.GetConfigFor(Ruleset.Value.CreateInstance()); + config.BindWith(ManiaRulesetSetting.ColourCode, configColourCode); + } + public ManiaPlayfield Playfield => null; } } diff --git a/osu.Game.Rulesets.Mania.Tests/Editor/TestSceneHoldNotePlacementBlueprint.cs b/osu.Game.Rulesets.Mania.Tests/Editor/TestSceneHoldNotePlacementBlueprint.cs index 87c74a12cf..eb36e19048 100644 --- a/osu.Game.Rulesets.Mania.Tests/Editor/TestSceneHoldNotePlacementBlueprint.cs +++ b/osu.Game.Rulesets.Mania.Tests/Editor/TestSceneHoldNotePlacementBlueprint.cs @@ -13,6 +13,6 @@ namespace osu.Game.Rulesets.Mania.Tests.Editor public class TestSceneHoldNotePlacementBlueprint : ManiaPlacementBlueprintTestScene { protected override DrawableHitObject CreateHitObject(HitObject hitObject) => new DrawableHoldNote((HoldNote)hitObject); - protected override PlacementBlueprint CreateBlueprint() => new HoldNotePlacementBlueprint(); + protected override PlacementBlueprint CreateBlueprint() => new HoldNotePlacementBlueprint(null); } } diff --git a/osu.Game.Rulesets.Mania.Tests/Editor/TestSceneHoldNoteSelectionBlueprint.cs b/osu.Game.Rulesets.Mania.Tests/Editor/TestSceneHoldNoteSelectionBlueprint.cs index 24f4c6858e..9674985d09 100644 --- a/osu.Game.Rulesets.Mania.Tests/Editor/TestSceneHoldNoteSelectionBlueprint.cs +++ b/osu.Game.Rulesets.Mania.Tests/Editor/TestSceneHoldNoteSelectionBlueprint.cs @@ -23,7 +23,7 @@ namespace osu.Game.Rulesets.Mania.Tests.Editor public TestSceneHoldNoteSelectionBlueprint() { - var holdNote = new HoldNote { Column = 0, Duration = 1000 }; + var holdNote = new HoldNote(null) { Column = 0, Duration = 1000 }; holdNote.ApplyDefaults(new ControlPointInfo(), new BeatmapDifficulty()); base.Content.Child = content = new ScrollingTestContainer(ScrollingDirection.Down) diff --git a/osu.Game.Rulesets.Mania.Tests/Editor/TestSceneManiaHitObjectComposer.cs b/osu.Game.Rulesets.Mania.Tests/Editor/TestSceneManiaHitObjectComposer.cs index aaf96c63a6..1f3f4842c7 100644 --- a/osu.Game.Rulesets.Mania.Tests/Editor/TestSceneManiaHitObjectComposer.cs +++ b/osu.Game.Rulesets.Mania.Tests/Editor/TestSceneManiaHitObjectComposer.cs @@ -159,7 +159,7 @@ namespace osu.Game.Rulesets.Mania.Tests.Editor AddStep("setup beatmap", () => { composer.EditorBeatmap.Clear(); - composer.EditorBeatmap.Add(new HoldNote + composer.EditorBeatmap.Add(new HoldNote(Beatmap.Value.Beatmap) { Column = 1, EndTime = 200 @@ -201,9 +201,10 @@ namespace osu.Game.Rulesets.Mania.Tests.Editor public TestComposer() { + var beatmap = new ManiaBeatmap(new StageDefinition { Columns = 4 }); InternalChildren = new Drawable[] { - EditorBeatmap = new EditorBeatmap(new ManiaBeatmap(new StageDefinition { Columns = 4 })) + EditorBeatmap = new EditorBeatmap(beatmap) { BeatmapInfo = { Ruleset = new ManiaRuleset().RulesetInfo } }, @@ -211,7 +212,7 @@ namespace osu.Game.Rulesets.Mania.Tests.Editor }; for (int i = 0; i < 10; i++) - EditorBeatmap.Add(new Note { StartTime = 125 * i }); + EditorBeatmap.Add(new Note(beatmap) { StartTime = 125 * i }); } } } diff --git a/osu.Game.Rulesets.Mania.Tests/Editor/TestSceneNotePlacementBlueprint.cs b/osu.Game.Rulesets.Mania.Tests/Editor/TestSceneNotePlacementBlueprint.cs index 36c34a8fb9..08a22ea28e 100644 --- a/osu.Game.Rulesets.Mania.Tests/Editor/TestSceneNotePlacementBlueprint.cs +++ b/osu.Game.Rulesets.Mania.Tests/Editor/TestSceneNotePlacementBlueprint.cs @@ -55,6 +55,6 @@ namespace osu.Game.Rulesets.Mania.Tests.Editor private Note getNote() => this.ChildrenOfType().FirstOrDefault()?.HitObject; protected override DrawableHitObject CreateHitObject(HitObject hitObject) => new DrawableNote((Note)hitObject); - protected override PlacementBlueprint CreateBlueprint() => new NotePlacementBlueprint(); + protected override PlacementBlueprint CreateBlueprint() => new NotePlacementBlueprint(null); } } diff --git a/osu.Game.Rulesets.Mania.Tests/Editor/TestSceneNoteSelectionBlueprint.cs b/osu.Game.Rulesets.Mania.Tests/Editor/TestSceneNoteSelectionBlueprint.cs index 0e47a12a8e..caf89599be 100644 --- a/osu.Game.Rulesets.Mania.Tests/Editor/TestSceneNoteSelectionBlueprint.cs +++ b/osu.Game.Rulesets.Mania.Tests/Editor/TestSceneNoteSelectionBlueprint.cs @@ -21,7 +21,7 @@ namespace osu.Game.Rulesets.Mania.Tests.Editor public TestSceneNoteSelectionBlueprint() { - var note = new Note { Column = 0 }; + var note = new Note(null) { Column = 0 }; note.ApplyDefaults(new ControlPointInfo(), new BeatmapDifficulty()); DrawableNote drawableObject; diff --git a/osu.Game.Rulesets.Mania.Tests/ManiaInputTestScene.cs b/osu.Game.Rulesets.Mania.Tests/ManiaInputTestScene.cs index 9049bb3a82..ea7432f3a7 100644 --- a/osu.Game.Rulesets.Mania.Tests/ManiaInputTestScene.cs +++ b/osu.Game.Rulesets.Mania.Tests/ManiaInputTestScene.cs @@ -1,15 +1,21 @@ // Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. +using osu.Framework.Allocation; +using osu.Framework.Bindables; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Input.Bindings; +using osu.Game.Rulesets.Mania.Configuration; +using osu.Game.Rulesets.Mania.UI; using osu.Game.Tests.Visual; namespace osu.Game.Rulesets.Mania.Tests { public abstract class ManiaInputTestScene : OsuTestScene { + [Cached] + protected readonly Bindable configColourCode = new Bindable(); private readonly Container content; protected override Container Content => content ?? base.Content; @@ -18,6 +24,13 @@ namespace osu.Game.Rulesets.Mania.Tests base.Content.Add(content = new LocalInputManager(keys)); } + [BackgroundDependencyLoader] + private void load(RulesetConfigCache configCache) + { + var config = (ManiaRulesetConfigManager)configCache.GetConfigFor(Ruleset.Value.CreateInstance()); + config.BindWith(ManiaRulesetSetting.ColourCode, configColourCode); + } + private class LocalInputManager : ManiaInputManager { public LocalInputManager(int variant) diff --git a/osu.Game.Rulesets.Mania.Tests/Mods/TestSceneManiaModPerfect.cs b/osu.Game.Rulesets.Mania.Tests/Mods/TestSceneManiaModPerfect.cs index 2e3b21aed7..23d0e82439 100644 --- a/osu.Game.Rulesets.Mania.Tests/Mods/TestSceneManiaModPerfect.cs +++ b/osu.Game.Rulesets.Mania.Tests/Mods/TestSceneManiaModPerfect.cs @@ -19,10 +19,10 @@ namespace osu.Game.Rulesets.Mania.Tests.Mods [TestCase(false)] [TestCase(true)] - public void TestNote(bool shouldMiss) => CreateHitObjectTest(new HitObjectTestData(new Note { StartTime = 1000 }), shouldMiss); + public void TestNote(bool shouldMiss) => CreateHitObjectTest(new HitObjectTestData(new Note(Beatmap.Value.Beatmap) { StartTime = 1000 }), shouldMiss); [TestCase(false)] [TestCase(true)] - public void TestHoldNote(bool shouldMiss) => CreateHitObjectTest(new HitObjectTestData(new HoldNote { StartTime = 1000, EndTime = 3000 }), shouldMiss); + public void TestHoldNote(bool shouldMiss) => CreateHitObjectTest(new HitObjectTestData(new HoldNote(Beatmap.Value.Beatmap) { StartTime = 1000, EndTime = 3000 }), shouldMiss); } } diff --git a/osu.Game.Rulesets.Mania.Tests/Skinning/ManiaSkinnableTestScene.cs b/osu.Game.Rulesets.Mania.Tests/Skinning/ManiaSkinnableTestScene.cs index 1d84a2dfcb..3b19386da6 100644 --- a/osu.Game.Rulesets.Mania.Tests/Skinning/ManiaSkinnableTestScene.cs +++ b/osu.Game.Rulesets.Mania.Tests/Skinning/ManiaSkinnableTestScene.cs @@ -7,6 +7,8 @@ using osu.Framework.Bindables; using osu.Framework.Extensions.Color4Extensions; using osu.Framework.Graphics; using osu.Framework.Graphics.Shapes; +using osu.Game.Rulesets.Mania.Configuration; +using osu.Game.Rulesets.Mania.UI; using osu.Game.Rulesets.UI.Scrolling; using osu.Game.Rulesets.UI.Scrolling.Algorithms; using osu.Game.Tests.Visual; @@ -24,6 +26,9 @@ namespace osu.Game.Rulesets.Mania.Tests.Skinning [Cached(Type = typeof(IScrollingInfo))] private readonly TestScrollingInfo scrollingInfo = new TestScrollingInfo(); + [Cached] + protected readonly Bindable configColourCode = new Bindable(); + protected override Ruleset CreateRulesetForSkinProvider() => new ManiaRuleset(); protected ManiaSkinnableTestScene() @@ -38,6 +43,13 @@ namespace osu.Game.Rulesets.Mania.Tests.Skinning }); } + [BackgroundDependencyLoader] + private void load(RulesetConfigCache configCache) + { + var config = (ManiaRulesetConfigManager)configCache.GetConfigFor(Ruleset.Value.CreateInstance()); + config.BindWith(ManiaRulesetSetting.ColourCode, configColourCode); + } + [Test] public void TestScrollingDown() { diff --git a/osu.Game.Rulesets.Mania.Tests/Skinning/TestSceneHoldNote.cs b/osu.Game.Rulesets.Mania.Tests/Skinning/TestSceneHoldNote.cs index e88ff8e2ac..e13d0bbd7f 100644 --- a/osu.Game.Rulesets.Mania.Tests/Skinning/TestSceneHoldNote.cs +++ b/osu.Game.Rulesets.Mania.Tests/Skinning/TestSceneHoldNote.cs @@ -41,7 +41,7 @@ namespace osu.Game.Rulesets.Mania.Tests.Skinning protected override DrawableManiaHitObject CreateHitObject() { - var note = new HoldNote { Duration = 1000 }; + var note = new HoldNote(Beatmap.Value.Beatmap) { Duration = 1000 }; note.ApplyDefaults(new ControlPointInfo(), new BeatmapDifficulty()); return new DrawableHoldNote(note); diff --git a/osu.Game.Rulesets.Mania.Tests/Skinning/TestSceneNote.cs b/osu.Game.Rulesets.Mania.Tests/Skinning/TestSceneNote.cs index bc3bdf0bcb..eac288872a 100644 --- a/osu.Game.Rulesets.Mania.Tests/Skinning/TestSceneNote.cs +++ b/osu.Game.Rulesets.Mania.Tests/Skinning/TestSceneNote.cs @@ -12,7 +12,7 @@ namespace osu.Game.Rulesets.Mania.Tests.Skinning { protected override DrawableManiaHitObject CreateHitObject() { - var note = new Note(); + var note = new Note(Beatmap.Value.Beatmap); note.ApplyDefaults(new ControlPointInfo(), new BeatmapDifficulty()); return new DrawableNote(note); diff --git a/osu.Game.Rulesets.Mania.Tests/TestSceneAutoGeneration.cs b/osu.Game.Rulesets.Mania.Tests/TestSceneAutoGeneration.cs index cffec3dfd5..b2b9d607c6 100644 --- a/osu.Game.Rulesets.Mania.Tests/TestSceneAutoGeneration.cs +++ b/osu.Game.Rulesets.Mania.Tests/TestSceneAutoGeneration.cs @@ -29,7 +29,7 @@ namespace osu.Game.Rulesets.Mania.Tests // | | var beatmap = new ManiaBeatmap(new StageDefinition { Columns = 1 }); - beatmap.HitObjects.Add(new Note { StartTime = 1000 }); + beatmap.HitObjects.Add(new Note(beatmap) { StartTime = 1000 }); var generated = new ManiaAutoGenerator(beatmap).Generate(); @@ -50,7 +50,7 @@ namespace osu.Game.Rulesets.Mania.Tests // | | var beatmap = new ManiaBeatmap(new StageDefinition { Columns = 1 }); - beatmap.HitObjects.Add(new HoldNote { StartTime = 1000, Duration = 2000 }); + beatmap.HitObjects.Add(new HoldNote(beatmap) { StartTime = 1000, Duration = 2000 }); var generated = new ManiaAutoGenerator(beatmap).Generate(); @@ -69,8 +69,8 @@ namespace osu.Game.Rulesets.Mania.Tests // | | | var beatmap = new ManiaBeatmap(new StageDefinition { Columns = 2 }); - beatmap.HitObjects.Add(new Note { StartTime = 1000 }); - beatmap.HitObjects.Add(new Note { StartTime = 1000, Column = 1 }); + beatmap.HitObjects.Add(new Note(beatmap) { StartTime = 1000 }); + beatmap.HitObjects.Add(new Note(beatmap) { StartTime = 1000, Column = 1 }); var generated = new ManiaAutoGenerator(beatmap).Generate(); @@ -91,8 +91,8 @@ namespace osu.Game.Rulesets.Mania.Tests // | | | var beatmap = new ManiaBeatmap(new StageDefinition { Columns = 2 }); - beatmap.HitObjects.Add(new HoldNote { StartTime = 1000, Duration = 2000 }); - beatmap.HitObjects.Add(new HoldNote { StartTime = 1000, Duration = 2000, Column = 1 }); + beatmap.HitObjects.Add(new HoldNote(beatmap) { StartTime = 1000, Duration = 2000 }); + beatmap.HitObjects.Add(new HoldNote(beatmap) { StartTime = 1000, Duration = 2000, Column = 1 }); var generated = new ManiaAutoGenerator(beatmap).Generate(); @@ -114,8 +114,8 @@ namespace osu.Game.Rulesets.Mania.Tests // | | | var beatmap = new ManiaBeatmap(new StageDefinition { Columns = 2 }); - beatmap.HitObjects.Add(new Note { StartTime = 1000 }); - beatmap.HitObjects.Add(new Note { StartTime = 2000, Column = 1 }); + beatmap.HitObjects.Add(new Note(beatmap) { StartTime = 1000 }); + beatmap.HitObjects.Add(new Note(beatmap) { StartTime = 2000, Column = 1 }); var generated = new ManiaAutoGenerator(beatmap).Generate(); @@ -141,8 +141,8 @@ namespace osu.Game.Rulesets.Mania.Tests // | | | var beatmap = new ManiaBeatmap(new StageDefinition { Columns = 2 }); - beatmap.HitObjects.Add(new HoldNote { StartTime = 1000, Duration = 2000 }); - beatmap.HitObjects.Add(new HoldNote { StartTime = 2000, Duration = 2000, Column = 1 }); + beatmap.HitObjects.Add(new HoldNote(beatmap) { StartTime = 1000, Duration = 2000 }); + beatmap.HitObjects.Add(new HoldNote(beatmap) { StartTime = 2000, Duration = 2000, Column = 1 }); var generated = new ManiaAutoGenerator(beatmap).Generate(); @@ -168,8 +168,8 @@ namespace osu.Game.Rulesets.Mania.Tests // | | | var beatmap = new ManiaBeatmap(new StageDefinition { Columns = 2 }); - beatmap.HitObjects.Add(new HoldNote { StartTime = 1000, Duration = 2000 }); - beatmap.HitObjects.Add(new Note { StartTime = 3000, Column = 1 }); + beatmap.HitObjects.Add(new HoldNote(beatmap) { StartTime = 1000, Duration = 2000 }); + beatmap.HitObjects.Add(new Note(beatmap) { StartTime = 3000, Column = 1 }); var generated = new ManiaAutoGenerator(beatmap).Generate(); diff --git a/osu.Game.Rulesets.Mania.Tests/TestSceneColumn.cs b/osu.Game.Rulesets.Mania.Tests/TestSceneColumn.cs index d9b1ad22fa..59da73a540 100644 --- a/osu.Game.Rulesets.Mania.Tests/TestSceneColumn.cs +++ b/osu.Game.Rulesets.Mania.Tests/TestSceneColumn.cs @@ -62,7 +62,7 @@ namespace osu.Game.Rulesets.Mania.Tests { for (int i = 0; i < columns.Count; i++) { - var obj = new Note { Column = i, StartTime = Time.Current + 2000 }; + var obj = new Note(null) { Column = i, StartTime = Time.Current + 2000 }; obj.ApplyDefaults(new ControlPointInfo(), new BeatmapDifficulty()); columns[i].Add(new DrawableNote(obj)); @@ -73,7 +73,7 @@ namespace osu.Game.Rulesets.Mania.Tests { for (int i = 0; i < columns.Count; i++) { - var obj = new HoldNote { Column = i, StartTime = Time.Current + 2000, Duration = 500 }; + var obj = new HoldNote(null) { Column = i, StartTime = Time.Current + 2000, Duration = 500 }; obj.ApplyDefaults(new ControlPointInfo(), new BeatmapDifficulty()); columns[i].Add(new DrawableHoldNote(obj)); diff --git a/osu.Game.Rulesets.Mania.Tests/TestSceneHoldNoteInput.cs b/osu.Game.Rulesets.Mania.Tests/TestSceneHoldNoteInput.cs index 668487f673..c92fe03483 100644 --- a/osu.Game.Rulesets.Mania.Tests/TestSceneHoldNoteInput.cs +++ b/osu.Game.Rulesets.Mania.Tests/TestSceneHoldNoteInput.cs @@ -249,21 +249,6 @@ namespace osu.Game.Rulesets.Mania.Tests var beatmap = new Beatmap { - HitObjects = - { - new HoldNote - { - StartTime = 1000, - Duration = 500, - Column = 0, - }, - new HoldNote - { - StartTime = 1000 + 500 + windows.WindowFor(HitResult.Miss) + 10, - Duration = 500, - Column = 0, - }, - }, BeatmapInfo = { BaseDifficulty = new BeatmapDifficulty @@ -274,6 +259,20 @@ namespace osu.Game.Rulesets.Mania.Tests Ruleset = new ManiaRuleset().RulesetInfo }, }; + beatmap.HitObjects = new List { + new HoldNote(beatmap) + { + StartTime = 1000, + Duration = 500, + Column = 0, + }, + new HoldNote(beatmap) + { + StartTime = 1000 + 500 + windows.WindowFor(HitResult.Miss) + 10, + Duration = 500, + Column = 0, + }, + }; performTest(new List { @@ -297,21 +296,21 @@ namespace osu.Game.Rulesets.Mania.Tests var beatmap = new Beatmap { - HitObjects = - { - new HoldNote - { - StartTime = time_head, - Duration = time_tail - time_head, - Column = 0, - } - }, BeatmapInfo = { BaseDifficulty = new BeatmapDifficulty { SliderTickRate = tick_rate }, Ruleset = new ManiaRuleset().RulesetInfo }, }; + beatmap.HitObjects = new List + { + new HoldNote(beatmap) + { + StartTime = time_head, + Duration = time_tail - time_head, + Column = 0, + } + }; performTest(new List { @@ -329,17 +328,17 @@ namespace osu.Game.Rulesets.Mania.Tests { var beatmap = new Beatmap { - HitObjects = + BeatmapInfo = { Ruleset = new ManiaRuleset().RulesetInfo }, + }; + beatmap.HitObjects = new List { - new HoldNote + new HoldNote(beatmap) { StartTime = 1000, Duration = 0, Column = 0, }, - }, - BeatmapInfo = { Ruleset = new ManiaRuleset().RulesetInfo }, - }; + }; performTest(new List { @@ -374,21 +373,21 @@ namespace osu.Game.Rulesets.Mania.Tests { beatmap = new Beatmap { - HitObjects = - { - new HoldNote - { - StartTime = time_head, - Duration = time_tail - time_head, - Column = 0, - } - }, BeatmapInfo = { BaseDifficulty = new BeatmapDifficulty { SliderTickRate = 4 }, Ruleset = new ManiaRuleset().RulesetInfo }, }; + beatmap.HitObjects = new List + { + new HoldNote(beatmap) + { + StartTime = time_head, + Duration = time_tail - time_head, + Column = 0, + } + }; beatmap.ControlPointInfo.Add(0, new DifficultyControlPoint { SpeedMultiplier = 0.1f }); } diff --git a/osu.Game.Rulesets.Mania.Tests/TestSceneNotes.cs b/osu.Game.Rulesets.Mania.Tests/TestSceneNotes.cs index 706268e478..3660895347 100644 --- a/osu.Game.Rulesets.Mania.Tests/TestSceneNotes.cs +++ b/osu.Game.Rulesets.Mania.Tests/TestSceneNotes.cs @@ -15,8 +15,10 @@ using osu.Game.Beatmaps; using osu.Game.Beatmaps.ControlPoints; using osu.Game.Graphics; using osu.Game.Graphics.Sprites; +using osu.Game.Rulesets.Mania.Configuration; using osu.Game.Rulesets.Mania.Objects; using osu.Game.Rulesets.Mania.Objects.Drawables; +using osu.Game.Rulesets.Mania.UI; using osu.Game.Rulesets.Objects.Drawables; using osu.Game.Rulesets.Objects.Types; using osu.Game.Rulesets.UI.Scrolling; @@ -29,6 +31,10 @@ namespace osu.Game.Rulesets.Mania.Tests [TestFixture] public class TestSceneNotes : OsuTestScene { + + [Cached] + protected readonly Bindable configColourCode = new Bindable(); + [Test] public void TestVariousNotes() { @@ -63,9 +69,16 @@ namespace osu.Game.Rulesets.Mania.Tests AddAssert("hold note 2 facing upwards", () => verifyAnchors(holdNote2, Anchor.y0)); } + [BackgroundDependencyLoader] + private void load(RulesetConfigCache configCache) + { + var config = (ManiaRulesetConfigManager)configCache.GetConfigFor(Ruleset.Value.CreateInstance()); + config.BindWith(ManiaRulesetSetting.ColourCode, configColourCode); + } + private Drawable createNoteDisplay(ScrollingDirection direction, int identifier, out DrawableNote hitObject) { - var note = new Note { StartTime = 0 }; + var note = new Note(null) { StartTime = 0 }; note.ApplyDefaults(new ControlPointInfo(), new BeatmapDifficulty()); return new ScrollingTestContainer(direction) @@ -80,7 +93,7 @@ namespace osu.Game.Rulesets.Mania.Tests private Drawable createHoldNoteDisplay(ScrollingDirection direction, int identifier, out DrawableHoldNote hitObject) { - var note = new HoldNote { StartTime = 0, Duration = 5000 }; + var note = new HoldNote(null) { StartTime = 0, Duration = 5000 }; note.ApplyDefaults(new ControlPointInfo(), new BeatmapDifficulty()); return new ScrollingTestContainer(direction) diff --git a/osu.Game.Rulesets.Mania.Tests/TestSceneOutOfOrderHits.cs b/osu.Game.Rulesets.Mania.Tests/TestSceneOutOfOrderHits.cs index 18891f8c58..65195fdd3f 100644 --- a/osu.Game.Rulesets.Mania.Tests/TestSceneOutOfOrderHits.cs +++ b/osu.Game.Rulesets.Mania.Tests/TestSceneOutOfOrderHits.cs @@ -34,7 +34,7 @@ namespace osu.Game.Rulesets.Mania.Tests { double time = 1000 + i * 100; - objects.Add(new Note { StartTime = time }); + objects.Add(new Note(Beatmap.Value.Beatmap) { StartTime = time }); // don't hit the first note if (i > 0) @@ -60,12 +60,12 @@ namespace osu.Game.Rulesets.Mania.Tests { var objects = new List { - new HoldNote + new HoldNote(Beatmap.Value.Beatmap) { StartTime = 1000, EndTime = 1010, }, - new HoldNote + new HoldNote(Beatmap.Value.Beatmap) { StartTime = 1020, EndTime = 1030 @@ -83,12 +83,12 @@ namespace osu.Game.Rulesets.Mania.Tests { var objects = new List { - new HoldNote + new HoldNote(Beatmap.Value.Beatmap) { StartTime = 1000, EndTime = 1010, }, - new HoldNote + new HoldNote(Beatmap.Value.Beatmap) { StartTime = 1020, EndTime = 1030 diff --git a/osu.Game.Rulesets.Mania.Tests/TestSceneStage.cs b/osu.Game.Rulesets.Mania.Tests/TestSceneStage.cs index 7376a90f17..777163cca7 100644 --- a/osu.Game.Rulesets.Mania.Tests/TestSceneStage.cs +++ b/osu.Game.Rulesets.Mania.Tests/TestSceneStage.cs @@ -91,7 +91,7 @@ namespace osu.Game.Rulesets.Mania.Tests { for (int i = 0; i < stage.Columns.Count; i++) { - var obj = new Note { Column = i, StartTime = Time.Current + 2000 }; + var obj = new Note(null) { Column = i, StartTime = Time.Current + 2000 }; obj.ApplyDefaults(new ControlPointInfo(), new BeatmapDifficulty()); stage.Add(new DrawableNote(obj)); @@ -105,7 +105,7 @@ namespace osu.Game.Rulesets.Mania.Tests { for (int i = 0; i < stage.Columns.Count; i++) { - var obj = new HoldNote { Column = i, StartTime = Time.Current + 2000, Duration = 500 }; + var obj = new HoldNote(null) { Column = i, StartTime = Time.Current + 2000, Duration = 500 }; obj.ApplyDefaults(new ControlPointInfo(), new BeatmapDifficulty()); stage.Add(new DrawableHoldNote(obj)); diff --git a/osu.Game.Rulesets.Mania/Beatmaps/ManiaBeatmapConverter.cs b/osu.Game.Rulesets.Mania/Beatmaps/ManiaBeatmapConverter.cs index 26393c8edb..5f03c93d55 100644 --- a/osu.Game.Rulesets.Mania/Beatmaps/ManiaBeatmapConverter.cs +++ b/osu.Game.Rulesets.Mania/Beatmaps/ManiaBeatmapConverter.cs @@ -247,7 +247,7 @@ namespace osu.Game.Rulesets.Mania.Beatmaps if (HitObject is IHasDuration endTimeData) { - pattern.Add(new HoldNote + pattern.Add(new HoldNote(Beatmap) { StartTime = HitObject.StartTime, Duration = endTimeData.Duration, @@ -258,7 +258,7 @@ namespace osu.Game.Rulesets.Mania.Beatmaps } else if (HitObject is IHasXPosition) { - pattern.Add(new Note + pattern.Add(new Note(Beatmap) { StartTime = HitObject.StartTime, Samples = HitObject.Samples, diff --git a/osu.Game.Rulesets.Mania/Beatmaps/Patterns/Legacy/DistanceObjectPatternGenerator.cs b/osu.Game.Rulesets.Mania/Beatmaps/Patterns/Legacy/DistanceObjectPatternGenerator.cs index 26e5d381e2..a936878a38 100644 --- a/osu.Game.Rulesets.Mania/Beatmaps/Patterns/Legacy/DistanceObjectPatternGenerator.cs +++ b/osu.Game.Rulesets.Mania/Beatmaps/Patterns/Legacy/DistanceObjectPatternGenerator.cs @@ -512,7 +512,7 @@ namespace osu.Game.Rulesets.Mania.Beatmaps.Patterns.Legacy if (startTime == endTime) { - newObject = new Note + newObject = new Note(Beatmap) { StartTime = startTime, Samples = sampleInfoListAt(startTime), @@ -521,7 +521,7 @@ namespace osu.Game.Rulesets.Mania.Beatmaps.Patterns.Legacy } else { - newObject = new HoldNote + newObject = new HoldNote(Beatmap) { StartTime = startTime, Duration = endTime - startTime, diff --git a/osu.Game.Rulesets.Mania/Beatmaps/Patterns/Legacy/EndTimeObjectPatternGenerator.cs b/osu.Game.Rulesets.Mania/Beatmaps/Patterns/Legacy/EndTimeObjectPatternGenerator.cs index f816a70ab3..9422146803 100644 --- a/osu.Game.Rulesets.Mania/Beatmaps/Patterns/Legacy/EndTimeObjectPatternGenerator.cs +++ b/osu.Game.Rulesets.Mania/Beatmaps/Patterns/Legacy/EndTimeObjectPatternGenerator.cs @@ -76,7 +76,7 @@ namespace osu.Game.Rulesets.Mania.Beatmaps.Patterns.Legacy if (holdNote) { - newObject = new HoldNote + newObject = new HoldNote(Beatmap) { StartTime = HitObject.StartTime, Duration = endTime - HitObject.StartTime, @@ -87,7 +87,7 @@ namespace osu.Game.Rulesets.Mania.Beatmaps.Patterns.Legacy } else { - newObject = new Note + newObject = new Note(Beatmap) { StartTime = HitObject.StartTime, Samples = HitObject.Samples, diff --git a/osu.Game.Rulesets.Mania/Beatmaps/Patterns/Legacy/HitObjectPatternGenerator.cs b/osu.Game.Rulesets.Mania/Beatmaps/Patterns/Legacy/HitObjectPatternGenerator.cs index 54c37e9742..bbb4d4b466 100644 --- a/osu.Game.Rulesets.Mania/Beatmaps/Patterns/Legacy/HitObjectPatternGenerator.cs +++ b/osu.Game.Rulesets.Mania/Beatmaps/Patterns/Legacy/HitObjectPatternGenerator.cs @@ -441,7 +441,7 @@ namespace osu.Game.Rulesets.Mania.Beatmaps.Patterns.Legacy /// The column to add the note to. private void addToPattern(Pattern pattern, int column) { - pattern.Add(new Note + pattern.Add(new Note(Beatmap) { StartTime = HitObject.StartTime, Samples = HitObject.Samples, diff --git a/osu.Game.Rulesets.Mania/Configuration/ManiaRulesetConfigManager.cs b/osu.Game.Rulesets.Mania/Configuration/ManiaRulesetConfigManager.cs index 39d0f4bae4..292d494d88 100644 --- a/osu.Game.Rulesets.Mania/Configuration/ManiaRulesetConfigManager.cs +++ b/osu.Game.Rulesets.Mania/Configuration/ManiaRulesetConfigManager.cs @@ -22,6 +22,7 @@ namespace osu.Game.Rulesets.Mania.Configuration SetDefault(ManiaRulesetSetting.ScrollTime, 1500.0, DrawableManiaRuleset.MIN_TIME_RANGE, DrawableManiaRuleset.MAX_TIME_RANGE, 5); SetDefault(ManiaRulesetSetting.ScrollDirection, ManiaScrollingDirection.Down); + SetDefault(ManiaRulesetSetting.ColourCode, ManiaColourCode.Off); } public override TrackedSettings CreateTrackedSettings() => new TrackedSettings @@ -34,6 +35,7 @@ namespace osu.Game.Rulesets.Mania.Configuration public enum ManiaRulesetSetting { ScrollTime, - ScrollDirection + ScrollDirection, + ColourCode } } diff --git a/osu.Game.Rulesets.Mania/Edit/Blueprints/HoldNotePlacementBlueprint.cs b/osu.Game.Rulesets.Mania/Edit/Blueprints/HoldNotePlacementBlueprint.cs index 093a8da24f..b3902524a0 100644 --- a/osu.Game.Rulesets.Mania/Edit/Blueprints/HoldNotePlacementBlueprint.cs +++ b/osu.Game.Rulesets.Mania/Edit/Blueprints/HoldNotePlacementBlueprint.cs @@ -5,6 +5,7 @@ using System; using osu.Framework.Allocation; using osu.Framework.Graphics; using osu.Framework.Input.Events; +using osu.Game.Beatmaps; using osu.Game.Rulesets.Edit; using osu.Game.Rulesets.Mania.Edit.Blueprints.Components; using osu.Game.Rulesets.Mania.Objects; @@ -23,8 +24,8 @@ namespace osu.Game.Rulesets.Mania.Edit.Blueprints [Resolved] private IScrollingInfo scrollingInfo { get; set; } - public HoldNotePlacementBlueprint() - : base(new HoldNote()) + public HoldNotePlacementBlueprint(IBeatmap beatmap) + : base(new HoldNote(beatmap)) { RelativeSizeAxes = Axes.Both; diff --git a/osu.Game.Rulesets.Mania/Edit/Blueprints/NotePlacementBlueprint.cs b/osu.Game.Rulesets.Mania/Edit/Blueprints/NotePlacementBlueprint.cs index 3db89c8ae6..cc0ef5181a 100644 --- a/osu.Game.Rulesets.Mania/Edit/Blueprints/NotePlacementBlueprint.cs +++ b/osu.Game.Rulesets.Mania/Edit/Blueprints/NotePlacementBlueprint.cs @@ -3,6 +3,7 @@ using osu.Framework.Graphics; using osu.Framework.Input.Events; +using osu.Game.Beatmaps; using osu.Game.Rulesets.Edit; using osu.Game.Rulesets.Mania.Edit.Blueprints.Components; using osu.Game.Rulesets.Mania.Objects; @@ -14,8 +15,8 @@ namespace osu.Game.Rulesets.Mania.Edit.Blueprints { private readonly EditNotePiece piece; - public NotePlacementBlueprint() - : base(new Note()) + public NotePlacementBlueprint(IBeatmap beatmap) + : base(new Note(beatmap)) { RelativeSizeAxes = Axes.Both; diff --git a/osu.Game.Rulesets.Mania/Edit/HoldNoteCompositionTool.cs b/osu.Game.Rulesets.Mania/Edit/HoldNoteCompositionTool.cs index a5f10ed436..696278de4d 100644 --- a/osu.Game.Rulesets.Mania/Edit/HoldNoteCompositionTool.cs +++ b/osu.Game.Rulesets.Mania/Edit/HoldNoteCompositionTool.cs @@ -5,19 +5,22 @@ using osu.Framework.Graphics; using osu.Game.Beatmaps; using osu.Game.Rulesets.Edit; using osu.Game.Rulesets.Edit.Tools; +using osu.Game.Rulesets.Mania.Beatmaps; using osu.Game.Rulesets.Mania.Edit.Blueprints; namespace osu.Game.Rulesets.Mania.Edit { public class HoldNoteCompositionTool : HitObjectCompositionTool { - public HoldNoteCompositionTool() + private ManiaBeatmap Beatmap; + public HoldNoteCompositionTool(ManiaBeatmap beatmap) : base("Hold") { + Beatmap = beatmap; } public override Drawable CreateIcon() => new BeatmapStatisticIcon(BeatmapStatisticsIconType.Sliders); - public override PlacementBlueprint CreatePlacementBlueprint() => new HoldNotePlacementBlueprint(); + public override PlacementBlueprint CreatePlacementBlueprint() => new HoldNotePlacementBlueprint(Beatmap); } } diff --git a/osu.Game.Rulesets.Mania/Edit/ManiaHitObjectComposer.cs b/osu.Game.Rulesets.Mania/Edit/ManiaHitObjectComposer.cs index d9570bf8be..0defeb026d 100644 --- a/osu.Game.Rulesets.Mania/Edit/ManiaHitObjectComposer.cs +++ b/osu.Game.Rulesets.Mania/Edit/ManiaHitObjectComposer.cs @@ -93,8 +93,8 @@ namespace osu.Game.Rulesets.Mania.Edit protected override IReadOnlyList CompositionTools => new HitObjectCompositionTool[] { - new NoteCompositionTool(), - new HoldNoteCompositionTool() + new NoteCompositionTool(drawableRuleset.Beatmap), + new HoldNoteCompositionTool(drawableRuleset.Beatmap) }; protected override void UpdateAfterChildren() diff --git a/osu.Game.Rulesets.Mania/Edit/NoteCompositionTool.cs b/osu.Game.Rulesets.Mania/Edit/NoteCompositionTool.cs index 9f54152596..c77c3722c6 100644 --- a/osu.Game.Rulesets.Mania/Edit/NoteCompositionTool.cs +++ b/osu.Game.Rulesets.Mania/Edit/NoteCompositionTool.cs @@ -5,6 +5,7 @@ using osu.Framework.Graphics; using osu.Game.Beatmaps; using osu.Game.Rulesets.Edit; using osu.Game.Rulesets.Edit.Tools; +using osu.Game.Rulesets.Mania.Beatmaps; using osu.Game.Rulesets.Mania.Edit.Blueprints; using osu.Game.Rulesets.Mania.Objects; @@ -12,13 +13,16 @@ namespace osu.Game.Rulesets.Mania.Edit { public class NoteCompositionTool : HitObjectCompositionTool { - public NoteCompositionTool() + private ManiaBeatmap Beatmap; + + public NoteCompositionTool(ManiaBeatmap beatmap) : base(nameof(Note)) { + Beatmap = beatmap; } public override Drawable CreateIcon() => new BeatmapStatisticIcon(BeatmapStatisticsIconType.Circles); - public override PlacementBlueprint CreatePlacementBlueprint() => new NotePlacementBlueprint(); + public override PlacementBlueprint CreatePlacementBlueprint() => new NotePlacementBlueprint(Beatmap); } } diff --git a/osu.Game.Rulesets.Mania/ManiaSettingsSubsection.cs b/osu.Game.Rulesets.Mania/ManiaSettingsSubsection.cs index de77af8306..d46076d3bc 100644 --- a/osu.Game.Rulesets.Mania/ManiaSettingsSubsection.cs +++ b/osu.Game.Rulesets.Mania/ManiaSettingsSubsection.cs @@ -37,6 +37,11 @@ namespace osu.Game.Rulesets.Mania Current = config.GetBindable(ManiaRulesetSetting.ScrollTime), KeyboardStep = 5 }, + new SettingsEnumDropdown + { + LabelText = "Colour-coded notes", + Current = config.GetBindable(ManiaRulesetSetting.ColourCode), + } }; } diff --git a/osu.Game.Rulesets.Mania/Mods/ManiaModInvert.cs b/osu.Game.Rulesets.Mania/Mods/ManiaModInvert.cs index 1ea45c295c..11310c6642 100644 --- a/osu.Game.Rulesets.Mania/Mods/ManiaModInvert.cs +++ b/osu.Game.Rulesets.Mania/Mods/ManiaModInvert.cs @@ -55,7 +55,7 @@ namespace osu.Game.Rulesets.Mania.Mods // Decrease the duration by at most a 1/4 beat to ensure there's no instantaneous notes. duration = Math.Max(duration / 2, duration - beatLength / 4); - newColumnObjects.Add(new HoldNote + newColumnObjects.Add(new HoldNote(maniaBeatmap) { Column = column.Key, StartTime = locations[i].startTime, diff --git a/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableNote.cs b/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableNote.cs index b512986ccb..436e0923c4 100644 --- a/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableNote.cs +++ b/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableNote.cs @@ -2,12 +2,16 @@ // See the LICENCE file in the repository root for full licence text. using System.Diagnostics; +using osu.Framework.Allocation; using osu.Framework.Bindables; using osu.Framework.Graphics; using osu.Framework.Input.Bindings; +using osu.Game.Graphics; using osu.Game.Rulesets.Mania.Skinning.Default; +using osu.Game.Rulesets.Mania.UI; using osu.Game.Rulesets.Scoring; using osu.Game.Rulesets.UI.Scrolling; +using osu.Game.Screens.Edit; using osu.Game.Skinning; namespace osu.Game.Rulesets.Mania.Objects.Drawables @@ -17,6 +21,12 @@ namespace osu.Game.Rulesets.Mania.Objects.Drawables /// public class DrawableNote : DrawableManiaHitObject, IKeyBindingHandler { + [Resolved] + private OsuColour colours { get; set; } + + [Resolved] + private Bindable configColourCode { get; set; } + protected virtual ManiaSkinComponents Component => ManiaSkinComponents.Note; private readonly Drawable headPiece; @@ -34,6 +44,26 @@ namespace osu.Game.Rulesets.Mania.Objects.Drawables }); } + protected override void LoadComplete() + { + base.LoadComplete(); + + HitObject.SnapBindable.BindValueChanged(snap => UpdateSnapColour(configColourCode.Value, snap.NewValue), true); + configColourCode.BindValueChanged(colourCode => UpdateSnapColour(colourCode.NewValue, HitObject.Snap)); + } + + private void UpdateSnapColour(ManiaColourCode colourCode, int snap) + { + if (colourCode == ManiaColourCode.On) + { + Colour = BindableBeatDivisor.GetColourFor(HitObject.Snap, colours); + } + else + { + Colour = Colour4.White; + } + } + protected override void OnDirectionChanged(ValueChangedEvent e) { base.OnDirectionChanged(e); diff --git a/osu.Game.Rulesets.Mania/Objects/HoldNote.cs b/osu.Game.Rulesets.Mania/Objects/HoldNote.cs index 6cc7ff92d3..bf0631170a 100644 --- a/osu.Game.Rulesets.Mania/Objects/HoldNote.cs +++ b/osu.Game.Rulesets.Mania/Objects/HoldNote.cs @@ -17,6 +17,8 @@ namespace osu.Game.Rulesets.Mania.Objects /// public class HoldNote : ManiaHitObject, IHasDuration { + public IBeatmap Beatmap; + public double EndTime { get => StartTime + Duration; @@ -84,6 +86,11 @@ namespace osu.Game.Rulesets.Mania.Objects /// private double tickSpacing = 50; + public HoldNote(IBeatmap beatmap) : base() + { + Beatmap = beatmap; + } + protected override void ApplyDefaultsToSelf(ControlPointInfo controlPointInfo, BeatmapDifficulty difficulty) { base.ApplyDefaultsToSelf(controlPointInfo, difficulty); @@ -98,14 +105,14 @@ namespace osu.Game.Rulesets.Mania.Objects createTicks(cancellationToken); - AddNested(Head = new Note + AddNested(Head = new Note(Beatmap) { StartTime = StartTime, Column = Column, Samples = GetNodeSamples(0), }); - AddNested(Tail = new TailNote + AddNested(Tail = new TailNote(Beatmap) { StartTime = EndTime, Column = Column, diff --git a/osu.Game.Rulesets.Mania/Objects/Note.cs b/osu.Game.Rulesets.Mania/Objects/Note.cs index 0035960c63..6ee0232c5b 100644 --- a/osu.Game.Rulesets.Mania/Objects/Note.cs +++ b/osu.Game.Rulesets.Mania/Objects/Note.cs @@ -1,6 +1,11 @@ // Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. +using System; +using osu.Framework.Bindables; +using osu.Framework.Utils; +using osu.Game.Beatmaps; +using osu.Game.Beatmaps.ControlPoints; using osu.Game.Rulesets.Judgements; using osu.Game.Rulesets.Mania.Judgements; @@ -12,5 +17,79 @@ namespace osu.Game.Rulesets.Mania.Objects public class Note : ManiaHitObject { public override Judgement CreateJudgement() => new ManiaJudgement(); + + private IBeatmap Beatmap; + + public readonly Bindable SnapBindable = new Bindable(); + + public int Snap + { + get => SnapBindable.Value; + set => SnapBindable.Value = value; + } + + public Note(IBeatmap beatmap) : base() + { + Beatmap = beatmap; + this.StartTimeBindable.BindValueChanged(_ => SnapToBeatmap(), true); + } + + private void SnapToBeatmap() + { + if (Beatmap != null) + { + TimingControlPoint currentTimingPoint = Beatmap.ControlPointInfo.TimingPointAt(StartTime); + int timeSignature = (int)currentTimingPoint.TimeSignature; + double startTime = currentTimingPoint.Time; + double secondsPerFourCounts = currentTimingPoint.BeatLength * 4; + + double offset = startTime % secondsPerFourCounts; + double snapResult = StartTime % secondsPerFourCounts - offset; + + if (AlmostDivisibleBy(snapResult, secondsPerFourCounts / 4.0)) + { + Snap = 1; + } + else if (AlmostDivisibleBy(snapResult, secondsPerFourCounts / 8.0)) + { + Snap = 2; + } + else if (AlmostDivisibleBy(snapResult, secondsPerFourCounts / 12.0)) + { + Snap = 3; + } + else if (AlmostDivisibleBy(snapResult, secondsPerFourCounts / 16.0)) + { + Snap = 4; + } + else if (AlmostDivisibleBy(snapResult, secondsPerFourCounts / 24.0)) + { + Snap = 6; + } + else if (AlmostDivisibleBy(snapResult, secondsPerFourCounts / 32.0)) + { + Snap = 8; + } + else if (AlmostDivisibleBy(snapResult, secondsPerFourCounts / 48.0)) + { + Snap = 12; + } + else if (AlmostDivisibleBy(snapResult, secondsPerFourCounts / 64.0)) + { + Snap = 16; + } + else + { + Snap = 0; + } + } + } + + private const double LENIENCY_MS = 1.0; + private static bool AlmostDivisibleBy(double dividend, double divisor) + { + double remainder = Math.Abs(dividend) % divisor; + return Precision.AlmostEquals(remainder, 0, LENIENCY_MS) || Precision.AlmostEquals(remainder - divisor, 0, LENIENCY_MS); + } } } diff --git a/osu.Game.Rulesets.Mania/Objects/TailNote.cs b/osu.Game.Rulesets.Mania/Objects/TailNote.cs index 5a30fd6a12..bc56408691 100644 --- a/osu.Game.Rulesets.Mania/Objects/TailNote.cs +++ b/osu.Game.Rulesets.Mania/Objects/TailNote.cs @@ -1,6 +1,7 @@ // Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. +using osu.Game.Beatmaps; using osu.Game.Rulesets.Judgements; using osu.Game.Rulesets.Mania.Judgements; @@ -8,6 +9,10 @@ namespace osu.Game.Rulesets.Mania.Objects { public class TailNote : Note { + public TailNote(IBeatmap beatmap) : base(beatmap) + { + } + public override Judgement CreateJudgement() => new ManiaJudgement(); } } diff --git a/osu.Game.Rulesets.Mania/UI/DrawableManiaRuleset.cs b/osu.Game.Rulesets.Mania/UI/DrawableManiaRuleset.cs index 4ee060e91e..dc9c525cb0 100644 --- a/osu.Game.Rulesets.Mania/UI/DrawableManiaRuleset.cs +++ b/osu.Game.Rulesets.Mania/UI/DrawableManiaRuleset.cs @@ -51,6 +51,9 @@ namespace osu.Game.Rulesets.Mania.UI protected new ManiaRulesetConfigManager Config => (ManiaRulesetConfigManager)base.Config; + [Cached] + protected readonly Bindable configColourCode = new Bindable(); + public ScrollVisualisationMethod ScrollMethod { get => scrollMethod; @@ -104,6 +107,8 @@ namespace osu.Game.Rulesets.Mania.UI configDirection.BindValueChanged(direction => Direction.Value = (ScrollingDirection)direction.NewValue, true); Config.BindWith(ManiaRulesetSetting.ScrollTime, configTimeRange); + + Config.BindWith(ManiaRulesetSetting.ColourCode, configColourCode); } protected override void AdjustScrollSpeed(int amount) diff --git a/osu.Game.Rulesets.Mania/UI/ManiaColourCode.cs b/osu.Game.Rulesets.Mania/UI/ManiaColourCode.cs new file mode 100644 index 0000000000..91b637b71d --- /dev/null +++ b/osu.Game.Rulesets.Mania/UI/ManiaColourCode.cs @@ -0,0 +1,11 @@ +// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. +// See the LICENCE file in the repository root for full licence text. + +namespace osu.Game.Rulesets.Mania.UI +{ + public enum ManiaColourCode + { + Off, + On + } +} diff --git a/osu.Game.Tests/Visual/Collections/TestSceneManageCollectionsDialog.cs b/osu.Game.Tests/Visual/Collections/TestSceneManageCollectionsDialog.cs index eca857f9e5..d8d419bceb 100644 --- a/osu.Game.Tests/Visual/Collections/TestSceneManageCollectionsDialog.cs +++ b/osu.Game.Tests/Visual/Collections/TestSceneManageCollectionsDialog.cs @@ -140,12 +140,12 @@ namespace osu.Game.Tests.Visual.Collections AddStep("add dropdown", () => { Add(new CollectionFilterDropdown - { - Anchor = Anchor.TopRight, - Origin = Anchor.TopRight, - RelativeSizeAxes = Axes.X, - Width = 0.4f, - } + { + Anchor = Anchor.TopRight, + Origin = Anchor.TopRight, + RelativeSizeAxes = Axes.X, + Width = 0.4f, + } ); }); AddStep("add two collections with same name", () => manager.Collections.AddRange(new[]