mirror of
https://github.com/ppy/osu.git
synced 2024-12-14 10:52:53 +08:00
Use less dodgy method of specifying allowable notification types
This commit is contained in:
parent
79cec7707d
commit
e04a57d67f
@ -114,7 +114,7 @@ namespace osu.Game.Overlays
|
|||||||
Children = new[]
|
Children = new[]
|
||||||
{
|
{
|
||||||
// The main section adds as a catch-all for notifications which don't group into other sections.
|
// The main section adds as a catch-all for notifications which don't group into other sections.
|
||||||
new NotificationSection(AccountsStrings.NotificationsTitle, new[] { typeof(Notification) }),
|
new NotificationSection(AccountsStrings.NotificationsTitle),
|
||||||
new NotificationSection(NotificationsStrings.RunningTasks, new[] { typeof(ProgressNotification) }),
|
new NotificationSection(NotificationsStrings.RunningTasks, new[] { typeof(ProgressNotification) }),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -206,7 +206,8 @@ namespace osu.Game.Overlays
|
|||||||
var ourType = notification.GetType();
|
var ourType = notification.GetType();
|
||||||
int depth = notification.DisplayOnTop ? -runningDepth : runningDepth;
|
int depth = notification.DisplayOnTop ? -runningDepth : runningDepth;
|
||||||
|
|
||||||
var section = sections.Children.Last(s => s.AcceptedNotificationTypes.Any(accept => accept.IsAssignableFrom(ourType)));
|
var section = sections.Children.FirstOrDefault(s => s.AcceptedNotificationTypes?.Any(accept => accept.IsAssignableFrom(ourType)) == true)
|
||||||
|
?? sections.First();
|
||||||
|
|
||||||
section.Add(notification, depth);
|
section.Add(notification, depth);
|
||||||
|
|
||||||
|
@ -37,13 +37,17 @@ namespace osu.Game.Overlays.Notifications
|
|||||||
notifications.Insert((int)position, notification);
|
notifications.Insert((int)position, notification);
|
||||||
}
|
}
|
||||||
|
|
||||||
public IEnumerable<Type> AcceptedNotificationTypes { get; }
|
/// <summary>
|
||||||
|
/// Enumerable of notification types accepted in this section.
|
||||||
|
/// If <see langword="null"/>, the section accepts any and all notifications.
|
||||||
|
/// </summary>
|
||||||
|
public IEnumerable<Type>? AcceptedNotificationTypes { get; }
|
||||||
|
|
||||||
private readonly LocalisableString titleText;
|
private readonly LocalisableString titleText;
|
||||||
|
|
||||||
public NotificationSection(LocalisableString title, IEnumerable<Type> acceptedNotificationTypes)
|
public NotificationSection(LocalisableString title, IEnumerable<Type>? acceptedNotificationTypes = null)
|
||||||
{
|
{
|
||||||
AcceptedNotificationTypes = acceptedNotificationTypes.ToArray();
|
AcceptedNotificationTypes = acceptedNotificationTypes?.ToArray();
|
||||||
|
|
||||||
titleText = title;
|
titleText = title;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user