From eaa171baf47fbc82ef77c44135aa9042091bd581 Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Mon, 17 Apr 2017 20:02:36 +0900 Subject: [PATCH] Rewrite bar lines to make sure they're centered at their beat's start position. --- osu.Game.Modes.Taiko/UI/TaikoHitRenderer.cs | 64 +++++++-------------- 1 file changed, 22 insertions(+), 42 deletions(-) diff --git a/osu.Game.Modes.Taiko/UI/TaikoHitRenderer.cs b/osu.Game.Modes.Taiko/UI/TaikoHitRenderer.cs index 32476dff7f..a7968a10dd 100644 --- a/osu.Game.Modes.Taiko/UI/TaikoHitRenderer.cs +++ b/osu.Game.Modes.Taiko/UI/TaikoHitRenderer.cs @@ -2,10 +2,8 @@ // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE using osu.Framework.Allocation; -using osu.Framework.MathUtils; using osu.Framework.Graphics; using osu.Game.Beatmaps; -using osu.Game.Beatmaps.Timing; using osu.Game.Modes.Objects.Drawables; using osu.Game.Modes.Objects.Types; using osu.Game.Modes.Replays; @@ -49,55 +47,37 @@ namespace osu.Game.Modes.Taiko.UI if (timingPoints.Count == 0) return; - int currentIndex = 0; - - while (currentIndex < timingPoints.Count && Precision.AlmostEquals(timingPoints[currentIndex].BeatLength, 0)) - currentIndex++; - - double time = timingPoints[currentIndex].Time; - double measureLength = timingPoints[currentIndex].BeatLength * (int)timingPoints[currentIndex].TimeSignature; - - // Find the bar line time closest to 0 - time -= measureLength * (int)(time / measureLength); - - // Always start barlines from a positive time - while (time < 0) - time += measureLength; - + int currentTimingPoint = 0; int currentBeat = 0; + double time = timingPoints[currentTimingPoint].Time; while (time <= lastHitTime) - { - ControlPoint current = timingPoints[currentIndex]; - - if (time > current.Time || current.OmitFirstBarLine) + { + int nextTimingPoint = currentTimingPoint + 1; + if (nextTimingPoint < timingPoints.Count && time > timingPoints[nextTimingPoint].Time) { - bool isMajor = currentBeat % (int)current.TimeSignature == 0; - - var barLine = new BarLine - { - StartTime = time, - }; - - barLine.ApplyDefaults(Beatmap.TimingInfo, Beatmap.BeatmapInfo.Difficulty); - - taikoPlayfield.AddBarLine(isMajor ? new DrawableBarLineMajor(barLine) : new DrawableBarLine(barLine)); - - currentBeat++; + currentTimingPoint = nextTimingPoint; + time = timingPoints[currentTimingPoint].Time; + currentBeat = 0; } - double bl = current.BeatLength; + var currentPoint = timingPoints[currentTimingPoint]; + var barLine = new BarLine + { + StartTime = time, + }; + + barLine.ApplyDefaults(Beatmap.TimingInfo, Beatmap.BeatmapInfo.Difficulty); + + bool isMajor = currentBeat % (int)currentPoint.TimeSignature == 0; + taikoPlayfield.AddBarLine(isMajor ? new DrawableBarLineMajor(barLine) : new DrawableBarLine(barLine)); + + double bl = currentPoint.BeatLength; if (bl < 800) - bl *= (int)current.TimeSignature; + bl *= (int)currentPoint.TimeSignature; time += bl; - - if (currentIndex + 1 >= timingPoints.Count || time < timingPoints[currentIndex + 1].Time) - continue; - - currentBeat = 0; - currentIndex++; - time = timingPoints[currentIndex].Time; + currentBeat++; } }