1
0
mirror of https://github.com/ppy/osu.git synced 2024-09-23 10:07:25 +08:00
osu-lazer/osu.Game/Screens/OnlinePlay/Lounge/Components/PlaylistCountPill.cs

59 lines
1.8 KiB
C#
Raw Normal View History

2021-07-12 14:11:53 +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.
2021-08-05 19:56:14 +08:00
using Humanizer;
2021-07-12 14:18:38 +08:00
using osu.Framework.Allocation;
using osu.Framework.Bindables;
using osu.Framework.Extensions.LocalisationExtensions;
2021-07-12 14:11:53 +08:00
using osu.Framework.Graphics;
using osu.Game.Graphics;
using osu.Game.Graphics.Containers;
using osu.Game.Online.Rooms;
2021-07-12 14:11:53 +08:00
2021-07-13 15:02:18 +08:00
namespace osu.Game.Screens.OnlinePlay.Lounge.Components
2021-07-12 14:11:53 +08:00
{
/// <summary>
/// A pill that displays the playlist item count.
/// </summary>
2021-07-12 14:18:38 +08:00
public class PlaylistCountPill : OnlinePlayComposite
2021-07-12 14:11:53 +08:00
{
private OsuTextFlowContainer count;
2021-07-12 14:18:38 +08:00
public PlaylistCountPill()
{
AutoSizeAxes = Axes.Both;
}
[BackgroundDependencyLoader]
private void load()
{
InternalChild = new PillContainer
{
Child = count = new OsuTextFlowContainer(s => s.Font = OsuFont.GetFont(size: 12))
{
AutoSizeAxes = Axes.Both,
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
}
};
}
2021-07-12 14:11:53 +08:00
protected override void LoadComplete()
{
base.LoadComplete();
PlaylistItemStats.BindValueChanged(updateCount, true);
2021-07-12 14:11:53 +08:00
}
private void updateCount(ValueChangedEvent<Room.RoomPlaylistItemStats> valueChangedEvent)
2021-07-12 14:11:53 +08:00
{
int activeItems = valueChangedEvent.NewValue.CountActive;
2021-07-12 14:11:53 +08:00
count.Clear();
count.AddText(activeItems.ToLocalisableString(), s => s.Font = s.Font.With(weight: FontWeight.Bold));
2021-08-05 19:56:14 +08:00
count.AddText(" ");
count.AddText("Beatmap".ToQuantity(activeItems, ShowQuantityAs.None));
2021-07-12 14:11:53 +08:00
}
}
}