mirror of
https://github.com/ppy/osu.git
synced 2025-02-15 04:12:57 +08: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}"; };
|
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]
|
[Test]
|
||||||
public void TestForwardWithFlingRight()
|
public void TestForwardWithFlingRight()
|
||||||
{
|
{
|
||||||
@ -411,32 +437,6 @@ namespace osu.Game.Tests.Visual.UserInterface
|
|||||||
AddUntilStep("wait for update applied", () => applyUpdate);
|
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]
|
[Test]
|
||||||
public void TestImportantWhileClosed()
|
public void TestImportantWhileClosed()
|
||||||
{
|
{
|
||||||
|
@ -29,11 +29,6 @@ namespace osu.Game.Localisation
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public static LocalisableString ClearAll => new TranslatableString(getKey(@"clear_all"), @"Clear All");
|
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>
|
/// <summary>
|
||||||
/// "Your battery level is low! Charge your device to prevent interruptions during gameplay."
|
/// "Your battery level is low! Charge your device to prevent interruptions during gameplay."
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -42,8 +42,8 @@ namespace osu.Game.Overlays
|
|||||||
IEnumerable<Notification> AllNotifications { get; }
|
IEnumerable<Notification> AllNotifications { get; }
|
||||||
|
|
||||||
/// <summary>
|
/// <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>
|
/// </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,
|
RelativeSizeAxes = Axes.X,
|
||||||
Children = new[]
|
Children = new[]
|
||||||
{
|
{
|
||||||
new NotificationSection(AccountsStrings.NotificationsTitle, new[] { typeof(SimpleNotification) }, NotificationsStrings.ClearAll),
|
new NotificationSection(AccountsStrings.NotificationsTitle, new[] { typeof(SimpleNotification) }),
|
||||||
new NotificationSection(NotificationsStrings.RunningTasks, new[] { typeof(ProgressNotification) }, NotificationsStrings.CancelAll),
|
new NotificationSection(NotificationsStrings.RunningTasks, new[] { typeof(ProgressNotification) }),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -13,6 +13,7 @@ using osu.Framework.Localisation;
|
|||||||
using osu.Game.Graphics;
|
using osu.Game.Graphics;
|
||||||
using osu.Game.Graphics.Containers;
|
using osu.Game.Graphics.Containers;
|
||||||
using osu.Game.Graphics.Sprites;
|
using osu.Game.Graphics.Sprites;
|
||||||
|
using osu.Game.Localisation;
|
||||||
using osuTK;
|
using osuTK;
|
||||||
|
|
||||||
namespace osu.Game.Overlays.Notifications
|
namespace osu.Game.Overlays.Notifications
|
||||||
@ -38,15 +39,12 @@ namespace osu.Game.Overlays.Notifications
|
|||||||
|
|
||||||
public IEnumerable<Type> AcceptedNotificationTypes { get; }
|
public IEnumerable<Type> AcceptedNotificationTypes { get; }
|
||||||
|
|
||||||
private readonly LocalisableString clearButtonText;
|
|
||||||
|
|
||||||
private readonly LocalisableString titleText;
|
private readonly LocalisableString titleText;
|
||||||
|
|
||||||
public NotificationSection(LocalisableString title, IEnumerable<Type> acceptedNotificationTypes, LocalisableString clearButtonText)
|
public NotificationSection(LocalisableString title, IEnumerable<Type> acceptedNotificationTypes)
|
||||||
{
|
{
|
||||||
AcceptedNotificationTypes = acceptedNotificationTypes.ToArray();
|
AcceptedNotificationTypes = acceptedNotificationTypes.ToArray();
|
||||||
|
|
||||||
this.clearButtonText = clearButtonText.ToUpper();
|
|
||||||
titleText = title;
|
titleText = title;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -75,7 +73,7 @@ namespace osu.Game.Overlays.Notifications
|
|||||||
{
|
{
|
||||||
new ClearAllButton
|
new ClearAllButton
|
||||||
{
|
{
|
||||||
Text = clearButtonText,
|
Text = NotificationsStrings.ClearAll.ToUpper(),
|
||||||
Anchor = Anchor.TopRight,
|
Anchor = Anchor.TopRight,
|
||||||
Origin = Anchor.TopRight,
|
Origin = Anchor.TopRight,
|
||||||
Action = clearAll
|
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()
|
protected override void Update()
|
||||||
{
|
{
|
||||||
|
@ -27,6 +27,11 @@ namespace osu.Game.Overlays.Notifications
|
|||||||
|
|
||||||
public Func<bool>? CancelRequested { get; set; }
|
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;
|
protected override bool AllowFlingDismiss => false;
|
||||||
|
|
||||||
public override string PopOutSampleName => State is ProgressNotificationState.Cancelled ? base.PopOutSampleName : "";
|
public override string PopOutSampleName => State is ProgressNotificationState.Cancelled ? base.PopOutSampleName : "";
|
||||||
|
Loading…
Reference in New Issue
Block a user