Inverse ignore user settings bindable to "apply user settings" instead

This commit is contained in:
Salman Ahmed
2021-04-15 00:04:38 +03:00
parent 7a9ff2ab38
commit 175b8da2b2
9 changed files with 29 additions and 32 deletions

View File

@ -157,9 +157,9 @@ namespace osu.Game.Tests.Visual.Background
{ {
performFullSetup(); performFullSetup();
AddUntilStep("Screen is dimmed and blur applied", () => songSelect.IsBackgroundDimmed() && songSelect.IsUserBlurApplied()); AddUntilStep("Screen is dimmed and blur applied", () => songSelect.IsBackgroundDimmed() && songSelect.IsUserBlurApplied());
AddStep("Disable user dim", () => songSelect.IgnoreUserSettings.Value = true); AddStep("Disable user dim", () => songSelect.ApplyUserSettings.Value = false);
AddUntilStep("Screen is undimmed and user blur removed", () => songSelect.IsBackgroundUndimmed() && songSelect.IsUserBlurDisabled()); AddUntilStep("Screen is undimmed and user blur removed", () => songSelect.IsBackgroundUndimmed() && songSelect.IsUserBlurDisabled());
AddStep("Enable user dim", () => songSelect.IgnoreUserSettings.Value = false); AddStep("Enable user dim", () => songSelect.ApplyUserSettings.Value = true);
AddUntilStep("Screen is dimmed and blur applied", () => songSelect.IsBackgroundDimmed() && songSelect.IsUserBlurApplied()); AddUntilStep("Screen is dimmed and blur applied", () => songSelect.IsBackgroundDimmed() && songSelect.IsUserBlurApplied());
} }
@ -176,10 +176,10 @@ namespace osu.Game.Tests.Visual.Background
player.ReplacesBackground.Value = true; player.ReplacesBackground.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.ApplyUserSettings.Value = true);
AddStep("Set dim level to 1", () => songSelect.DimLevel.Value = 1f); AddStep("Set dim level to 1", () => songSelect.DimLevel.Value = 1f);
AddUntilStep("Storyboard is invisible", () => !player.IsStoryboardVisible); AddUntilStep("Storyboard is invisible", () => !player.IsStoryboardVisible);
AddStep("Disable user dim", () => player.DimmableStoryboard.IgnoreUserSettings.Value = true); AddStep("Disable user dim", () => player.DimmableStoryboard.ApplyUserSettings.Value = false);
AddUntilStep("Storyboard is visible", () => player.IsStoryboardVisible); AddUntilStep("Storyboard is visible", () => player.IsStoryboardVisible);
} }
@ -195,8 +195,8 @@ namespace osu.Game.Tests.Visual.Background
AddStep("Ignore user settings", () => AddStep("Ignore user settings", () =>
{ {
player.ApplyToBackground(b => b.IgnoreUserSettings.Value = true); player.ApplyToBackground(b => b.ApplyUserSettings.Value = false);
player.DimmableStoryboard.IgnoreUserSettings.Value = true; player.DimmableStoryboard.ApplyUserSettings.Value = false;
}); });
AddUntilStep("Storyboard is visible", () => player.IsStoryboardVisible); AddUntilStep("Storyboard is visible", () => player.IsStoryboardVisible);
AddUntilStep("Background is invisible", () => songSelect.IsBackgroundInvisible()); AddUntilStep("Background is invisible", () => songSelect.IsBackgroundInvisible());
@ -308,11 +308,11 @@ namespace osu.Game.Tests.Visual.Background
protected override BackgroundScreen CreateBackground() protected override BackgroundScreen CreateBackground()
{ {
background = new FadeAccessibleBackground(Beatmap.Value); background = new FadeAccessibleBackground(Beatmap.Value);
IgnoreUserSettings.BindTo(background.IgnoreUserSettings); ApplyUserSettings.BindTo(background.ApplyUserSettings);
return background; return background;
} }
public readonly Bindable<bool> IgnoreUserSettings = new Bindable<bool>(); public readonly Bindable<bool> ApplyUserSettings = new Bindable<bool>();
public readonly Bindable<double> DimLevel = new BindableDouble(); public readonly Bindable<double> DimLevel = new BindableDouble();
public readonly Bindable<double> BlurLevel = new BindableDouble(); public readonly Bindable<double> BlurLevel = new BindableDouble();

View File

@ -94,7 +94,7 @@ namespace osu.Game.Tests.Visual.Background
AddStep("set dim level 0.6", () => userDimContainer.UserDimLevel.Value = test_user_dim); AddStep("set dim level 0.6", () => userDimContainer.UserDimLevel.Value = test_user_dim);
AddUntilStep("dim reached", () => userDimContainer.DimEqual(test_user_dim)); AddUntilStep("dim reached", () => userDimContainer.DimEqual(test_user_dim));
AddStep("ignore settings", () => userDimContainer.IgnoreUserSettings.Value = true); AddStep("ignore settings", () => userDimContainer.ApplyUserSettings.Value = false);
AddUntilStep("no dim", () => userDimContainer.DimEqual(0)); AddUntilStep("no dim", () => userDimContainer.DimEqual(0));
AddStep("set break", () => isBreakTime.Value = true); AddStep("set break", () => isBreakTime.Value = true);
AddAssert("no dim", () => userDimContainer.DimEqual(0)); AddAssert("no dim", () => userDimContainer.DimEqual(0));

View File

@ -24,9 +24,9 @@ namespace osu.Game.Graphics.Containers
protected const double BACKGROUND_FADE_DURATION = 800; protected 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 effect settings should be applied to this container.
/// </summary> /// </summary>
public readonly Bindable<bool> IgnoreUserSettings = new Bindable<bool>(); public readonly Bindable<bool> ApplyUserSettings = new Bindable<bool>(true);
/// <summary> /// <summary>
/// Whether or not the storyboard loaded should completely hide the background behind it. /// Whether or not the storyboard loaded should completely hide the background behind it.
@ -52,7 +52,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 : 0, 0); protected float DimLevel => Math.Max(ApplyUserSettings.Value ? (float)UserDimLevel.Value - breakLightening : 0, 0);
protected override Container<Drawable> Content => dimContent; protected override Container<Drawable> Content => dimContent;
@ -78,7 +78,7 @@ namespace osu.Game.Graphics.Containers
IsBreakTime.ValueChanged += _ => UpdateVisuals(); IsBreakTime.ValueChanged += _ => UpdateVisuals();
ShowStoryboard.ValueChanged += _ => UpdateVisuals(); ShowStoryboard.ValueChanged += _ => UpdateVisuals();
StoryboardReplacesBackground.ValueChanged += _ => UpdateVisuals(); StoryboardReplacesBackground.ValueChanged += _ => UpdateVisuals();
IgnoreUserSettings.ValueChanged += _ => UpdateVisuals(); ApplyUserSettings.ValueChanged += _ => UpdateVisuals();
} }
protected override void LoadComplete() protected override void LoadComplete()

View File

@ -37,8 +37,8 @@ namespace osu.Game.Rulesets.Mods
public void ApplyToPlayer(Player player) public void ApplyToPlayer(Player player)
{ {
player.ApplyToBackground(b => b.IgnoreUserSettings.Value = true); player.ApplyToBackground(b => b.ApplyUserSettings.Value = false);
player.DimmableStoryboard.IgnoreUserSettings.Value = true; player.DimmableStoryboard.ApplyUserSettings.Value = false;
player.BreakOverlay.Hide(); player.BreakOverlay.Hide();
} }

View File

@ -27,9 +27,9 @@ namespace osu.Game.Screens.Backgrounds
private WorkingBeatmap beatmap; private WorkingBeatmap beatmap;
/// <summary> /// <summary>
/// Whether or not user-configured settings relating to brightness of elements should be ignored /// Whether or not user-configured effect settings should be applied to this background screen.
/// </summary> /// </summary>
public readonly Bindable<bool> IgnoreUserSettings = new Bindable<bool>(); public readonly Bindable<bool> ApplyUserSettings = new Bindable<bool>();
public readonly Bindable<bool> StoryboardReplacesBackground = new Bindable<bool>(); public readonly Bindable<bool> StoryboardReplacesBackground = new Bindable<bool>();
@ -50,10 +50,7 @@ namespace osu.Game.Screens.Backgrounds
InternalChild = dimmable = CreateFadeContainer(); InternalChild = dimmable = CreateFadeContainer();
// Beatmap background screens should not apply user settings by default. dimmable.ApplyUserSettings.BindTo(ApplyUserSettings);
IgnoreUserSettings.Value = true;
dimmable.IgnoreUserSettings.BindTo(IgnoreUserSettings);
dimmable.IsBreakTime.BindTo(IsBreakTime); dimmable.IsBreakTime.BindTo(IsBreakTime);
dimmable.BlurAmount.BindTo(BlurAmount); dimmable.BlurAmount.BindTo(BlurAmount);
@ -151,7 +148,7 @@ namespace osu.Game.Screens.Backgrounds
/// <summary> /// <summary>
/// As an optimisation, we add the two blur portions to be applied rather than actually applying two separate blurs. /// As an optimisation, we add the two blur portions to be applied rather than actually applying two separate blurs.
/// </summary> /// </summary>
private Vector2 blurTarget => !IgnoreUserSettings.Value private Vector2 blurTarget => ApplyUserSettings.Value
? new Vector2(BlurAmount.Value + (float)userBlurLevel.Value * USER_BLUR_FACTOR) ? new Vector2(BlurAmount.Value + (float)userBlurLevel.Value * USER_BLUR_FACTOR)
: new Vector2(BlurAmount.Value); : new Vector2(BlurAmount.Value);
@ -170,8 +167,8 @@ namespace osu.Game.Screens.Backgrounds
} }
protected override bool ShowDimContent protected override bool ShowDimContent
// The background needs to be hidden in the case of it being replaced by the storyboard // The background needs to be hidden in the case of it being replaced by the storyboard.
=> (!ShowStoryboard.Value && !IgnoreUserSettings.Value) || !StoryboardReplacesBackground.Value; => (ApplyUserSettings.Value && !ShowStoryboard.Value) || !StoryboardReplacesBackground.Value;
protected override void UpdateVisuals() protected override void UpdateVisuals()
{ {

View File

@ -467,7 +467,7 @@ namespace osu.Game.Screens.Edit
// todo: temporary. we want to be applying dim using the UserDimContainer eventually. // todo: temporary. we want to be applying dim using the UserDimContainer eventually.
b.FadeColour(Color4.DarkGray, 500); b.FadeColour(Color4.DarkGray, 500);
b.IgnoreUserSettings.Value = true; b.ApplyUserSettings.Value = false;
b.BlurAmount.Value = 0; b.BlurAmount.Value = 0;
}); });

View File

@ -38,14 +38,14 @@ namespace osu.Game.Screens.Play
base.LoadComplete(); base.LoadComplete();
} }
protected override bool ShowDimContent => IgnoreUserSettings.Value || (ShowStoryboard.Value && DimLevel < 1); protected override bool ShowDimContent => !ApplyUserSettings.Value || (ShowStoryboard.Value && DimLevel < 1);
private void initializeStoryboard(bool async) private void initializeStoryboard(bool async)
{ {
if (drawableStoryboard != null) if (drawableStoryboard != null)
return; return;
if (!ShowStoryboard.Value && !IgnoreUserSettings.Value) if (ApplyUserSettings.Value && !ShowStoryboard.Value)
return; return;
drawableStoryboard = storyboard.CreateDrawable(); drawableStoryboard = storyboard.CreateDrawable();

View File

@ -764,7 +764,7 @@ namespace osu.Game.Screens.Play
ApplyToBackground(b => ApplyToBackground(b =>
{ {
b.IgnoreUserSettings.Value = false; b.ApplyUserSettings.Value = true;
b.BlurAmount.Value = 0; b.BlurAmount.Value = 0;
// bind component bindables. // bind component bindables.
@ -913,7 +913,7 @@ namespace osu.Game.Screens.Play
float fadeOutDuration = instant ? 0 : 250; float fadeOutDuration = instant ? 0 : 250;
this.FadeOut(fadeOutDuration); this.FadeOut(fadeOutDuration);
ApplyToBackground(b => b.IgnoreUserSettings.Value = true); ApplyToBackground(b => b.ApplyUserSettings.Value = false);
storyboardReplacesBackground.Value = false; storyboardReplacesBackground.Value = false;
} }

View File

@ -229,7 +229,7 @@ namespace osu.Game.Screens.Play
content.ScaleTo(0.7f, 150, Easing.InQuint); content.ScaleTo(0.7f, 150, Easing.InQuint);
this.FadeOut(150); this.FadeOut(150);
ApplyToBackground(b => b.IgnoreUserSettings.Value = true); ApplyToBackground(b => b.ApplyUserSettings.Value = false);
BackgroundBrightnessReduction = false; BackgroundBrightnessReduction = false;
Beatmap.Value.Track.RemoveAdjustment(AdjustableProperty.Volume, volumeAdjustment); Beatmap.Value.Track.RemoveAdjustment(AdjustableProperty.Volume, volumeAdjustment);
@ -277,7 +277,7 @@ namespace osu.Game.Screens.Play
// Preview user-defined background dim and blur when hovered on the visual settings panel. // Preview user-defined background dim and blur when hovered on the visual settings panel.
ApplyToBackground(b => ApplyToBackground(b =>
{ {
b.IgnoreUserSettings.Value = false; b.ApplyUserSettings.Value = true;
b.BlurAmount.Value = 0; b.BlurAmount.Value = 0;
}); });
@ -288,7 +288,7 @@ namespace osu.Game.Screens.Play
ApplyToBackground(b => ApplyToBackground(b =>
{ {
// Returns background dim and blur to the values specified by PlayerLoader. // Returns background dim and blur to the values specified by PlayerLoader.
b.IgnoreUserSettings.Value = true; b.ApplyUserSettings.Value = false;
b.BlurAmount.Value = BACKGROUND_BLUR; b.BlurAmount.Value = BACKGROUND_BLUR;
}); });