Merge branch 'master' into non-concurrent-sample-playback

This commit is contained in:
smoogipoo
2021-02-12 17:22:15 +09:00
295 changed files with 7478 additions and 2398 deletions

View File

@ -3,6 +3,8 @@
using System;
using osu.Framework.Allocation;
using osu.Framework.Audio;
using osu.Framework.Audio.Sample;
using osu.Framework.Extensions.Color4Extensions;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Colour;
@ -40,6 +42,11 @@ namespace osu.Game.Overlays.Notifications
/// </summary>
public virtual bool DisplayOnTop => true;
private Sample samplePopIn;
private Sample 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;
private readonly CloseButton closeButton;
protected Container IconContent;
@ -107,7 +114,7 @@ namespace osu.Game.Overlays.Notifications
closeButton = new CloseButton
{
Alpha = 0,
Action = Close,
Action = () => Close(),
Anchor = Anchor.CentreRight,
Origin = Anchor.CentreRight,
Margin = new MarginPadding
@ -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)
{
closeButton.FadeIn(75);
@ -143,6 +157,9 @@ namespace osu.Game.Overlays.Notifications
protected override void LoadComplete()
{
base.LoadComplete();
samplePopIn?.Play();
this.FadeInFromZero(200);
NotificationContent.MoveToX(DrawSize.X);
NotificationContent.MoveToX(0, 500, Easing.OutQuint);
@ -150,12 +167,15 @@ namespace osu.Game.Overlays.Notifications
public bool WasClosed;
public virtual void Close()
public virtual void Close(bool playSound = true)
{
if (WasClosed) return;
WasClosed = true;
if (playSound)
samplePopOut?.Play();
Closed?.Invoke();
this.FadeOut(100);
Expire();