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;
|
|
|
|
|
using osu.Game.Users;
|
|
|
|
|
|
2020-03-03 14:37:01 +00:00
|
|
|
|
namespace osu.Game.Overlays.Home.Friends
|
|
|
|
|
{
|
2020-03-04 20:08:58 +00:00
|
|
|
|
public class FriendsOnlineStatusControl : OverlayStreamControl<FriendsBundle>
|
2020-03-03 14:37:01 +00:00
|
|
|
|
{
|
2020-03-04 20:08:58 +00:00
|
|
|
|
protected override OverlayStreamItem<FriendsBundle> CreateStreamItem(FriendsBundle value) => new FriendsOnlineStatusItem(value);
|
2020-03-03 15:08:51 +00:00
|
|
|
|
|
|
|
|
|
public void Populate(List<User> users)
|
|
|
|
|
{
|
|
|
|
|
var userCount = users.Count;
|
|
|
|
|
var onlineUsersCount = users.Count(user => user.IsOnline);
|
|
|
|
|
|
|
|
|
|
AddItem(new FriendsBundle(FriendsOnlineStatus.All, userCount));
|
|
|
|
|
AddItem(new FriendsBundle(FriendsOnlineStatus.Online, onlineUsersCount));
|
|
|
|
|
AddItem(new FriendsBundle(FriendsOnlineStatus.Offline, userCount - onlineUsersCount));
|
|
|
|
|
|
|
|
|
|
Current.Value = Items.FirstOrDefault();
|
|
|
|
|
}
|
2020-03-03 14:37:01 +00:00
|
|
|
|
}
|
|
|
|
|
}
|