1
0
mirror of https://github.com/ppy/osu.git synced 2024-09-22 04:07:25 +08:00

Allow the notification overlay to close when all notifications are dismissed

This commit is contained in:
Dean Herbert 2017-08-22 19:51:42 +09:00
parent ad16f41e26
commit 480d839d67
3 changed files with 14 additions and 3 deletions

View File

@ -22,7 +22,7 @@ namespace osu.Game.Overlays
private ScrollContainer scrollContainer;
private FlowContainer<NotificationSection> 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;

View File

@ -19,9 +19,9 @@ namespace osu.Game.Overlays.Notifications
public abstract class Notification : Container
{
/// <summary>
/// Use requested close.
/// User requested close.
/// </summary>
public Action Closed;
public event Action Closed;
/// <summary>
/// Run on user activating the notification. Return true to close.

View File

@ -24,6 +24,8 @@ namespace osu.Game.Overlays.Notifications
private FlowContainer<Notification> notifications;
public int DisplayedCount => notifications.Count;
public void Add(Notification notification)
{
notifications.Add(notification);