mirror of
https://github.com/ppy/osu.git
synced 2025-03-28 10:17:19 +08:00
Re-order methods
This commit is contained in:
parent
c937ef5d24
commit
fc15c63a88
@ -168,36 +168,6 @@ namespace osu.Game.Rulesets.Edit
|
|||||||
/// <param name="snapped">Whether to snap to the closest beat.</param>
|
/// <param name="snapped">Whether to snap to the closest beat.</param>
|
||||||
public void SeekForward(bool snapped = false) => seek(1, snapped);
|
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)
|
private void seek(int direction, bool snapped)
|
||||||
{
|
{
|
||||||
// Todo: This should not be a constant, but feels good for now
|
// Todo: This should not be a constant, but feels good for now
|
||||||
@ -253,6 +223,36 @@ namespace osu.Game.Rulesets.Edit
|
|||||||
adjustableClock.Seek(seekTime);
|
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;
|
private void setCompositionTool(ICompositionTool tool) => CurrentTool = tool;
|
||||||
|
|
||||||
protected virtual RulesetContainer CreateRulesetContainer(Ruleset ruleset, WorkingBeatmap beatmap) => ruleset.CreateRulesetContainerWith(beatmap, true);
|
protected virtual RulesetContainer CreateRulesetContainer(Ruleset ruleset, WorkingBeatmap beatmap) => ruleset.CreateRulesetContainerWith(beatmap, true);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user