diff --git a/osu.Game.Rulesets.Mania.Tests/Editor/ManiaPlacementBlueprintTestScene.cs b/osu.Game.Rulesets.Mania.Tests/Editor/ManiaPlacementBlueprintTestScene.cs index 8a605a7ca3..c04b875245 100644 --- a/osu.Game.Rulesets.Mania.Tests/Editor/ManiaPlacementBlueprintTestScene.cs +++ b/osu.Game.Rulesets.Mania.Tests/Editor/ManiaPlacementBlueprintTestScene.cs @@ -31,7 +31,7 @@ public abstract class ManiaPlacementBlueprintTestScene : PlacementBlueprintTestS private IScrollingInfo scrollingInfo; [Cached] - protected readonly Bindable configColourCodedNotes = new Bindable(); + protected readonly Bindable ConfigColourCodedNotes = new Bindable(); protected ManiaPlacementBlueprintTestScene() { @@ -50,7 +50,7 @@ protected ManiaPlacementBlueprintTestScene() private void load(RulesetConfigCache configCache) { var config = (ManiaRulesetConfigManager)configCache.GetConfigFor(Ruleset.Value.CreateInstance()); - config.BindWith(ManiaRulesetSetting.ColourCodedNotes, configColourCodedNotes); + config.BindWith(ManiaRulesetSetting.ColourCodedNotes, ConfigColourCodedNotes); } protected override SnapResult SnapForBlueprint(PlacementBlueprint blueprint) diff --git a/osu.Game.Rulesets.Mania.Tests/Editor/ManiaSelectionBlueprintTestScene.cs b/osu.Game.Rulesets.Mania.Tests/Editor/ManiaSelectionBlueprintTestScene.cs index 854d0fb14e..1c11dc397e 100644 --- a/osu.Game.Rulesets.Mania.Tests/Editor/ManiaSelectionBlueprintTestScene.cs +++ b/osu.Game.Rulesets.Mania.Tests/Editor/ManiaSelectionBlueprintTestScene.cs @@ -18,7 +18,7 @@ public abstract class ManiaSelectionBlueprintTestScene : SelectionBlueprintTestS private readonly IAdjustableClock clock = new StopwatchClock(); [Cached] - protected readonly Bindable configColourCodedNotes = new Bindable(); + protected readonly Bindable ConfigColourCodedNotes = new Bindable(); protected ManiaSelectionBlueprintTestScene() { @@ -35,7 +35,7 @@ protected ManiaSelectionBlueprintTestScene() private void load(RulesetConfigCache configCache) { var config = (ManiaRulesetConfigManager)configCache.GetConfigFor(Ruleset.Value.CreateInstance()); - config.BindWith(ManiaRulesetSetting.ColourCodedNotes, configColourCodedNotes); + config.BindWith(ManiaRulesetSetting.ColourCodedNotes, ConfigColourCodedNotes); } public ManiaPlayfield Playfield => null; diff --git a/osu.Game.Rulesets.Mania.Tests/ManiaInputTestScene.cs b/osu.Game.Rulesets.Mania.Tests/ManiaInputTestScene.cs index f54d90016c..2b2db8aa96 100644 --- a/osu.Game.Rulesets.Mania.Tests/ManiaInputTestScene.cs +++ b/osu.Game.Rulesets.Mania.Tests/ManiaInputTestScene.cs @@ -17,7 +17,7 @@ public abstract class ManiaInputTestScene : OsuTestScene protected override Container Content => content ?? base.Content; [Cached] - protected readonly Bindable configColourCodedNotes = new Bindable(); + protected readonly Bindable ConfigColourCodedNotes = new Bindable(); protected ManiaInputTestScene(int keys) { @@ -28,7 +28,7 @@ protected ManiaInputTestScene(int keys) private void load(RulesetConfigCache configCache) { var config = (ManiaRulesetConfigManager)configCache.GetConfigFor(Ruleset.Value.CreateInstance()); - config.BindWith(ManiaRulesetSetting.ColourCodedNotes, configColourCodedNotes); + config.BindWith(ManiaRulesetSetting.ColourCodedNotes, ConfigColourCodedNotes); } private class LocalInputManager : ManiaInputManager diff --git a/osu.Game.Rulesets.Mania.Tests/Skinning/ManiaSkinnableTestScene.cs b/osu.Game.Rulesets.Mania.Tests/Skinning/ManiaSkinnableTestScene.cs index 05f07bad12..941d01a1d6 100644 --- a/osu.Game.Rulesets.Mania.Tests/Skinning/ManiaSkinnableTestScene.cs +++ b/osu.Game.Rulesets.Mania.Tests/Skinning/ManiaSkinnableTestScene.cs @@ -26,7 +26,7 @@ public abstract class ManiaSkinnableTestScene : SkinnableTestScene private readonly TestScrollingInfo scrollingInfo = new TestScrollingInfo(); [Cached] - protected readonly Bindable configColourCodedNotes = new Bindable(); + protected readonly Bindable ConfigColourCodedNotes = new Bindable(); protected override Ruleset CreateRulesetForSkinProvider() => new ManiaRuleset(); @@ -46,7 +46,7 @@ protected ManiaSkinnableTestScene() private void load(RulesetConfigCache configCache) { var config = (ManiaRulesetConfigManager)configCache.GetConfigFor(Ruleset.Value.CreateInstance()); - config.BindWith(ManiaRulesetSetting.ColourCodedNotes, configColourCodedNotes); + config.BindWith(ManiaRulesetSetting.ColourCodedNotes, ConfigColourCodedNotes); } [Test] diff --git a/osu.Game.Rulesets.Mania.Tests/TestSceneNotes.cs b/osu.Game.Rulesets.Mania.Tests/TestSceneNotes.cs index 9828db7687..1d053688a2 100644 --- a/osu.Game.Rulesets.Mania.Tests/TestSceneNotes.cs +++ b/osu.Game.Rulesets.Mania.Tests/TestSceneNotes.cs @@ -31,13 +31,13 @@ namespace osu.Game.Rulesets.Mania.Tests public class TestSceneNotes : OsuTestScene { [Cached] - protected readonly Bindable configColourCodedNotes = new Bindable(); + protected readonly Bindable ConfigColourCodedNotes = new Bindable(); [BackgroundDependencyLoader] private void load(RulesetConfigCache configCache) { var config = (ManiaRulesetConfigManager)configCache.GetConfigFor(Ruleset.Value.CreateInstance()); - config.BindWith(ManiaRulesetSetting.ColourCodedNotes, configColourCodedNotes); + config.BindWith(ManiaRulesetSetting.ColourCodedNotes, ConfigColourCodedNotes); } [Test] diff --git a/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableNote.cs b/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableNote.cs index cfae01f5f2..04c4b06c88 100644 --- a/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableNote.cs +++ b/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableNote.cs @@ -1,7 +1,6 @@ // 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 System.Diagnostics; using osu.Framework.Allocation; using osu.Framework.Bindables; @@ -64,8 +63,8 @@ protected override void LoadComplete() { HitObject.StartTimeBindable.BindValueChanged(_ => Snap = snapFinder.FindSnap(HitObject), true); - SnapBindable.BindValueChanged(snap => UpdateSnapColour(configColourCodedNotes.Value, snap.NewValue), true); - configColourCodedNotes.BindValueChanged(colourCode => UpdateSnapColour(colourCode.NewValue, Snap)); + SnapBindable.BindValueChanged(snap => updateSnapColour(configColourCodedNotes.Value, snap.NewValue), true); + configColourCodedNotes.BindValueChanged(colourCode => updateSnapColour(colourCode.NewValue, Snap)); } } @@ -109,7 +108,7 @@ public virtual void OnReleased(ManiaAction action) { } - private void UpdateSnapColour(bool colourCode, int snap) + private void updateSnapColour(bool colourCode, int snap) { if (colourCode) { diff --git a/osu.Game.Rulesets.Mania/UI/DrawableManiaRuleset.cs b/osu.Game.Rulesets.Mania/UI/DrawableManiaRuleset.cs index 818d6429e4..17535c9bc9 100644 --- a/osu.Game.Rulesets.Mania/UI/DrawableManiaRuleset.cs +++ b/osu.Game.Rulesets.Mania/UI/DrawableManiaRuleset.cs @@ -56,7 +56,7 @@ public class DrawableManiaRuleset : DrawableScrollingRuleset protected new ManiaRulesetConfigManager Config => (ManiaRulesetConfigManager)base.Config; [Cached] - protected readonly Bindable configColourCodedNotes = new Bindable(); + protected readonly Bindable ConfigColourCodedNotes = new Bindable(); public ScrollVisualisationMethod ScrollMethod { @@ -114,7 +114,7 @@ private void load() Config.BindWith(ManiaRulesetSetting.ScrollTime, configTimeRange); - Config.BindWith(ManiaRulesetSetting.ColourCodedNotes, configColourCodedNotes); + Config.BindWith(ManiaRulesetSetting.ColourCodedNotes, ConfigColourCodedNotes); } protected override void AdjustScrollSpeed(int amount) diff --git a/osu.Game.Rulesets.Mania/Utils/SnapFinder.cs b/osu.Game.Rulesets.Mania/Utils/SnapFinder.cs index 01a9339552..83df0eb756 100644 --- a/osu.Game.Rulesets.Mania/Utils/SnapFinder.cs +++ b/osu.Game.Rulesets.Mania/Utils/SnapFinder.cs @@ -11,7 +11,8 @@ namespace osu.Game.Rulesets.Mania.Utils { public class SnapFinder { - private ManiaBeatmap beatmap; + private readonly ManiaBeatmap beatmap; + public SnapFinder(ManiaBeatmap beatmap) { this.beatmap = beatmap; @@ -20,42 +21,41 @@ public SnapFinder(ManiaBeatmap beatmap) public int FindSnap(HitObject hitObject) { TimingControlPoint currentTimingPoint = beatmap.ControlPointInfo.TimingPointAt(hitObject.StartTime); - int timeSignature = (int)currentTimingPoint.TimeSignature; double startTime = currentTimingPoint.Time; double secondsPerFourCounts = currentTimingPoint.BeatLength * 4; double offset = startTime % secondsPerFourCounts; double snapResult = hitObject.StartTime % secondsPerFourCounts - offset; - if (AlmostDivisibleBy(snapResult, secondsPerFourCounts / 4.0)) + if (almostDivisibleBy(snapResult, secondsPerFourCounts / 4.0)) { return 1; } - else if (AlmostDivisibleBy(snapResult, secondsPerFourCounts / 8.0)) + else if (almostDivisibleBy(snapResult, secondsPerFourCounts / 8.0)) { return 2; } - else if (AlmostDivisibleBy(snapResult, secondsPerFourCounts / 12.0)) + else if (almostDivisibleBy(snapResult, secondsPerFourCounts / 12.0)) { return 3; } - else if (AlmostDivisibleBy(snapResult, secondsPerFourCounts / 16.0)) + else if (almostDivisibleBy(snapResult, secondsPerFourCounts / 16.0)) { return 4; } - else if (AlmostDivisibleBy(snapResult, secondsPerFourCounts / 24.0)) + else if (almostDivisibleBy(snapResult, secondsPerFourCounts / 24.0)) { return 6; } - else if (AlmostDivisibleBy(snapResult, secondsPerFourCounts / 32.0)) + else if (almostDivisibleBy(snapResult, secondsPerFourCounts / 32.0)) { return 8; } - else if (AlmostDivisibleBy(snapResult, secondsPerFourCounts / 48.0)) + else if (almostDivisibleBy(snapResult, secondsPerFourCounts / 48.0)) { return 12; } - else if (AlmostDivisibleBy(snapResult, secondsPerFourCounts / 64.0)) + else if (almostDivisibleBy(snapResult, secondsPerFourCounts / 64.0)) { return 16; } @@ -65,11 +65,12 @@ public int FindSnap(HitObject hitObject) } } - private const double LENIENCY_MS = 1.0; - private static bool AlmostDivisibleBy(double dividend, double divisor) + 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); + return Precision.AlmostEquals(remainder, 0, leniency_ms) || Precision.AlmostEquals(remainder - divisor, 0, leniency_ms); } } }