From 2467ece0205dc2b4827269c370892556bddd1ec9 Mon Sep 17 00:00:00 2001 From: David Zhao Date: Wed, 20 Mar 2019 14:58:32 +0900 Subject: [PATCH] store a field --- osu.Game/Graphics/Containers/UserDimContainer.cs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/osu.Game/Graphics/Containers/UserDimContainer.cs b/osu.Game/Graphics/Containers/UserDimContainer.cs index 22b0175a94..61129b43af 100644 --- a/osu.Game/Graphics/Containers/UserDimContainer.cs +++ b/osu.Game/Graphics/Containers/UserDimContainer.cs @@ -1,7 +1,6 @@ // Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. -using System.Linq; using osu.Framework.Allocation; using osu.Framework.Bindables; using osu.Framework.Graphics; @@ -55,6 +54,8 @@ namespace osu.Game.Graphics.Containers ? new Vector2(BlurAmount.Value + (float)blurLevel.Value * 25) : new Vector2(BlurAmount.Value); + private Background background; + /// /// Creates a new . /// @@ -74,7 +75,10 @@ namespace osu.Game.Graphics.Containers { // We need to blur instantly here in the case of changing beatmap backgrounds, where blurring shouldn't be from 0 every time the beatmap is changed. if (drawable is Background b) + { + background = b; b.BlurTo(blurTarget, 0, Easing.OutQuint); + } base.Add(drawable); } @@ -113,7 +117,7 @@ namespace osu.Game.Graphics.Containers // This only works if the background is a direct child of DimContainer. // 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 via the direct children of DimContainer. - DimContainer.Children.OfType().FirstOrDefault()?.BlurTo(blurTarget, background_fade_duration, Easing.OutQuint); + background?.BlurTo(blurTarget, background_fade_duration, Easing.OutQuint); } DimContainer.FadeColour(EnableUserDim.Value ? OsuColour.Gray(1 - (float)dimLevel.Value) : Color4.White, background_fade_duration, Easing.OutQuint);