Remove passed in BaetDivisor

This commit is contained in:
Dean Herbert 2020-01-23 15:31:56 +09:00
parent 098d643955
commit ccf911884b
4 changed files with 11 additions and 13 deletions

View File

@ -262,21 +262,21 @@ namespace osu.Game.Rulesets.Edit
public override float DurationToDistance(double referenceTime, double duration) 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)); return (float)(duration / beatLength * GetBeatSnapDistanceAt(referenceTime));
} }
public override double DistanceToDuration(double referenceTime, float distance) 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; return distance / GetBeatSnapDistanceAt(referenceTime) * beatLength;
} }
public override double GetSnappedDurationFromDistance(double referenceTime, float distance) 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) 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) protected override void Dispose(bool isDisposing)
{ {

View File

@ -10,17 +10,15 @@ namespace osu.Game.Rulesets.Edit
/// </summary> /// </summary>
/// <param name="referenceTime">The time of the timing point which <paramref name="duration"/> resides in.</param> /// <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="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> /// <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> /// <summary>
/// Get the most appropriate beat length at a given time. /// Get the most appropriate beat length at a given time.
/// </summary> /// </summary>
/// <param name="referenceTime">A reference time used for lookup.</param> /// <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> /// <returns>The most appropriate beat length.</returns>
double GetBeatLengthAtTime(double referenceTime, int beatDivisor); double GetBeatLengthAtTime(double referenceTime);
/// <summary> /// <summary>
/// Returns the current beat divisor. /// Returns the current beat divisor.

View File

@ -353,9 +353,9 @@ namespace osu.Game.Screens.Edit
beatmapManager.Export(Beatmap.Value.BeatmapSetInfo); 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; public int BeatDivisor => beatDivisor.Value;
} }

View File

@ -126,15 +126,15 @@ namespace osu.Game.Screens.Edit
return list.Count - 1; 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 // A 1ms offset prevents rounding errors due to minute variations in duration
return (int)((duration + 1) / beatLength) * beatLength; 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; public int BeatDivisor => beatDivisor?.Value ?? 1;
} }