diff --git a/osu.Game/Graphics/Containers/VisualSettingsContainer.cs b/osu.Game/Graphics/Containers/VisualSettingsContainer.cs index cd81fa98ea..3d9e340d5f 100644 --- a/osu.Game/Graphics/Containers/VisualSettingsContainer.cs +++ b/osu.Game/Graphics/Containers/VisualSettingsContainer.cs @@ -1,11 +1,16 @@ // Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. +using System; using osu.Framework.Allocation; using osu.Framework.Bindables; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; +using osu.Framework.Logging; +using osu.Game.Beatmaps; using osu.Game.Configuration; +using osu.Game.Graphics.Backgrounds; +using osu.Game.Screens.Backgrounds; using osuTK; using osuTK.Graphics; @@ -19,6 +24,8 @@ namespace osu.Game.Graphics.Containers { private const float background_fade_duration = 800; + public Action ContentLoadComplete = () => { }; + private Bindable dimLevel { get; set; } private Bindable blurLevel { get; set; } @@ -35,13 +42,13 @@ namespace osu.Game.Graphics.Containers /// public readonly Bindable StoryboardReplacesBackground = new Bindable(); - protected BufferedContainer LocalContainer { get; } + protected Container LocalContainer { get; } protected override Container Content => LocalContainer; private readonly bool isStoryboard; - private Vector2 returnBlur; + public Bindable AddedBlur = new Bindable(); /// /// Creates a new . @@ -55,7 +62,7 @@ namespace osu.Game.Graphics.Containers public VisualSettingsContainer(bool isStoryboard = false) { this.isStoryboard = isStoryboard; - AddInternal(LocalContainer = new BufferedContainer { RelativeSizeAxes = Axes.Both }); + AddInternal(LocalContainer = new Container { RelativeSizeAxes = Axes.Both }); } [BackgroundDependencyLoader] @@ -64,20 +71,21 @@ namespace osu.Game.Graphics.Containers dimLevel = config.GetBindable(OsuSetting.DimLevel); blurLevel = config.GetBindable(OsuSetting.BlurLevel); showStoryboard = config.GetBindable(OsuSetting.ShowStoryboard); - EnableVisualSettings.ValueChanged += _ => updateVisuals(); - dimLevel.ValueChanged += _ => updateVisuals(); - blurLevel.ValueChanged += _ => updateVisuals(); - showStoryboard.ValueChanged += _ => updateVisuals(); - StoryboardReplacesBackground.ValueChanged += _ => updateVisuals(); + EnableVisualSettings.ValueChanged += _ => UpdateVisuals(); + dimLevel.ValueChanged += _ => UpdateVisuals(); + blurLevel.ValueChanged += _ => UpdateVisuals(); + showStoryboard.ValueChanged += _ => UpdateVisuals(); + StoryboardReplacesBackground.ValueChanged += _ => UpdateVisuals(); + AddedBlur.ValueChanged += _ => UpdateVisuals(); } protected override void LoadComplete() { base.LoadComplete(); - updateVisuals(); + UpdateVisuals(); } - private void updateVisuals() + public void UpdateVisuals() { if (isStoryboard) { @@ -88,8 +96,17 @@ namespace osu.Game.Graphics.Containers // The background needs to be hidden in the case of it being replaced by the storyboard LocalContainer.FadeTo(showStoryboard.Value && StoryboardReplacesBackground.Value ? 0 : 1, background_fade_duration, Easing.OutQuint); - // Only blur if this container contains a background - LocalContainer.BlurTo(EnableVisualSettings.Value ? new Vector2((float)blurLevel.Value * 25) : new Vector2(0), background_fade_duration, Easing.OutQuint); + foreach (Drawable c in LocalContainer) + { + // Only blur if this container contains a background + // We can't blur the container like we did with the dim because buffered containers add considerable draw overhead. + // As a result, this blurs the background directly. + ((Background)c)?.BlurTo(EnableVisualSettings.Value + ? new Vector2(AddedBlur.Value + (float)blurLevel.Value * 25) + : new Vector2(AddedBlur.Value), background_fade_duration, Easing.OutQuint); + + Logger.Log("Enable visual settings: " + EnableVisualSettings.Value + " Added blur is: " + AddedBlur.Value); + } } LocalContainer.FadeColour(EnableVisualSettings.Value ? OsuColour.Gray(1 - (float)dimLevel.Value) : Color4.White, background_fade_duration, Easing.OutQuint); diff --git a/osu.Game/Screens/Backgrounds/BackgroundScreenBeatmap.cs b/osu.Game/Screens/Backgrounds/BackgroundScreenBeatmap.cs index ee393fc13e..3670ac7663 100644 --- a/osu.Game/Screens/Backgrounds/BackgroundScreenBeatmap.cs +++ b/osu.Game/Screens/Backgrounds/BackgroundScreenBeatmap.cs @@ -8,7 +8,6 @@ using osu.Framework.Graphics.Textures; using osu.Game.Beatmaps; using osu.Game.Graphics.Backgrounds; using osu.Game.Graphics.Containers; -using osuTK; namespace osu.Game.Screens.Backgrounds { @@ -23,6 +22,8 @@ namespace osu.Game.Screens.Backgrounds public readonly Bindable StoryboardReplacesBackground = new Bindable(); + public readonly Bindable AddedBlur = new Bindable(); + private readonly VisualSettingsContainer fadeContainer; protected virtual VisualSettingsContainer CreateFadeContainer() => new VisualSettingsContainer { RelativeSizeAxes = Axes.Both }; @@ -52,6 +53,7 @@ namespace osu.Game.Screens.Backgrounds b.Depth = newDepth; fadeContainer.Add(Background = b); + fadeContainer.UpdateVisuals(); Background.BlurSigma = BlurTarget; StoryboardReplacesBackground.BindTo(fadeContainer.StoryboardReplacesBackground); })); @@ -64,6 +66,7 @@ namespace osu.Game.Screens.Backgrounds Beatmap = beatmap; InternalChild = fadeContainer = CreateFadeContainer(); fadeContainer.EnableVisualSettings.BindTo(EnableVisualSettings); + fadeContainer.AddedBlur.BindTo(AddedBlur); } public override bool Equals(BackgroundScreen other) diff --git a/osu.Game/Screens/Play/PlayerLoader.cs b/osu.Game/Screens/Play/PlayerLoader.cs index e45421ce4a..6eee681e67 100644 --- a/osu.Game/Screens/Play/PlayerLoader.cs +++ b/osu.Game/Screens/Play/PlayerLoader.cs @@ -26,7 +26,7 @@ namespace osu.Game.Screens.Play { public class PlayerLoader : ScreenWithBeatmapBackground { - protected static readonly Vector2 BACKGROUND_BLUR = new Vector2(15); + private const float background_blur = 15; private readonly Func createPlayer; @@ -119,7 +119,7 @@ namespace osu.Game.Screens.Play private void contentIn() { - Background?.BlurTo(BACKGROUND_BLUR, 800, Easing.OutQuint); + Background.AddedBlur.Value = background_blur; content.ScaleTo(1, 650, Easing.OutQuint); content.FadeInFromZero(400); @@ -127,7 +127,7 @@ namespace osu.Game.Screens.Play private void contentOut() { - Background?.BlurTo(new Vector2(0), 800, Easing.OutQuint); + Background.AddedBlur.Value = 0; content.ScaleTo(0.7f, 300, Easing.InQuint); content.FadeOut(250); @@ -166,7 +166,7 @@ namespace osu.Game.Screens.Play { if (this.IsCurrentScreen()) { - Background.BlurTo(BACKGROUND_BLUR, 800, Easing.OutQuint); + Background.AddedBlur.Value = background_blur; Background.EnableVisualSettings.Value = false; } @@ -179,7 +179,7 @@ namespace osu.Game.Screens.Play { if (this.IsCurrentScreen() && Background != null) { - Background.BlurTo(new Vector2(0), 800, Easing.OutQuint); + Background.AddedBlur.Value = 0; Background.EnableVisualSettings.Value = true; } } @@ -239,6 +239,8 @@ namespace osu.Game.Screens.Play public override void OnSuspending(IScreen next) { + Background.EnableVisualSettings.Value = true; + base.OnSuspending(next); cancelLoad(); } @@ -249,7 +251,7 @@ namespace osu.Game.Screens.Play this.FadeOut(150); cancelLoad(); - Background.EnableVisualSettings.Value = false; + Background.EnableVisualSettings.Value = true; return base.OnExiting(next); } diff --git a/osu.Game/Screens/Ranking/Results.cs b/osu.Game/Screens/Ranking/Results.cs index eb3ce66547..a30534a5d3 100644 --- a/osu.Game/Screens/Ranking/Results.cs +++ b/osu.Game/Screens/Ranking/Results.cs @@ -24,7 +24,7 @@ namespace osu.Game.Screens.Ranking { public abstract class Results : OsuScreen { - protected static readonly Vector2 BACKGROUND_BLUR = new Vector2(20); + private const float background_blur = 20; private Container circleOuterBackground; private Container circleOuter; @@ -58,7 +58,7 @@ namespace osu.Game.Screens.Ranking public override void OnEntering(IScreen last) { base.OnEntering(last); - (Background as BackgroundScreenBeatmap)?.BlurTo(BACKGROUND_BLUR, 2500, Easing.OutQuint); + ((BackgroundScreenBeatmap)Background).AddedBlur.Value = background_blur; Background.ScaleTo(1.1f, transition_time, Easing.OutQuint); allCircles.ForEach(c => diff --git a/osu.Game/Screens/Select/SongSelect.cs b/osu.Game/Screens/Select/SongSelect.cs index d10e6994d5..22e4b2ffa2 100644 --- a/osu.Game/Screens/Select/SongSelect.cs +++ b/osu.Game/Screens/Select/SongSelect.cs @@ -37,8 +37,8 @@ namespace osu.Game.Screens.Select { public abstract class SongSelect : OsuScreen { - protected static readonly Vector2 BACKGROUND_BLUR = new Vector2(20); private static readonly Vector2 wedged_container_size = new Vector2(0.5f, 245); + private const float background_blur = 20; private const float left_area_padding = 20; public readonly FilterControl FilterControl; @@ -556,8 +556,9 @@ namespace osu.Game.Screens.Select if (Background is BackgroundScreenBeatmap backgroundModeBeatmap) { backgroundModeBeatmap.Beatmap = beatmap; - backgroundModeBeatmap.BlurTo(BACKGROUND_BLUR, 750, Easing.OutQuint); + backgroundModeBeatmap.AddedBlur.Value = background_blur; backgroundModeBeatmap.FadeColour(Color4.White, 250); + Logger.Log("blur updated!"); } beatmapInfoWedge.Beatmap = beatmap;