1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-12 21:02:54 +08:00

Initial implementation of adjustable positional hitobject audio strength

This commit is contained in:
mk-56 2021-11-28 02:58:08 +01:00
parent a0cc7bbdc8
commit eaa464e548
4 changed files with 37 additions and 2 deletions

View File

@ -97,6 +97,7 @@ namespace osu.Game.Configuration
SetDefault(OsuSetting.MenuParallax, true); SetDefault(OsuSetting.MenuParallax, true);
// Gameplay // Gameplay
SetDefault(OsuSetting.PositionalHitsoundsLevel, 0.8f, 0.1f, 1f);
SetDefault(OsuSetting.DimLevel, 0.8, 0, 1, 0.01); SetDefault(OsuSetting.DimLevel, 0.8, 0, 1, 0.01);
SetDefault(OsuSetting.BlurLevel, 0, 0, 1, 0.01); SetDefault(OsuSetting.BlurLevel, 0, 0, 1, 0.01);
SetDefault(OsuSetting.LightenDuringBreaks, true); SetDefault(OsuSetting.LightenDuringBreaks, true);
@ -251,6 +252,7 @@ namespace osu.Game.Configuration
BlurLevel, BlurLevel,
LightenDuringBreaks, LightenDuringBreaks,
ShowStoryboard, ShowStoryboard,
PositionalHitsoundsLevel,
KeyOverlay, KeyOverlay,
PositionalHitSounds, PositionalHitSounds,
AlwaysPlayFirstComboBreak, AlwaysPlayFirstComboBreak,

View File

@ -32,6 +32,11 @@ namespace osu.Game.Localisation
/// <summary> /// <summary>
/// "Master" /// "Master"
/// </summary> /// </summary>
public static LocalisableString PositionalLevel => new TranslatableString(getKey(@"positional_hitsound_audio_level"), @"Positional hitsound audio level.");
/// <summary>
/// "Level"
/// </summary>
public static LocalisableString MasterVolume => new TranslatableString(getKey(@"master_volume"), @"Master"); public static LocalisableString MasterVolume => new TranslatableString(getKey(@"master_volume"), @"Master");
/// <summary> /// <summary>

View File

@ -2,10 +2,13 @@
// See the LICENCE file in the repository root for full licence text. // See the LICENCE file in the repository root for full licence text.
using osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Framework.Bindables;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Localisation; using osu.Framework.Localisation;
using osu.Game.Configuration; using osu.Game.Configuration;
using osu.Game.Localisation; using osu.Game.Localisation;
using osu.Framework.Graphics.Containers;
namespace osu.Game.Overlays.Settings.Sections.Gameplay namespace osu.Game.Overlays.Settings.Sections.Gameplay
{ {
@ -13,9 +16,15 @@ namespace osu.Game.Overlays.Settings.Sections.Gameplay
{ {
protected override LocalisableString Header => GameplaySettingsStrings.AudioHeader; protected override LocalisableString Header => GameplaySettingsStrings.AudioHeader;
private Bindable<float> positionalHitsoundsLevel;
private FillFlowContainer<SettingsSlider<float>> positionalHitsoundsSettings;
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load(OsuConfigManager config) private void load(OsuConfigManager config,OsuConfigManager osuConfig)
{ {
positionalHitsoundsLevel = osuConfig.GetBindable<float>(OsuSetting.PositionalHitsoundsLevel);
Children = new Drawable[] Children = new Drawable[]
{ {
new SettingsCheckbox new SettingsCheckbox
@ -23,6 +32,23 @@ namespace osu.Game.Overlays.Settings.Sections.Gameplay
LabelText = GameplaySettingsStrings.PositionalHitsounds, LabelText = GameplaySettingsStrings.PositionalHitsounds,
Current = config.GetBindable<bool>(OsuSetting.PositionalHitSounds) Current = config.GetBindable<bool>(OsuSetting.PositionalHitSounds)
}, },
positionalHitsoundsSettings = new FillFlowContainer<SettingsSlider<float>>
{
Direction = FillDirection.Vertical,
RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y,
Masking = true,
Children = new[]
{
new SettingsSlider<float>
{
LabelText = AudioSettingsStrings.PositionalLevel,
Current = positionalHitsoundsLevel,
KeyboardStep = 0.01f,
DisplayAsPercentage = true,
},
}
},
new SettingsCheckbox new SettingsCheckbox
{ {
LabelText = GameplaySettingsStrings.AlwaysPlayFirstComboBreak, LabelText = GameplaySettingsStrings.AlwaysPlayFirstComboBreak,

View File

@ -22,6 +22,7 @@ using osu.Game.Rulesets.Scoring;
using osu.Game.Rulesets.UI; using osu.Game.Rulesets.UI;
using osu.Game.Skinning; using osu.Game.Skinning;
using osuTK.Graphics; using osuTK.Graphics;
using osu.Game.Overlays.Settings.Sections.Gameplay;
namespace osu.Game.Rulesets.Objects.Drawables namespace osu.Game.Rulesets.Objects.Drawables
{ {
@ -124,6 +125,7 @@ namespace osu.Game.Rulesets.Objects.Drawables
public readonly Bindable<double> StartTimeBindable = new Bindable<double>(); public readonly Bindable<double> StartTimeBindable = new Bindable<double>();
private readonly BindableList<HitSampleInfo> samplesBindable = new BindableList<HitSampleInfo>(); private readonly BindableList<HitSampleInfo> samplesBindable = new BindableList<HitSampleInfo>();
private readonly Bindable<bool> userPositionalHitSounds = new Bindable<bool>(); private readonly Bindable<bool> userPositionalHitSounds = new Bindable<bool>();
private readonly Bindable<float> positionalHitsoundsLevel = new Bindable<float>();
private readonly Bindable<int> comboIndexBindable = new Bindable<int>(); private readonly Bindable<int> comboIndexBindable = new Bindable<int>();
private readonly Bindable<int> comboIndexWithOffsetsBindable = new Bindable<int>(); private readonly Bindable<int> comboIndexWithOffsetsBindable = new Bindable<int>();
@ -532,7 +534,7 @@ namespace osu.Game.Rulesets.Objects.Drawables
/// <param name="position">The lookup X position. Generally should be <see cref="SamplePlaybackPosition"/>.</param> /// <param name="position">The lookup X position. Generally should be <see cref="SamplePlaybackPosition"/>.</param>
protected double CalculateSamplePlaybackBalance(double position) 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); return balance_adjust_amount * (userPositionalHitSounds.Value ? position - 0.5f : 0);
} }