1
0
mirror of https://github.com/ppy/osu.git synced 2026-05-13 20:33:35 +08:00

Fix editor not showing beatmap background in some cases

This commit is contained in:
Dean Herbert
2026-04-01 02:03:11 +09:00
Unverified
parent bb63a17c30
commit 5c20254f76
2 changed files with 19 additions and 25 deletions
@@ -29,6 +29,8 @@ namespace osu.Game.Graphics.Backgrounds
public Action? StoryboardLoaded { get; set; }
public readonly BindableBool ShowStoryboard = new BindableBool(true);
[Resolved(CanBeNull = true)]
private MusicController? musicController { get; set; }
@@ -75,13 +77,11 @@ namespace osu.Game.Graphics.Backgrounds
void finishLoad(DrawableStoryboard s)
{
if (Beatmap.Storyboard.ReplacesBackground)
Sprite.FadeOut(BackgroundScreen.TRANSITION_LENGTH, Easing.InQuint);
Storyboard.FadeInFromZero(BackgroundScreen.TRANSITION_LENGTH, Easing.OutQuint);
Storyboard.Add(s);
StoryboardLoaded?.Invoke();
updateStoryboardVisibility();
}
}
@@ -97,8 +97,7 @@ namespace osu.Game.Graphics.Backgrounds
Storyboard.Clear();
drawableStoryboard = null;
Sprite.Alpha = 1f;
updateStoryboardVisibility();
}
protected override void LoadComplete()
@@ -108,6 +107,17 @@ namespace osu.Game.Graphics.Backgrounds
musicController.TrackChanged += onTrackChanged;
updateStoryboardClockSource(Beatmap);
ShowStoryboard.BindValueChanged(_ => updateStoryboardVisibility(), true);
}
private void updateStoryboardVisibility()
{
bool showStoryboard = drawableStoryboard != null && ShowStoryboard.Value;
bool showBackground = !showStoryboard || !Beatmap.Storyboard.ReplacesBackground;
Storyboard.FadeTo(showStoryboard ? 1 : 0, BackgroundScreen.TRANSITION_LENGTH, Easing.OutQuint);
Sprite.FadeTo(showBackground ? 1 : 0, BackgroundScreen.TRANSITION_LENGTH, Easing.OutQuint);
}
private void onTrackChanged(WorkingBeatmap newBeatmap, TrackChangeDirection _) => updateStoryboardClockSource(newBeatmap);
@@ -25,7 +25,7 @@ namespace osu.Game.Screens.Backgrounds
private Bindable<float> dimLevel = null!;
private Bindable<bool> showStoryboard = null!;
private BeatmapBackgroundWithStoryboard? background;
private BeatmapBackgroundWithStoryboard background = null!;
private readonly Container content;
private readonly Box blackBox;
@@ -65,7 +65,6 @@ namespace osu.Game.Screens.Backgrounds
showStoryboard = config.GetBindable<bool>(OsuSetting.EditorShowStoryboard);
content.Child = createContent();
updateState(withAnimation: false);
}
protected override void LoadComplete()
@@ -73,9 +72,6 @@ namespace osu.Game.Screens.Backgrounds
base.LoadComplete();
dimLevel.BindValueChanged(_ => dimContainer.FadeColour(OsuColour.Gray(1 - dimLevel.Value), 500, Easing.OutQuint), true);
showStoryboard.BindValueChanged(_ => updateState());
updateState(withAnimation: false);
}
public override void OnEntering(ScreenTransitionEvent e)
@@ -87,7 +83,7 @@ namespace osu.Game.Screens.Backgrounds
public override bool OnExiting(ScreenExitEvent e)
{
// The storyboard will do weird things with clock time changing on exit, so let's just hide it instead.
background?.UnloadStoryboard();
background.UnloadStoryboard();
return base.OnExiting(e);
}
@@ -95,27 +91,15 @@ namespace osu.Game.Screens.Backgrounds
public void RefreshBackgroundAsync()
{
cancellationTokenSource?.Cancel();
LoadComponentAsync(createContent(), loaded =>
{
content.Child = loaded;
updateState(withAnimation: false);
}, (cancellationTokenSource = new CancellationTokenSource()).Token);
LoadComponentAsync(createContent(), d => content.Child = d, (cancellationTokenSource = new CancellationTokenSource()).Token);
}
private Drawable createContent() => background = new BeatmapBackgroundWithStoryboard(beatmap.Value)
{
RelativeSizeAxes = Axes.Both,
StoryboardLoaded = () => updateState(withAnimation: false)
ShowStoryboard = { BindTarget = showStoryboard },
};
private void updateState(bool withAnimation = true)
{
background?.Storyboard.FadeTo(showStoryboard.Value ? 1 : 0, withAnimation ? 500 : 0, Easing.OutQuint);
// if the storyboard is disabled, in some cases (e.g. involving `StoryboardReplacesBackground`)
// we still need to show the background sprite, because if we don't, then there will be no background shown at all
background?.Sprite.FadeTo(showStoryboard.Value ? 0 : 1, withAnimation ? 500 : 0, Easing.OutQuint);
}
public override bool Equals(BackgroundScreen? other)
{
if (other is not EditorBackgroundScreen otherBeatmapBackground)