diff --git a/osu.Game/Overlays/NotificationOverlay.cs b/osu.Game/Overlays/NotificationOverlay.cs index 7eabb592c6..5b9c3d20a0 100644 --- a/osu.Game/Overlays/NotificationOverlay.cs +++ b/osu.Game/Overlays/NotificationOverlay.cs @@ -22,7 +22,7 @@ namespace osu.Game.Overlays private ScrollContainer scrollContainer; private FlowContainer sections; - [BackgroundDependencyLoader(permitNulls: true)] + [BackgroundDependencyLoader] private void load() { Width = width; @@ -72,6 +72,13 @@ namespace osu.Game.Overlays private int runningDepth; + private void notificationClosed() + { + // hide ourselves if all notifications have been dismissed. + if (sections.Select(c => c.DisplayedCount).Sum() > 0) + State = Visibility.Hidden; + } + public void Post(Notification notification) { Schedule(() => @@ -81,6 +88,8 @@ namespace osu.Game.Overlays ++runningDepth; notification.Depth = notification.DisplayOnTop ? runningDepth : -runningDepth; + notification.Closed += notificationClosed; + var hasCompletionTarget = notification as IHasCompletionTarget; if (hasCompletionTarget != null) hasCompletionTarget.CompletionTarget = Post; diff --git a/osu.Game/Overlays/Notifications/Notification.cs b/osu.Game/Overlays/Notifications/Notification.cs index 14446a468c..b63efd3226 100644 --- a/osu.Game/Overlays/Notifications/Notification.cs +++ b/osu.Game/Overlays/Notifications/Notification.cs @@ -19,9 +19,9 @@ namespace osu.Game.Overlays.Notifications public abstract class Notification : Container { /// - /// Use requested close. + /// User requested close. /// - public Action Closed; + public event Action Closed; /// /// Run on user activating the notification. Return true to close. diff --git a/osu.Game/Overlays/Notifications/NotificationSection.cs b/osu.Game/Overlays/Notifications/NotificationSection.cs index efd3b39ee2..705800d4aa 100644 --- a/osu.Game/Overlays/Notifications/NotificationSection.cs +++ b/osu.Game/Overlays/Notifications/NotificationSection.cs @@ -24,6 +24,8 @@ namespace osu.Game.Overlays.Notifications private FlowContainer notifications; + public int DisplayedCount => notifications.Count; + public void Add(Notification notification) { notifications.Add(notification);