Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SFX tweaks #25178

Merged
merged 7 commits into from
Oct 20, 2023
1 change: 1 addition & 0 deletions osu.Game/Graphics/UserInterface/OsuTextBox.cs
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ private void load(OverlayColourProvider? colourProvider, OsuColour colour, Audio

Placeholder.Colour = colourProvider?.Foreground1 ?? new Color4(180, 180, 180, 255);

// Note that `KeyBindingRow` uses similar logic for input feedback, so remember to update there if changing here.
var textAddedSamples = new Sample?[4];
for (int i = 0; i < textAddedSamples.Length; i++)
textAddedSamples[i] = audio.Samples.Get($@"Keyboard/key-press-{1 + i}");
Expand Down
2 changes: 1 addition & 1 deletion osu.Game/Overlays/LoginOverlay.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public partial class LoginOverlay : OsuFocusedOverlayContainer

private const float transition_time = 400;

protected override double PopInOutSampleBalance => OsuGameBase.SFX_STEREO_STRENGTH;
protected override double PopInOutSampleBalance => OsuGameBase.SFX_STEREO_STRENGTH * 0.75f;

[Cached]
private OverlayColourProvider colourProvider = new OverlayColourProvider(OverlayColourScheme.Purple);
Expand Down
2 changes: 2 additions & 0 deletions osu.Game/Overlays/News/NewsCard.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
using osu.Game.Graphics;
using osu.Game.Graphics.Containers;
using osu.Game.Graphics.Sprites;
using osu.Game.Graphics.UserInterface;
using osu.Game.Online.API.Requests.Responses;

namespace osu.Game.Overlays.News
Expand All @@ -28,6 +29,7 @@ public partial class NewsCard : OsuHoverContainer
private TextFlowContainer main = null!;

public NewsCard(APINewsPost post)
: base(HoverSampleSet.Button)
{
this.post = post;

Expand Down
3 changes: 1 addition & 2 deletions osu.Game/Overlays/NowPlayingOverlay.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,7 @@ public partial class NowPlayingOverlay : OsuFocusedOverlayContainer, INamedOverl
private Container playerContainer = null!;
private Container playlistContainer = null!;

protected override string PopInSampleName => "UI/now-playing-pop-in";
protected override string PopOutSampleName => "UI/now-playing-pop-out";
protected override double PopInOutSampleBalance => OsuGameBase.SFX_STEREO_STRENGTH * 0.75f;

[Resolved]
private MusicController musicController { get; set; } = null!;
Expand Down
6 changes: 0 additions & 6 deletions osu.Game/Overlays/RevertToDefaultButton.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
using osu.Framework.Localisation;
using osu.Game.Graphics;
using osu.Game.Graphics.Containers;
using osu.Game.Graphics.UserInterface;
using osu.Game.Localisation;
using osuTK;

Expand Down Expand Up @@ -56,11 +55,6 @@ public Bindable<T> Current
}
}

public RevertToDefaultButton()
: base(HoverSampleSet.Button)
{
}

[BackgroundDependencyLoader]
private void load()
{
Expand Down
13 changes: 12 additions & 1 deletion osu.Game/Overlays/Settings/Sections/Input/KeyBindingRow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
using System.Diagnostics;
using System.Linq;
using osu.Framework.Allocation;
using osu.Framework.Audio;
using osu.Framework.Audio.Sample;
using osu.Framework.Bindables;
using osu.Framework.Extensions;
using osu.Framework.Extensions.Color4Extensions;
Expand All @@ -17,6 +19,7 @@
using osu.Framework.Input.Bindings;
using osu.Framework.Input.Events;
using osu.Framework.Localisation;
using osu.Framework.Utils;
using osu.Game.Database;
using osu.Game.Graphics.Sprites;
using osu.Game.Graphics.UserInterface;
Expand Down Expand Up @@ -96,6 +99,8 @@ public bool MatchingFilter

private KeyButton? bindTarget;

private Sample?[]? keypressSamples;

private const float transition_time = 150;
private const float height = 20;
private const float padding = 5;
Expand All @@ -118,7 +123,7 @@ public KeyBindingRow(object action)
}

[BackgroundDependencyLoader]
private void load(OverlayColourProvider colourProvider)
private void load(OverlayColourProvider colourProvider, AudioManager audioManager)
{
RelativeSizeAxes = Axes.X;
AutoSizeAxes = Axes.Y;
Expand Down Expand Up @@ -202,6 +207,10 @@ private void load(OverlayColourProvider colourProvider)
Scheduler.AddOnce(updateButtons);
updateIsDefaultValue();
}, true);

keypressSamples = new Sample[4];
for (int i = 0; i < keypressSamples.Length; i++)
keypressSamples[i] = audioManager.Samples.Get($@"Keyboard/key-press-{1 + i}");
}

public void RestoreDefaults()
Expand Down Expand Up @@ -301,6 +310,8 @@ protected override bool OnKeyDown(KeyDownEvent e)

Debug.Assert(bindTarget != null);

keypressSamples?[RNG.Next(0, keypressSamples.Length)]?.Play();

bindTarget.UpdateKeyCombination(KeyCombination.FromInputState(e.CurrentState), KeyCombination.FromKey(e.Key));
if (!isModifier(e.Key)) finalise();

Expand Down
4 changes: 2 additions & 2 deletions osu.Game/Overlays/Settings/SidebarButton.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ public abstract partial class SidebarButton : OsuButton
[Resolved]
protected OverlayColourProvider ColourProvider { get; private set; } = null!;

protected SidebarButton()
: base(HoverSampleSet.ButtonSidebar)
protected SidebarButton(HoverSampleSet? hoverSounds = HoverSampleSet.ButtonSidebar)
: base(hoverSounds)
{
}

Expand Down
6 changes: 6 additions & 0 deletions osu.Game/Overlays/SettingsSubPanel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
using osu.Framework.Graphics.Sprites;
using osu.Game.Graphics;
using osu.Game.Graphics.Sprites;
using osu.Game.Graphics.UserInterface;
using osu.Game.Overlays.Settings;
using osuTK;

Expand Down Expand Up @@ -38,6 +39,11 @@ public partial class BackButton : SidebarButton
{
private Container content;

public BackButton()
: base(HoverSampleSet.Default)
{
}

[BackgroundDependencyLoader]
private void load()
{
Expand Down
3 changes: 3 additions & 0 deletions osu.Game/Overlays/Toolbar/ToolbarRulesetTabButton.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using osu.Framework.Graphics.Effects;
using osu.Framework.Graphics.UserInterface;
using osu.Framework.Input.Events;
using osu.Game.Graphics.UserInterface;
using osu.Game.Localisation;
using osu.Game.Rulesets;
using osuTK.Graphics;
Expand Down Expand Up @@ -38,6 +39,8 @@ public ToolbarRulesetTabButton(RulesetInfo value)

private partial class RulesetButton : ToolbarButton
{
protected override HoverSounds CreateHoverSounds(HoverSampleSet sampleSet) => new HoverSounds();

public bool Active
{
set
Expand Down