diff --git a/osu.Game/Online/FriendPresenceNotifier.cs b/osu.Game/Online/FriendPresenceNotifier.cs index bc2bf344b0..a73c705d76 100644 --- a/osu.Game/Online/FriendPresenceNotifier.cs +++ b/osu.Game/Online/FriendPresenceNotifier.cs @@ -31,15 +31,6 @@ namespace osu.Game.Online [Resolved] private MetadataClient metadataClient { get; set; } = null!; - [Resolved] - private ChannelManager channelManager { get; set; } = null!; - - [Resolved] - private ChatOverlay chatOverlay { get; set; } = null!; - - [Resolved] - private OsuColour colours { get; set; } = null!; - [Resolved] private OsuConfigManager config { get; set; } = null!; @@ -165,26 +156,7 @@ namespace osu.Game.Online return; } - APIUser? singleUser = onlineAlertQueue.Count == 1 ? onlineAlertQueue.Single() : null; - - notifications.Post(new SimpleNotification - { - Transient = true, - IsImportant = false, - Icon = FontAwesome.Solid.User, - Text = $"Online: {string.Join(@", ", onlineAlertQueue.Select(u => u.Username))}", - IconColour = colours.GrayD, - Activated = () => - { - if (singleUser != null) - { - channelManager.OpenPrivateChannel(singleUser); - chatOverlay.Show(); - } - - return true; - } - }); + notifications.Post(new FriendOnlineNotification(onlineAlertQueue.ToArray())); onlineAlertQueue.Clear(); lastOnlineAlertTime = null; @@ -204,17 +176,60 @@ namespace osu.Game.Online return; } - notifications.Post(new SimpleNotification - { - Transient = true, - IsImportant = false, - Icon = FontAwesome.Solid.UserSlash, - Text = $"Offline: {string.Join(@", ", offlineAlertQueue.Select(u => u.Username))}", - IconColour = colours.Gray3 - }); + notifications.Post(new FriendOfflineNotification(offlineAlertQueue.ToArray())); offlineAlertQueue.Clear(); lastOfflineAlertTime = null; } + + public partial class FriendOnlineNotification : SimpleNotification + { + private readonly ICollection users; + + public FriendOnlineNotification(ICollection users) + { + this.users = users; + Transient = true; + IsImportant = false; + Icon = FontAwesome.Solid.User; + Text = $"Online: {string.Join(@", ", users.Select(u => u.Username))}"; + } + + [BackgroundDependencyLoader] + private void load(OsuColour colours, ChannelManager channelManager, ChatOverlay chatOverlay) + { + IconColour = colours.GrayD; + Activated = () => + { + APIUser? singleUser = users.Count == 1 ? users.Single() : null; + + if (singleUser != null) + { + channelManager.OpenPrivateChannel(singleUser); + chatOverlay.Show(); + } + + return true; + }; + } + + public override string PopInSampleName => "UI/notification-friend-online"; + } + + private partial class FriendOfflineNotification : SimpleNotification + { + public FriendOfflineNotification(ICollection users) + { + Transient = true; + IsImportant = false; + Icon = FontAwesome.Solid.UserSlash; + Text = $"Offline: {string.Join(@", ", users.Select(u => u.Username))}"; + } + + [BackgroundDependencyLoader] + private void load(OsuColour colours) => IconColour = colours.Gray3; + + public override string PopInSampleName => "UI/notification-friend-offline"; + } } } diff --git a/osu.Game/osu.Game.csproj b/osu.Game/osu.Game.csproj index 53b1a3a4c3..fb01a9d0e9 100644 --- a/osu.Game/osu.Game.csproj +++ b/osu.Game/osu.Game.csproj @@ -36,7 +36,7 @@ - +