Add correct AudioLeadIn support

This commit is contained in:
Dean Herbert
2019-11-21 16:55:18 +09:00
parent 586e31efc2
commit 2dd2e3d861
2 changed files with 14 additions and 5 deletions

View File

@ -41,6 +41,8 @@ namespace osu.Game.Screens.Play
private readonly double gameplayStartTime;
private readonly double firstHitObjectTime;
public readonly Bindable<double> UserPlaybackRate = new BindableDouble(1)
{
Default = 1,
@ -61,11 +63,12 @@ namespace osu.Game.Screens.Play
private readonly FramedOffsetClock platformOffsetClock;
public GameplayClockContainer(WorkingBeatmap beatmap, IReadOnlyList<Mod> mods, double gameplayStartTime)
public GameplayClockContainer(WorkingBeatmap beatmap, IReadOnlyList<Mod> mods, double gameplayStartTime, double firstHitObjectTime)
{
this.beatmap = beatmap;
this.mods = mods;
this.gameplayStartTime = gameplayStartTime;
this.firstHitObjectTime = firstHitObjectTime;
RelativeSizeAxes = Axes.Both;
@ -102,11 +105,17 @@ namespace osu.Game.Screens.Play
userAudioOffset = config.GetBindable<double>(OsuSetting.AudioOffset);
userAudioOffset.BindValueChanged(offset => userOffsetClock.Offset = offset.NewValue, true);
double startTime = -beatmap.BeatmapInfo.AudioLeadIn;
// sane default provided by ruleset.
double startTime = Math.Min(0, gameplayStartTime);
// if a storyboard is present, it may dictate the appropriate start time by having events in negative time space.
// this is commonly used to display an intro before the audio track start.
startTime = Math.Min(startTime, beatmap.Storyboard.FirstEventTime);
startTime = Math.Min(startTime, gameplayStartTime);
startTime = Math.Min(startTime, 0);
// some beatmaps specify a current lead-in time which should be used instead of the ruleset-provided value when available.
// this is not available as an option in the live editor but can still be applied via .osu editing.
if (beatmap.BeatmapInfo.AudioLeadIn > 0)
startTime = Math.Min(startTime, firstHitObjectTime - beatmap.BeatmapInfo.AudioLeadIn);
Seek(startTime);