From b2db550cb457abf41bcf12658731d6f9768655d2 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Wed, 23 Aug 2017 12:47:20 +0900 Subject: [PATCH] Fix notification count including fading (already closed) notifications --- osu.Game/Overlays/NotificationOverlay.cs | 2 +- osu.Game/Overlays/Notifications/Notification.cs | 6 +++--- osu.Game/Overlays/Notifications/NotificationSection.cs | 7 ++----- 3 files changed, 6 insertions(+), 9 deletions(-) diff --git a/osu.Game/Overlays/NotificationOverlay.cs b/osu.Game/Overlays/NotificationOverlay.cs index 5b9c3d20a0..260214a14f 100644 --- a/osu.Game/Overlays/NotificationOverlay.cs +++ b/osu.Game/Overlays/NotificationOverlay.cs @@ -75,7 +75,7 @@ namespace osu.Game.Overlays private void notificationClosed() { // hide ourselves if all notifications have been dismissed. - if (sections.Select(c => c.DisplayedCount).Sum() > 0) + if (sections.Select(c => c.DisplayedCount).Sum() == 0) State = Visibility.Hidden; } diff --git a/osu.Game/Overlays/Notifications/Notification.cs b/osu.Game/Overlays/Notifications/Notification.cs index b63efd3226..422051364e 100644 --- a/osu.Game/Overlays/Notifications/Notification.cs +++ b/osu.Game/Overlays/Notifications/Notification.cs @@ -142,12 +142,12 @@ namespace osu.Game.Overlays.Notifications NotificationContent.MoveToX(0, 500, Easing.OutQuint); } - private bool wasClosed; + public bool WasClosed; public virtual void Close() { - if (wasClosed) return; - wasClosed = true; + if (WasClosed) return; + WasClosed = true; Closed?.Invoke(); this.FadeOut(100); diff --git a/osu.Game/Overlays/Notifications/NotificationSection.cs b/osu.Game/Overlays/Notifications/NotificationSection.cs index 705800d4aa..09768ba0ea 100644 --- a/osu.Game/Overlays/Notifications/NotificationSection.cs +++ b/osu.Game/Overlays/Notifications/NotificationSection.cs @@ -24,12 +24,9 @@ namespace osu.Game.Overlays.Notifications private FlowContainer notifications; - public int DisplayedCount => notifications.Count; + public int DisplayedCount => notifications.Count(n => !n.WasClosed); - public void Add(Notification notification) - { - notifications.Add(notification); - } + public void Add(Notification notification) => notifications.Add(notification); public IEnumerable AcceptTypes;