1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-13 15:27:30 +08:00

Add back "clear all" button for progress notifications but only clear cancelled

This commit is contained in:
Dean Herbert 2023-07-07 13:10:49 +09:00
parent 070b3883ce
commit d93548f4ea
4 changed files with 19 additions and 18 deletions

View File

@ -44,6 +44,6 @@ namespace osu.Game.Overlays
/// <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 && p.State != ProgressNotificationState.Cancelled);
public IEnumerable<ProgressNotification> OngoingOperations => AllNotifications.OfType<ProgressNotification>().Where(p => !p.CompletedOrCancelled);
}
}

View File

@ -108,8 +108,8 @@ namespace osu.Game.Overlays
RelativeSizeAxes = Axes.X,
Children = new[]
{
new NotificationSection(AccountsStrings.NotificationsTitle, new[] { typeof(SimpleNotification) }, true),
new NotificationSection(NotificationsStrings.RunningTasks, new[] { typeof(ProgressNotification) }, false),
new NotificationSection(AccountsStrings.NotificationsTitle, new[] { typeof(SimpleNotification) }),
new NotificationSection(NotificationsStrings.RunningTasks, new[] { typeof(ProgressNotification) }),
}
}
}

View File

@ -41,14 +41,11 @@ namespace osu.Game.Overlays.Notifications
private readonly LocalisableString titleText;
private readonly bool allowClear;
public NotificationSection(LocalisableString title, IEnumerable<Type> acceptedNotificationTypes, bool allowClear)
public NotificationSection(LocalisableString title, IEnumerable<Type> acceptedNotificationTypes)
{
AcceptedNotificationTypes = acceptedNotificationTypes.ToArray();
titleText = title;
this.allowClear = allowClear;
}
[BackgroundDependencyLoader]
@ -72,17 +69,15 @@ namespace osu.Game.Overlays.Notifications
{
RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y,
Children = new[]
Children = new Drawable[]
{
allowClear
? new ClearAllButton
{
Text = NotificationsStrings.ClearAll,
Anchor = Anchor.TopRight,
Origin = Anchor.TopRight,
Action = clearAll
}
: Empty(),
new ClearAllButton
{
Text = NotificationsStrings.ClearAll,
Anchor = Anchor.TopRight,
Origin = Anchor.TopRight,
Action = clearAll
},
new FillFlowContainer
{
Margin = new MarginPadding
@ -118,7 +113,11 @@ namespace osu.Game.Overlays.Notifications
});
}
private void clearAll() => notifications.Children.ForEach(c => c.Close(true));
private void clearAll() => notifications.Children.ForEach(c =>
{
if (c is not ProgressNotification p || p.CompletedOrCancelled)
c.Close(true);
});
protected override void Update()
{

View File

@ -25,6 +25,8 @@ namespace osu.Game.Overlays.Notifications
public Func<bool>? CancelRequested { get; set; }
public bool CompletedOrCancelled => State == ProgressNotificationState.Completed || State == ProgressNotificationState.Cancelled;
protected override bool AllowFlingDismiss => false;
/// <summary>