From a618ed140e0bd631f3d0aeba8a625b37c991673d Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Wed, 2 Aug 2023 15:07:06 +0900 Subject: [PATCH 1/2] Move `StoryboardReplacesBackground` bindable more local to usage --- osu.Game/Graphics/Containers/UserDimContainer.cs | 6 ------ osu.Game/Screens/Backgrounds/BackgroundScreenBeatmap.cs | 9 +++++++-- osu.Game/Screens/Play/Player.cs | 2 -- 3 files changed, 7 insertions(+), 10 deletions(-) diff --git a/osu.Game/Graphics/Containers/UserDimContainer.cs b/osu.Game/Graphics/Containers/UserDimContainer.cs index 6f6292c3b2..4821e6b370 100644 --- a/osu.Game/Graphics/Containers/UserDimContainer.cs +++ b/osu.Game/Graphics/Containers/UserDimContainer.cs @@ -28,11 +28,6 @@ namespace osu.Game.Graphics.Containers /// public readonly Bindable IgnoreUserSettings = new Bindable(); - /// - /// Whether or not the storyboard loaded should completely hide the background behind it. - /// - public readonly Bindable StoryboardReplacesBackground = new Bindable(); - /// /// Whether player is in break time. /// Must be bound to to allow for dim adjustments in gameplay. @@ -83,7 +78,6 @@ namespace osu.Game.Graphics.Containers LightenDuringBreaks.ValueChanged += _ => UpdateVisuals(); IsBreakTime.ValueChanged += _ => UpdateVisuals(); ShowStoryboard.ValueChanged += _ => UpdateVisuals(); - StoryboardReplacesBackground.ValueChanged += _ => UpdateVisuals(); IgnoreUserSettings.ValueChanged += _ => UpdateVisuals(); } diff --git a/osu.Game/Screens/Backgrounds/BackgroundScreenBeatmap.cs b/osu.Game/Screens/Backgrounds/BackgroundScreenBeatmap.cs index 312fd496a1..8a3755f980 100644 --- a/osu.Game/Screens/Backgrounds/BackgroundScreenBeatmap.cs +++ b/osu.Game/Screens/Backgrounds/BackgroundScreenBeatmap.cs @@ -36,6 +36,9 @@ namespace osu.Game.Screens.Backgrounds /// public readonly Bindable IgnoreUserSettings = new Bindable(true); + /// + /// Whether or not the storyboard loaded should completely hide the background behind it. + /// public readonly Bindable StoryboardReplacesBackground = new Bindable(); /// @@ -60,12 +63,11 @@ namespace osu.Game.Screens.Backgrounds InternalChild = dimmable = CreateFadeContainer(); + dimmable.StoryboardReplacesBackground.BindTo(StoryboardReplacesBackground); dimmable.IgnoreUserSettings.BindTo(IgnoreUserSettings); dimmable.IsBreakTime.BindTo(IsBreakTime); dimmable.BlurAmount.BindTo(BlurAmount); dimmable.DimWhenUserSettingsIgnored.BindTo(DimWhenUserSettingsIgnored); - - StoryboardReplacesBackground.BindTo(dimmable.StoryboardReplacesBackground); } [BackgroundDependencyLoader] @@ -144,6 +146,8 @@ namespace osu.Game.Screens.Backgrounds /// public readonly Bindable BlurAmount = new BindableFloat(); + public readonly Bindable StoryboardReplacesBackground = new Bindable(); + public Background Background { get => background; @@ -187,6 +191,7 @@ namespace osu.Game.Screens.Backgrounds userBlurLevel.ValueChanged += _ => UpdateVisuals(); BlurAmount.ValueChanged += _ => UpdateVisuals(); + StoryboardReplacesBackground.ValueChanged += _ => UpdateVisuals(); } protected override bool ShowDimContent diff --git a/osu.Game/Screens/Play/Player.cs b/osu.Game/Screens/Play/Player.cs index 7d67e2657d..5f8e061d89 100644 --- a/osu.Game/Screens/Play/Player.cs +++ b/osu.Game/Screens/Play/Player.cs @@ -1049,8 +1049,6 @@ namespace osu.Game.Screens.Play DimmableStoryboard.IsBreakTime.BindTo(breakTracker.IsBreakTime); - DimmableStoryboard.StoryboardReplacesBackground.BindTo(storyboardReplacesBackground); - storyboardReplacesBackground.Value = Beatmap.Value.Storyboard.ReplacesBackground && Beatmap.Value.Storyboard.HasDrawable; foreach (var mod in GameplayState.Mods.OfType()) From 0e510088f90e0c177be9f7147be61e39c149c97c Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Wed, 2 Aug 2023 15:50:15 +0900 Subject: [PATCH 2/2] Ensure background of gameplay is black when storyboard is overriding background display --- .../Background/TestSceneUserDimBackgrounds.cs | 26 +++++++++---------- .../Graphics/Containers/UserDimContainer.cs | 7 +++-- .../Backgrounds/BackgroundScreenBeatmap.cs | 13 +++++++--- 3 files changed, 28 insertions(+), 18 deletions(-) diff --git a/osu.Game.Tests/Visual/Background/TestSceneUserDimBackgrounds.cs b/osu.Game.Tests/Visual/Background/TestSceneUserDimBackgrounds.cs index 5df5337a96..566ccd6bd5 100644 --- a/osu.Game.Tests/Visual/Background/TestSceneUserDimBackgrounds.cs +++ b/osu.Game.Tests/Visual/Background/TestSceneUserDimBackgrounds.cs @@ -125,13 +125,13 @@ namespace osu.Game.Tests.Visual.Background createFakeStoryboard(); AddStep("Enable Storyboard", () => { - player.ReplacesBackground.Value = true; + player.StoryboardReplacesBackground.Value = true; player.StoryboardEnabled.Value = true; }); - AddUntilStep("Background is invisible, storyboard is visible", () => songSelect.IsBackgroundInvisible() && player.IsStoryboardVisible); + AddUntilStep("Background is black, storyboard is visible", () => songSelect.IsBackgroundVisible() && songSelect.IsBackgroundBlack() && player.IsStoryboardVisible); AddStep("Disable Storyboard", () => { - player.ReplacesBackground.Value = false; + player.StoryboardReplacesBackground.Value = false; player.StoryboardEnabled.Value = false; }); AddUntilStep("Background is visible, storyboard is invisible", () => songSelect.IsBackgroundVisible() && !player.IsStoryboardVisible); @@ -173,7 +173,7 @@ namespace osu.Game.Tests.Visual.Background createFakeStoryboard(); AddStep("Enable Storyboard", () => { - player.ReplacesBackground.Value = true; + player.StoryboardReplacesBackground.Value = true; player.StoryboardEnabled.Value = true; }); AddStep("Enable user dim", () => player.DimmableStoryboard.IgnoreUserSettings.Value = false); @@ -188,7 +188,7 @@ namespace osu.Game.Tests.Visual.Background { performFullSetup(); createFakeStoryboard(); - AddStep("Enable replacing background", () => player.ReplacesBackground.Value = true); + AddStep("Enable replacing background", () => player.StoryboardReplacesBackground.Value = true); AddUntilStep("Storyboard is invisible", () => !player.IsStoryboardVisible); AddUntilStep("Background is visible", () => songSelect.IsBackgroundVisible()); @@ -199,11 +199,11 @@ namespace osu.Game.Tests.Visual.Background player.DimmableStoryboard.IgnoreUserSettings.Value = true; }); AddUntilStep("Storyboard is visible", () => player.IsStoryboardVisible); - AddUntilStep("Background is invisible", () => songSelect.IsBackgroundInvisible()); + AddUntilStep("Background is dimmed", () => songSelect.IsBackgroundVisible() && songSelect.IsBackgroundBlack()); - AddStep("Disable background replacement", () => player.ReplacesBackground.Value = false); + AddStep("Disable background replacement", () => player.StoryboardReplacesBackground.Value = false); AddUntilStep("Storyboard is visible", () => player.IsStoryboardVisible); - AddUntilStep("Background is visible", () => songSelect.IsBackgroundVisible()); + AddUntilStep("Background is visible", () => songSelect.IsBackgroundVisible() && !songSelect.IsBackgroundBlack()); } /// @@ -257,7 +257,7 @@ namespace osu.Game.Tests.Visual.Background private void createFakeStoryboard() => AddStep("Create storyboard", () => { player.StoryboardEnabled.Value = false; - player.ReplacesBackground.Value = false; + player.StoryboardReplacesBackground.Value = false; player.DimmableStoryboard.Add(new OsuSpriteText { Size = new Vector2(500, 50), @@ -323,6 +323,8 @@ namespace osu.Game.Tests.Visual.Background config.BindWith(OsuSetting.BlurLevel, BlurLevel); } + public bool IsBackgroundBlack() => background.CurrentColour == OsuColour.Gray(0); + public bool IsBackgroundDimmed() => background.CurrentColour == OsuColour.Gray(1f - background.CurrentDim); public bool IsBackgroundUndimmed() => background.CurrentColour == Color4.White; @@ -331,8 +333,6 @@ namespace osu.Game.Tests.Visual.Background public bool IsUserBlurDisabled() => background.CurrentBlur == new Vector2(0); - public bool IsBackgroundInvisible() => background.CurrentAlpha == 0; - public bool IsBackgroundVisible() => background.CurrentAlpha == 1; public bool IsBackgroundBlur() => Precision.AlmostEquals(background.CurrentBlur, new Vector2(BACKGROUND_BLUR), 0.1f); @@ -367,7 +367,7 @@ namespace osu.Game.Tests.Visual.Background { base.OnEntering(e); - ApplyToBackground(b => ReplacesBackground.BindTo(b.StoryboardReplacesBackground)); + ApplyToBackground(b => StoryboardReplacesBackground.BindTo(b.StoryboardReplacesBackground)); } public new DimmableStoryboard DimmableStoryboard => base.DimmableStoryboard; @@ -376,7 +376,7 @@ namespace osu.Game.Tests.Visual.Background public bool BlockLoad; public Bindable StoryboardEnabled; - public readonly Bindable ReplacesBackground = new Bindable(); + public readonly Bindable StoryboardReplacesBackground = new Bindable(); public readonly Bindable IsPaused = new Bindable(); public LoadBlockingTestPlayer(bool allowPause = true) diff --git a/osu.Game/Graphics/Containers/UserDimContainer.cs b/osu.Game/Graphics/Containers/UserDimContainer.cs index 4821e6b370..625702ef6e 100644 --- a/osu.Game/Graphics/Containers/UserDimContainer.cs +++ b/osu.Game/Graphics/Containers/UserDimContainer.cs @@ -24,8 +24,11 @@ namespace osu.Game.Graphics.Containers public const double BACKGROUND_FADE_DURATION = 800; /// - /// Whether or not user-configured settings relating to brightness of elements should be ignored + /// Whether or not user-configured settings relating to brightness of elements should be ignored. /// + /// + /// For best or worst, this also bypasses storyboard disable. Not sure this is correct but leaving it as to not break anything. + /// public readonly Bindable IgnoreUserSettings = new Bindable(); /// @@ -52,7 +55,7 @@ namespace osu.Game.Graphics.Containers private float breakLightening => LightenDuringBreaks.Value && IsBreakTime.Value ? BREAK_LIGHTEN_AMOUNT : 0; - protected float DimLevel => Math.Max(!IgnoreUserSettings.Value ? (float)UserDimLevel.Value - breakLightening : DimWhenUserSettingsIgnored.Value, 0); + protected virtual float DimLevel => Math.Max(!IgnoreUserSettings.Value ? (float)UserDimLevel.Value - breakLightening : DimWhenUserSettingsIgnored.Value, 0); protected override Container Content => dimContent; diff --git a/osu.Game/Screens/Backgrounds/BackgroundScreenBeatmap.cs b/osu.Game/Screens/Backgrounds/BackgroundScreenBeatmap.cs index 8a3755f980..1506b884b4 100644 --- a/osu.Game/Screens/Backgrounds/BackgroundScreenBeatmap.cs +++ b/osu.Game/Screens/Backgrounds/BackgroundScreenBeatmap.cs @@ -194,9 +194,16 @@ namespace osu.Game.Screens.Backgrounds StoryboardReplacesBackground.ValueChanged += _ => UpdateVisuals(); } - protected override bool ShowDimContent - // The background needs to be hidden in the case of it being replaced by the storyboard - => (!ShowStoryboard.Value && !IgnoreUserSettings.Value) || !StoryboardReplacesBackground.Value; + protected override float DimLevel + { + get + { + if ((IgnoreUserSettings.Value || ShowStoryboard.Value) && StoryboardReplacesBackground.Value) + return 1; + + return base.DimLevel; + } + } protected override void UpdateVisuals() {