From 76d5225bb9ee9bfcc599bf9ec6f769c3658a4b3c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Dach?= Date: Tue, 11 Jan 2022 22:00:04 +0100 Subject: [PATCH] Rewrite storyboard clock management in slightly different way --- .../Backgrounds/BeatmapBackgroundWithStoryboard.cs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/osu.Game/Graphics/Backgrounds/BeatmapBackgroundWithStoryboard.cs b/osu.Game/Graphics/Backgrounds/BeatmapBackgroundWithStoryboard.cs index c5c8a25f4a..56ef87c1f4 100644 --- a/osu.Game/Graphics/Backgrounds/BeatmapBackgroundWithStoryboard.cs +++ b/osu.Game/Graphics/Backgrounds/BeatmapBackgroundWithStoryboard.cs @@ -15,7 +15,7 @@ namespace osu.Game.Graphics.Backgrounds { public class BeatmapBackgroundWithStoryboard : BeatmapBackground { - private InterpolatingFramedClock storyboardClock = null!; + private readonly InterpolatingFramedClock storyboardClock; [Resolved(CanBeNull = true)] private MusicController? musicController { get; set; } @@ -23,6 +23,7 @@ namespace osu.Game.Graphics.Backgrounds public BeatmapBackgroundWithStoryboard(WorkingBeatmap beatmap, string fallbackTextureName = "Backgrounds/bg1") : base(beatmap, fallbackTextureName) { + storyboardClock = new InterpolatingFramedClock(); } [BackgroundDependencyLoader] @@ -38,7 +39,7 @@ namespace osu.Game.Graphics.Backgrounds { RelativeSizeAxes = Axes.Both, Volume = { Value = 0 }, - Child = new DrawableStoryboard(Beatmap.Storyboard) { Clock = storyboardClock = new InterpolatingFramedClock(Beatmap.Track) } + Child = new DrawableStoryboard(Beatmap.Storyboard) { Clock = storyboardClock } }, AddInternal); } @@ -47,9 +48,13 @@ namespace osu.Game.Graphics.Backgrounds base.LoadComplete(); if (musicController != null) musicController.TrackChanged += onTrackChanged; + + updateStoryboardClockSource(Beatmap); } - private void onTrackChanged(WorkingBeatmap newBeatmap, TrackChangeDirection _) + private void onTrackChanged(WorkingBeatmap newBeatmap, TrackChangeDirection _) => updateStoryboardClockSource(newBeatmap); + + private void updateStoryboardClockSource(WorkingBeatmap newBeatmap) { if (newBeatmap != Beatmap) return;