From eaa464e548582da39515ded5d9421146eabdcfc6 Mon Sep 17 00:00:00 2001 From: mk-56 Date: Sun, 28 Nov 2021 02:58:08 +0100 Subject: [PATCH] Initial implementation of adjustable positional hitobject audio strength --- osu.Game/Configuration/OsuConfigManager.cs | 2 ++ osu.Game/Localisation/AudioSettingsStrings.cs | 5 ++++ .../Sections/Gameplay/AudioSettings.cs | 28 ++++++++++++++++++- .../Objects/Drawables/DrawableHitObject.cs | 4 ++- 4 files changed, 37 insertions(+), 2 deletions(-) diff --git a/osu.Game/Configuration/OsuConfigManager.cs b/osu.Game/Configuration/OsuConfigManager.cs index 84da3f666d..a124c1c5ae 100644 --- a/osu.Game/Configuration/OsuConfigManager.cs +++ b/osu.Game/Configuration/OsuConfigManager.cs @@ -97,6 +97,7 @@ namespace osu.Game.Configuration SetDefault(OsuSetting.MenuParallax, true); // Gameplay + SetDefault(OsuSetting.PositionalHitsoundsLevel, 0.8f, 0.1f, 1f); SetDefault(OsuSetting.DimLevel, 0.8, 0, 1, 0.01); SetDefault(OsuSetting.BlurLevel, 0, 0, 1, 0.01); SetDefault(OsuSetting.LightenDuringBreaks, true); @@ -251,6 +252,7 @@ namespace osu.Game.Configuration BlurLevel, LightenDuringBreaks, ShowStoryboard, + PositionalHitsoundsLevel, KeyOverlay, PositionalHitSounds, AlwaysPlayFirstComboBreak, diff --git a/osu.Game/Localisation/AudioSettingsStrings.cs b/osu.Game/Localisation/AudioSettingsStrings.cs index 008781c2e5..a55816b401 100644 --- a/osu.Game/Localisation/AudioSettingsStrings.cs +++ b/osu.Game/Localisation/AudioSettingsStrings.cs @@ -32,6 +32,11 @@ namespace osu.Game.Localisation /// /// "Master" /// + public static LocalisableString PositionalLevel => new TranslatableString(getKey(@"positional_hitsound_audio_level"), @"Positional hitsound audio level."); + + /// + /// "Level" + /// public static LocalisableString MasterVolume => new TranslatableString(getKey(@"master_volume"), @"Master"); /// diff --git a/osu.Game/Overlays/Settings/Sections/Gameplay/AudioSettings.cs b/osu.Game/Overlays/Settings/Sections/Gameplay/AudioSettings.cs index dba64d695a..c239fd282a 100644 --- a/osu.Game/Overlays/Settings/Sections/Gameplay/AudioSettings.cs +++ b/osu.Game/Overlays/Settings/Sections/Gameplay/AudioSettings.cs @@ -2,10 +2,13 @@ // See the LICENCE file in the repository root for full licence text. using osu.Framework.Allocation; +using osu.Framework.Bindables; using osu.Framework.Graphics; using osu.Framework.Localisation; using osu.Game.Configuration; using osu.Game.Localisation; +using osu.Framework.Graphics.Containers; + namespace osu.Game.Overlays.Settings.Sections.Gameplay { @@ -13,9 +16,15 @@ namespace osu.Game.Overlays.Settings.Sections.Gameplay { protected override LocalisableString Header => GameplaySettingsStrings.AudioHeader; + private Bindable positionalHitsoundsLevel; + + private FillFlowContainer> positionalHitsoundsSettings; + + [BackgroundDependencyLoader] - private void load(OsuConfigManager config) + private void load(OsuConfigManager config,OsuConfigManager osuConfig) { + positionalHitsoundsLevel = osuConfig.GetBindable(OsuSetting.PositionalHitsoundsLevel); Children = new Drawable[] { new SettingsCheckbox @@ -23,6 +32,23 @@ namespace osu.Game.Overlays.Settings.Sections.Gameplay LabelText = GameplaySettingsStrings.PositionalHitsounds, Current = config.GetBindable(OsuSetting.PositionalHitSounds) }, + positionalHitsoundsSettings = new FillFlowContainer> + { + Direction = FillDirection.Vertical, + RelativeSizeAxes = Axes.X, + AutoSizeAxes = Axes.Y, + Masking = true, + Children = new[] + { + new SettingsSlider + { + LabelText = AudioSettingsStrings.PositionalLevel, + Current = positionalHitsoundsLevel, + KeyboardStep = 0.01f, + DisplayAsPercentage = true, + }, + } + }, new SettingsCheckbox { LabelText = GameplaySettingsStrings.AlwaysPlayFirstComboBreak, diff --git a/osu.Game/Rulesets/Objects/Drawables/DrawableHitObject.cs b/osu.Game/Rulesets/Objects/Drawables/DrawableHitObject.cs index 01817147ae..1a0fe8d004 100644 --- a/osu.Game/Rulesets/Objects/Drawables/DrawableHitObject.cs +++ b/osu.Game/Rulesets/Objects/Drawables/DrawableHitObject.cs @@ -22,6 +22,7 @@ using osu.Game.Rulesets.Scoring; using osu.Game.Rulesets.UI; using osu.Game.Skinning; using osuTK.Graphics; +using osu.Game.Overlays.Settings.Sections.Gameplay; namespace osu.Game.Rulesets.Objects.Drawables { @@ -124,6 +125,7 @@ namespace osu.Game.Rulesets.Objects.Drawables public readonly Bindable StartTimeBindable = new Bindable(); private readonly BindableList samplesBindable = new BindableList(); private readonly Bindable userPositionalHitSounds = new Bindable(); + private readonly Bindable positionalHitsoundsLevel = new Bindable(); private readonly Bindable comboIndexBindable = new Bindable(); private readonly Bindable comboIndexWithOffsetsBindable = new Bindable(); @@ -532,7 +534,7 @@ namespace osu.Game.Rulesets.Objects.Drawables /// The lookup X position. Generally should be . protected double CalculateSamplePlaybackBalance(double position) { - const float balance_adjust_amount = 0.4f; + float balance_adjust_amount = positionalHitsoundsLevel.Value; return balance_adjust_amount * (userPositionalHitSounds.Value ? position - 0.5f : 0); }