diff --git a/osu.Game/Rulesets/Edit/HitObjectComposer.cs b/osu.Game/Rulesets/Edit/HitObjectComposer.cs index 12529c9eac..8cb6caaa12 100644 --- a/osu.Game/Rulesets/Edit/HitObjectComposer.cs +++ b/osu.Game/Rulesets/Edit/HitObjectComposer.cs @@ -168,36 +168,6 @@ namespace osu.Game.Rulesets.Edit /// Whether to snap to the closest beat. public void SeekForward(bool snapped = false) => seek(1, snapped); - 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); - return; - } - - var timingPoint = beatmap.Value.Beatmap.ControlPointInfo.TimingPointAt(seekTime); - double beatSnapLength = timingPoint.BeatLength / beat_snap_divisor; - - // We will be snapping to beats within the timing point - seekTime -= timingPoint.Time; - - // Determine the index from the current timing point of the closest beat to seekTime - int closestBeat = (int)Math.Round(seekTime / beatSnapLength); - seekTime = timingPoint.Time + closestBeat * beatSnapLength; - - // Depending on beatSnapLength, we may snap to a beat that is beyond timingPoint's end time, but we want to instead snap to - // the next timing point's start time - var nextTimingPoint = beatmap.Value.Beatmap.ControlPointInfo.TimingPoints.FirstOrDefault(t => t.Time > timingPoint.Time); - if (seekTime > nextTimingPoint?.Time) - seekTime = nextTimingPoint.Time; - - adjustableClock.Seek(seekTime); - } - private void seek(int direction, bool snapped) { // Todo: This should not be a constant, but feels good for now @@ -253,6 +223,36 @@ namespace osu.Game.Rulesets.Edit adjustableClock.Seek(seekTime); } + 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); + return; + } + + var timingPoint = beatmap.Value.Beatmap.ControlPointInfo.TimingPointAt(seekTime); + double beatSnapLength = timingPoint.BeatLength / beat_snap_divisor; + + // We will be snapping to beats within the timing point + seekTime -= timingPoint.Time; + + // Determine the index from the current timing point of the closest beat to seekTime + int closestBeat = (int)Math.Round(seekTime / beatSnapLength); + seekTime = timingPoint.Time + closestBeat * beatSnapLength; + + // Depending on beatSnapLength, we may snap to a beat that is beyond timingPoint's end time, but we want to instead snap to + // the next timing point's start time + var nextTimingPoint = beatmap.Value.Beatmap.ControlPointInfo.TimingPoints.FirstOrDefault(t => t.Time > timingPoint.Time); + if (seekTime > nextTimingPoint?.Time) + seekTime = nextTimingPoint.Time; + + adjustableClock.Seek(seekTime); + } + private void setCompositionTool(ICompositionTool tool) => CurrentTool = tool; protected virtual RulesetContainer CreateRulesetContainer(Ruleset ruleset, WorkingBeatmap beatmap) => ruleset.CreateRulesetContainerWith(beatmap, true);