Initial clean up pass on notification logic

This commit is contained in:
Dean Herbert 2021-09-05 12:54:21 +09:00
parent cdd0262ca1
commit 1d23ac0f2d
2 changed files with 8 additions and 4 deletions

View File

@ -6,7 +6,6 @@ using osu.Framework.Audio;
using osu.Framework.Audio.Sample; using osu.Framework.Audio.Sample;
using osu.Framework.Extensions; using osu.Framework.Extensions;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Game.Configuration;
using osu.Framework.Utils; using osu.Framework.Utils;
namespace osu.Game.Graphics.UserInterface namespace osu.Game.Graphics.UserInterface
@ -28,7 +27,7 @@ namespace osu.Game.Graphics.UserInterface
} }
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load(AudioManager audio, SessionStatics statics) private void load(AudioManager audio)
{ {
sampleHover = audio.Samples.Get($@"UI/{SampleSet.GetDescription()}-hover") sampleHover = audio.Samples.Get($@"UI/{SampleSet.GetDescription()}-hover")
?? audio.Samples.Get($@"UI/{HoverSampleSet.Default.GetDescription()}-hover"); ?? audio.Samples.Get($@"UI/{HoverSampleSet.Default.GetDescription()}-hover");

View File

@ -98,14 +98,16 @@ namespace osu.Game.Overlays
private int runningDepth; private int runningDepth;
private void notificationClosed() => updateCounts();
private readonly Scheduler postScheduler = new Scheduler(); private readonly Scheduler postScheduler = new Scheduler();
public override bool IsPresent => base.IsPresent || postScheduler.HasPendingTasks; public override bool IsPresent => base.IsPresent || postScheduler.HasPendingTasks;
private bool processingPosts = true; private bool processingPosts = true;
/// <summary>
/// Post a new notification for display.
/// </summary>
/// <param name="notification">The notification to display.</param>
public void Post(Notification notification) => postScheduler.Add(() => public void Post(Notification notification) => postScheduler.Add(() =>
{ {
++runningDepth; ++runningDepth;
@ -129,6 +131,7 @@ namespace osu.Game.Overlays
protected override void Update() protected override void Update()
{ {
base.Update(); base.Update();
if (processingPosts) if (processingPosts)
postScheduler.Update(); postScheduler.Update();
} }
@ -151,6 +154,8 @@ namespace osu.Game.Overlays
this.FadeTo(0, TRANSITION_LENGTH, Easing.OutQuint); this.FadeTo(0, TRANSITION_LENGTH, Easing.OutQuint);
} }
private void notificationClosed() => updateCounts();
private void updateCounts() private void updateCounts()
{ {
UnreadCount.Value = sections.Select(c => c.UnreadCount).Sum(); UnreadCount.Value = sections.Select(c => c.UnreadCount).Sum();