1
0
mirror of https://github.com/ppy/osu.git synced 2024-09-21 19:27:24 +08:00

Don't play 'popout' sample when ProgressNotification completes

This commit is contained in:
Jamie Taylor 2023-07-07 01:50:15 +09:00
parent d4f5d0c878
commit a55ba963a9
No known key found for this signature in database
GPG Key ID: 2ACFA8B6370B8C8C
3 changed files with 9 additions and 3 deletions

View File

@ -169,7 +169,7 @@ namespace osu.Game.Overlays
Logger.Log($"⚠️ {notification.Text}");
notification.Closed += notificationClosed;
notification.Closed += () => notificationClosed(notification);
if (notification is IHasCompletionTarget hasCompletionTarget)
hasCompletionTarget.CompletionTarget = Post;
@ -229,17 +229,20 @@ namespace osu.Game.Overlays
mainContent.FadeEdgeEffectTo(0, WaveContainer.DISAPPEAR_DURATION, Easing.In);
}
private void notificationClosed() => Schedule(() =>
private void notificationClosed(Notification notification) => Schedule(() =>
{
updateCounts();
// this debounce is currently shared between popin/popout sounds, which means one could potentially not play when the user is expecting it.
// popout is constant across all notification types, and should therefore be handled using playback concurrency instead, but seems broken at the moment.
playDebouncedSample("UI/overlay-pop-out");
playDebouncedSample(notification.PopOutSampleName);
});
private void playDebouncedSample(string sampleName)
{
if (string.IsNullOrEmpty(sampleName))
return;
if (lastSamplePlayback == null || Time.Current - lastSamplePlayback > OsuGameBase.SAMPLE_DEBOUNCE_TIME)
{
audio.Samples.Get(sampleName)?.Play();

View File

@ -51,6 +51,7 @@ namespace osu.Game.Overlays.Notifications
public virtual bool DisplayOnTop => true;
public virtual string PopInSampleName => "UI/notification-default";
public virtual string PopOutSampleName => "UI/overlay-pop-out";
protected NotificationLight Light;

View File

@ -29,6 +29,8 @@ namespace osu.Game.Overlays.Notifications
protected override bool AllowFlingDismiss => false;
public override string PopOutSampleName => State is ProgressNotificationState.Cancelled ? base.PopOutSampleName : "";
/// <summary>
/// The function to post completion notifications back to.
/// </summary>