mirror of
https://github.com/ppy/osu
synced 2024-12-22 14:54:35 +00:00
Merge pull request #24144 from peppy/no-dismiss-all-progress-notifications
Remove the ability to cancel all "in progress" tasks
This commit is contained in:
commit
0f56080fe3
@ -52,6 +52,32 @@ namespace osu.Game.Tests.Visual.UserInterface
|
||||
notificationOverlay.UnreadCount.ValueChanged += count => { displayedCount.Text = $"unread count: {count.NewValue}"; };
|
||||
});
|
||||
|
||||
[Test]
|
||||
public void TestBasicFlow()
|
||||
{
|
||||
setState(Visibility.Visible);
|
||||
AddStep(@"simple #1", sendHelloNotification);
|
||||
AddStep(@"simple #2", sendAmazingNotification);
|
||||
AddStep(@"progress #1", sendUploadProgress);
|
||||
AddStep(@"progress #2", sendDownloadProgress);
|
||||
|
||||
checkProgressingCount(2);
|
||||
|
||||
setState(Visibility.Hidden);
|
||||
|
||||
AddRepeatStep(@"add many simple", sendManyNotifications, 3);
|
||||
|
||||
waitForCompletion();
|
||||
|
||||
AddStep(@"progress #3", sendUploadProgress);
|
||||
|
||||
checkProgressingCount(1);
|
||||
|
||||
checkDisplayedCount(33);
|
||||
|
||||
waitForCompletion();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestForwardWithFlingRight()
|
||||
{
|
||||
@ -411,32 +437,6 @@ namespace osu.Game.Tests.Visual.UserInterface
|
||||
AddUntilStep("wait for update applied", () => applyUpdate);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestBasicFlow()
|
||||
{
|
||||
setState(Visibility.Visible);
|
||||
AddStep(@"simple #1", sendHelloNotification);
|
||||
AddStep(@"simple #2", sendAmazingNotification);
|
||||
AddStep(@"progress #1", sendUploadProgress);
|
||||
AddStep(@"progress #2", sendDownloadProgress);
|
||||
|
||||
checkProgressingCount(2);
|
||||
|
||||
setState(Visibility.Hidden);
|
||||
|
||||
AddRepeatStep(@"add many simple", sendManyNotifications, 3);
|
||||
|
||||
waitForCompletion();
|
||||
|
||||
AddStep(@"progress #3", sendUploadProgress);
|
||||
|
||||
checkProgressingCount(1);
|
||||
|
||||
checkDisplayedCount(33);
|
||||
|
||||
waitForCompletion();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestImportantWhileClosed()
|
||||
{
|
||||
|
@ -29,11 +29,6 @@ namespace osu.Game.Localisation
|
||||
/// </summary>
|
||||
public static LocalisableString ClearAll => new TranslatableString(getKey(@"clear_all"), @"Clear All");
|
||||
|
||||
/// <summary>
|
||||
/// "Cancel All"
|
||||
/// </summary>
|
||||
public static LocalisableString CancelAll => new TranslatableString(getKey(@"cancel_all"), @"Cancel All");
|
||||
|
||||
/// <summary>
|
||||
/// "Your battery level is low! Charge your device to prevent interruptions during gameplay."
|
||||
/// </summary>
|
||||
|
@ -42,8 +42,8 @@ namespace osu.Game.Overlays
|
||||
IEnumerable<Notification> AllNotifications { get; }
|
||||
|
||||
/// <summary>
|
||||
/// All ongoing operations (ie. any <see cref="ProgressNotification"/> not in a completed state).
|
||||
/// All ongoing operations (ie. any <see cref="ProgressNotification"/> not in a completed or cancelled state).
|
||||
/// </summary>
|
||||
public IEnumerable<ProgressNotification> OngoingOperations => AllNotifications.OfType<ProgressNotification>().Where(p => p.State != ProgressNotificationState.Completed && p.State != ProgressNotificationState.Cancelled);
|
||||
public IEnumerable<ProgressNotification> OngoingOperations => AllNotifications.OfType<ProgressNotification>().Where(p => p.Ongoing);
|
||||
}
|
||||
}
|
||||
|
@ -108,8 +108,8 @@ namespace osu.Game.Overlays
|
||||
RelativeSizeAxes = Axes.X,
|
||||
Children = new[]
|
||||
{
|
||||
new NotificationSection(AccountsStrings.NotificationsTitle, new[] { typeof(SimpleNotification) }, NotificationsStrings.ClearAll),
|
||||
new NotificationSection(NotificationsStrings.RunningTasks, new[] { typeof(ProgressNotification) }, NotificationsStrings.CancelAll),
|
||||
new NotificationSection(AccountsStrings.NotificationsTitle, new[] { typeof(SimpleNotification) }),
|
||||
new NotificationSection(NotificationsStrings.RunningTasks, new[] { typeof(ProgressNotification) }),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -13,6 +13,7 @@ using osu.Framework.Localisation;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Graphics.Containers;
|
||||
using osu.Game.Graphics.Sprites;
|
||||
using osu.Game.Localisation;
|
||||
using osuTK;
|
||||
|
||||
namespace osu.Game.Overlays.Notifications
|
||||
@ -38,15 +39,12 @@ namespace osu.Game.Overlays.Notifications
|
||||
|
||||
public IEnumerable<Type> AcceptedNotificationTypes { get; }
|
||||
|
||||
private readonly LocalisableString clearButtonText;
|
||||
|
||||
private readonly LocalisableString titleText;
|
||||
|
||||
public NotificationSection(LocalisableString title, IEnumerable<Type> acceptedNotificationTypes, LocalisableString clearButtonText)
|
||||
public NotificationSection(LocalisableString title, IEnumerable<Type> acceptedNotificationTypes)
|
||||
{
|
||||
AcceptedNotificationTypes = acceptedNotificationTypes.ToArray();
|
||||
|
||||
this.clearButtonText = clearButtonText.ToUpper();
|
||||
titleText = title;
|
||||
}
|
||||
|
||||
@ -75,7 +73,7 @@ namespace osu.Game.Overlays.Notifications
|
||||
{
|
||||
new ClearAllButton
|
||||
{
|
||||
Text = clearButtonText,
|
||||
Text = NotificationsStrings.ClearAll.ToUpper(),
|
||||
Anchor = Anchor.TopRight,
|
||||
Origin = Anchor.TopRight,
|
||||
Action = clearAll
|
||||
@ -115,10 +113,11 @@ namespace osu.Game.Overlays.Notifications
|
||||
});
|
||||
}
|
||||
|
||||
private void clearAll()
|
||||
private void clearAll() => notifications.Children.ForEach(c =>
|
||||
{
|
||||
notifications.Children.ForEach(c => c.Close(true));
|
||||
}
|
||||
if (c is not ProgressNotification p || !p.Ongoing)
|
||||
c.Close(true);
|
||||
});
|
||||
|
||||
protected override void Update()
|
||||
{
|
||||
|
@ -27,6 +27,11 @@ namespace osu.Game.Overlays.Notifications
|
||||
|
||||
public Func<bool>? CancelRequested { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Whether the operation represented by the <see cref="ProgressNotification"/> is still ongoing.
|
||||
/// </summary>
|
||||
public bool Ongoing => State != ProgressNotificationState.Completed && State != ProgressNotificationState.Cancelled;
|
||||
|
||||
protected override bool AllowFlingDismiss => false;
|
||||
|
||||
public override string PopOutSampleName => State is ProgressNotificationState.Cancelled ? base.PopOutSampleName : "";
|
||||
|
Loading…
Reference in New Issue
Block a user