mirror of
https://github.com/osukey/osukey.git
synced 2025-07-02 00:40:09 +09:00
Add support for Notification sounds
This commit is contained in:
@ -3,6 +3,8 @@
|
|||||||
|
|
||||||
using System;
|
using System;
|
||||||
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;
|
||||||
@ -40,6 +42,11 @@ namespace osu.Game.Overlays.Notifications
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public virtual bool DisplayOnTop => true;
|
public virtual bool DisplayOnTop => true;
|
||||||
|
|
||||||
|
private SampleChannel samplePopIn;
|
||||||
|
private SampleChannel samplePopOut;
|
||||||
|
protected virtual string PopInSampleName => "UI/notification-pop-in";
|
||||||
|
protected virtual string PopOutSampleName => "UI/overlay-pop-out"; // TODO: replace with a unique sample?
|
||||||
|
|
||||||
protected NotificationLight Light;
|
protected NotificationLight Light;
|
||||||
private readonly CloseButton closeButton;
|
private readonly CloseButton closeButton;
|
||||||
protected Container IconContent;
|
protected Container IconContent;
|
||||||
@ -120,6 +127,13 @@ namespace osu.Game.Overlays.Notifications
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[BackgroundDependencyLoader]
|
||||||
|
private void load(AudioManager audio)
|
||||||
|
{
|
||||||
|
samplePopIn = audio.Samples.Get(PopInSampleName);
|
||||||
|
samplePopOut = audio.Samples.Get(PopOutSampleName);
|
||||||
|
}
|
||||||
|
|
||||||
protected override bool OnHover(HoverEvent e)
|
protected override bool OnHover(HoverEvent e)
|
||||||
{
|
{
|
||||||
closeButton.FadeIn(75);
|
closeButton.FadeIn(75);
|
||||||
@ -143,6 +157,9 @@ namespace osu.Game.Overlays.Notifications
|
|||||||
protected override void LoadComplete()
|
protected override void LoadComplete()
|
||||||
{
|
{
|
||||||
base.LoadComplete();
|
base.LoadComplete();
|
||||||
|
|
||||||
|
samplePopIn?.Play();
|
||||||
|
|
||||||
this.FadeInFromZero(200);
|
this.FadeInFromZero(200);
|
||||||
NotificationContent.MoveToX(DrawSize.X);
|
NotificationContent.MoveToX(DrawSize.X);
|
||||||
NotificationContent.MoveToX(0, 500, Easing.OutQuint);
|
NotificationContent.MoveToX(0, 500, Easing.OutQuint);
|
||||||
@ -150,12 +167,17 @@ namespace osu.Game.Overlays.Notifications
|
|||||||
|
|
||||||
public bool WasClosed;
|
public bool WasClosed;
|
||||||
|
|
||||||
public virtual void Close()
|
public virtual void Close() => Close(true);
|
||||||
|
|
||||||
|
public virtual void Close(bool playSound)
|
||||||
{
|
{
|
||||||
if (WasClosed) return;
|
if (WasClosed) return;
|
||||||
|
|
||||||
WasClosed = true;
|
WasClosed = true;
|
||||||
|
|
||||||
|
if (playSound)
|
||||||
|
samplePopOut?.Play();
|
||||||
|
|
||||||
Closed?.Invoke();
|
Closed?.Invoke();
|
||||||
this.FadeOut(100);
|
this.FadeOut(100);
|
||||||
Expire();
|
Expire();
|
||||||
|
@ -109,7 +109,12 @@ namespace osu.Game.Overlays.Notifications
|
|||||||
|
|
||||||
private void clearAll()
|
private void clearAll()
|
||||||
{
|
{
|
||||||
notifications.Children.ForEach(c => c.Close());
|
bool playSound = true;
|
||||||
|
notifications.Children.ForEach(c =>
|
||||||
|
{
|
||||||
|
c.Close(playSound);
|
||||||
|
playSound = false;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void Update()
|
protected override void Update()
|
||||||
|
Reference in New Issue
Block a user