2021-07-12 15:15:26 +08: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.
|
|
|
|
|
2022-06-17 15:37:17 +08:00
|
|
|
#nullable disable
|
|
|
|
|
2021-07-12 15:15:26 +08:00
|
|
|
using System.Linq;
|
|
|
|
using osu.Framework.Allocation;
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
using osu.Framework.Graphics.Containers;
|
|
|
|
using osu.Framework.Graphics.Sprites;
|
|
|
|
using osu.Game.Graphics;
|
|
|
|
using osu.Game.Graphics.Containers;
|
|
|
|
using osu.Game.Screens.OnlinePlay.Multiplayer;
|
|
|
|
using osuTK;
|
|
|
|
|
2021-07-13 15:02:18 +08:00
|
|
|
namespace osu.Game.Screens.OnlinePlay.Lounge.Components
|
2021-07-12 15:15:26 +08:00
|
|
|
{
|
2022-11-24 13:32:20 +08:00
|
|
|
public partial class RankRangePill : MultiplayerRoomComposite
|
2021-07-12 15:15:26 +08:00
|
|
|
{
|
|
|
|
private OsuTextFlowContainer rankFlow;
|
|
|
|
|
|
|
|
public RankRangePill()
|
|
|
|
{
|
|
|
|
AutoSizeAxes = Axes.Both;
|
|
|
|
}
|
|
|
|
|
|
|
|
[BackgroundDependencyLoader]
|
|
|
|
private void load()
|
|
|
|
{
|
|
|
|
InternalChild = new PillContainer
|
|
|
|
{
|
|
|
|
Child = new FillFlowContainer
|
|
|
|
{
|
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
Origin = Anchor.Centre,
|
|
|
|
AutoSizeAxes = Axes.Both,
|
|
|
|
Spacing = new Vector2(4),
|
|
|
|
Children = new Drawable[]
|
|
|
|
{
|
|
|
|
new SpriteIcon
|
|
|
|
{
|
|
|
|
Anchor = Anchor.CentreLeft,
|
|
|
|
Origin = Anchor.CentreLeft,
|
|
|
|
Size = new Vector2(8),
|
|
|
|
Icon = FontAwesome.Solid.User
|
|
|
|
},
|
|
|
|
rankFlow = new OsuTextFlowContainer(s => s.Font = OsuFont.GetFont(size: 12))
|
|
|
|
{
|
|
|
|
Anchor = Anchor.CentreLeft,
|
|
|
|
Origin = Anchor.CentreLeft,
|
|
|
|
AutoSizeAxes = Axes.Both,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
protected override void OnRoomUpdated()
|
|
|
|
{
|
|
|
|
base.OnRoomUpdated();
|
|
|
|
|
|
|
|
rankFlow.Clear();
|
|
|
|
|
|
|
|
if (Room == null || Room.Users.All(u => u.User == null))
|
|
|
|
{
|
|
|
|
rankFlow.AddText("-");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2021-08-05 20:40:09 +08:00
|
|
|
int minRank = Room.Users.Select(u => u.User?.Statistics.GlobalRank ?? 0).DefaultIfEmpty(0).Min();
|
|
|
|
int maxRank = Room.Users.Select(u => u.User?.Statistics.GlobalRank ?? 0).DefaultIfEmpty(0).Max();
|
|
|
|
|
2021-07-12 15:15:26 +08:00
|
|
|
rankFlow.AddText("#");
|
2021-08-05 20:40:09 +08:00
|
|
|
rankFlow.AddText(minRank.ToString("#,0"), s => s.Font = s.Font.With(weight: FontWeight.Bold));
|
2021-07-12 15:15:26 +08:00
|
|
|
|
|
|
|
rankFlow.AddText(" - ");
|
|
|
|
|
|
|
|
rankFlow.AddText("#");
|
2021-08-05 20:40:09 +08:00
|
|
|
rankFlow.AddText(maxRank.ToString("#,0"), s => s.Font = s.Font.With(weight: FontWeight.Bold));
|
2021-07-12 15:15:26 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|