2022-04-18 10:59:57 +00:00
|
|
|
|
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
|
|
|
|
// See the LICENCE file in the repository root for full licence text.
|
|
|
|
|
|
2023-06-23 05:58:19 +00:00
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
2022-04-18 10:59:57 +00:00
|
|
|
|
using osu.Framework.Allocation;
|
2022-04-19 02:10:11 +00:00
|
|
|
|
using osu.Framework.Bindables;
|
2022-04-18 10:59:57 +00:00
|
|
|
|
using osu.Game.Overlays.Notifications;
|
|
|
|
|
|
|
|
|
|
namespace osu.Game.Overlays
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// An overlay which is capable of showing notifications to the user.
|
|
|
|
|
/// </summary>
|
|
|
|
|
[Cached]
|
|
|
|
|
public interface INotificationOverlay
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Post a new notification for display.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="notification">The notification to display.</param>
|
|
|
|
|
void Post(Notification notification);
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Hide the overlay, if it is currently visible.
|
|
|
|
|
/// </summary>
|
|
|
|
|
void Hide();
|
2022-04-19 02:10:11 +00:00
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Current number of unread notifications.
|
|
|
|
|
/// </summary>
|
|
|
|
|
IBindable<int> UnreadCount { get; }
|
2023-06-21 10:06:47 +00:00
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Whether there are any ongoing operations, such as imports or downloads.
|
|
|
|
|
/// </summary>
|
2023-06-23 05:58:19 +00:00
|
|
|
|
public bool HasOngoingOperations => OngoingOperations.Any();
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// All current displayed notifications, whether in the toast tray or a section.
|
|
|
|
|
/// </summary>
|
|
|
|
|
IEnumerable<Notification> AllNotifications { get; }
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
2023-07-08 12:11:58 +00:00
|
|
|
|
/// All ongoing operations (ie. any <see cref="ProgressNotification"/> not in a completed or cancelled state).
|
2023-06-23 05:58:19 +00:00
|
|
|
|
/// </summary>
|
2023-07-08 12:11:58 +00:00
|
|
|
|
public IEnumerable<ProgressNotification> OngoingOperations => AllNotifications.OfType<ProgressNotification>().Where(p => p.Ongoing);
|
2022-04-18 10:59:57 +00:00
|
|
|
|
}
|
|
|
|
|
}
|