mirror of
https://github.com/ppy/osu.git
synced 2025-02-19 14:42:56 +08:00
Merge pull request #1171 from peppy/zero-notifications-closes
Allow the notification overlay to close when all notifications are dismissed
This commit is contained in:
commit
354e6c1297
@ -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;
|
||||
|
@ -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.
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user