1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-27 02:32:59 +08:00

Use alternative workaround

This commit is contained in:
Bartłomiej Dach 2023-12-29 11:07:45 +01:00
parent cd1f6b46c4
commit 99cddb6317
No known key found for this signature in database

View File

@ -141,17 +141,29 @@ namespace osu.Game.Screens.Edit.Compose.Components.Timeline
waveformOpacity = config.GetBindable<float>(OsuSetting.EditorWaveformOpacity);
track.BindTo(editorClock.Track);
// schedule added as without it, `beatmap.Value.Track.Length` can be 0 immediately after a track switch.
track.BindValueChanged(_ => Schedule(() =>
track.BindValueChanged(_ =>
{
waveform.Waveform = beatmap.Value.Waveform;
waveform.RelativePositionAxes = Axes.X;
waveform.X = -(float)(Editor.WAVEFORM_VISUAL_OFFSET / beatmap.Value.Track.Length);
}), true);
Scheduler.AddOnce(applyVisualOffset, beatmap);
}, true);
Zoom = (float)(defaultTimelineZoom * editorBeatmap.BeatmapInfo.TimelineZoom);
}
private void applyVisualOffset(IBindable<WorkingBeatmap> beatmap)
{
waveform.RelativePositionAxes = Axes.X;
if (beatmap.Value.Track.Length > 0)
waveform.X = -(float)(Editor.WAVEFORM_VISUAL_OFFSET / beatmap.Value.Track.Length);
else
{
// sometimes this can be the case immediately after a track switch.
// reschedule with the hope that the track length eventually populates.
Scheduler.AddOnce(applyVisualOffset, beatmap);
}
}
protected override void LoadComplete()
{
base.LoadComplete();