From 044e4d0acddffaffc1055f9042eaacea365e4b0b Mon Sep 17 00:00:00 2001 From: ColdVolcano Date: Mon, 25 Dec 2017 19:11:49 -0600 Subject: [PATCH 1/7] Add blur to background in Player --- osu.Game/Configuration/OsuConfigManager.cs | 2 ++ .../Sections/Gameplay/GeneralSettings.cs | 6 ++++++ osu.Game/Screens/Play/Player.cs | 20 ++++++++++++------- 3 files changed, 21 insertions(+), 7 deletions(-) diff --git a/osu.Game/Configuration/OsuConfigManager.cs b/osu.Game/Configuration/OsuConfigManager.cs index f4c7bdb586..d359a0a2d6 100644 --- a/osu.Game/Configuration/OsuConfigManager.cs +++ b/osu.Game/Configuration/OsuConfigManager.cs @@ -65,6 +65,7 @@ namespace osu.Game.Configuration // Gameplay Set(OsuSetting.DimLevel, 0.3, 0, 1, 0.01); + Set(OsuSetting.BlurLevel, 0, 0, 1, 0.01); Set(OsuSetting.ShowInterface, true); Set(OsuSetting.KeyOverlay, false); @@ -90,6 +91,7 @@ namespace osu.Game.Configuration GameplayCursorSize, AutoCursorSize, DimLevel, + BlurLevel, ShowStoryboard, KeyOverlay, FloatingComments, diff --git a/osu.Game/Overlays/Settings/Sections/Gameplay/GeneralSettings.cs b/osu.Game/Overlays/Settings/Sections/Gameplay/GeneralSettings.cs index 8ec6af5cd0..95d127a55f 100644 --- a/osu.Game/Overlays/Settings/Sections/Gameplay/GeneralSettings.cs +++ b/osu.Game/Overlays/Settings/Sections/Gameplay/GeneralSettings.cs @@ -22,6 +22,12 @@ namespace osu.Game.Overlays.Settings.Sections.Gameplay Bindable = config.GetBindable(OsuSetting.DimLevel), KeyboardStep = 0.1f }, + new SettingsSlider + { + LabelText = "Background blur", + Bindable = config.GetBindable(OsuSetting.BlurLevel), + KeyboardStep = 0.1f + }, new SettingsCheckbox { LabelText = "Show score overlay", diff --git a/osu.Game/Screens/Play/Player.cs b/osu.Game/Screens/Play/Player.cs index 340fc39d52..8430acbc73 100644 --- a/osu.Game/Screens/Play/Player.cs +++ b/osu.Game/Screens/Play/Player.cs @@ -65,6 +65,7 @@ namespace osu.Game.Screens.Play #region User Settings private Bindable dimLevel; + private Bindable blurLevel; private Bindable showStoryboard; private Bindable mouseWheelDisabled; private Bindable userAudioOffset; @@ -74,7 +75,7 @@ namespace osu.Game.Screens.Play #endregion private BreakOverlay breakOverlay; - private Container storyboardContainer; + private BufferedContainer storyboardContainer; private DrawableStoryboard storyboard; private HUDOverlay hudOverlay; @@ -88,6 +89,7 @@ namespace osu.Game.Screens.Play this.api = api; dimLevel = config.GetBindable(OsuSetting.DimLevel); + blurLevel = config.GetBindable(OsuSetting.BlurLevel); showStoryboard = config.GetBindable(OsuSetting.ShowStoryboard); mouseWheelDisabled = config.GetBindable(OsuSetting.MouseDisableWheel); @@ -147,7 +149,7 @@ namespace osu.Game.Screens.Play Children = new Drawable[] { - storyboardContainer = new Container + storyboardContainer = new BufferedContainer { RelativeSizeAxes = Axes.Both, Clock = offsetClock, @@ -309,9 +311,9 @@ namespace osu.Game.Screens.Play if (!loadedSuccessfully) return; - (Background as BackgroundScreenBeatmap)?.BlurTo(Vector2.Zero, 1000, Easing.OutQuint); + dimLevel.ValueChanged += backgroundLevel_ValueChanged; + blurLevel.ValueChanged += backgroundLevel_ValueChanged; - dimLevel.ValueChanged += dimLevel_ValueChanged; showStoryboard.ValueChanged += showStoryboard_ValueChanged; updateBackgroundElements(); @@ -368,7 +370,7 @@ namespace osu.Game.Screens.Play return true; } - private void dimLevel_ValueChanged(double newValue) + private void backgroundLevel_ValueChanged(double newValue) => updateBackgroundElements(); private void showStoryboard_ValueChanged(bool newValue) @@ -377,6 +379,7 @@ namespace osu.Game.Screens.Play private void updateBackgroundElements() { var opacity = 1 - (float)dimLevel; + var blur = new Vector2((float)blurLevel.Value * 25); if (showStoryboard && storyboard == null) initializeStoryboard(true); @@ -385,14 +388,17 @@ namespace osu.Game.Screens.Play var storyboardVisible = showStoryboard && beatmap.Storyboard.HasDrawable; storyboardContainer.FadeColour(new Color4(opacity, opacity, opacity, 1), 800); - storyboardContainer.FadeTo(storyboardVisible && opacity > 0 ? 1 : 0); + storyboardContainer.FadeTo(storyboardVisible && opacity > 0 ? 1 : 0, 800, Easing.OutQuint); + storyboardContainer.BlurTo(blur, 800, Easing.OutQuint); Background?.FadeTo(!storyboardVisible || beatmap.Background == null ? opacity : 0, 800, Easing.OutQuint); + (Background as BackgroundScreenBeatmap)?.BlurTo(blur, 800, Easing.OutQuint); } private void fadeOut() { - dimLevel.ValueChanged -= dimLevel_ValueChanged; + dimLevel.ValueChanged -= backgroundLevel_ValueChanged; + blurLevel.ValueChanged -= backgroundLevel_ValueChanged; showStoryboard.ValueChanged -= showStoryboard_ValueChanged; const float fade_out_duration = 250; From bc90793b1c59da7ca83bb9a5ca4b6ae1fcd62c72 Mon Sep 17 00:00:00 2001 From: ColdVolcano Date: Mon, 25 Dec 2017 19:18:57 -0600 Subject: [PATCH 2/7] Trim whitespace --- osu.Game/Overlays/Settings/Sections/Gameplay/GeneralSettings.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Overlays/Settings/Sections/Gameplay/GeneralSettings.cs b/osu.Game/Overlays/Settings/Sections/Gameplay/GeneralSettings.cs index 95d127a55f..0808c18b6f 100644 --- a/osu.Game/Overlays/Settings/Sections/Gameplay/GeneralSettings.cs +++ b/osu.Game/Overlays/Settings/Sections/Gameplay/GeneralSettings.cs @@ -27,7 +27,7 @@ namespace osu.Game.Overlays.Settings.Sections.Gameplay LabelText = "Background blur", Bindable = config.GetBindable(OsuSetting.BlurLevel), KeyboardStep = 0.1f - }, + }, new SettingsCheckbox { LabelText = "Show score overlay", From 3845c7ac7de3f17ea64aa225037915f71280baf4 Mon Sep 17 00:00:00 2001 From: ColdVolcano Date: Thu, 28 Dec 2017 14:31:34 -0600 Subject: [PATCH 3/7] Remove bluring of storyboard --- osu.Game/Screens/Play/Player.cs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/osu.Game/Screens/Play/Player.cs b/osu.Game/Screens/Play/Player.cs index 8430acbc73..8b94f41686 100644 --- a/osu.Game/Screens/Play/Player.cs +++ b/osu.Game/Screens/Play/Player.cs @@ -75,7 +75,7 @@ namespace osu.Game.Screens.Play #endregion private BreakOverlay breakOverlay; - private BufferedContainer storyboardContainer; + private Container storyboardContainer; private DrawableStoryboard storyboard; private HUDOverlay hudOverlay; @@ -149,7 +149,7 @@ namespace osu.Game.Screens.Play Children = new Drawable[] { - storyboardContainer = new BufferedContainer + storyboardContainer = new Container { RelativeSizeAxes = Axes.Both, Clock = offsetClock, @@ -389,7 +389,6 @@ namespace osu.Game.Screens.Play storyboardContainer.FadeColour(new Color4(opacity, opacity, opacity, 1), 800); storyboardContainer.FadeTo(storyboardVisible && opacity > 0 ? 1 : 0, 800, Easing.OutQuint); - storyboardContainer.BlurTo(blur, 800, Easing.OutQuint); Background?.FadeTo(!storyboardVisible || beatmap.Background == null ? opacity : 0, 800, Easing.OutQuint); (Background as BackgroundScreenBeatmap)?.BlurTo(blur, 800, Easing.OutQuint); From df62ca14b7f67007216e0d1726342cd7d2da57ee Mon Sep 17 00:00:00 2001 From: ColdVolcano Date: Fri, 29 Dec 2017 23:41:36 -0600 Subject: [PATCH 4/7] Don't unbind when not necessary --- osu.Game/Screens/Play/Player.cs | 17 +++-------------- 1 file changed, 3 insertions(+), 14 deletions(-) diff --git a/osu.Game/Screens/Play/Player.cs b/osu.Game/Screens/Play/Player.cs index 8b94f41686..5346de2bb7 100644 --- a/osu.Game/Screens/Play/Player.cs +++ b/osu.Game/Screens/Play/Player.cs @@ -311,10 +311,9 @@ namespace osu.Game.Screens.Play if (!loadedSuccessfully) return; - dimLevel.ValueChanged += backgroundLevel_ValueChanged; - blurLevel.ValueChanged += backgroundLevel_ValueChanged; - - showStoryboard.ValueChanged += showStoryboard_ValueChanged; + dimLevel.ValueChanged += value => updateBackgroundElements(); + blurLevel.ValueChanged += value => updateBackgroundElements(); + showStoryboard.ValueChanged += value => updateBackgroundElements(); updateBackgroundElements(); Content.Alpha = 0; @@ -370,12 +369,6 @@ namespace osu.Game.Screens.Play return true; } - private void backgroundLevel_ValueChanged(double newValue) - => updateBackgroundElements(); - - private void showStoryboard_ValueChanged(bool newValue) - => updateBackgroundElements(); - private void updateBackgroundElements() { var opacity = 1 - (float)dimLevel; @@ -396,10 +389,6 @@ namespace osu.Game.Screens.Play private void fadeOut() { - dimLevel.ValueChanged -= backgroundLevel_ValueChanged; - blurLevel.ValueChanged -= backgroundLevel_ValueChanged; - showStoryboard.ValueChanged -= showStoryboard_ValueChanged; - const float fade_out_duration = 250; RulesetContainer?.FadeOut(fade_out_duration); From 2518d16a77f97f7ecb5fbcc4e0932b1212ab613a Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Tue, 9 Jan 2018 21:34:25 +0900 Subject: [PATCH 5/7] Denote unused variable --- osu.Game/Screens/Play/Player.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/osu.Game/Screens/Play/Player.cs b/osu.Game/Screens/Play/Player.cs index 87a7c7dd59..f700bf1a03 100644 --- a/osu.Game/Screens/Play/Player.cs +++ b/osu.Game/Screens/Play/Player.cs @@ -318,9 +318,9 @@ namespace osu.Game.Screens.Play if (!loadedSuccessfully) return; - dimLevel.ValueChanged += value => updateBackgroundElements(); - blurLevel.ValueChanged += value => updateBackgroundElements(); - showStoryboard.ValueChanged += value => updateBackgroundElements(); + dimLevel.ValueChanged += _ => updateBackgroundElements(); + blurLevel.ValueChanged += _ => updateBackgroundElements(); + showStoryboard.ValueChanged += _ => updateBackgroundElements(); updateBackgroundElements(); Content.Alpha = 0; From fcb197f7b6230c26af195c4e1da5347618d81250 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Tue, 9 Jan 2018 22:21:15 +0900 Subject: [PATCH 6/7] Simplify logic --- .../Backgrounds/BackgroundScreenBeatmap.cs | 13 ++++--------- osu.Game/Screens/Play/Player.cs | 15 +++++++++------ 2 files changed, 13 insertions(+), 15 deletions(-) diff --git a/osu.Game/Screens/Backgrounds/BackgroundScreenBeatmap.cs b/osu.Game/Screens/Backgrounds/BackgroundScreenBeatmap.cs index dd76ac5421..1ce84289b2 100644 --- a/osu.Game/Screens/Backgrounds/BackgroundScreenBeatmap.cs +++ b/osu.Game/Screens/Backgrounds/BackgroundScreenBeatmap.cs @@ -4,6 +4,7 @@ using osu.Framework.Allocation; using osu.Framework.Graphics; using osu.Framework.Graphics.Textures; +using osu.Framework.Graphics.Transforms; using OpenTK; using osu.Game.Beatmaps; using osu.Game.Graphics.Backgrounds; @@ -19,10 +20,7 @@ namespace osu.Game.Screens.Backgrounds public WorkingBeatmap Beatmap { - get - { - return beatmap; - } + get { return beatmap; } set { if (beatmap == value && beatmap != null) @@ -56,11 +54,8 @@ namespace osu.Game.Screens.Backgrounds Beatmap = beatmap; } - public void BlurTo(Vector2 sigma, double duration, Easing easing = Easing.None) - { - background?.BlurTo(sigma, duration, easing); - blurTarget = sigma; - } + public TransformSequence BlurTo(Vector2 sigma, double duration, Easing easing = Easing.None) + => background?.BlurTo(blurTarget = sigma, duration, easing); public override bool Equals(BackgroundScreen other) { diff --git a/osu.Game/Screens/Play/Player.cs b/osu.Game/Screens/Play/Player.cs index f700bf1a03..79ae8fca30 100644 --- a/osu.Game/Screens/Play/Player.cs +++ b/osu.Game/Screens/Play/Player.cs @@ -24,10 +24,10 @@ using osu.Game.Rulesets.Scoring; using osu.Game.Screens.Ranking; using osu.Framework.Audio.Sample; using osu.Game.Beatmaps; +using osu.Game.Graphics; using osu.Game.Online.API; using osu.Game.Screens.Play.BreaksOverlay; using osu.Game.Storyboards.Drawables; -using OpenTK.Graphics; namespace osu.Game.Screens.Play { @@ -378,8 +378,9 @@ namespace osu.Game.Screens.Play private void updateBackgroundElements() { + const float duration = 800; + var opacity = 1 - (float)dimLevel; - var blur = new Vector2((float)blurLevel.Value * 25); if (showStoryboard && storyboard == null) initializeStoryboard(true); @@ -387,11 +388,13 @@ namespace osu.Game.Screens.Play var beatmap = Beatmap.Value; var storyboardVisible = showStoryboard && beatmap.Storyboard.HasDrawable; - storyboardContainer.FadeColour(new Color4(opacity, opacity, opacity, 1), 800); - storyboardContainer.FadeTo(storyboardVisible && opacity > 0 ? 1 : 0, 800, Easing.OutQuint); + storyboardContainer + .FadeColour(OsuColour.Gray(opacity), duration, Easing.OutQuint) + .FadeTo(storyboardVisible && opacity > 0 ? 1 : 0, duration, Easing.OutQuint); - Background?.FadeTo(!storyboardVisible || beatmap.Background == null ? opacity : 0, 800, Easing.OutQuint); - (Background as BackgroundScreenBeatmap)?.BlurTo(blur, 800, Easing.OutQuint); + (Background as BackgroundScreenBeatmap)? + .BlurTo(new Vector2((float)blurLevel.Value * 25), duration, Easing.OutQuint)? + .FadeTo(!storyboardVisible || beatmap.Background == null ? opacity : 0, duration, Easing.OutQuint); } private void fadeOut() From 9ec8f130a694c785878cf5b17716f94e73c06a97 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Wed, 10 Jan 2018 13:24:26 +0900 Subject: [PATCH 7/7] Ensure changes are only applied when we are the current screen --- osu.Game/Screens/Play/Player.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/osu.Game/Screens/Play/Player.cs b/osu.Game/Screens/Play/Player.cs index 79ae8fca30..c24b5e0d2a 100644 --- a/osu.Game/Screens/Play/Player.cs +++ b/osu.Game/Screens/Play/Player.cs @@ -378,6 +378,8 @@ namespace osu.Game.Screens.Play private void updateBackgroundElements() { + if (!IsCurrentScreen) return; + const float duration = 800; var opacity = 1 - (float)dimLevel;