mirror of
https://github.com/ppy/osu
synced 2025-03-04 18:40:24 +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
|
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||||
|
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.MathUtils;
|
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Game.Beatmaps;
|
using osu.Game.Beatmaps;
|
||||||
using osu.Game.Beatmaps.Timing;
|
|
||||||
using osu.Game.Modes.Objects.Drawables;
|
using osu.Game.Modes.Objects.Drawables;
|
||||||
using osu.Game.Modes.Objects.Types;
|
using osu.Game.Modes.Objects.Types;
|
||||||
using osu.Game.Modes.Replays;
|
using osu.Game.Modes.Replays;
|
||||||
@ -49,55 +47,37 @@ namespace osu.Game.Modes.Taiko.UI
|
|||||||
if (timingPoints.Count == 0)
|
if (timingPoints.Count == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
int currentIndex = 0;
|
int currentTimingPoint = 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 currentBeat = 0;
|
int currentBeat = 0;
|
||||||
|
double time = timingPoints[currentTimingPoint].Time;
|
||||||
while (time <= lastHitTime)
|
while (time <= lastHitTime)
|
||||||
{
|
{
|
||||||
ControlPoint current = timingPoints[currentIndex];
|
int nextTimingPoint = currentTimingPoint + 1;
|
||||||
|
if (nextTimingPoint < timingPoints.Count && time > timingPoints[nextTimingPoint].Time)
|
||||||
if (time > current.Time || current.OmitFirstBarLine)
|
|
||||||
{
|
{
|
||||||
bool isMajor = currentBeat % (int)current.TimeSignature == 0;
|
currentTimingPoint = nextTimingPoint;
|
||||||
|
time = timingPoints[currentTimingPoint].Time;
|
||||||
var barLine = new BarLine
|
currentBeat = 0;
|
||||||
{
|
|
||||||
StartTime = time,
|
|
||||||
};
|
|
||||||
|
|
||||||
barLine.ApplyDefaults(Beatmap.TimingInfo, Beatmap.BeatmapInfo.Difficulty);
|
|
||||||
|
|
||||||
taikoPlayfield.AddBarLine(isMajor ? new DrawableBarLineMajor(barLine) : new DrawableBarLine(barLine));
|
|
||||||
|
|
||||||
currentBeat++;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
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)
|
if (bl < 800)
|
||||||
bl *= (int)current.TimeSignature;
|
bl *= (int)currentPoint.TimeSignature;
|
||||||
|
|
||||||
time += bl;
|
time += bl;
|
||||||
|
currentBeat++;
|
||||||
if (currentIndex + 1 >= timingPoints.Count || time < timingPoints[currentIndex + 1].Time)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
currentBeat = 0;
|
|
||||||
currentIndex++;
|
|
||||||
time = timingPoints[currentIndex].Time;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user