diff --git a/osu.Game.Tests/Visual/Background/TestSceneBackgroundScreenBeatmap.cs b/osu.Game.Tests/Visual/Background/TestSceneBackgroundScreenBeatmap.cs index 09aaee4adc..6a4145b24f 100644 --- a/osu.Game.Tests/Visual/Background/TestSceneBackgroundScreenBeatmap.cs +++ b/osu.Game.Tests/Visual/Background/TestSceneBackgroundScreenBeatmap.cs @@ -405,7 +405,7 @@ namespace osu.Game.Tests.Visual.Background private class TestDimmableStoryboardContainer : DimmableStoryboardContainer { - public float CurrentAlpha => DimContainer.Alpha; + public float CurrentAlpha => Content.Alpha; public TestDimmableStoryboardContainer() : base(new Storyboard()) @@ -415,8 +415,8 @@ namespace osu.Game.Tests.Visual.Background private class TestDimmableBackgroundContainer : DimmableBackgroundContainer { - public Color4 CurrentColour => DimContainer.Colour; - public float CurrentAlpha => DimContainer.Alpha; + public Color4 CurrentColour => Content.Colour; + public float CurrentAlpha => Content.Alpha; } } } diff --git a/osu.Game/Graphics/Containers/DimmableBackgroundContainer.cs b/osu.Game/Graphics/Containers/DimmableBackgroundContainer.cs index 7339548069..32b333528f 100644 --- a/osu.Game/Graphics/Containers/DimmableBackgroundContainer.cs +++ b/osu.Game/Graphics/Containers/DimmableBackgroundContainer.cs @@ -55,14 +55,16 @@ namespace osu.Game.Graphics.Containers private void load(OsuConfigManager config) { userBlurLevel = config.GetBindable(OsuSetting.BlurLevel); - BlurAmount.ValueChanged += _ => UpdateVisuals(); userBlurLevel.ValueChanged += _ => UpdateVisuals(); + BlurAmount.ValueChanged += _ => UpdateVisuals(); } - protected override void ApplyFade() + protected override bool ShowDimContent => !ShowStoryboard.Value || !StoryboardReplacesBackground.Value; // The background needs to be hidden in the case of it being replaced by the storyboard + + protected override void UpdateVisuals() { - // The background needs to be hidden in the case of it being replaced by the storyboard - DimContainer.FadeTo(ShowStoryboard.Value && StoryboardReplacesBackground.Value ? 0 : 1, BACKGROUND_FADE_DURATION, Easing.OutQuint); + base.UpdateVisuals(); + Background?.BlurTo(blurTarget, BACKGROUND_FADE_DURATION, Easing.OutQuint); } } diff --git a/osu.Game/Graphics/Containers/DimmableStoryboardContainer.cs b/osu.Game/Graphics/Containers/DimmableStoryboardContainer.cs index 16379baeab..0d87e64447 100644 --- a/osu.Game/Graphics/Containers/DimmableStoryboardContainer.cs +++ b/osu.Game/Graphics/Containers/DimmableStoryboardContainer.cs @@ -2,7 +2,6 @@ // See the LICENCE file in the repository root for full licence text. using osu.Framework.Allocation; -using osu.Framework.Graphics; using osu.Game.Storyboards; using osu.Game.Storyboards.Drawables; @@ -37,10 +36,7 @@ namespace osu.Game.Graphics.Containers base.LoadComplete(); } - protected override void ApplyFade() - { - DimContainer.FadeTo(!ShowStoryboard.Value || UserDimLevel.Value == 1 ? 0 : 1, BACKGROUND_FADE_DURATION, Easing.OutQuint); - } + protected override bool ShowDimContent => ShowStoryboard.Value && UserDimLevel.Value < 1; private void initializeStoryboard(bool async) { diff --git a/osu.Game/Graphics/Containers/UserDimContainer.cs b/osu.Game/Graphics/Containers/UserDimContainer.cs index e6a040fcd8..93af0be923 100644 --- a/osu.Game/Graphics/Containers/UserDimContainer.cs +++ b/osu.Game/Graphics/Containers/UserDimContainer.cs @@ -31,16 +31,16 @@ namespace osu.Game.Graphics.Containers protected Bindable ShowStoryboard { get; private set; } - protected Container DimContainer { get; } + protected override Container Content => dimContent; - protected override Container Content => DimContainer; + private Container dimContent { get; } /// /// Creates a new . /// protected UserDimContainer() { - AddInternal(DimContainer = new Container { RelativeSizeAxes = Axes.Both }); + AddInternal(dimContent = new Container { RelativeSizeAxes = Axes.Both }); } [BackgroundDependencyLoader] @@ -62,19 +62,17 @@ namespace osu.Game.Graphics.Containers } /// - /// Apply non-dim related settings to the content, such as hiding and blurring. + /// Whether the content of this container should currently be visible. /// - /// - /// While both backgrounds and storyboards allow user dim levels to be applied, storyboards can be toggled via - /// and can cause backgrounds to become hidden via . Storyboards are also currently unable to be blurred. - /// - protected abstract void ApplyFade(); + protected virtual bool ShowDimContent => true; - protected void UpdateVisuals() + /// + /// Should be invoked when any dependent dim level or user setting is changed and bring the visual state up-to-date. + /// + protected virtual void UpdateVisuals() { - ApplyFade(); - - DimContainer.FadeColour(EnableUserDim.Value ? OsuColour.Gray(1 - (float)UserDimLevel.Value) : Color4.White, BACKGROUND_FADE_DURATION, Easing.OutQuint); + dimContent.FadeTo(ShowDimContent ? 1 : 0, BACKGROUND_FADE_DURATION, Easing.OutQuint); + dimContent.FadeColour(EnableUserDim.Value ? OsuColour.Gray(1 - (float)UserDimLevel.Value) : Color4.White, BACKGROUND_FADE_DURATION, Easing.OutQuint); } } }