2020-03-03 14:37:01 +00:00
|
|
|
|
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
|
|
|
|
// See the LICENCE file in the repository root for full licence text.
|
|
|
|
|
|
2020-03-03 15:08:51 +00:00
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
2021-11-04 09:02:44 +00:00
|
|
|
|
using osu.Game.Online.API.Requests.Responses;
|
2020-03-03 15:08:51 +00:00
|
|
|
|
|
2020-03-16 06:42:21 +00:00
|
|
|
|
namespace osu.Game.Overlays.Dashboard.Friends
|
2020-03-03 14:37:01 +00:00
|
|
|
|
{
|
2020-03-23 01:47:27 +00:00
|
|
|
|
public class FriendOnlineStreamControl : OverlayStreamControl<FriendStream>
|
2020-03-03 14:37:01 +00:00
|
|
|
|
{
|
2020-03-23 01:47:27 +00:00
|
|
|
|
protected override OverlayStreamItem<FriendStream> CreateStreamItem(FriendStream value) => new FriendsOnlineStatusItem(value);
|
2020-03-03 15:08:51 +00:00
|
|
|
|
|
2021-11-04 09:02:44 +00:00
|
|
|
|
public void Populate(List<APIUser> users)
|
2020-03-03 15:08:51 +00:00
|
|
|
|
{
|
2020-03-16 06:42:21 +00:00
|
|
|
|
Clear();
|
2020-03-03 15:08:51 +00:00
|
|
|
|
|
2021-10-27 04:04:41 +00:00
|
|
|
|
int userCount = users.Count;
|
|
|
|
|
int onlineUsersCount = users.Count(user => user.IsOnline);
|
2020-03-22 17:13:54 +00:00
|
|
|
|
|
2020-03-23 01:47:27 +00:00
|
|
|
|
AddItem(new FriendStream(OnlineStatus.All, userCount));
|
|
|
|
|
AddItem(new FriendStream(OnlineStatus.Online, onlineUsersCount));
|
|
|
|
|
AddItem(new FriendStream(OnlineStatus.Offline, userCount - onlineUsersCount));
|
2020-03-03 15:08:51 +00:00
|
|
|
|
|
|
|
|
|
Current.Value = Items.FirstOrDefault();
|
|
|
|
|
}
|
2020-03-03 14:37:01 +00:00
|
|
|
|
}
|
|
|
|
|
}
|