From 0cf4bf2352048fd6feca7495a69b6d9e09b992f9 Mon Sep 17 00:00:00 2001 From: David Zhao Date: Mon, 8 Jul 2019 18:46:12 +0900 Subject: [PATCH 01/16] Manually set clock for storyboard if loading before being given a parent --- osu.Game/Screens/Play/Player.cs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/osu.Game/Screens/Play/Player.cs b/osu.Game/Screens/Play/Player.cs index 0da9c77f25..ea614e7658 100644 --- a/osu.Game/Screens/Play/Player.cs +++ b/osu.Game/Screens/Play/Player.cs @@ -362,7 +362,12 @@ namespace osu.Game.Screens.Play storyboard.Masking = true; if (asyncLoad) - LoadComponentAsync(storyboard, StoryboardContainer.Add); + LoadComponentAsync(storyboard, c => + { + // Since the storyboard was loaded before it can be added to the draw hierarchy, manually set the clock for it here. + c.Clock = GameplayClockContainer.GameplayClock; + StoryboardContainer.Add(c); + }); else StoryboardContainer.Add(storyboard); } From 89cb8a0cacb4ac50a1b83cbf32923d40ba5d13d7 Mon Sep 17 00:00:00 2001 From: David Zhao Date: Tue, 9 Jul 2019 16:23:59 +0900 Subject: [PATCH 02/16] Move storyboard initialization to new StoryboardContainer --- .../TestSceneBackgroundScreenBeatmap.cs | 26 ++++---- .../Containers/StoryboardContainer.cs | 59 +++++++++++++++++++ .../Graphics/Containers/UserDimContainer.cs | 52 ++++++++-------- osu.Game/Screens/Play/Player.cs | 42 ++----------- 4 files changed, 103 insertions(+), 76 deletions(-) create mode 100644 osu.Game/Graphics/Containers/StoryboardContainer.cs diff --git a/osu.Game.Tests/Visual/Background/TestSceneBackgroundScreenBeatmap.cs b/osu.Game.Tests/Visual/Background/TestSceneBackgroundScreenBeatmap.cs index 8b941e4633..0d62bf9bdc 100644 --- a/osu.Game.Tests/Visual/Background/TestSceneBackgroundScreenBeatmap.cs +++ b/osu.Game.Tests/Visual/Background/TestSceneBackgroundScreenBeatmap.cs @@ -28,6 +28,7 @@ using osu.Game.Screens.Backgrounds; using osu.Game.Screens.Play; using osu.Game.Screens.Play.PlayerSettings; using osu.Game.Screens.Select; +using osu.Game.Storyboards; using osu.Game.Tests.Resources; using osu.Game.Users; using osuTK; @@ -333,9 +334,9 @@ namespace osu.Game.Tests.Visual.Background { protected override BackgroundScreen CreateBackground() => new FadeAccessibleBackground(Beatmap.Value); - protected override UserDimContainer CreateStoryboardContainer() + protected override StoryboardContainer CreateStoryboardContainer(Storyboard storyboard) { - return new TestUserDimContainer(true) + return new TestStoryboardContainer { RelativeSizeAxes = Axes.Both, Alpha = 1, @@ -343,7 +344,7 @@ namespace osu.Game.Tests.Visual.Background }; } - public UserDimContainer CurrentStoryboardContainer => StoryboardContainer; + public TestStoryboardContainer CurrentStoryboardContainer => (TestStoryboardContainer)StoryboardContainer; // Whether or not the player should be allowed to load. public bool BlockLoad; @@ -357,9 +358,9 @@ namespace osu.Game.Tests.Visual.Background { } - public bool IsStoryboardVisible() => ((TestUserDimContainer)CurrentStoryboardContainer).CurrentAlpha == 1; + public bool IsStoryboardVisible() => CurrentStoryboardContainer.CurrentAlpha == 1; - public bool IsStoryboardInvisible() => ((TestUserDimContainer)CurrentStoryboardContainer).CurrentAlpha <= 1; + public bool IsStoryboardInvisible() => CurrentStoryboardContainer.CurrentAlpha <= 1; [BackgroundDependencyLoader] private void load(OsuConfigManager config, CancellationToken token) @@ -408,15 +409,20 @@ namespace osu.Game.Tests.Visual.Background } } + private class TestStoryboardContainer : StoryboardContainer + { + public float CurrentAlpha => DimContainer.Alpha; + + public TestStoryboardContainer() + : base(new Storyboard()) + { + } + } + private class TestUserDimContainer : UserDimContainer { public Color4 CurrentColour => DimContainer.Colour; public float CurrentAlpha => DimContainer.Alpha; - - public TestUserDimContainer(bool isStoryboard = false) - : base(isStoryboard) - { - } } } } diff --git a/osu.Game/Graphics/Containers/StoryboardContainer.cs b/osu.Game/Graphics/Containers/StoryboardContainer.cs new file mode 100644 index 0000000000..c425d38d48 --- /dev/null +++ b/osu.Game/Graphics/Containers/StoryboardContainer.cs @@ -0,0 +1,59 @@ +// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. +// See the LICENCE file in the repository root for full licence text. + +using osu.Framework.Allocation; +using osu.Framework.Graphics; +using osu.Game.Storyboards; +using osu.Game.Storyboards.Drawables; + +namespace osu.Game.Graphics.Containers +{ + /// + /// A container that handles loading, as well as applies user-specified visual settings to it. + /// + public class StoryboardContainer : UserDimContainer + { + private readonly Storyboard storyboard; + private DrawableStoryboard drawableStoryboard; + + public StoryboardContainer(Storyboard storyboard) + { + this.storyboard = storyboard; + } + + [BackgroundDependencyLoader] + private void load() + { + initializeStoryboard(false); + } + + protected override void LoadComplete() + { + ShowStoryboard.ValueChanged += _ => initializeStoryboard(true); + base.LoadComplete(); + } + + protected override void ApplyFade() + { + // Storyboards cannot be blurred, so we should just hide the storyboard if it gets toggled. + DimContainer.FadeTo(!ShowStoryboard.Value || UserDimLevel.Value == 1 ? 0 : 1, BACKGROUND_FADE_DURATION, Easing.OutQuint); + } + + private void initializeStoryboard(bool async) + { + if (drawableStoryboard != null) + return; + + if (!ShowStoryboard.Value) + return; + + drawableStoryboard = storyboard.CreateDrawable(); + drawableStoryboard.Masking = true; + + if (async) + LoadComponentAsync(drawableStoryboard, Add); + else + Add(drawableStoryboard); + } + } +} diff --git a/osu.Game/Graphics/Containers/UserDimContainer.cs b/osu.Game/Graphics/Containers/UserDimContainer.cs index fe9eb7baf4..b14051f432 100644 --- a/osu.Game/Graphics/Containers/UserDimContainer.cs +++ b/osu.Game/Graphics/Containers/UserDimContainer.cs @@ -16,11 +16,10 @@ namespace osu.Game.Graphics.Containers { /// /// A container that applies user-configured visual settings to its contents. - /// This container specifies behavior that applies to both Storyboards and Backgrounds. /// public class UserDimContainer : Container { - private const float background_fade_duration = 800; + protected const float BACKGROUND_FADE_DURATION = 800; /// /// Whether or not user-configured dim levels should be applied to the container. @@ -40,17 +39,15 @@ namespace osu.Game.Graphics.Containers /// public readonly Bindable BlurAmount = new Bindable(); - private Bindable userDimLevel { get; set; } + protected Bindable UserDimLevel { get; private set; } - private Bindable userBlurLevel { get; set; } - - private Bindable showStoryboard { get; set; } + protected Bindable ShowStoryboard { get; private set; } protected Container DimContainer { get; } protected override Container Content => DimContainer; - private readonly bool isStoryboard; + private Bindable userBlurLevel { get; set; } /// /// As an optimisation, we add the two blur portions to be applied rather than actually applying two separate blurs. @@ -62,15 +59,12 @@ namespace osu.Game.Graphics.Containers /// /// Creates a new . /// - /// Whether or not this instance contains a storyboard. /// - /// While both backgrounds and storyboards allow user dim levels to be applied, storyboards can be toggled via + /// While both backgrounds and storyboards allow user dim levels to be applied, storyboards can be toggled via /// and can cause backgrounds to become hidden via . Storyboards are also currently unable to be blurred. /// - /// - public UserDimContainer(bool isStoryboard = false) + public UserDimContainer() { - this.isStoryboard = isStoryboard; AddInternal(DimContainer = new Container { RelativeSizeAxes = Axes.Both }); } @@ -97,16 +91,16 @@ namespace osu.Game.Graphics.Containers [BackgroundDependencyLoader] private void load(OsuConfigManager config) { - userDimLevel = config.GetBindable(OsuSetting.DimLevel); + UserDimLevel = config.GetBindable(OsuSetting.DimLevel); userBlurLevel = config.GetBindable(OsuSetting.BlurLevel); - showStoryboard = config.GetBindable(OsuSetting.ShowStoryboard); + ShowStoryboard = config.GetBindable(OsuSetting.ShowStoryboard); EnableUserDim.ValueChanged += _ => updateVisuals(); - userDimLevel.ValueChanged += _ => updateVisuals(); - userBlurLevel.ValueChanged += _ => updateVisuals(); - showStoryboard.ValueChanged += _ => updateVisuals(); + UserDimLevel.ValueChanged += _ => updateVisuals(); + ShowStoryboard.ValueChanged += _ => updateVisuals(); StoryboardReplacesBackground.ValueChanged += _ => updateVisuals(); BlurAmount.ValueChanged += _ => updateVisuals(); + userBlurLevel.ValueChanged += _ => updateVisuals(); } protected override void LoadComplete() @@ -115,21 +109,21 @@ namespace osu.Game.Graphics.Containers updateVisuals(); } + /// + /// Apply non-dim related settings to the background, such as hiding and blurring. + /// + protected virtual void ApplyFade() + { + // The background needs to be hidden in the case of it being replaced by the storyboard + DimContainer.FadeTo(ShowStoryboard.Value && StoryboardReplacesBackground.Value ? 0 : 1, BACKGROUND_FADE_DURATION, Easing.OutQuint); + Background?.BlurTo(blurTarget, BACKGROUND_FADE_DURATION, Easing.OutQuint); + } + private void updateVisuals() { - if (isStoryboard) - { - DimContainer.FadeTo(!showStoryboard.Value || userDimLevel.Value == 1 ? 0 : 1, background_fade_duration, Easing.OutQuint); - } - else - { - // The background needs to be hidden in the case of it being replaced by the storyboard - DimContainer.FadeTo(showStoryboard.Value && StoryboardReplacesBackground.Value ? 0 : 1, background_fade_duration, Easing.OutQuint); + ApplyFade(); - Background?.BlurTo(blurTarget, background_fade_duration, Easing.OutQuint); - } - - DimContainer.FadeColour(EnableUserDim.Value ? OsuColour.Gray(1 - (float)userDimLevel.Value) : Color4.White, background_fade_duration, Easing.OutQuint); + DimContainer.FadeColour(EnableUserDim.Value ? OsuColour.Gray(1 - (float)UserDimLevel.Value) : Color4.White, BACKGROUND_FADE_DURATION, Easing.OutQuint); } } } diff --git a/osu.Game/Screens/Play/Player.cs b/osu.Game/Screens/Play/Player.cs index ea614e7658..621df0b562 100644 --- a/osu.Game/Screens/Play/Player.cs +++ b/osu.Game/Screens/Play/Player.cs @@ -26,7 +26,7 @@ using osu.Game.Rulesets.UI; using osu.Game.Scoring; using osu.Game.Screens.Ranking; using osu.Game.Skinning; -using osu.Game.Storyboards.Drawables; +using osu.Game.Storyboards; using osu.Game.Users; namespace osu.Game.Screens.Play @@ -109,7 +109,7 @@ namespace osu.Game.Screens.Play sampleRestart = audio.Samples.Get(@"Gameplay/restart"); mouseWheelDisabled = config.GetBindable(OsuSetting.MouseDisableWheel); - showStoryboard = config.GetBindable(OsuSetting.ShowStoryboard); + config.GetBindable(OsuSetting.ShowStoryboard); ScoreProcessor = DrawableRuleset.CreateScoreProcessor(); ScoreProcessor.Mods.BindTo(Mods); @@ -121,7 +121,7 @@ namespace osu.Game.Screens.Play GameplayClockContainer.Children = new[] { - StoryboardContainer = CreateStoryboardContainer(), + StoryboardContainer = CreateStoryboardContainer(Beatmap.Value.Storyboard), new ScalingContainer(ScalingMode.Gameplay) { Child = new LocalSkinOverrideContainer(working.Skin) @@ -199,9 +199,6 @@ namespace osu.Game.Screens.Play // bind clock into components that require it DrawableRuleset.IsPaused.BindTo(GameplayClockContainer.IsPaused); - // load storyboard as part of player's load if we can - initializeStoryboard(false); - // Bind ScoreProcessor to ourselves ScoreProcessor.AllJudged += onCompletion; ScoreProcessor.Failed += onFail; @@ -336,42 +333,15 @@ namespace osu.Game.Screens.Play #region Storyboard - private DrawableStoryboard storyboard; - protected UserDimContainer StoryboardContainer { get; private set; } + protected StoryboardContainer StoryboardContainer { get; private set; } - protected virtual UserDimContainer CreateStoryboardContainer() => new UserDimContainer(true) + protected virtual StoryboardContainer CreateStoryboardContainer(Storyboard storyboard) => new StoryboardContainer(storyboard) { RelativeSizeAxes = Axes.Both, Alpha = 1, EnableUserDim = { Value = true } }; - private Bindable showStoryboard; - - private void initializeStoryboard(bool asyncLoad) - { - if (StoryboardContainer == null || storyboard != null) - return; - - if (!showStoryboard.Value) - return; - - var beatmap = Beatmap.Value; - - storyboard = beatmap.Storyboard.CreateDrawable(); - storyboard.Masking = true; - - if (asyncLoad) - LoadComponentAsync(storyboard, c => - { - // Since the storyboard was loaded before it can be added to the draw hierarchy, manually set the clock for it here. - c.Clock = GameplayClockContainer.GameplayClock; - StoryboardContainer.Add(c); - }); - else - StoryboardContainer.Add(storyboard); - } - #endregion #region Fail Logic @@ -491,8 +461,6 @@ namespace osu.Game.Screens.Play .Delay(250) .FadeIn(250); - showStoryboard.ValueChanged += _ => initializeStoryboard(true); - Background.EnableUserDim.Value = true; Background.BlurAmount.Value = 0; From 1b5fadf93f468ea0c6894cba50e80f03797d48f0 Mon Sep 17 00:00:00 2001 From: David Zhao Date: Tue, 9 Jul 2019 16:38:12 +0900 Subject: [PATCH 03/16] move comment to more relevant location --- osu.Game/Graphics/Containers/UserDimContainer.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/osu.Game/Graphics/Containers/UserDimContainer.cs b/osu.Game/Graphics/Containers/UserDimContainer.cs index b14051f432..89c1821425 100644 --- a/osu.Game/Graphics/Containers/UserDimContainer.cs +++ b/osu.Game/Graphics/Containers/UserDimContainer.cs @@ -59,10 +59,6 @@ namespace osu.Game.Graphics.Containers /// /// Creates a new . /// - /// - /// While both backgrounds and storyboards allow user dim levels to be applied, storyboards can be toggled via - /// and can cause backgrounds to become hidden via . Storyboards are also currently unable to be blurred. - /// public UserDimContainer() { AddInternal(DimContainer = new Container { RelativeSizeAxes = Axes.Both }); @@ -112,6 +108,10 @@ namespace osu.Game.Graphics.Containers /// /// Apply non-dim related settings to the background, such as hiding and blurring. /// + /// + /// While both backgrounds and storyboards allow user dim levels to be applied, storyboards can be toggled via + /// and can cause backgrounds to become hidden via . Storyboards are also currently unable to be blurred. + /// protected virtual void ApplyFade() { // The background needs to be hidden in the case of it being replaced by the storyboard From 5bb21ecae0aa027c80ef2108ac3a1991495ed6f3 Mon Sep 17 00:00:00 2001 From: David Zhao Date: Tue, 9 Jul 2019 16:50:37 +0900 Subject: [PATCH 04/16] remove storyboard region --- .../Containers/StoryboardContainer.cs | 2 +- .../Graphics/Containers/UserDimContainer.cs | 2 +- osu.Game/Screens/Play/Player.cs | 22 ++++++++----------- 3 files changed, 11 insertions(+), 15 deletions(-) diff --git a/osu.Game/Graphics/Containers/StoryboardContainer.cs b/osu.Game/Graphics/Containers/StoryboardContainer.cs index c425d38d48..472e22e212 100644 --- a/osu.Game/Graphics/Containers/StoryboardContainer.cs +++ b/osu.Game/Graphics/Containers/StoryboardContainer.cs @@ -35,7 +35,7 @@ namespace osu.Game.Graphics.Containers protected override void ApplyFade() { - // Storyboards cannot be blurred, so we should just hide the storyboard if it gets toggled. + // Storyboards cannot be blurred, so just hide the storyboard if it gets toggled. DimContainer.FadeTo(!ShowStoryboard.Value || UserDimLevel.Value == 1 ? 0 : 1, BACKGROUND_FADE_DURATION, Easing.OutQuint); } diff --git a/osu.Game/Graphics/Containers/UserDimContainer.cs b/osu.Game/Graphics/Containers/UserDimContainer.cs index 89c1821425..ad6f73eff5 100644 --- a/osu.Game/Graphics/Containers/UserDimContainer.cs +++ b/osu.Game/Graphics/Containers/UserDimContainer.cs @@ -106,7 +106,7 @@ namespace osu.Game.Graphics.Containers } /// - /// Apply non-dim related settings to the background, such as hiding and blurring. + /// Apply non-dim related settings to the content, such as hiding and blurring. /// /// /// While both backgrounds and storyboards allow user dim levels to be applied, storyboards can be toggled via diff --git a/osu.Game/Screens/Play/Player.cs b/osu.Game/Screens/Play/Player.cs index 621df0b562..d9e050a681 100644 --- a/osu.Game/Screens/Play/Player.cs +++ b/osu.Game/Screens/Play/Player.cs @@ -76,6 +76,15 @@ namespace osu.Game.Screens.Play protected GameplayClockContainer GameplayClockContainer { get; private set; } + protected StoryboardContainer StoryboardContainer { get; private set; } + + protected virtual StoryboardContainer CreateStoryboardContainer(Storyboard storyboard) => new StoryboardContainer(storyboard) + { + RelativeSizeAxes = Axes.Both, + Alpha = 1, + EnableUserDim = { Value = true } + }; + [Cached] [Cached(Type = typeof(IBindable>))] protected new readonly Bindable> Mods = new Bindable>(Array.Empty()); @@ -331,19 +340,6 @@ namespace osu.Game.Screens.Play protected virtual Results CreateResults(ScoreInfo score) => new SoloResults(score); - #region Storyboard - - protected StoryboardContainer StoryboardContainer { get; private set; } - - protected virtual StoryboardContainer CreateStoryboardContainer(Storyboard storyboard) => new StoryboardContainer(storyboard) - { - RelativeSizeAxes = Axes.Both, - Alpha = 1, - EnableUserDim = { Value = true } - }; - - #endregion - #region Fail Logic protected FailOverlay FailOverlay { get; private set; } From 41afe89c0b1ee2f194c48f45c119fcab5dde72f3 Mon Sep 17 00:00:00 2001 From: David Zhao Date: Wed, 10 Jul 2019 00:46:34 +0900 Subject: [PATCH 05/16] delete no longer needed bindable --- osu.Game/Screens/Play/Player.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/osu.Game/Screens/Play/Player.cs b/osu.Game/Screens/Play/Player.cs index d9e050a681..663113f747 100644 --- a/osu.Game/Screens/Play/Player.cs +++ b/osu.Game/Screens/Play/Player.cs @@ -118,7 +118,6 @@ namespace osu.Game.Screens.Play sampleRestart = audio.Samples.Get(@"Gameplay/restart"); mouseWheelDisabled = config.GetBindable(OsuSetting.MouseDisableWheel); - config.GetBindable(OsuSetting.ShowStoryboard); ScoreProcessor = DrawableRuleset.CreateScoreProcessor(); ScoreProcessor.Mods.BindTo(Mods); From 7929104b8a8297c7333cc127b97d16370d453a71 Mon Sep 17 00:00:00 2001 From: David Zhao Date: Wed, 10 Jul 2019 12:24:05 +0900 Subject: [PATCH 06/16] move default into StoryboardContainer, fix load bug, remove comment --- .../Background/TestSceneBackgroundScreenBeatmap.cs | 10 +--------- osu.Game/Graphics/Containers/StoryboardContainer.cs | 5 +++-- osu.Game/Screens/Play/Player.cs | 7 +------ 3 files changed, 5 insertions(+), 17 deletions(-) diff --git a/osu.Game.Tests/Visual/Background/TestSceneBackgroundScreenBeatmap.cs b/osu.Game.Tests/Visual/Background/TestSceneBackgroundScreenBeatmap.cs index 0d62bf9bdc..f0e50f8498 100644 --- a/osu.Game.Tests/Visual/Background/TestSceneBackgroundScreenBeatmap.cs +++ b/osu.Game.Tests/Visual/Background/TestSceneBackgroundScreenBeatmap.cs @@ -334,15 +334,7 @@ namespace osu.Game.Tests.Visual.Background { protected override BackgroundScreen CreateBackground() => new FadeAccessibleBackground(Beatmap.Value); - protected override StoryboardContainer CreateStoryboardContainer(Storyboard storyboard) - { - return new TestStoryboardContainer - { - RelativeSizeAxes = Axes.Both, - Alpha = 1, - EnableUserDim = { Value = true } - }; - } + protected override StoryboardContainer CreateStoryboardContainer(Storyboard storyboard) => new TestStoryboardContainer { RelativeSizeAxes = Axes.Both }; public TestStoryboardContainer CurrentStoryboardContainer => (TestStoryboardContainer)StoryboardContainer; diff --git a/osu.Game/Graphics/Containers/StoryboardContainer.cs b/osu.Game/Graphics/Containers/StoryboardContainer.cs index 472e22e212..899cbe1f0d 100644 --- a/osu.Game/Graphics/Containers/StoryboardContainer.cs +++ b/osu.Game/Graphics/Containers/StoryboardContainer.cs @@ -19,6 +19,8 @@ namespace osu.Game.Graphics.Containers public StoryboardContainer(Storyboard storyboard) { this.storyboard = storyboard; + EnableUserDim.Default = true; + EnableUserDim.Value = true; } [BackgroundDependencyLoader] @@ -29,13 +31,12 @@ namespace osu.Game.Graphics.Containers protected override void LoadComplete() { - ShowStoryboard.ValueChanged += _ => initializeStoryboard(true); + ShowStoryboard.BindValueChanged(_ => initializeStoryboard(true), true); base.LoadComplete(); } protected override void ApplyFade() { - // Storyboards cannot be blurred, so just hide the storyboard if it gets toggled. DimContainer.FadeTo(!ShowStoryboard.Value || UserDimLevel.Value == 1 ? 0 : 1, BACKGROUND_FADE_DURATION, Easing.OutQuint); } diff --git a/osu.Game/Screens/Play/Player.cs b/osu.Game/Screens/Play/Player.cs index 663113f747..f44cb069a9 100644 --- a/osu.Game/Screens/Play/Player.cs +++ b/osu.Game/Screens/Play/Player.cs @@ -78,12 +78,7 @@ namespace osu.Game.Screens.Play protected StoryboardContainer StoryboardContainer { get; private set; } - protected virtual StoryboardContainer CreateStoryboardContainer(Storyboard storyboard) => new StoryboardContainer(storyboard) - { - RelativeSizeAxes = Axes.Both, - Alpha = 1, - EnableUserDim = { Value = true } - }; + protected virtual StoryboardContainer CreateStoryboardContainer(Storyboard storyboard) => new StoryboardContainer(storyboard) { RelativeSizeAxes = Axes.Both }; [Cached] [Cached(Type = typeof(IBindable>))] From 221ee58f550549a6f0e65c68a0baf4e68771cad6 Mon Sep 17 00:00:00 2001 From: David Zhao Date: Wed, 10 Jul 2019 12:36:58 +0900 Subject: [PATCH 07/16] make storyboard text more visible --- .../Visual/Background/TestSceneBackgroundScreenBeatmap.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/osu.Game.Tests/Visual/Background/TestSceneBackgroundScreenBeatmap.cs b/osu.Game.Tests/Visual/Background/TestSceneBackgroundScreenBeatmap.cs index f0e50f8498..d9f4631ea8 100644 --- a/osu.Game.Tests/Visual/Background/TestSceneBackgroundScreenBeatmap.cs +++ b/osu.Game.Tests/Visual/Background/TestSceneBackgroundScreenBeatmap.cs @@ -10,6 +10,7 @@ using osu.Framework.Allocation; using osu.Framework.Audio; using osu.Framework.Bindables; using osu.Framework.Graphics; +using osu.Framework.Graphics.Sprites; using osu.Framework.Input.Events; using osu.Framework.Input.States; using osu.Framework.Platform; @@ -244,12 +245,13 @@ namespace osu.Game.Tests.Visual.Background player.ReplacesBackground.Value = false; player.CurrentStoryboardContainer.Add(new OsuSpriteText { - Size = new Vector2(250, 50), + Size = new Vector2(500, 50), Alpha = 1, - Colour = Color4.Tomato, + Colour = Color4.White, Anchor = Anchor.Centre, Origin = Anchor.Centre, Text = "THIS IS A STORYBOARD", + Font = new FontUsage(size: 50) }); }); From 321266e96fc1de7735441dbb70ead7c856bff191 Mon Sep 17 00:00:00 2001 From: David Zhao Date: Thu, 11 Jul 2019 13:17:28 +0900 Subject: [PATCH 08/16] Make UserDimContainer abstract --- .../TestSceneBackgroundScreenBeatmap.cs | 20 +++--- .../Containers/DimmableBackgroundContainer.cs | 68 +++++++++++++++++++ ...iner.cs => DimmableStoryboardContainer.cs} | 6 +- .../Graphics/Containers/UserDimContainer.cs | 67 +++--------------- .../Backgrounds/BackgroundScreenBeatmap.cs | 4 +- osu.Game/Screens/Play/Player.cs | 8 +-- 6 files changed, 95 insertions(+), 78 deletions(-) create mode 100644 osu.Game/Graphics/Containers/DimmableBackgroundContainer.cs rename osu.Game/Graphics/Containers/{StoryboardContainer.cs => DimmableStoryboardContainer.cs} (89%) diff --git a/osu.Game.Tests/Visual/Background/TestSceneBackgroundScreenBeatmap.cs b/osu.Game.Tests/Visual/Background/TestSceneBackgroundScreenBeatmap.cs index d9f4631ea8..09aaee4adc 100644 --- a/osu.Game.Tests/Visual/Background/TestSceneBackgroundScreenBeatmap.cs +++ b/osu.Game.Tests/Visual/Background/TestSceneBackgroundScreenBeatmap.cs @@ -243,7 +243,7 @@ namespace osu.Game.Tests.Visual.Background { player.StoryboardEnabled.Value = false; player.ReplacesBackground.Value = false; - player.CurrentStoryboardContainer.Add(new OsuSpriteText + player.CurrentDimmableStoryboardContainer.Add(new OsuSpriteText { Size = new Vector2(500, 50), Alpha = 1, @@ -336,9 +336,9 @@ namespace osu.Game.Tests.Visual.Background { protected override BackgroundScreen CreateBackground() => new FadeAccessibleBackground(Beatmap.Value); - protected override StoryboardContainer CreateStoryboardContainer(Storyboard storyboard) => new TestStoryboardContainer { RelativeSizeAxes = Axes.Both }; + protected override DimmableStoryboardContainer CreateStoryboardContainer(Storyboard storyboard) => new TestDimmableStoryboardContainer { RelativeSizeAxes = Axes.Both }; - public TestStoryboardContainer CurrentStoryboardContainer => (TestStoryboardContainer)StoryboardContainer; + public TestDimmableStoryboardContainer CurrentDimmableStoryboardContainer => (TestDimmableStoryboardContainer)DimmableStoryboardContainer; // Whether or not the player should be allowed to load. public bool BlockLoad; @@ -352,9 +352,9 @@ namespace osu.Game.Tests.Visual.Background { } - public bool IsStoryboardVisible() => CurrentStoryboardContainer.CurrentAlpha == 1; + public bool IsStoryboardVisible() => CurrentDimmableStoryboardContainer.CurrentAlpha == 1; - public bool IsStoryboardInvisible() => CurrentStoryboardContainer.CurrentAlpha <= 1; + public bool IsStoryboardInvisible() => CurrentDimmableStoryboardContainer.CurrentAlpha <= 1; [BackgroundDependencyLoader] private void load(OsuConfigManager config, CancellationToken token) @@ -387,7 +387,7 @@ namespace osu.Game.Tests.Visual.Background private class FadeAccessibleBackground : BackgroundScreenBeatmap { - protected override UserDimContainer CreateFadeContainer() => fadeContainer = new TestUserDimContainer { RelativeSizeAxes = Axes.Both }; + protected override DimmableBackgroundContainer CreateFadeContainer() => fadeContainer = new TestDimmableBackgroundContainer { RelativeSizeAxes = Axes.Both }; public Color4 CurrentColour => fadeContainer.CurrentColour; @@ -395,7 +395,7 @@ namespace osu.Game.Tests.Visual.Background public Vector2 CurrentBlur => Background.BlurSigma; - private TestUserDimContainer fadeContainer; + private TestDimmableBackgroundContainer fadeContainer; public FadeAccessibleBackground(WorkingBeatmap beatmap) : base(beatmap) @@ -403,17 +403,17 @@ namespace osu.Game.Tests.Visual.Background } } - private class TestStoryboardContainer : StoryboardContainer + private class TestDimmableStoryboardContainer : DimmableStoryboardContainer { public float CurrentAlpha => DimContainer.Alpha; - public TestStoryboardContainer() + public TestDimmableStoryboardContainer() : base(new Storyboard()) { } } - private class TestUserDimContainer : UserDimContainer + private class TestDimmableBackgroundContainer : DimmableBackgroundContainer { public Color4 CurrentColour => DimContainer.Colour; public float CurrentAlpha => DimContainer.Alpha; diff --git a/osu.Game/Graphics/Containers/DimmableBackgroundContainer.cs b/osu.Game/Graphics/Containers/DimmableBackgroundContainer.cs new file mode 100644 index 0000000000..2d010943bd --- /dev/null +++ b/osu.Game/Graphics/Containers/DimmableBackgroundContainer.cs @@ -0,0 +1,68 @@ +// 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.Game.Configuration; +using osu.Game.Graphics.Backgrounds; +using osuTK; + +namespace osu.Game.Graphics.Containers +{ + public class DimmableBackgroundContainer : UserDimContainer + { + /// + /// The amount of blur to be applied to the background in addition to user-specified blur. + /// + /// + /// Used in contexts where there can potentially be both user and screen-specified blurring occuring at the same time, such as in + /// + public readonly Bindable BlurAmount = new Bindable(); + + private Bindable userBlurLevel { get; set; } + + private Background background; + + public Background Background + { + get => background; + set + { + base.Add(background = value); + background.BlurTo(blurTarget, 0, Easing.OutQuint); + } + } + + public override void Add(Drawable drawable) + { + if (drawable is Background) + throw new InvalidOperationException($"Use {nameof(Background)} to set a background."); + + base.Add(drawable); + } + + /// + /// As an optimisation, we add the two blur portions to be applied rather than actually applying two separate blurs. + /// + private Vector2 blurTarget => EnableUserDim.Value + ? new Vector2(BlurAmount.Value + (float)userBlurLevel.Value * 25) + : new Vector2(BlurAmount.Value); + + [BackgroundDependencyLoader] + private void load(OsuConfigManager config) + { + userBlurLevel = config.GetBindable(OsuSetting.BlurLevel); + BlurAmount.ValueChanged += _ => UpdateVisuals(); + userBlurLevel.ValueChanged += _ => UpdateVisuals(); + } + + protected override void ApplyFade() + { + // The background needs to be hidden in the case of it being replaced by the storyboard + DimContainer.FadeTo(ShowStoryboard.Value && StoryboardReplacesBackground.Value ? 0 : 1, BACKGROUND_FADE_DURATION, Easing.OutQuint); + Background?.BlurTo(blurTarget, BACKGROUND_FADE_DURATION, Easing.OutQuint); + } + } +} diff --git a/osu.Game/Graphics/Containers/StoryboardContainer.cs b/osu.Game/Graphics/Containers/DimmableStoryboardContainer.cs similarity index 89% rename from osu.Game/Graphics/Containers/StoryboardContainer.cs rename to osu.Game/Graphics/Containers/DimmableStoryboardContainer.cs index 899cbe1f0d..a8a7b67e01 100644 --- a/osu.Game/Graphics/Containers/StoryboardContainer.cs +++ b/osu.Game/Graphics/Containers/DimmableStoryboardContainer.cs @@ -11,16 +11,14 @@ namespace osu.Game.Graphics.Containers /// /// A container that handles loading, as well as applies user-specified visual settings to it. /// - public class StoryboardContainer : UserDimContainer + public class DimmableStoryboardContainer : UserDimContainer { private readonly Storyboard storyboard; private DrawableStoryboard drawableStoryboard; - public StoryboardContainer(Storyboard storyboard) + public DimmableStoryboardContainer(Storyboard storyboard) { this.storyboard = storyboard; - EnableUserDim.Default = true; - EnableUserDim.Value = true; } [BackgroundDependencyLoader] diff --git a/osu.Game/Graphics/Containers/UserDimContainer.cs b/osu.Game/Graphics/Containers/UserDimContainer.cs index ad6f73eff5..e6a040fcd8 100644 --- a/osu.Game/Graphics/Containers/UserDimContainer.cs +++ b/osu.Game/Graphics/Containers/UserDimContainer.cs @@ -1,15 +1,11 @@ // 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.Game.Configuration; -using osu.Game.Graphics.Backgrounds; -using osu.Game.Screens.Play; -using osuTK; using osuTK.Graphics; namespace osu.Game.Graphics.Containers @@ -17,7 +13,7 @@ namespace osu.Game.Graphics.Containers /// /// A container that applies user-configured visual settings to its contents. /// - public class UserDimContainer : Container + public abstract class UserDimContainer : Container { protected const float BACKGROUND_FADE_DURATION = 800; @@ -31,14 +27,6 @@ namespace osu.Game.Graphics.Containers /// public readonly Bindable StoryboardReplacesBackground = new Bindable(); - /// - /// The amount of blur to be applied to the background in addition to user-specified blur. - /// - /// - /// Used in contexts where there can potentially be both user and screen-specified blurring occuring at the same time, such as in - /// - public readonly Bindable BlurAmount = new Bindable(); - protected Bindable UserDimLevel { get; private set; } protected Bindable ShowStoryboard { get; private set; } @@ -47,62 +35,30 @@ namespace osu.Game.Graphics.Containers protected override Container Content => DimContainer; - private Bindable userBlurLevel { get; set; } - - /// - /// As an optimisation, we add the two blur portions to be applied rather than actually applying two separate blurs. - /// - private Vector2 blurTarget => EnableUserDim.Value - ? new Vector2(BlurAmount.Value + (float)userBlurLevel.Value * 25) - : new Vector2(BlurAmount.Value); - /// /// Creates a new . /// - public UserDimContainer() + protected UserDimContainer() { AddInternal(DimContainer = new Container { RelativeSizeAxes = Axes.Both }); } - private Background background; - - public Background Background - { - get => background; - set - { - base.Add(background = value); - background.BlurTo(blurTarget, 0, Easing.OutQuint); - } - } - - public override void Add(Drawable drawable) - { - if (drawable is Background) - throw new InvalidOperationException($"Use {nameof(Background)} to set a background."); - - base.Add(drawable); - } - [BackgroundDependencyLoader] private void load(OsuConfigManager config) { UserDimLevel = config.GetBindable(OsuSetting.DimLevel); - userBlurLevel = config.GetBindable(OsuSetting.BlurLevel); ShowStoryboard = config.GetBindable(OsuSetting.ShowStoryboard); - EnableUserDim.ValueChanged += _ => updateVisuals(); - UserDimLevel.ValueChanged += _ => updateVisuals(); - ShowStoryboard.ValueChanged += _ => updateVisuals(); - StoryboardReplacesBackground.ValueChanged += _ => updateVisuals(); - BlurAmount.ValueChanged += _ => updateVisuals(); - userBlurLevel.ValueChanged += _ => updateVisuals(); + EnableUserDim.ValueChanged += _ => UpdateVisuals(); + UserDimLevel.ValueChanged += _ => UpdateVisuals(); + ShowStoryboard.ValueChanged += _ => UpdateVisuals(); + StoryboardReplacesBackground.ValueChanged += _ => UpdateVisuals(); } protected override void LoadComplete() { base.LoadComplete(); - updateVisuals(); + UpdateVisuals(); } /// @@ -112,14 +68,9 @@ namespace osu.Game.Graphics.Containers /// While both backgrounds and storyboards allow user dim levels to be applied, storyboards can be toggled via /// and can cause backgrounds to become hidden via . Storyboards are also currently unable to be blurred. /// - protected virtual void ApplyFade() - { - // The background needs to be hidden in the case of it being replaced by the storyboard - DimContainer.FadeTo(ShowStoryboard.Value && StoryboardReplacesBackground.Value ? 0 : 1, BACKGROUND_FADE_DURATION, Easing.OutQuint); - Background?.BlurTo(blurTarget, BACKGROUND_FADE_DURATION, Easing.OutQuint); - } + protected abstract void ApplyFade(); - private void updateVisuals() + protected void UpdateVisuals() { ApplyFade(); diff --git a/osu.Game/Screens/Backgrounds/BackgroundScreenBeatmap.cs b/osu.Game/Screens/Backgrounds/BackgroundScreenBeatmap.cs index b6c2d016d2..1bb613755b 100644 --- a/osu.Game/Screens/Backgrounds/BackgroundScreenBeatmap.cs +++ b/osu.Game/Screens/Backgrounds/BackgroundScreenBeatmap.cs @@ -30,9 +30,9 @@ namespace osu.Game.Screens.Backgrounds /// public readonly Bindable BlurAmount = new Bindable(); - private readonly UserDimContainer fadeContainer; + private readonly DimmableBackgroundContainer fadeContainer; - protected virtual UserDimContainer CreateFadeContainer() => new UserDimContainer { RelativeSizeAxes = Axes.Both }; + protected virtual DimmableBackgroundContainer CreateFadeContainer() => new DimmableBackgroundContainer() { RelativeSizeAxes = Axes.Both }; public BackgroundScreenBeatmap(WorkingBeatmap beatmap = null) { diff --git a/osu.Game/Screens/Play/Player.cs b/osu.Game/Screens/Play/Player.cs index f44cb069a9..55e759d215 100644 --- a/osu.Game/Screens/Play/Player.cs +++ b/osu.Game/Screens/Play/Player.cs @@ -76,9 +76,9 @@ namespace osu.Game.Screens.Play protected GameplayClockContainer GameplayClockContainer { get; private set; } - protected StoryboardContainer StoryboardContainer { get; private set; } + protected DimmableStoryboardContainer DimmableStoryboardContainer { get; private set; } - protected virtual StoryboardContainer CreateStoryboardContainer(Storyboard storyboard) => new StoryboardContainer(storyboard) { RelativeSizeAxes = Axes.Both }; + protected virtual DimmableStoryboardContainer CreateStoryboardContainer(Storyboard storyboard) => new DimmableStoryboardContainer(storyboard) { RelativeSizeAxes = Axes.Both }; [Cached] [Cached(Type = typeof(IBindable>))] @@ -124,7 +124,7 @@ namespace osu.Game.Screens.Play GameplayClockContainer.Children = new[] { - StoryboardContainer = CreateStoryboardContainer(Beatmap.Value.Storyboard), + DimmableStoryboardContainer = CreateStoryboardContainer(Beatmap.Value.Storyboard), new ScalingContainer(ScalingMode.Gameplay) { Child = new LocalSkinOverrideContainer(working.Skin) @@ -455,7 +455,7 @@ namespace osu.Game.Screens.Play Background.BlurAmount.Value = 0; Background.StoryboardReplacesBackground.BindTo(storyboardReplacesBackground); - StoryboardContainer.StoryboardReplacesBackground.BindTo(storyboardReplacesBackground); + DimmableStoryboardContainer.StoryboardReplacesBackground.BindTo(storyboardReplacesBackground); storyboardReplacesBackground.Value = Beatmap.Value.Storyboard.ReplacesBackground && Beatmap.Value.Storyboard.HasDrawable; From ac170a695749c8b1e9b9662d193de78348a93e7c Mon Sep 17 00:00:00 2001 From: David Zhao Date: Thu, 11 Jul 2019 14:00:25 +0900 Subject: [PATCH 09/16] add comment and cleanup --- osu.Game/Graphics/Containers/DimmableBackgroundContainer.cs | 1 + osu.Game/Graphics/Containers/DimmableStoryboardContainer.cs | 4 ++++ osu.Game/Screens/Backgrounds/BackgroundScreenBeatmap.cs | 2 +- 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/osu.Game/Graphics/Containers/DimmableBackgroundContainer.cs b/osu.Game/Graphics/Containers/DimmableBackgroundContainer.cs index 2d010943bd..f415792993 100644 --- a/osu.Game/Graphics/Containers/DimmableBackgroundContainer.cs +++ b/osu.Game/Graphics/Containers/DimmableBackgroundContainer.cs @@ -7,6 +7,7 @@ using osu.Framework.Bindables; using osu.Framework.Graphics; using osu.Game.Configuration; using osu.Game.Graphics.Backgrounds; +using osu.Game.Screens.Play; using osuTK; namespace osu.Game.Graphics.Containers diff --git a/osu.Game/Graphics/Containers/DimmableStoryboardContainer.cs b/osu.Game/Graphics/Containers/DimmableStoryboardContainer.cs index a8a7b67e01..16379baeab 100644 --- a/osu.Game/Graphics/Containers/DimmableStoryboardContainer.cs +++ b/osu.Game/Graphics/Containers/DimmableStoryboardContainer.cs @@ -19,6 +19,10 @@ namespace osu.Game.Graphics.Containers public DimmableStoryboardContainer(Storyboard storyboard) { this.storyboard = storyboard; + + // Storyboards current do not get used in scenarios without user dim, so default to enabled here. + EnableUserDim.Default = true; + EnableUserDim.Value = true; } [BackgroundDependencyLoader] diff --git a/osu.Game/Screens/Backgrounds/BackgroundScreenBeatmap.cs b/osu.Game/Screens/Backgrounds/BackgroundScreenBeatmap.cs index 1bb613755b..97f77f789a 100644 --- a/osu.Game/Screens/Backgrounds/BackgroundScreenBeatmap.cs +++ b/osu.Game/Screens/Backgrounds/BackgroundScreenBeatmap.cs @@ -32,7 +32,7 @@ namespace osu.Game.Screens.Backgrounds private readonly DimmableBackgroundContainer fadeContainer; - protected virtual DimmableBackgroundContainer CreateFadeContainer() => new DimmableBackgroundContainer() { RelativeSizeAxes = Axes.Both }; + protected virtual DimmableBackgroundContainer CreateFadeContainer() => new DimmableBackgroundContainer { RelativeSizeAxes = Axes.Both }; public BackgroundScreenBeatmap(WorkingBeatmap beatmap = null) { From 932243cfd4c7908d548d15df939d4eb2df6e8eb1 Mon Sep 17 00:00:00 2001 From: David Zhao Date: Thu, 11 Jul 2019 14:14:00 +0900 Subject: [PATCH 10/16] public before private --- .../Graphics/Containers/DimmableBackgroundContainer.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/osu.Game/Graphics/Containers/DimmableBackgroundContainer.cs b/osu.Game/Graphics/Containers/DimmableBackgroundContainer.cs index f415792993..7339548069 100644 --- a/osu.Game/Graphics/Containers/DimmableBackgroundContainer.cs +++ b/osu.Game/Graphics/Containers/DimmableBackgroundContainer.cs @@ -22,10 +22,6 @@ namespace osu.Game.Graphics.Containers /// public readonly Bindable BlurAmount = new Bindable(); - private Bindable userBlurLevel { get; set; } - - private Background background; - public Background Background { get => background; @@ -36,6 +32,10 @@ namespace osu.Game.Graphics.Containers } } + private Bindable userBlurLevel { get; set; } + + private Background background; + public override void Add(Drawable drawable) { if (drawable is Background) From 0d9f978857a869f433bd6733d3640a0fb387cdcd Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 12 Jul 2019 11:38:15 +0900 Subject: [PATCH 11/16] Don't expose DimContainer --- .../TestSceneBackgroundScreenBeatmap.cs | 6 ++--- .../Containers/DimmableBackgroundContainer.cs | 10 ++++---- .../Containers/DimmableStoryboardContainer.cs | 6 +---- .../Graphics/Containers/UserDimContainer.cs | 24 +++++++++---------- 4 files changed, 21 insertions(+), 25 deletions(-) diff --git a/osu.Game.Tests/Visual/Background/TestSceneBackgroundScreenBeatmap.cs b/osu.Game.Tests/Visual/Background/TestSceneBackgroundScreenBeatmap.cs index 09aaee4adc..6a4145b24f 100644 --- a/osu.Game.Tests/Visual/Background/TestSceneBackgroundScreenBeatmap.cs +++ b/osu.Game.Tests/Visual/Background/TestSceneBackgroundScreenBeatmap.cs @@ -405,7 +405,7 @@ namespace osu.Game.Tests.Visual.Background private class TestDimmableStoryboardContainer : DimmableStoryboardContainer { - public float CurrentAlpha => DimContainer.Alpha; + public float CurrentAlpha => Content.Alpha; public TestDimmableStoryboardContainer() : base(new Storyboard()) @@ -415,8 +415,8 @@ namespace osu.Game.Tests.Visual.Background private class TestDimmableBackgroundContainer : DimmableBackgroundContainer { - public Color4 CurrentColour => DimContainer.Colour; - public float CurrentAlpha => DimContainer.Alpha; + public Color4 CurrentColour => Content.Colour; + public float CurrentAlpha => Content.Alpha; } } } diff --git a/osu.Game/Graphics/Containers/DimmableBackgroundContainer.cs b/osu.Game/Graphics/Containers/DimmableBackgroundContainer.cs index 7339548069..32b333528f 100644 --- a/osu.Game/Graphics/Containers/DimmableBackgroundContainer.cs +++ b/osu.Game/Graphics/Containers/DimmableBackgroundContainer.cs @@ -55,14 +55,16 @@ namespace osu.Game.Graphics.Containers private void load(OsuConfigManager config) { userBlurLevel = config.GetBindable(OsuSetting.BlurLevel); - BlurAmount.ValueChanged += _ => UpdateVisuals(); userBlurLevel.ValueChanged += _ => UpdateVisuals(); + BlurAmount.ValueChanged += _ => UpdateVisuals(); } - protected override void ApplyFade() + protected override bool ShowDimContent => !ShowStoryboard.Value || !StoryboardReplacesBackground.Value; // The background needs to be hidden in the case of it being replaced by the storyboard + + protected override void UpdateVisuals() { - // The background needs to be hidden in the case of it being replaced by the storyboard - DimContainer.FadeTo(ShowStoryboard.Value && StoryboardReplacesBackground.Value ? 0 : 1, BACKGROUND_FADE_DURATION, Easing.OutQuint); + base.UpdateVisuals(); + Background?.BlurTo(blurTarget, BACKGROUND_FADE_DURATION, Easing.OutQuint); } } diff --git a/osu.Game/Graphics/Containers/DimmableStoryboardContainer.cs b/osu.Game/Graphics/Containers/DimmableStoryboardContainer.cs index 16379baeab..0d87e64447 100644 --- a/osu.Game/Graphics/Containers/DimmableStoryboardContainer.cs +++ b/osu.Game/Graphics/Containers/DimmableStoryboardContainer.cs @@ -2,7 +2,6 @@ // See the LICENCE file in the repository root for full licence text. using osu.Framework.Allocation; -using osu.Framework.Graphics; using osu.Game.Storyboards; using osu.Game.Storyboards.Drawables; @@ -37,10 +36,7 @@ namespace osu.Game.Graphics.Containers base.LoadComplete(); } - protected override void ApplyFade() - { - DimContainer.FadeTo(!ShowStoryboard.Value || UserDimLevel.Value == 1 ? 0 : 1, BACKGROUND_FADE_DURATION, Easing.OutQuint); - } + protected override bool ShowDimContent => ShowStoryboard.Value && UserDimLevel.Value < 1; private void initializeStoryboard(bool async) { diff --git a/osu.Game/Graphics/Containers/UserDimContainer.cs b/osu.Game/Graphics/Containers/UserDimContainer.cs index e6a040fcd8..93af0be923 100644 --- a/osu.Game/Graphics/Containers/UserDimContainer.cs +++ b/osu.Game/Graphics/Containers/UserDimContainer.cs @@ -31,16 +31,16 @@ namespace osu.Game.Graphics.Containers protected Bindable ShowStoryboard { get; private set; } - protected Container DimContainer { get; } + protected override Container Content => dimContent; - protected override Container Content => DimContainer; + private Container dimContent { get; } /// /// Creates a new . /// protected UserDimContainer() { - AddInternal(DimContainer = new Container { RelativeSizeAxes = Axes.Both }); + AddInternal(dimContent = new Container { RelativeSizeAxes = Axes.Both }); } [BackgroundDependencyLoader] @@ -62,19 +62,17 @@ namespace osu.Game.Graphics.Containers } /// - /// Apply non-dim related settings to the content, such as hiding and blurring. + /// Whether the content of this container should currently be visible. /// - /// - /// While both backgrounds and storyboards allow user dim levels to be applied, storyboards can be toggled via - /// and can cause backgrounds to become hidden via . Storyboards are also currently unable to be blurred. - /// - protected abstract void ApplyFade(); + protected virtual bool ShowDimContent => true; - protected void UpdateVisuals() + /// + /// Should be invoked when any dependent dim level or user setting is changed and bring the visual state up-to-date. + /// + protected virtual void UpdateVisuals() { - ApplyFade(); - - DimContainer.FadeColour(EnableUserDim.Value ? OsuColour.Gray(1 - (float)UserDimLevel.Value) : Color4.White, BACKGROUND_FADE_DURATION, Easing.OutQuint); + dimContent.FadeTo(ShowDimContent ? 1 : 0, BACKGROUND_FADE_DURATION, Easing.OutQuint); + dimContent.FadeColour(EnableUserDim.Value ? OsuColour.Gray(1 - (float)UserDimLevel.Value) : Color4.White, BACKGROUND_FADE_DURATION, Easing.OutQuint); } } } From b5ca7faca4dad93ea1bb0c31a3426f2e74433d67 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 12 Jul 2019 11:40:32 +0900 Subject: [PATCH 12/16] Move default value for EnableUserDim to base class --- osu.Game/Graphics/Containers/DimmableStoryboardContainer.cs | 4 ---- osu.Game/Graphics/Containers/UserDimContainer.cs | 2 +- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/osu.Game/Graphics/Containers/DimmableStoryboardContainer.cs b/osu.Game/Graphics/Containers/DimmableStoryboardContainer.cs index 0d87e64447..d0ef7a2c25 100644 --- a/osu.Game/Graphics/Containers/DimmableStoryboardContainer.cs +++ b/osu.Game/Graphics/Containers/DimmableStoryboardContainer.cs @@ -18,10 +18,6 @@ namespace osu.Game.Graphics.Containers public DimmableStoryboardContainer(Storyboard storyboard) { this.storyboard = storyboard; - - // Storyboards current do not get used in scenarios without user dim, so default to enabled here. - EnableUserDim.Default = true; - EnableUserDim.Value = true; } [BackgroundDependencyLoader] diff --git a/osu.Game/Graphics/Containers/UserDimContainer.cs b/osu.Game/Graphics/Containers/UserDimContainer.cs index 93af0be923..f5958a092b 100644 --- a/osu.Game/Graphics/Containers/UserDimContainer.cs +++ b/osu.Game/Graphics/Containers/UserDimContainer.cs @@ -20,7 +20,7 @@ namespace osu.Game.Graphics.Containers /// /// Whether or not user-configured dim levels should be applied to the container. /// - public readonly Bindable EnableUserDim = new Bindable(); + public readonly Bindable EnableUserDim = new Bindable(true); /// /// Whether or not the storyboard loaded should completely hide the background behind it. From 46f7bb885bbd445c851c4259663d3260d2ada4e3 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 12 Jul 2019 11:50:06 +0900 Subject: [PATCH 13/16] Move classes to local namespaces Also renames test scene to more appropriate name. --- ...eatmap.cs => TestSceneUserDimContainer.cs} | 26 +++---- .../Containers/DimmableBackgroundContainer.cs | 71 ----------------- .../Backgrounds/BackgroundScreenBeatmap.cs | 76 +++++++++++++++++-- .../Play/DimmableStoryboard.cs} | 7 +- osu.Game/Screens/Play/Player.cs | 8 +- 5 files changed, 90 insertions(+), 98 deletions(-) rename osu.Game.Tests/Visual/Background/{TestSceneBackgroundScreenBeatmap.cs => TestSceneUserDimContainer.cs} (92%) delete mode 100644 osu.Game/Graphics/Containers/DimmableBackgroundContainer.cs rename osu.Game/{Graphics/Containers/DimmableStoryboardContainer.cs => Screens/Play/DimmableStoryboard.cs} (89%) diff --git a/osu.Game.Tests/Visual/Background/TestSceneBackgroundScreenBeatmap.cs b/osu.Game.Tests/Visual/Background/TestSceneUserDimContainer.cs similarity index 92% rename from osu.Game.Tests/Visual/Background/TestSceneBackgroundScreenBeatmap.cs rename to osu.Game.Tests/Visual/Background/TestSceneUserDimContainer.cs index 6a4145b24f..5578fee42d 100644 --- a/osu.Game.Tests/Visual/Background/TestSceneBackgroundScreenBeatmap.cs +++ b/osu.Game.Tests/Visual/Background/TestSceneUserDimContainer.cs @@ -38,7 +38,7 @@ using osuTK.Graphics; namespace osu.Game.Tests.Visual.Background { [TestFixture] - public class TestSceneBackgroundScreenBeatmap : ManualInputManagerTestScene + public class TestSceneUserDimContainer : ManualInputManagerTestScene { public override IReadOnlyList RequiredTypes => new[] { @@ -243,7 +243,7 @@ namespace osu.Game.Tests.Visual.Background { player.StoryboardEnabled.Value = false; player.ReplacesBackground.Value = false; - player.CurrentDimmableStoryboardContainer.Add(new OsuSpriteText + player.DimmableStoryboard.Add(new OsuSpriteText { Size = new Vector2(500, 50), Alpha = 1, @@ -336,9 +336,9 @@ namespace osu.Game.Tests.Visual.Background { protected override BackgroundScreen CreateBackground() => new FadeAccessibleBackground(Beatmap.Value); - protected override DimmableStoryboardContainer CreateStoryboardContainer(Storyboard storyboard) => new TestDimmableStoryboardContainer { RelativeSizeAxes = Axes.Both }; + protected override DimmableStoryboard CreateStoryboardContainer(Storyboard storyboard) => new TestDimmableStoryboard { RelativeSizeAxes = Axes.Both }; - public TestDimmableStoryboardContainer CurrentDimmableStoryboardContainer => (TestDimmableStoryboardContainer)DimmableStoryboardContainer; + public new TestDimmableStoryboard DimmableStoryboard => (TestDimmableStoryboard)base.DimmableStoryboard; // Whether or not the player should be allowed to load. public bool BlockLoad; @@ -352,9 +352,9 @@ namespace osu.Game.Tests.Visual.Background { } - public bool IsStoryboardVisible() => CurrentDimmableStoryboardContainer.CurrentAlpha == 1; + public bool IsStoryboardVisible() => DimmableStoryboard.CurrentAlpha == 1; - public bool IsStoryboardInvisible() => CurrentDimmableStoryboardContainer.CurrentAlpha <= 1; + public bool IsStoryboardInvisible() => DimmableStoryboard.CurrentAlpha <= 1; [BackgroundDependencyLoader] private void load(OsuConfigManager config, CancellationToken token) @@ -387,15 +387,15 @@ namespace osu.Game.Tests.Visual.Background private class FadeAccessibleBackground : BackgroundScreenBeatmap { - protected override DimmableBackgroundContainer CreateFadeContainer() => fadeContainer = new TestDimmableBackgroundContainer { RelativeSizeAxes = Axes.Both }; + protected override DimmableBackground CreateFadeContainer() => dimmable = new TestDimmableBackground { RelativeSizeAxes = Axes.Both }; - public Color4 CurrentColour => fadeContainer.CurrentColour; + public Color4 CurrentColour => dimmable.CurrentColour; - public float CurrentAlpha => fadeContainer.CurrentAlpha; + public float CurrentAlpha => dimmable.CurrentAlpha; public Vector2 CurrentBlur => Background.BlurSigma; - private TestDimmableBackgroundContainer fadeContainer; + private TestDimmableBackground dimmable; public FadeAccessibleBackground(WorkingBeatmap beatmap) : base(beatmap) @@ -403,17 +403,17 @@ namespace osu.Game.Tests.Visual.Background } } - private class TestDimmableStoryboardContainer : DimmableStoryboardContainer + private class TestDimmableStoryboard : DimmableStoryboard { public float CurrentAlpha => Content.Alpha; - public TestDimmableStoryboardContainer() + public TestDimmableStoryboard() : base(new Storyboard()) { } } - private class TestDimmableBackgroundContainer : DimmableBackgroundContainer + private class TestDimmableBackground : BackgroundScreenBeatmap.DimmableBackground { public Color4 CurrentColour => Content.Colour; public float CurrentAlpha => Content.Alpha; diff --git a/osu.Game/Graphics/Containers/DimmableBackgroundContainer.cs b/osu.Game/Graphics/Containers/DimmableBackgroundContainer.cs deleted file mode 100644 index 32b333528f..0000000000 --- a/osu.Game/Graphics/Containers/DimmableBackgroundContainer.cs +++ /dev/null @@ -1,71 +0,0 @@ -// 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.Game.Configuration; -using osu.Game.Graphics.Backgrounds; -using osu.Game.Screens.Play; -using osuTK; - -namespace osu.Game.Graphics.Containers -{ - public class DimmableBackgroundContainer : UserDimContainer - { - /// - /// The amount of blur to be applied to the background in addition to user-specified blur. - /// - /// - /// Used in contexts where there can potentially be both user and screen-specified blurring occuring at the same time, such as in - /// - public readonly Bindable BlurAmount = new Bindable(); - - public Background Background - { - get => background; - set - { - base.Add(background = value); - background.BlurTo(blurTarget, 0, Easing.OutQuint); - } - } - - private Bindable userBlurLevel { get; set; } - - private Background background; - - public override void Add(Drawable drawable) - { - if (drawable is Background) - throw new InvalidOperationException($"Use {nameof(Background)} to set a background."); - - base.Add(drawable); - } - - /// - /// As an optimisation, we add the two blur portions to be applied rather than actually applying two separate blurs. - /// - private Vector2 blurTarget => EnableUserDim.Value - ? new Vector2(BlurAmount.Value + (float)userBlurLevel.Value * 25) - : new Vector2(BlurAmount.Value); - - [BackgroundDependencyLoader] - private void load(OsuConfigManager config) - { - userBlurLevel = config.GetBindable(OsuSetting.BlurLevel); - userBlurLevel.ValueChanged += _ => UpdateVisuals(); - BlurAmount.ValueChanged += _ => UpdateVisuals(); - } - - protected override bool ShowDimContent => !ShowStoryboard.Value || !StoryboardReplacesBackground.Value; // The background needs to be hidden in the case of it being replaced by the storyboard - - protected override void UpdateVisuals() - { - base.UpdateVisuals(); - - Background?.BlurTo(blurTarget, BACKGROUND_FADE_DURATION, Easing.OutQuint); - } - } -} diff --git a/osu.Game/Screens/Backgrounds/BackgroundScreenBeatmap.cs b/osu.Game/Screens/Backgrounds/BackgroundScreenBeatmap.cs index 97f77f789a..8d6caf4c71 100644 --- a/osu.Game/Screens/Backgrounds/BackgroundScreenBeatmap.cs +++ b/osu.Game/Screens/Backgrounds/BackgroundScreenBeatmap.cs @@ -1,14 +1,18 @@ // 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 System.Threading; using osu.Framework.Allocation; using osu.Framework.Bindables; using osu.Framework.Graphics; using osu.Framework.Graphics.Textures; using osu.Game.Beatmaps; +using osu.Game.Configuration; using osu.Game.Graphics.Backgrounds; using osu.Game.Graphics.Containers; +using osu.Game.Screens.Play; +using osuTK; namespace osu.Game.Screens.Backgrounds { @@ -30,16 +34,17 @@ namespace osu.Game.Screens.Backgrounds /// public readonly Bindable BlurAmount = new Bindable(); - private readonly DimmableBackgroundContainer fadeContainer; + private readonly DimmableBackground dimmable; - protected virtual DimmableBackgroundContainer CreateFadeContainer() => new DimmableBackgroundContainer { RelativeSizeAxes = Axes.Both }; + protected virtual DimmableBackground CreateFadeContainer() => new DimmableBackground { RelativeSizeAxes = Axes.Both }; public BackgroundScreenBeatmap(WorkingBeatmap beatmap = null) { Beatmap = beatmap; - InternalChild = fadeContainer = CreateFadeContainer(); - fadeContainer.EnableUserDim.BindTo(EnableUserDim); - fadeContainer.BlurAmount.BindTo(BlurAmount); + + InternalChild = dimmable = CreateFadeContainer(); + dimmable.EnableUserDim.BindTo(EnableUserDim); + dimmable.BlurAmount.BindTo(BlurAmount); } [BackgroundDependencyLoader] @@ -86,8 +91,8 @@ namespace osu.Game.Screens.Backgrounds } b.Depth = newDepth; - fadeContainer.Background = Background = b; - StoryboardReplacesBackground.BindTo(fadeContainer.StoryboardReplacesBackground); + dimmable.Background = Background = b; + StoryboardReplacesBackground.BindTo(dimmable.StoryboardReplacesBackground); } public override bool Equals(BackgroundScreen other) @@ -112,5 +117,62 @@ namespace osu.Game.Screens.Backgrounds Sprite.Texture = Beatmap?.Background ?? textures.Get(@"Backgrounds/bg1"); } } + + public class DimmableBackground : UserDimContainer + { + /// + /// The amount of blur to be applied to the background in addition to user-specified blur. + /// + /// + /// Used in contexts where there can potentially be both user and screen-specified blurring occuring at the same time, such as in + /// + public readonly Bindable BlurAmount = new Bindable(); + + public Background Background + { + get => background; + set + { + base.Add(background = value); + background.BlurTo(blurTarget, 0, Easing.OutQuint); + } + } + + private Bindable userBlurLevel { get; set; } + + private Background background; + + public override void Add(Drawable drawable) + { + if (drawable is Background) + throw new InvalidOperationException($"Use {nameof(Background)} to set a background."); + + base.Add(drawable); + } + + /// + /// As an optimisation, we add the two blur portions to be applied rather than actually applying two separate blurs. + /// + private Vector2 blurTarget => EnableUserDim.Value + ? new Vector2(BlurAmount.Value + (float)userBlurLevel.Value * 25) + : new Vector2(BlurAmount.Value); + + [BackgroundDependencyLoader] + private void load(OsuConfigManager config) + { + userBlurLevel = config.GetBindable(OsuSetting.BlurLevel); + userBlurLevel.ValueChanged += _ => UpdateVisuals(); + BlurAmount.ValueChanged += _ => UpdateVisuals(); + } + + protected override bool ShowDimContent => !ShowStoryboard.Value || !StoryboardReplacesBackground.Value; // The background needs to be hidden in the case of it being replaced by the storyboard + + protected override void UpdateVisuals() + { + base.UpdateVisuals(); + + Background?.BlurTo(blurTarget, BACKGROUND_FADE_DURATION, Easing.OutQuint); + } + } } } diff --git a/osu.Game/Graphics/Containers/DimmableStoryboardContainer.cs b/osu.Game/Screens/Play/DimmableStoryboard.cs similarity index 89% rename from osu.Game/Graphics/Containers/DimmableStoryboardContainer.cs rename to osu.Game/Screens/Play/DimmableStoryboard.cs index d0ef7a2c25..45dff039b6 100644 --- a/osu.Game/Graphics/Containers/DimmableStoryboardContainer.cs +++ b/osu.Game/Screens/Play/DimmableStoryboard.cs @@ -2,20 +2,21 @@ // See the LICENCE file in the repository root for full licence text. using osu.Framework.Allocation; +using osu.Game.Graphics.Containers; using osu.Game.Storyboards; using osu.Game.Storyboards.Drawables; -namespace osu.Game.Graphics.Containers +namespace osu.Game.Screens.Play { /// /// A container that handles loading, as well as applies user-specified visual settings to it. /// - public class DimmableStoryboardContainer : UserDimContainer + public class DimmableStoryboard : UserDimContainer { private readonly Storyboard storyboard; private DrawableStoryboard drawableStoryboard; - public DimmableStoryboardContainer(Storyboard storyboard) + public DimmableStoryboard(Storyboard storyboard) { this.storyboard = storyboard; } diff --git a/osu.Game/Screens/Play/Player.cs b/osu.Game/Screens/Play/Player.cs index 55e759d215..0396d85d75 100644 --- a/osu.Game/Screens/Play/Player.cs +++ b/osu.Game/Screens/Play/Player.cs @@ -76,9 +76,9 @@ namespace osu.Game.Screens.Play protected GameplayClockContainer GameplayClockContainer { get; private set; } - protected DimmableStoryboardContainer DimmableStoryboardContainer { get; private set; } + protected DimmableStoryboard DimmableStoryboard { get; private set; } - protected virtual DimmableStoryboardContainer CreateStoryboardContainer(Storyboard storyboard) => new DimmableStoryboardContainer(storyboard) { RelativeSizeAxes = Axes.Both }; + protected virtual DimmableStoryboard CreateStoryboardContainer(Storyboard storyboard) => new DimmableStoryboard(storyboard) { RelativeSizeAxes = Axes.Both }; [Cached] [Cached(Type = typeof(IBindable>))] @@ -124,7 +124,7 @@ namespace osu.Game.Screens.Play GameplayClockContainer.Children = new[] { - DimmableStoryboardContainer = CreateStoryboardContainer(Beatmap.Value.Storyboard), + DimmableStoryboard = CreateStoryboardContainer(Beatmap.Value.Storyboard), new ScalingContainer(ScalingMode.Gameplay) { Child = new LocalSkinOverrideContainer(working.Skin) @@ -455,7 +455,7 @@ namespace osu.Game.Screens.Play Background.BlurAmount.Value = 0; Background.StoryboardReplacesBackground.BindTo(storyboardReplacesBackground); - DimmableStoryboardContainer.StoryboardReplacesBackground.BindTo(storyboardReplacesBackground); + DimmableStoryboard.StoryboardReplacesBackground.BindTo(storyboardReplacesBackground); storyboardReplacesBackground.Value = Beatmap.Value.Storyboard.ReplacesBackground && Beatmap.Value.Storyboard.HasDrawable; From 8b67f88d161283548df4ff732d7f2e33fefa528c Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 12 Jul 2019 12:04:45 +0900 Subject: [PATCH 14/16] Don't expose dimmable container creation in player --- .../Background/TestSceneUserDimContainer.cs | 23 ++++--------------- .../Graphics/Containers/UserDimContainer.cs | 9 +++++++- osu.Game/Screens/Play/Player.cs | 5 +--- 3 files changed, 13 insertions(+), 24 deletions(-) diff --git a/osu.Game.Tests/Visual/Background/TestSceneUserDimContainer.cs b/osu.Game.Tests/Visual/Background/TestSceneUserDimContainer.cs index 5578fee42d..f0893abadc 100644 --- a/osu.Game.Tests/Visual/Background/TestSceneUserDimContainer.cs +++ b/osu.Game.Tests/Visual/Background/TestSceneUserDimContainer.cs @@ -29,7 +29,6 @@ using osu.Game.Screens.Backgrounds; using osu.Game.Screens.Play; using osu.Game.Screens.Play.PlayerSettings; using osu.Game.Screens.Select; -using osu.Game.Storyboards; using osu.Game.Tests.Resources; using osu.Game.Users; using osuTK; @@ -139,14 +138,14 @@ namespace osu.Game.Tests.Visual.Background player.StoryboardEnabled.Value = true; }); waitForDim(); - AddAssert("Background is invisible, storyboard is visible", () => songSelect.IsBackgroundInvisible() && player.IsStoryboardVisible()); + AddAssert("Background is invisible, storyboard is visible", () => songSelect.IsBackgroundInvisible() && player.IsStoryboardVisible); AddStep("Storyboard Disabled", () => { player.ReplacesBackground.Value = false; player.StoryboardEnabled.Value = false; }); waitForDim(); - AddAssert("Background is visible, storyboard is invisible", () => songSelect.IsBackgroundVisible() && player.IsStoryboardInvisible()); + AddAssert("Background is visible, storyboard is invisible", () => songSelect.IsBackgroundVisible() && !player.IsStoryboardVisible); } /// @@ -336,9 +335,7 @@ namespace osu.Game.Tests.Visual.Background { protected override BackgroundScreen CreateBackground() => new FadeAccessibleBackground(Beatmap.Value); - protected override DimmableStoryboard CreateStoryboardContainer(Storyboard storyboard) => new TestDimmableStoryboard { RelativeSizeAxes = Axes.Both }; - - public new TestDimmableStoryboard DimmableStoryboard => (TestDimmableStoryboard)base.DimmableStoryboard; + public new DimmableStoryboard DimmableStoryboard => base.DimmableStoryboard; // Whether or not the player should be allowed to load. public bool BlockLoad; @@ -352,9 +349,7 @@ namespace osu.Game.Tests.Visual.Background { } - public bool IsStoryboardVisible() => DimmableStoryboard.CurrentAlpha == 1; - - public bool IsStoryboardInvisible() => DimmableStoryboard.CurrentAlpha <= 1; + public bool IsStoryboardVisible => DimmableStoryboard.ContentDisplayed; [BackgroundDependencyLoader] private void load(OsuConfigManager config, CancellationToken token) @@ -403,16 +398,6 @@ namespace osu.Game.Tests.Visual.Background } } - private class TestDimmableStoryboard : DimmableStoryboard - { - public float CurrentAlpha => Content.Alpha; - - public TestDimmableStoryboard() - : base(new Storyboard()) - { - } - } - private class TestDimmableBackground : BackgroundScreenBeatmap.DimmableBackground { public Color4 CurrentColour => Content.Colour; diff --git a/osu.Game/Graphics/Containers/UserDimContainer.cs b/osu.Game/Graphics/Containers/UserDimContainer.cs index f5958a092b..03de5f651f 100644 --- a/osu.Game/Graphics/Containers/UserDimContainer.cs +++ b/osu.Game/Graphics/Containers/UserDimContainer.cs @@ -27,6 +27,11 @@ namespace osu.Game.Graphics.Containers /// public readonly Bindable StoryboardReplacesBackground = new Bindable(); + /// + /// Whether the content of this container is currently being displayed. + /// + public bool ContentDisplayed { get; private set; } + protected Bindable UserDimLevel { get; private set; } protected Bindable ShowStoryboard { get; private set; } @@ -71,7 +76,9 @@ namespace osu.Game.Graphics.Containers /// protected virtual void UpdateVisuals() { - dimContent.FadeTo(ShowDimContent ? 1 : 0, BACKGROUND_FADE_DURATION, Easing.OutQuint); + ContentDisplayed = ShowDimContent; + + dimContent.FadeTo((ContentDisplayed) ? 1 : 0, BACKGROUND_FADE_DURATION, Easing.OutQuint); dimContent.FadeColour(EnableUserDim.Value ? OsuColour.Gray(1 - (float)UserDimLevel.Value) : Color4.White, BACKGROUND_FADE_DURATION, Easing.OutQuint); } } diff --git a/osu.Game/Screens/Play/Player.cs b/osu.Game/Screens/Play/Player.cs index 0396d85d75..8dc16af575 100644 --- a/osu.Game/Screens/Play/Player.cs +++ b/osu.Game/Screens/Play/Player.cs @@ -26,7 +26,6 @@ using osu.Game.Rulesets.UI; using osu.Game.Scoring; using osu.Game.Screens.Ranking; using osu.Game.Skinning; -using osu.Game.Storyboards; using osu.Game.Users; namespace osu.Game.Screens.Play @@ -78,8 +77,6 @@ namespace osu.Game.Screens.Play protected DimmableStoryboard DimmableStoryboard { get; private set; } - protected virtual DimmableStoryboard CreateStoryboardContainer(Storyboard storyboard) => new DimmableStoryboard(storyboard) { RelativeSizeAxes = Axes.Both }; - [Cached] [Cached(Type = typeof(IBindable>))] protected new readonly Bindable> Mods = new Bindable>(Array.Empty()); @@ -124,7 +121,7 @@ namespace osu.Game.Screens.Play GameplayClockContainer.Children = new[] { - DimmableStoryboard = CreateStoryboardContainer(Beatmap.Value.Storyboard), + DimmableStoryboard = new DimmableStoryboard(Beatmap.Value.Storyboard) { RelativeSizeAxes = Axes.Both }, new ScalingContainer(ScalingMode.Gameplay) { Child = new LocalSkinOverrideContainer(working.Skin) From 671f7f99cd139bf255a3d7e393d9e8ac211517df Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 12 Jul 2019 13:44:43 +0900 Subject: [PATCH 15/16] Use constant for blur amount --- .../Visual/Background/TestSceneUserDimContainer.cs | 2 +- osu.Game/Screens/Backgrounds/BackgroundScreenBeatmap.cs | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/osu.Game.Tests/Visual/Background/TestSceneUserDimContainer.cs b/osu.Game.Tests/Visual/Background/TestSceneUserDimContainer.cs index f0893abadc..dc4ceed59e 100644 --- a/osu.Game.Tests/Visual/Background/TestSceneUserDimContainer.cs +++ b/osu.Game.Tests/Visual/Background/TestSceneUserDimContainer.cs @@ -302,7 +302,7 @@ namespace osu.Game.Tests.Visual.Background public bool IsBackgroundUndimmed() => ((FadeAccessibleBackground)Background).CurrentColour == Color4.White; - public bool IsUserBlurApplied() => ((FadeAccessibleBackground)Background).CurrentBlur == new Vector2((float)BlurLevel.Value * 25); + public bool IsUserBlurApplied() => ((FadeAccessibleBackground)Background).CurrentBlur == new Vector2((float)BlurLevel.Value * BackgroundScreenBeatmap.USER_BLUR_FACTOR); public bool IsUserBlurDisabled() => ((FadeAccessibleBackground)Background).CurrentBlur == new Vector2(0); diff --git a/osu.Game/Screens/Backgrounds/BackgroundScreenBeatmap.cs b/osu.Game/Screens/Backgrounds/BackgroundScreenBeatmap.cs index 8d6caf4c71..7b4feb1819 100644 --- a/osu.Game/Screens/Backgrounds/BackgroundScreenBeatmap.cs +++ b/osu.Game/Screens/Backgrounds/BackgroundScreenBeatmap.cs @@ -18,6 +18,11 @@ namespace osu.Game.Screens.Backgrounds { public class BackgroundScreenBeatmap : BackgroundScreen { + /// + /// The amount of blur to apply when full user blur is requested. + /// + public const float USER_BLUR_FACTOR = 25; + protected Background Background; private WorkingBeatmap beatmap; @@ -154,7 +159,7 @@ namespace osu.Game.Screens.Backgrounds /// As an optimisation, we add the two blur portions to be applied rather than actually applying two separate blurs. /// private Vector2 blurTarget => EnableUserDim.Value - ? new Vector2(BlurAmount.Value + (float)userBlurLevel.Value * 25) + ? new Vector2(BlurAmount.Value + (float)userBlurLevel.Value * USER_BLUR_FACTOR) : new Vector2(BlurAmount.Value); [BackgroundDependencyLoader] From 44855d8bb2203af41b8c57c7f56b1f12172c208e Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 12 Jul 2019 13:45:34 +0900 Subject: [PATCH 16/16] Ensure any existing background is expired if set more than once --- osu.Game/Screens/Backgrounds/BackgroundScreenBeatmap.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/osu.Game/Screens/Backgrounds/BackgroundScreenBeatmap.cs b/osu.Game/Screens/Backgrounds/BackgroundScreenBeatmap.cs index 7b4feb1819..08f1881038 100644 --- a/osu.Game/Screens/Backgrounds/BackgroundScreenBeatmap.cs +++ b/osu.Game/Screens/Backgrounds/BackgroundScreenBeatmap.cs @@ -138,6 +138,8 @@ namespace osu.Game.Screens.Backgrounds get => background; set { + background?.Expire(); + base.Add(background = value); background.BlurTo(blurTarget, 0, Easing.OutQuint); }