Rename methods to match generally how these find-methods are named elsewhere

This commit is contained in:
Dean Herbert 2021-04-28 16:57:52 +09:00
parent 48d6c9ac4b
commit f3c7694eeb
4 changed files with 10 additions and 10 deletions

View File

@ -85,7 +85,7 @@ namespace osu.Game.Tests.NonVisual
}; };
for (int i = 0; i < divisors.Count; ++i) for (int i = 0; i < divisors.Count; ++i)
Assert.AreEqual(closestDivisors[i], beatmap.ControlPointInfo.ClosestBeatDivisor(beatmap.HitObjects[i].StartTime), $"at index {i}"); Assert.AreEqual(closestDivisors[i], beatmap.ControlPointInfo.GetClosestBeatDivisor(beatmap.HitObjects[i].StartTime), $"at index {i}");
} }
} }
} }

View File

@ -167,7 +167,7 @@ namespace osu.Game.Beatmaps.ControlPoints
/// <param name="time">The time to find the closest snapped time to.</param> /// <param name="time">The time to find the closest snapped time to.</param>
/// <param name="beatDivisor">The beat divisor to snap to.</param> /// <param name="beatDivisor">The beat divisor to snap to.</param>
/// <param name="referenceTime">An optional reference point to use for timing point lookup.</param> /// <param name="referenceTime">An optional reference point to use for timing point lookup.</param>
public int ClosestSnapTime(double time, int beatDivisor, double? referenceTime = null) public int GetClosestSnappedTime(double time, int beatDivisor, double? referenceTime = null)
{ {
var timingPoint = TimingPointAt(referenceTime ?? time); var timingPoint = TimingPointAt(referenceTime ?? time);
var beatLength = timingPoint.BeatLength / beatDivisor; var beatLength = timingPoint.BeatLength / beatDivisor;
@ -182,9 +182,9 @@ namespace osu.Game.Beatmaps.ControlPoints
/// </summary> /// </summary>
/// <param name="time">The time to find the closest snapped time to.</param> /// <param name="time">The time to find the closest snapped time to.</param>
/// <param name="referenceTime">An optional reference point to use for timing point lookup.</param> /// <param name="referenceTime">An optional reference point to use for timing point lookup.</param>
public int ClosestSnapTime(double time, double? referenceTime = null) public int GetClosestSnappedTime(double time, double? referenceTime = null)
{ {
return ClosestSnapTime(time, ClosestBeatDivisor(time, referenceTime), referenceTime); return GetClosestSnappedTime(time, GetClosestBeatDivisor(time, referenceTime), referenceTime);
} }
/// <summary> /// <summary>
@ -192,9 +192,9 @@ namespace osu.Game.Beatmaps.ControlPoints
/// </summary> /// </summary>
/// <param name="time">The time to find the closest beat snap divisor to.</param> /// <param name="time">The time to find the closest beat snap divisor to.</param>
/// <param name="referenceTime">An optional reference point to use for timing point lookup.</param> /// <param name="referenceTime">An optional reference point to use for timing point lookup.</param>
public int ClosestBeatDivisor(double time, double? referenceTime = null) public int GetClosestBeatDivisor(double time, double? referenceTime = null)
{ {
double getUnsnap(int divisor) => Math.Abs(time - ClosestSnapTime(time, divisor, referenceTime)); double getUnsnap(int divisor) => Math.Abs(time - GetClosestSnappedTime(time, divisor, referenceTime));
int[] divisors = BindableBeatDivisor.VALID_DIVISORS; int[] divisors = BindableBeatDivisor.VALID_DIVISORS;
double smallestUnsnap = divisors.Min(getUnsnap); double smallestUnsnap = divisors.Min(getUnsnap);

View File

@ -28,7 +28,7 @@ namespace osu.Game.Rulesets.Edit.Checks
foreach (var hitobject in playableBeatmap.HitObjects) foreach (var hitobject in playableBeatmap.HitObjects)
{ {
double startUnsnap = hitobject.StartTime - controlPointInfo.ClosestSnapTime(hitobject.StartTime); double startUnsnap = hitobject.StartTime - controlPointInfo.GetClosestSnappedTime(hitobject.StartTime);
string startPostfix = hitobject is IHasDuration ? "start" : ""; string startPostfix = hitobject is IHasDuration ? "start" : "";
foreach (var issue in getUnsnapIssues(hitobject, startUnsnap, hitobject.StartTime, startPostfix)) foreach (var issue in getUnsnapIssues(hitobject, startUnsnap, hitobject.StartTime, startPostfix))
yield return issue; yield return issue;
@ -39,7 +39,7 @@ namespace osu.Game.Rulesets.Edit.Checks
{ {
double spanDuration = hasRepeats.Duration / (hasRepeats.RepeatCount + 1); double spanDuration = hasRepeats.Duration / (hasRepeats.RepeatCount + 1);
double repeatTime = hitobject.StartTime + spanDuration * (repeatIndex + 1); double repeatTime = hitobject.StartTime + spanDuration * (repeatIndex + 1);
double repeatUnsnap = repeatTime - controlPointInfo.ClosestSnapTime(repeatTime); double repeatUnsnap = repeatTime - controlPointInfo.GetClosestSnappedTime(repeatTime);
foreach (var issue in getUnsnapIssues(hitobject, repeatUnsnap, repeatTime, "repeat")) foreach (var issue in getUnsnapIssues(hitobject, repeatUnsnap, repeatTime, "repeat"))
yield return issue; yield return issue;
} }
@ -47,7 +47,7 @@ namespace osu.Game.Rulesets.Edit.Checks
if (hitobject is IHasDuration hasDuration) if (hitobject is IHasDuration hasDuration)
{ {
double endUnsnap = hasDuration.EndTime - controlPointInfo.ClosestSnapTime(hasDuration.EndTime); double endUnsnap = hasDuration.EndTime - controlPointInfo.GetClosestSnappedTime(hasDuration.EndTime);
foreach (var issue in getUnsnapIssues(hitobject, endUnsnap, hasDuration.EndTime, "end")) foreach (var issue in getUnsnapIssues(hitobject, endUnsnap, hasDuration.EndTime, "end"))
yield return issue; yield return issue;
} }

View File

@ -301,7 +301,7 @@ namespace osu.Game.Screens.Edit
return list.Count - 1; return list.Count - 1;
} }
public double SnapTime(double time, double? referenceTime) => ControlPointInfo.ClosestSnapTime(time, BeatDivisor, referenceTime); public double SnapTime(double time, double? referenceTime) => ControlPointInfo.GetClosestSnappedTime(time, BeatDivisor, referenceTime);
public double GetBeatLengthAtTime(double referenceTime) => ControlPointInfo.TimingPointAt(referenceTime).BeatLength / BeatDivisor; public double GetBeatLengthAtTime(double referenceTime) => ControlPointInfo.TimingPointAt(referenceTime).BeatLength / BeatDivisor;