1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-11 11:37:28 +08:00

Merge pull request #24145 from nekodex/more-notification-sounds

Add new notification sounds
This commit is contained in:
Dean Herbert 2023-07-07 17:33:23 +09:00 committed by GitHub
commit 03f311d086
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 24 additions and 7 deletions

View File

@ -171,6 +171,8 @@ namespace osu.Game.Online.Chat
public abstract partial class HighlightMessageNotification : SimpleNotification public abstract partial class HighlightMessageNotification : SimpleNotification
{ {
public override string PopInSampleName => "UI/notification-mention";
protected HighlightMessageNotification(Message message, Channel channel) protected HighlightMessageNotification(Message message, Channel channel)
{ {
this.message = message; this.message = message;

View File

@ -169,7 +169,7 @@ namespace osu.Game.Overlays
Logger.Log($"⚠️ {notification.Text}"); Logger.Log($"⚠️ {notification.Text}");
notification.Closed += notificationClosed; notification.Closed += () => notificationClosed(notification);
if (notification is IHasCompletionTarget hasCompletionTarget) if (notification is IHasCompletionTarget hasCompletionTarget)
hasCompletionTarget.CompletionTarget = Post; hasCompletionTarget.CompletionTarget = Post;
@ -229,17 +229,20 @@ namespace osu.Game.Overlays
mainContent.FadeEdgeEffectTo(0, WaveContainer.DISAPPEAR_DURATION, Easing.In); mainContent.FadeEdgeEffectTo(0, WaveContainer.DISAPPEAR_DURATION, Easing.In);
} }
private void notificationClosed() => Schedule(() => private void notificationClosed(Notification notification) => Schedule(() =>
{ {
updateCounts(); updateCounts();
// this debounce is currently shared between popin/popout sounds, which means one could potentially not play when the user is expecting it. // 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. // 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) private void playDebouncedSample(string sampleName)
{ {
if (string.IsNullOrEmpty(sampleName))
return;
if (lastSamplePlayback == null || Time.Current - lastSamplePlayback > OsuGameBase.SAMPLE_DEBOUNCE_TIME) if (lastSamplePlayback == null || Time.Current - lastSamplePlayback > OsuGameBase.SAMPLE_DEBOUNCE_TIME)
{ {
audio.Samples.Get(sampleName)?.Play(); audio.Samples.Get(sampleName)?.Play();

View File

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

View File

@ -10,6 +10,8 @@ namespace osu.Game.Overlays.Notifications
{ {
public partial class ProgressCompletionNotification : SimpleNotification public partial class ProgressCompletionNotification : SimpleNotification
{ {
public override string PopInSampleName => "UI/notification-done";
public ProgressCompletionNotification() public ProgressCompletionNotification()
{ {
Icon = FontAwesome.Solid.Check; Icon = FontAwesome.Solid.Check;

View File

@ -4,6 +4,8 @@
using System; using System;
using System.Threading; using System.Threading;
using osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Framework.Audio;
using osu.Framework.Audio.Sample;
using osu.Framework.Extensions.Color4Extensions; using osu.Framework.Extensions.Color4Extensions;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Graphics.Colour; using osu.Framework.Graphics.Colour;
@ -27,6 +29,8 @@ namespace osu.Game.Overlays.Notifications
protected override bool AllowFlingDismiss => false; protected override bool AllowFlingDismiss => false;
public override string PopOutSampleName => State is ProgressNotificationState.Cancelled ? base.PopOutSampleName : "";
/// <summary> /// <summary>
/// The function to post completion notifications back to. /// The function to post completion notifications back to.
/// </summary> /// </summary>
@ -122,6 +126,7 @@ namespace osu.Game.Overlays.Notifications
cancellationTokenSource.Cancel(); cancellationTokenSource.Cancel();
IconContent.FadeColour(ColourInfo.GradientVertical(Color4.Gray, Color4.Gray.Lighten(0.5f)), colour_fade_duration); IconContent.FadeColour(ColourInfo.GradientVertical(Color4.Gray, Color4.Gray.Lighten(0.5f)), colour_fade_duration);
cancelSample?.Play();
loadingSpinner.Hide(); loadingSpinner.Hide();
var icon = new SpriteIcon var icon = new SpriteIcon
@ -190,6 +195,8 @@ namespace osu.Game.Overlays.Notifications
private LoadingSpinner loadingSpinner = null!; private LoadingSpinner loadingSpinner = null!;
private Sample? cancelSample;
private readonly TextFlowContainer textDrawable; private readonly TextFlowContainer textDrawable;
public ProgressNotification() public ProgressNotification()
@ -217,7 +224,7 @@ namespace osu.Game.Overlays.Notifications
} }
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load(OsuColour colours) private void load(OsuColour colours, AudioManager audioManager)
{ {
colourQueued = colours.YellowDark; colourQueued = colours.YellowDark;
colourActive = colours.Blue; colourActive = colours.Blue;
@ -236,6 +243,8 @@ namespace osu.Game.Overlays.Notifications
Size = new Vector2(loading_spinner_size), Size = new Vector2(loading_spinner_size),
} }
}); });
cancelSample = audioManager.Samples.Get(@"UI/notification-cancel");
} }
public override void Close(bool runFlingAnimation) public override void Close(bool runFlingAnimation)

View File

@ -7,7 +7,7 @@ namespace osu.Game.Overlays.Notifications
{ {
public partial class SimpleErrorNotification : SimpleNotification public partial class SimpleErrorNotification : SimpleNotification
{ {
public override string PopInSampleName => "UI/error-notification-pop-in"; public override string PopInSampleName => "UI/notification-error";
public SimpleErrorNotification() public SimpleErrorNotification()
{ {

View File

@ -37,7 +37,7 @@
</PackageReference> </PackageReference>
<PackageReference Include="Realm" Version="11.1.2" /> <PackageReference Include="Realm" Version="11.1.2" />
<PackageReference Include="ppy.osu.Framework" Version="2023.625.0" /> <PackageReference Include="ppy.osu.Framework" Version="2023.625.0" />
<PackageReference Include="ppy.osu.Game.Resources" Version="2023.625.0" /> <PackageReference Include="ppy.osu.Game.Resources" Version="2023.707.0" />
<PackageReference Include="Sentry" Version="3.28.1" /> <PackageReference Include="Sentry" Version="3.28.1" />
<PackageReference Include="SharpCompress" Version="0.32.2" /> <PackageReference Include="SharpCompress" Version="0.32.2" />
<PackageReference Include="NUnit" Version="3.13.3" /> <PackageReference Include="NUnit" Version="3.13.3" />