1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-11 10:07:52 +08:00

Expose all notifications from INotificationOverlay

Also fixes `HasOngoingOperations` not actually working.
This commit is contained in:
Dean Herbert 2023-06-23 14:58:19 +09:00
parent 20aedc82ac
commit 7fa07805b0
6 changed files with 29 additions and 4 deletions

View File

@ -3,6 +3,7 @@
#nullable disable
using System.Collections.Generic;
using System.Linq;
using JetBrains.Annotations;
using Moq;
@ -251,7 +252,7 @@ namespace osu.Game.Tests.Visual.Menus
public virtual IBindable<int> UnreadCount => null;
public bool HasOngoingOperations => false;
public IEnumerable<Notification> AllNotifications => Enumerable.Empty<Notification>();
}
}
}

View File

@ -215,7 +215,7 @@ namespace osu.Game.Tests.Visual.UserInterface
public virtual IBindable<int> UnreadCount => null;
public bool HasOngoingOperations => false;
public IEnumerable<Notification> AllNotifications => Enumerable.Empty<Notification>();
}
// interface mocks break hot reload, mocking this stub implementation instead works around it.

View File

@ -3,6 +3,8 @@
#nullable disable
using System.Collections.Generic;
using System.Linq;
using osu.Framework.Allocation;
using osu.Framework.Bindables;
using osu.Game.Overlays.Notifications;
@ -34,6 +36,16 @@ namespace osu.Game.Overlays
/// <summary>
/// Whether there are any ongoing operations, such as imports or downloads.
/// </summary>
bool HasOngoingOperations { get; }
public bool HasOngoingOperations => OngoingOperations.Any();
/// <summary>
/// All current displayed notifications, whether in the toast tray or a section.
/// </summary>
IEnumerable<Notification> AllNotifications { get; }
/// <summary>
/// All ongoing operations (ie. any <see cref="ProgressNotification"/> not in a completed state).
/// </summary>
public IEnumerable<ProgressNotification> OngoingOperations => AllNotifications.OfType<ProgressNotification>().Where(p => p.State != ProgressNotificationState.Completed);
}
}

View File

@ -1,6 +1,7 @@
// 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.
using System.Collections.Generic;
using System.Linq;
using osu.Framework.Allocation;
using osu.Framework.Audio;
@ -33,7 +34,8 @@ namespace osu.Game.Overlays
public const float TRANSITION_LENGTH = 600;
public bool HasOngoingOperations => sections.Any(s => s.Children.OfType<ProgressNotification>().Any());
public IEnumerable<Notification> AllNotifications =>
toastTray.Notifications.Concat(sections.SelectMany(s => s.Notifications));
private FlowContainer<NotificationSection> sections = null!;

View File

@ -28,6 +28,11 @@ namespace osu.Game.Overlays
public override bool ReceivePositionalInputAt(Vector2 screenSpacePos) => toastFlow.ReceivePositionalInputAt(screenSpacePos);
/// <summary>
/// All notifications currently being displayed by the toast tray.
/// </summary>
public IEnumerable<Notification> Notifications => toastFlow;
public bool IsDisplayingToasts => toastFlow.Count > 0;
private FillFlowContainer<Notification> toastFlow = null!;

View File

@ -19,6 +19,11 @@ namespace osu.Game.Overlays.Notifications
{
public partial class NotificationSection : AlwaysUpdateFillFlowContainer<Drawable>
{
/// <summary>
/// All notifications currently being displayed in this section.
/// </summary>
public IEnumerable<Notification> Notifications => notifications;
private OsuSpriteText countDrawable = null!;
private FlowContainer<Notification> notifications = null!;