1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-12 06:47:25 +08:00
osu-lazer/osu.Game/Overlays/Dashboard/Friends/FriendsOnlineStatusControl.cs

29 lines
1.0 KiB
C#
Raw Normal View History

// 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 23:08:51 +08:00
using System.Collections.Generic;
using System.Linq;
2020-03-17 13:51:54 +08:00
using osu.Game.Users;
2020-03-03 23:08:51 +08:00
2020-03-16 14:42:21 +08:00
namespace osu.Game.Overlays.Dashboard.Friends
{
2020-03-05 04:08:58 +08:00
public class FriendsOnlineStatusControl : OverlayStreamControl<FriendsBundle>
{
2020-03-05 04:08:58 +08:00
protected override OverlayStreamItem<FriendsBundle> CreateStreamItem(FriendsBundle value) => new FriendsOnlineStatusItem(value);
2020-03-03 23:08:51 +08:00
2020-03-17 13:51:54 +08:00
public void Populate(List<User> users)
2020-03-03 23:08:51 +08:00
{
2020-03-16 14:42:21 +08:00
Clear();
2020-03-03 23:08:51 +08:00
2020-03-23 01:13:54 +08:00
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));
2020-03-03 23:08:51 +08:00
Current.Value = Items.FirstOrDefault();
}
}
}