mirror of
https://github.com/ppy/osu
synced 2024-12-28 09:52:56 +00:00
Remove passed in BaetDivisor
This commit is contained in:
parent
098d643955
commit
ccf911884b
@ -262,21 +262,21 @@ namespace osu.Game.Rulesets.Edit
|
||||
|
||||
public override float DurationToDistance(double referenceTime, double duration)
|
||||
{
|
||||
double beatLength = beatSnapProvider.GetBeatLengthAtTime(referenceTime, beatSnapProvider.BeatDivisor);
|
||||
double beatLength = beatSnapProvider.GetBeatLengthAtTime(referenceTime);
|
||||
return (float)(duration / beatLength * GetBeatSnapDistanceAt(referenceTime));
|
||||
}
|
||||
|
||||
public override double DistanceToDuration(double referenceTime, float distance)
|
||||
{
|
||||
double beatLength = beatSnapProvider.GetBeatLengthAtTime(referenceTime, beatSnapProvider.BeatDivisor);
|
||||
double beatLength = beatSnapProvider.GetBeatLengthAtTime(referenceTime);
|
||||
return distance / GetBeatSnapDistanceAt(referenceTime) * beatLength;
|
||||
}
|
||||
|
||||
public override double GetSnappedDurationFromDistance(double referenceTime, float distance)
|
||||
=> beatSnapProvider.SnapTime(referenceTime, DistanceToDuration(referenceTime, distance), beatSnapProvider.BeatDivisor);
|
||||
=> beatSnapProvider.SnapTime(referenceTime, DistanceToDuration(referenceTime, distance));
|
||||
|
||||
public override float GetSnappedDistanceFromDistance(double referenceTime, float distance)
|
||||
=> DurationToDistance(referenceTime, beatSnapProvider.SnapTime(referenceTime, DistanceToDuration(referenceTime, distance), beatSnapProvider.BeatDivisor));
|
||||
=> DurationToDistance(referenceTime, beatSnapProvider.SnapTime(referenceTime, DistanceToDuration(referenceTime, distance)));
|
||||
|
||||
protected override void Dispose(bool isDisposing)
|
||||
{
|
||||
|
@ -10,17 +10,15 @@ namespace osu.Game.Rulesets.Edit
|
||||
/// </summary>
|
||||
/// <param name="referenceTime">The time of the timing point which <paramref name="duration"/> resides in.</param>
|
||||
/// <param name="duration">The duration to snap.</param>
|
||||
/// <param name="beatDivisor">The divisor to use for snapping purposes.</param>
|
||||
/// <returns>A value that represents <paramref name="duration"/> snapped to the closest beat of the timing point.</returns>
|
||||
double SnapTime(double referenceTime, double duration, int beatDivisor);
|
||||
double SnapTime(double referenceTime, double duration);
|
||||
|
||||
/// <summary>
|
||||
/// Get the most appropriate beat length at a given time.
|
||||
/// </summary>
|
||||
/// <param name="referenceTime">A reference time used for lookup.</param>
|
||||
/// <param name="beatDivisor">The divisor to use for snapping purposes.</param>
|
||||
/// <returns>The most appropriate beat length.</returns>
|
||||
double GetBeatLengthAtTime(double referenceTime, int beatDivisor);
|
||||
double GetBeatLengthAtTime(double referenceTime);
|
||||
|
||||
/// <summary>
|
||||
/// Returns the current beat divisor.
|
||||
|
@ -353,9 +353,9 @@ namespace osu.Game.Screens.Edit
|
||||
beatmapManager.Export(Beatmap.Value.BeatmapSetInfo);
|
||||
}
|
||||
|
||||
public double SnapTime(double referenceTime, double duration, int beatDivisor) => editorBeatmap.SnapTime(referenceTime, duration, beatDivisor);
|
||||
public double SnapTime(double referenceTime, double duration) => editorBeatmap.SnapTime(referenceTime, duration);
|
||||
|
||||
public double GetBeatLengthAtTime(double referenceTime, int beatDivisor) => editorBeatmap.GetBeatLengthAtTime(referenceTime, beatDivisor);
|
||||
public double GetBeatLengthAtTime(double referenceTime) => editorBeatmap.GetBeatLengthAtTime(referenceTime);
|
||||
|
||||
public int BeatDivisor => beatDivisor.Value;
|
||||
}
|
||||
|
@ -126,15 +126,15 @@ namespace osu.Game.Screens.Edit
|
||||
return list.Count - 1;
|
||||
}
|
||||
|
||||
public double SnapTime(double referenceTime, double duration, int beatDivisor)
|
||||
public double SnapTime(double referenceTime, double duration)
|
||||
{
|
||||
double beatLength = GetBeatLengthAtTime(referenceTime, beatDivisor);
|
||||
double beatLength = GetBeatLengthAtTime(referenceTime);
|
||||
|
||||
// A 1ms offset prevents rounding errors due to minute variations in duration
|
||||
return (int)((duration + 1) / beatLength) * beatLength;
|
||||
}
|
||||
|
||||
public double GetBeatLengthAtTime(double referenceTime, int beatDivisor) => ControlPointInfo.TimingPointAt(referenceTime).BeatLength / BeatDivisor;
|
||||
public double GetBeatLengthAtTime(double referenceTime) => ControlPointInfo.TimingPointAt(referenceTime).BeatLength / BeatDivisor;
|
||||
|
||||
public int BeatDivisor => beatDivisor?.Value ?? 1;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user