1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-11 13:37:25 +08:00

Ensure background of gameplay is black when storyboard is overriding background display

This commit is contained in:
Dean Herbert 2023-08-02 15:50:15 +09:00
parent a618ed140e
commit 0e510088f9
3 changed files with 28 additions and 18 deletions

View File

@ -125,13 +125,13 @@ namespace osu.Game.Tests.Visual.Background
createFakeStoryboard(); createFakeStoryboard();
AddStep("Enable Storyboard", () => AddStep("Enable Storyboard", () =>
{ {
player.ReplacesBackground.Value = true; player.StoryboardReplacesBackground.Value = true;
player.StoryboardEnabled.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", () => AddStep("Disable Storyboard", () =>
{ {
player.ReplacesBackground.Value = false; player.StoryboardReplacesBackground.Value = false;
player.StoryboardEnabled.Value = false; player.StoryboardEnabled.Value = false;
}); });
AddUntilStep("Background is visible, storyboard is invisible", () => songSelect.IsBackgroundVisible() && !player.IsStoryboardVisible); AddUntilStep("Background is visible, storyboard is invisible", () => songSelect.IsBackgroundVisible() && !player.IsStoryboardVisible);
@ -173,7 +173,7 @@ namespace osu.Game.Tests.Visual.Background
createFakeStoryboard(); createFakeStoryboard();
AddStep("Enable Storyboard", () => AddStep("Enable Storyboard", () =>
{ {
player.ReplacesBackground.Value = true; player.StoryboardReplacesBackground.Value = true;
player.StoryboardEnabled.Value = true; player.StoryboardEnabled.Value = true;
}); });
AddStep("Enable user dim", () => player.DimmableStoryboard.IgnoreUserSettings.Value = false); AddStep("Enable user dim", () => player.DimmableStoryboard.IgnoreUserSettings.Value = false);
@ -188,7 +188,7 @@ namespace osu.Game.Tests.Visual.Background
{ {
performFullSetup(); performFullSetup();
createFakeStoryboard(); createFakeStoryboard();
AddStep("Enable replacing background", () => player.ReplacesBackground.Value = true); AddStep("Enable replacing background", () => player.StoryboardReplacesBackground.Value = true);
AddUntilStep("Storyboard is invisible", () => !player.IsStoryboardVisible); AddUntilStep("Storyboard is invisible", () => !player.IsStoryboardVisible);
AddUntilStep("Background is visible", () => songSelect.IsBackgroundVisible()); AddUntilStep("Background is visible", () => songSelect.IsBackgroundVisible());
@ -199,11 +199,11 @@ namespace osu.Game.Tests.Visual.Background
player.DimmableStoryboard.IgnoreUserSettings.Value = true; player.DimmableStoryboard.IgnoreUserSettings.Value = true;
}); });
AddUntilStep("Storyboard is visible", () => player.IsStoryboardVisible); 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("Storyboard is visible", () => player.IsStoryboardVisible);
AddUntilStep("Background is visible", () => songSelect.IsBackgroundVisible()); AddUntilStep("Background is visible", () => songSelect.IsBackgroundVisible() && !songSelect.IsBackgroundBlack());
} }
/// <summary> /// <summary>
@ -257,7 +257,7 @@ namespace osu.Game.Tests.Visual.Background
private void createFakeStoryboard() => AddStep("Create storyboard", () => private void createFakeStoryboard() => AddStep("Create storyboard", () =>
{ {
player.StoryboardEnabled.Value = false; player.StoryboardEnabled.Value = false;
player.ReplacesBackground.Value = false; player.StoryboardReplacesBackground.Value = false;
player.DimmableStoryboard.Add(new OsuSpriteText player.DimmableStoryboard.Add(new OsuSpriteText
{ {
Size = new Vector2(500, 50), Size = new Vector2(500, 50),
@ -323,6 +323,8 @@ namespace osu.Game.Tests.Visual.Background
config.BindWith(OsuSetting.BlurLevel, BlurLevel); 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 IsBackgroundDimmed() => background.CurrentColour == OsuColour.Gray(1f - background.CurrentDim);
public bool IsBackgroundUndimmed() => background.CurrentColour == Color4.White; 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 IsUserBlurDisabled() => background.CurrentBlur == new Vector2(0);
public bool IsBackgroundInvisible() => background.CurrentAlpha == 0;
public bool IsBackgroundVisible() => background.CurrentAlpha == 1; public bool IsBackgroundVisible() => background.CurrentAlpha == 1;
public bool IsBackgroundBlur() => Precision.AlmostEquals(background.CurrentBlur, new Vector2(BACKGROUND_BLUR), 0.1f); 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); base.OnEntering(e);
ApplyToBackground(b => ReplacesBackground.BindTo(b.StoryboardReplacesBackground)); ApplyToBackground(b => StoryboardReplacesBackground.BindTo(b.StoryboardReplacesBackground));
} }
public new DimmableStoryboard DimmableStoryboard => base.DimmableStoryboard; public new DimmableStoryboard DimmableStoryboard => base.DimmableStoryboard;
@ -376,7 +376,7 @@ namespace osu.Game.Tests.Visual.Background
public bool BlockLoad; public bool BlockLoad;
public Bindable<bool> StoryboardEnabled; public Bindable<bool> StoryboardEnabled;
public readonly Bindable<bool> ReplacesBackground = new Bindable<bool>(); public readonly Bindable<bool> StoryboardReplacesBackground = new Bindable<bool>();
public readonly Bindable<bool> IsPaused = new Bindable<bool>(); public readonly Bindable<bool> IsPaused = new Bindable<bool>();
public LoadBlockingTestPlayer(bool allowPause = true) public LoadBlockingTestPlayer(bool allowPause = true)

View File

@ -24,8 +24,11 @@ namespace osu.Game.Graphics.Containers
public const double BACKGROUND_FADE_DURATION = 800; public const double BACKGROUND_FADE_DURATION = 800;
/// <summary> /// <summary>
/// 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.
/// </summary> /// </summary>
/// <remarks>
/// For best or worst, this also bypasses storyboard disable. Not sure this is correct but leaving it as to not break anything.
/// </remarks>
public readonly Bindable<bool> IgnoreUserSettings = new Bindable<bool>(); public readonly Bindable<bool> IgnoreUserSettings = new Bindable<bool>();
/// <summary> /// <summary>
@ -52,7 +55,7 @@ namespace osu.Game.Graphics.Containers
private float breakLightening => LightenDuringBreaks.Value && IsBreakTime.Value ? BREAK_LIGHTEN_AMOUNT : 0; 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<Drawable> Content => dimContent; protected override Container<Drawable> Content => dimContent;

View File

@ -194,9 +194,16 @@ namespace osu.Game.Screens.Backgrounds
StoryboardReplacesBackground.ValueChanged += _ => UpdateVisuals(); StoryboardReplacesBackground.ValueChanged += _ => UpdateVisuals();
} }
protected override bool ShowDimContent protected override float DimLevel
// The background needs to be hidden in the case of it being replaced by the storyboard {
=> (!ShowStoryboard.Value && !IgnoreUserSettings.Value) || !StoryboardReplacesBackground.Value; get
{
if ((IgnoreUserSettings.Value || ShowStoryboard.Value) && StoryboardReplacesBackground.Value)
return 1;
return base.DimLevel;
}
}
protected override void UpdateVisuals() protected override void UpdateVisuals()
{ {