mirror of
https://github.com/ppy/osu
synced 2024-12-13 02:17:32 +00:00
Rewrite bar lines to make sure they're centered at their beat's start position.
This commit is contained in:
parent
6239eab233
commit
eaa171baf4
@ -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++;
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user