From 6daa36477942d6179683ec59387ae898f0e0936b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9miah=20D=C3=89COMBE?= Date: Mon, 23 Jan 2023 13:53:31 +0100 Subject: [PATCH] adding setting to adjust blur of the background of the song select screen --- osu.Game/Configuration/OsuConfigManager.cs | 3 ++ osu.Game/Localisation/UserInterfaceStrings.cs | 6 ++++ .../UserInterface/SongSelectSettings.cs | 5 +++ osu.Game/Screens/Select/SongSelect.cs | 33 +++++++++++++++++-- 4 files changed, 44 insertions(+), 3 deletions(-) diff --git a/osu.Game/Configuration/OsuConfigManager.cs b/osu.Game/Configuration/OsuConfigManager.cs index 6cbb677a64..2b7c2102d4 100644 --- a/osu.Game/Configuration/OsuConfigManager.cs +++ b/osu.Game/Configuration/OsuConfigManager.cs @@ -60,6 +60,8 @@ namespace osu.Game.Configuration SetDefault(OsuSetting.ToolbarClockDisplayMode, ToolbarClockDisplayMode.Full); + SetDefault(OsuSetting.BeatmapSelectionBlurLevel, 1f, 0, 1f, 0.01f); + // Online settings SetDefault(OsuSetting.Username, string.Empty); SetDefault(OsuSetting.Token, string.Empty); @@ -339,6 +341,7 @@ namespace osu.Game.Configuration ChatDisplayHeight, BeatmapListingCardSize, ToolbarClockDisplayMode, + BeatmapSelectionBlurLevel, Version, ShowFirstRunSetup, ShowConvertedBeatmaps, diff --git a/osu.Game/Localisation/UserInterfaceStrings.cs b/osu.Game/Localisation/UserInterfaceStrings.cs index ea664d7b50..0bf7dae403 100644 --- a/osu.Game/Localisation/UserInterfaceStrings.cs +++ b/osu.Game/Localisation/UserInterfaceStrings.cs @@ -109,6 +109,12 @@ namespace osu.Game.Localisation /// public static LocalisableString ModSelectHotkeyStyle => new TranslatableString(getKey(@"mod_select_hotkey_style"), @"Mod select hotkey style"); + /// + /// "Beatmap selection blur level" + /// + public static LocalisableString BeatmapSelectionBlurLevel => new TranslatableString(getKey(@"beatmap_selection_blur_level"), @"Beatmap selection blur level"); + + /// /// "no limit" /// diff --git a/osu.Game/Overlays/Settings/Sections/UserInterface/SongSelectSettings.cs b/osu.Game/Overlays/Settings/Sections/UserInterface/SongSelectSettings.cs index 8b5e0b75b7..828119981f 100644 --- a/osu.Game/Overlays/Settings/Sections/UserInterface/SongSelectSettings.cs +++ b/osu.Game/Overlays/Settings/Sections/UserInterface/SongSelectSettings.cs @@ -42,6 +42,11 @@ namespace osu.Game.Overlays.Settings.Sections.UserInterface LabelText = UserInterfaceStrings.ModSelectHotkeyStyle, Current = config.GetBindable(OsuSetting.ModSelectHotkeyStyle), ClassicDefault = ModSelectHotkeyStyle.Classic + }, + new SettingsSlider + { + LabelText = UserInterfaceStrings.BeatmapSelectionBlurLevel, + Current = config.GetBindable(OsuSetting.BeatmapSelectionBlurLevel) } }; } diff --git a/osu.Game/Screens/Select/SongSelect.cs b/osu.Game/Screens/Select/SongSelect.cs index 4b3222c14a..bd1498f0dd 100644 --- a/osu.Game/Screens/Select/SongSelect.cs +++ b/osu.Game/Screens/Select/SongSelect.cs @@ -35,6 +35,7 @@ using osu.Game.Collections; using osu.Game.Graphics.UserInterface; using System.Diagnostics; using osu.Framework.Extensions.ObjectExtensions; +using osu.Game.Configuration; using osu.Game.Screens.Play; using osu.Game.Skinning; @@ -124,9 +125,26 @@ namespace osu.Game.Screens.Select [Resolved] internal IOverlayManager? OverlayManager { get; private set; } - [BackgroundDependencyLoader(true)] - private void load(AudioManager audio, OsuColour colours, ManageCollectionsDialog? manageCollectionsDialog, DifficultyRecommender? recommender) + private Bindable backgroundBlurLevel { get; set; } = new BindableFloat(); + + private void applyBackgroundBlur(float v) { + ApplyToBackground(background => + { + background.IgnoreUserSettings.Value = true; + background.BlurAmount.Value = v * BACKGROUND_BLUR; + }); + } + private void applyBackgroundBlur(ValueChangedEvent v) + { + applyBackgroundBlur(v.NewValue); + } + + [BackgroundDependencyLoader(true)] + private void load(AudioManager audio, OsuColour colours, ManageCollectionsDialog? manageCollectionsDialog, DifficultyRecommender? recommender, OsuConfigManager config) + { + backgroundBlurLevel = config.GetBindable(OsuSetting.BeatmapSelectionBlurLevel); + LoadComponentAsync(Carousel = new BeatmapCarousel { AllowSelection = false, // delay any selection until our bindables are ready to make a good choice. @@ -549,6 +567,9 @@ namespace osu.Game.Screens.Select { base.OnEntering(e); + backgroundBlurLevel.ValueChanged += applyBackgroundBlur; + applyBackgroundBlur(backgroundBlurLevel.Value); + this.FadeInFromZero(250); FilterControl.Activate(); @@ -596,6 +617,8 @@ namespace osu.Game.Screens.Select public override void OnResuming(ScreenTransitionEvent e) { base.OnResuming(e); + backgroundBlurLevel.ValueChanged += applyBackgroundBlur; + applyBackgroundBlur(backgroundBlurLevel.Value); // required due to https://github.com/ppy/osu-framework/issues/3218 ModSelect.SelectedMods.Disabled = false; @@ -641,6 +664,8 @@ namespace osu.Game.Screens.Select // Without this, it's possible for a transfer to happen while we are not the current screen. transferRulesetValue(); + backgroundBlurLevel.ValueChanged -= applyBackgroundBlur; + ModSelect.SelectedMods.UnbindFrom(selectedMods); playExitingTransition(); @@ -649,6 +674,8 @@ namespace osu.Game.Screens.Select public override bool OnExiting(ScreenExitEvent e) { + backgroundBlurLevel.ValueChanged -= applyBackgroundBlur; + if (base.OnExiting(e)) return true; @@ -742,7 +769,7 @@ namespace osu.Game.Screens.Select ApplyToBackground(backgroundModeBeatmap => { backgroundModeBeatmap.Beatmap = beatmap; - backgroundModeBeatmap.BlurAmount.Value = BACKGROUND_BLUR; + backgroundModeBeatmap.BlurAmount.Value = backgroundBlurLevel.Value * BACKGROUND_BLUR; backgroundModeBeatmap.FadeColour(Color4.White, 250); });