mirror of
https://github.com/ppy/osu.git
synced 2025-03-19 01:58:46 +08:00
Fix toast popups spamming samples when adjusting osu!mania scroll speed during gameplay
Not the most robust of fixes, but as per the reasoning described in the issue thread, a proper fix will take considerably more effort. This intends to fix the issue first and foremost, as it sounds so bad I'd want to mute my sound before adjusting currently. Closes #15718.
This commit is contained in:
parent
01ca9eb81c
commit
0c11fe7413
@ -5,12 +5,14 @@ using System;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Audio;
|
||||
using osu.Framework.Audio.Sample;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Configuration.Tracking;
|
||||
using osu.Framework.Extensions.Color4Extensions;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Effects;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
using osu.Game.Configuration;
|
||||
using osu.Game.Graphics;
|
||||
using osuTK;
|
||||
using osuTK.Graphics;
|
||||
@ -28,6 +30,8 @@ namespace osu.Game.Overlays.OSD
|
||||
private Sample sampleOff;
|
||||
private Sample sampleChange;
|
||||
|
||||
private Bindable<double?> lastPlaybackTime;
|
||||
|
||||
public TrackedSettingToast(SettingDescription description)
|
||||
: base(description.Name, description.Value, description.Shortcut)
|
||||
{
|
||||
@ -75,10 +79,28 @@ namespace osu.Game.Overlays.OSD
|
||||
optionLights.Add(new OptionLight { Glowing = i == selectedOption });
|
||||
}
|
||||
|
||||
[Resolved]
|
||||
private SessionStatics statics { get; set; }
|
||||
|
||||
protected override void LoadComplete()
|
||||
{
|
||||
base.LoadComplete();
|
||||
|
||||
playSound();
|
||||
}
|
||||
|
||||
private void playSound()
|
||||
{
|
||||
// This debounce code roughly follows what we're using in HoverSampleDebounceComponent.
|
||||
// We're sharing the existing static for hover sounds because it doesn't really matter if they block each other.
|
||||
// This is a simple solution, but if this ever becomes a problem (or other performance issues arise),
|
||||
// the whole toast system should be rewritten to avoid recreating this drawable each time a value changes.
|
||||
lastPlaybackTime = statics.GetBindable<double?>(Static.LastHoverSoundPlaybackTime);
|
||||
|
||||
bool enoughTimePassedSinceLastPlayback = !lastPlaybackTime.Value.HasValue || Time.Current - lastPlaybackTime.Value >= OsuGameBase.SAMPLE_DEBOUNCE_TIME;
|
||||
|
||||
if (!enoughTimePassedSinceLastPlayback) return;
|
||||
|
||||
if (optionCount == 1)
|
||||
{
|
||||
if (selectedOption == 0)
|
||||
@ -93,6 +115,8 @@ namespace osu.Game.Overlays.OSD
|
||||
sampleChange.Frequency.Value = 1 + (double)selectedOption / (optionCount - 1) * 0.25f;
|
||||
sampleChange.Play();
|
||||
}
|
||||
|
||||
lastPlaybackTime.Value = Time.Current;
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
|
@ -101,7 +101,7 @@ namespace osu.Game.Overlays
|
||||
DisplayTemporarily(box);
|
||||
});
|
||||
|
||||
private void displayTrackedSettingChange(SettingDescription description) => Display(new TrackedSettingToast(description));
|
||||
private void displayTrackedSettingChange(SettingDescription description) => Scheduler.AddOnce(Display, new TrackedSettingToast(description));
|
||||
|
||||
private TransformSequence<Drawable> fadeIn;
|
||||
private ScheduledDelegate fadeOut;
|
||||
|
Loading…
x
Reference in New Issue
Block a user