diff --git a/osu.Game.Tests/Visual/TestCaseEditorSeekSnapping.cs b/osu.Game.Tests/Visual/TestCaseEditorSeekSnapping.cs index bfdb39dd5e..e9e966a826 100644 --- a/osu.Game.Tests/Visual/TestCaseEditorSeekSnapping.cs +++ b/osu.Game.Tests/Visual/TestCaseEditorSeekSnapping.cs @@ -18,6 +18,7 @@ using osu.Game.Rulesets.Edit; using osu.Game.Rulesets.Edit.Tools; using osu.Game.Rulesets.Osu; using osu.Game.Rulesets.Osu.Objects; +using osu.Game.Screens.Edit.Screens.Compose; using osu.Game.Tests.Beatmaps; using OpenTK; using OpenTK.Graphics; @@ -31,6 +32,8 @@ namespace osu.Game.Tests.Visual private Track track; private HitObjectComposer composer; + private readonly BindableBeatDivisor beatDivisor = new BindableBeatDivisor(4); + private DecoupleableInterpolatingFramedClock clock; private DependencyContainer dependencies; @@ -44,6 +47,7 @@ namespace osu.Game.Tests.Visual clock = new DecoupleableInterpolatingFramedClock { IsCoupled = false }; dependencies.CacheAs(clock); dependencies.CacheAs(clock); + dependencies.Cache(beatDivisor); var testBeatmap = new Beatmap { diff --git a/osu.Game.Tests/Visual/TestCaseEditorSelectionLayer.cs b/osu.Game.Tests/Visual/TestCaseEditorSelectionLayer.cs index bbbfef477a..62289ea7cd 100644 --- a/osu.Game.Tests/Visual/TestCaseEditorSelectionLayer.cs +++ b/osu.Game.Tests/Visual/TestCaseEditorSelectionLayer.cs @@ -14,6 +14,7 @@ using osu.Game.Rulesets.Osu; using osu.Game.Rulesets.Osu.Edit; using osu.Game.Rulesets.Osu.Edit.Layers.Selection.Overlays; using osu.Game.Rulesets.Osu.Objects; +using osu.Game.Screens.Edit.Screens.Compose; using osu.Game.Screens.Edit.Screens.Compose.Layers; using osu.Game.Tests.Beatmaps; @@ -68,6 +69,7 @@ namespace osu.Game.Tests.Visual var clock = new DecoupleableInterpolatingFramedClock { IsCoupled = false }; dependencies.CacheAs(clock); dependencies.CacheAs(clock); + dependencies.Cache(new BindableBeatDivisor()); Child = new OsuHitObjectComposer(new OsuRuleset()); } diff --git a/osu.Game/Rulesets/Edit/HitObjectComposer.cs b/osu.Game/Rulesets/Edit/HitObjectComposer.cs index ae1c8af1a4..7ab9ff9164 100644 --- a/osu.Game/Rulesets/Edit/HitObjectComposer.cs +++ b/osu.Game/Rulesets/Edit/HitObjectComposer.cs @@ -16,6 +16,7 @@ using osu.Game.Beatmaps; using osu.Game.Rulesets.Edit.Tools; using osu.Game.Rulesets.Objects.Drawables; using osu.Game.Rulesets.UI; +using osu.Game.Screens.Edit.Screens.Compose; using osu.Game.Screens.Edit.Screens.Compose.Layers; using osu.Game.Screens.Edit.Screens.Compose.RadioButtons; @@ -31,6 +32,7 @@ namespace osu.Game.Rulesets.Edit private readonly List layerContainers = new List(); private readonly Bindable beatmap = new Bindable(); + private readonly Bindable beatDivisor = new Bindable(); private IAdjustableClock adjustableClock; @@ -42,9 +44,10 @@ namespace osu.Game.Rulesets.Edit } [BackgroundDependencyLoader] - private void load(OsuGameBase osuGame, IAdjustableClock adjustableClock, IFrameBasedClock framedClock) + private void load(OsuGameBase osuGame, IAdjustableClock adjustableClock, IFrameBasedClock framedClock, BindableBeatDivisor beatDivisor) { this.adjustableClock = adjustableClock; + this.beatDivisor.BindTo(beatDivisor); beatmap.BindTo(osuGame.Beatmap); @@ -167,9 +170,6 @@ namespace osu.Game.Rulesets.Edit private void seek(int direction, bool snapped) { - // Todo: This should not be a constant, but feels good for now - const int beat_snap_divisor = 4; - var cpi = beatmap.Value.Beatmap.ControlPointInfo; var timingPoint = cpi.TimingPointAt(adjustableClock.CurrentTime); @@ -181,7 +181,7 @@ namespace osu.Game.Rulesets.Edit timingPoint = cpi.TimingPoints[--activeIndex]; } - double seekAmount = timingPoint.BeatLength / beat_snap_divisor; + double seekAmount = timingPoint.BeatLength / beatDivisor; double seekTime = adjustableClock.CurrentTime + seekAmount * direction; if (!snapped || cpi.TimingPoints.Count == 0) @@ -222,9 +222,6 @@ namespace osu.Game.Rulesets.Edit public void SeekTo(double seekTime, bool snapped = false) { - // Todo: This should not be a constant, but feels good for now - const int beat_snap_divisor = 4; - if (!snapped) { adjustableClock.Seek(seekTime); @@ -232,7 +229,7 @@ namespace osu.Game.Rulesets.Edit } var timingPoint = beatmap.Value.Beatmap.ControlPointInfo.TimingPointAt(seekTime); - double beatSnapLength = timingPoint.BeatLength / beat_snap_divisor; + double beatSnapLength = timingPoint.BeatLength / beatDivisor; // We will be snapping to beats within the timing point seekTime -= timingPoint.Time; diff --git a/osu.Game/Screens/Edit/Screens/Compose/BindableBeatDivisor.cs b/osu.Game/Screens/Edit/Screens/Compose/BindableBeatDivisor.cs index eb68bce71b..df2521dc10 100644 --- a/osu.Game/Screens/Edit/Screens/Compose/BindableBeatDivisor.cs +++ b/osu.Game/Screens/Edit/Screens/Compose/BindableBeatDivisor.cs @@ -7,8 +7,8 @@ namespace osu.Game.Screens.Edit.Screens.Compose { public class BindableBeatDivisor : Bindable { - public BindableBeatDivisor() - : base(1) + public BindableBeatDivisor(int value = 1) + : base(value) { } }