diff --git a/osu.Game/Graphics/Containers/UserDimContainer.cs b/osu.Game/Graphics/Containers/UserDimContainer.cs index 717078ab99..c0c2525175 100644 --- a/osu.Game/Graphics/Containers/UserDimContainer.cs +++ b/osu.Game/Graphics/Containers/UserDimContainer.cs @@ -13,20 +13,42 @@ namespace osu.Game.Graphics.Containers public class UserDimContainer : Container { protected Bindable DimLevel; - + protected Bindable ShowStoryboard; public Bindable EnableUserDim = new Bindable(); + public Bindable StoryboardReplacesBackground = new Bindable(); + + private readonly bool isStoryboard; + + private const float BACKGROUND_FADE_DURATION = 800; + + public UserDimContainer(bool isStoryboard = false) + { + this.isStoryboard = isStoryboard; + } [BackgroundDependencyLoader] private void load(OsuConfigManager config) { DimLevel = config.GetBindable(OsuSetting.DimLevel); + ShowStoryboard = config.GetBindable(OsuSetting.ShowStoryboard); EnableUserDim.ValueChanged += _ => updateBackgroundDim(); DimLevel.ValueChanged += _ => updateBackgroundDim(); + ShowStoryboard.ValueChanged += _ => updateBackgroundDim(); } private void updateBackgroundDim() { - this.FadeColour(EnableUserDim ? OsuColour.Gray(1 - (float)DimLevel) : Color4.White, 800, Easing.OutQuint); + if (isStoryboard) + { + this.FadeTo(!ShowStoryboard || DimLevel == 1 ? 0 : 1, BACKGROUND_FADE_DURATION, Easing.OutQuint); + } + else + { + // The background needs to be hidden in the case of it being replaced + this.FadeTo(ShowStoryboard && StoryboardReplacesBackground ? 0 : 1, BACKGROUND_FADE_DURATION, Easing.OutQuint); + } + + this.FadeColour(EnableUserDim ? OsuColour.Gray(1 - (float)DimLevel) : Color4.White, BACKGROUND_FADE_DURATION, Easing.OutQuint); } } } diff --git a/osu.Game/Screens/Backgrounds/BackgroundScreenBeatmap.cs b/osu.Game/Screens/Backgrounds/BackgroundScreenBeatmap.cs index 2bbaee417e..d62cea4511 100644 --- a/osu.Game/Screens/Backgrounds/BackgroundScreenBeatmap.cs +++ b/osu.Game/Screens/Backgrounds/BackgroundScreenBeatmap.cs @@ -16,8 +16,8 @@ namespace osu.Game.Screens.Backgrounds { private WorkingBeatmap beatmap; protected Bindable DimLevel; - protected Bindable BlurLevel; public Bindable EnableUserDim; + public Bindable StoryboardReplacesBackground = new Bindable(); protected UserDimContainer FadeContainer; @@ -56,6 +56,7 @@ namespace osu.Game.Screens.Backgrounds b.Depth = newDepth; FadeContainer.Child = Background = b; Background.BlurSigma = BlurTarget; + FadeContainer.StoryboardReplacesBackground.BindTo(StoryboardReplacesBackground); })); }); } diff --git a/osu.Game/Screens/Play/Player.cs b/osu.Game/Screens/Play/Player.cs index 3f9f1a83d5..13c7703af9 100644 --- a/osu.Game/Screens/Play/Player.cs +++ b/osu.Game/Screens/Play/Player.cs @@ -175,7 +175,7 @@ namespace osu.Game.Screens.Play CheckCanPause = () => AllowPause && ValidForResume && !HasFailed && !RulesetContainer.HasReplayLoaded, Children = new Container[] { - storyboardContainer = new UserDimContainer + storyboardContainer = new UserDimContainer(true) { RelativeSizeAxes = Axes.Both, Alpha = 0, @@ -351,6 +351,8 @@ namespace osu.Game.Screens.Play DimLevel.ValueChanged += _ => UpdateBackgroundElements(); ShowStoryboard.ValueChanged += _ => UpdateBackgroundElements(); Background.EnableUserDim.Value = true; + storyboardContainer.StoryboardReplacesBackground.Value = Beatmap.Value.Storyboard.ReplacesBackground && Beatmap.Value.Storyboard.HasDrawable; + storyboardContainer.StoryboardReplacesBackground.BindTo(Background?.StoryboardReplacesBackground); Task.Run(() => { @@ -412,6 +414,7 @@ namespace osu.Game.Screens.Play float fadeOutDuration = instant ? 0 : 250; this.FadeOut(fadeOutDuration); Background.EnableUserDim.Value = false; + storyboardContainer.StoryboardReplacesBackground.Value = false; } protected override bool OnScroll(ScrollEvent e) => mouseWheelDisabled.Value && !pauseContainer.IsPaused; @@ -440,14 +443,6 @@ namespace osu.Game.Screens.Play if (ShowStoryboard && storyboard == null) initializeStoryboard(true); - - var beatmap = Beatmap.Value; - var storyboardVisible = ShowStoryboard && beatmap.Storyboard.HasDrawable; - - storyboardContainer?.FadeTo(storyboardVisible && 1 - (float)DimLevel > 0 ? 1 : 0, BACKGROUND_FADE_DURATION, Easing.OutQuint); - - if (storyboardVisible && beatmap.Storyboard.ReplacesBackground) - Background?.FadeColour(Color4.Black, BACKGROUND_FADE_DURATION, Easing.OutQuint); } protected virtual Results CreateResults(ScoreInfo score) => new SoloResults(score);