Fix song select potentially updating background parameters when not the current screen

This commit is contained in:
Dean Herbert 2023-02-16 18:45:22 +09:00
parent 9ed068c1e6
commit 394d368f16
2 changed files with 18 additions and 9 deletions

View File

@ -1,9 +1,9 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence. // Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text. // See the LICENCE file in the repository root for full licence text.
#nullable disable
using System; using System;
using System.Diagnostics;
using osu.Framework.Screens;
using osu.Game.Screens.Backgrounds; using osu.Game.Screens.Backgrounds;
namespace osu.Game.Screens.Play namespace osu.Game.Screens.Play
@ -12,6 +12,11 @@ namespace osu.Game.Screens.Play
{ {
protected override BackgroundScreen CreateBackground() => new BackgroundScreenBeatmap(Beatmap.Value); protected override BackgroundScreen CreateBackground() => new BackgroundScreenBeatmap(Beatmap.Value);
public void ApplyToBackground(Action<BackgroundScreenBeatmap> action) => base.ApplyToBackground(b => action.Invoke((BackgroundScreenBeatmap)b)); public void ApplyToBackground(Action<BackgroundScreenBeatmap> action)
{
Debug.Assert(this.IsCurrentScreen());
base.ApplyToBackground(b => action.Invoke((BackgroundScreenBeatmap)b));
}
} }
} }

View File

@ -765,14 +765,18 @@ namespace osu.Game.Screens.Select
/// <param name="beatmap">The working beatmap.</param> /// <param name="beatmap">The working beatmap.</param>
private void updateComponentFromBeatmap(WorkingBeatmap beatmap) private void updateComponentFromBeatmap(WorkingBeatmap beatmap)
{ {
ApplyToBackground(backgroundModeBeatmap => // If not the current screen, this will be applied in OnResuming.
if (this.IsCurrentScreen())
{ {
backgroundModeBeatmap.Beatmap = beatmap; ApplyToBackground(backgroundModeBeatmap =>
backgroundModeBeatmap.IgnoreUserSettings.Value = true; {
backgroundModeBeatmap.FadeColour(Color4.White, 250); backgroundModeBeatmap.Beatmap = beatmap;
backgroundModeBeatmap.IgnoreUserSettings.Value = true;
backgroundModeBeatmap.FadeColour(Color4.White, 250);
applyBlurToBackground(backgroundModeBeatmap); applyBlurToBackground(backgroundModeBeatmap);
}); });
}
beatmapInfoWedge.Beatmap = beatmap; beatmapInfoWedge.Beatmap = beatmap;