Add playlist count pill

This commit is contained in:
smoogipoo 2021-07-12 15:11:53 +09:00
parent 185e36bf97
commit a8cbffa57e
2 changed files with 59 additions and 2 deletions

View File

@ -0,0 +1,39 @@
// 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.
using System.Collections.Specialized;
using osu.Framework.Graphics;
using osu.Game.Graphics;
using osu.Game.Graphics.Containers;
namespace osu.Game.Screens.OnlinePlay.Components
{
/// <summary>
/// A pill that displays the playlist item count.
/// </summary>
public class PlaylistCountPill : RoomInfoPill
{
private OsuTextFlowContainer count;
protected override void LoadComplete()
{
base.LoadComplete();
Playlist.BindCollectionChanged(updateCount, true);
}
private void updateCount(object sender, NotifyCollectionChangedEventArgs e)
{
count.Clear();
count.AddText(Playlist.Count.ToString(), s => s.Font = s.Font.With(weight: FontWeight.Bold));
count.AddText(" Maps");
}
protected override Drawable CreateContent() => count = new OsuTextFlowContainer(s => s.Font = OsuFont.GetFont(size: 12))
{
AutoSizeAxes = Axes.Both,
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
};
}
}

View File

@ -168,7 +168,25 @@ namespace osu.Game.Screens.OnlinePlay.Lounge.Components
},
Children = new Drawable[]
{
new RoomStatusInfo(),
new FillFlowContainer
{
AutoSizeAxes = Axes.Both,
Direction = FillDirection.Horizontal,
Spacing = new Vector2(4),
Children = new Drawable[]
{
new RoomStatusPill
{
Anchor = Anchor.CentreLeft,
Origin = Anchor.CentreLeft
},
new EndDateInfo
{
Anchor = Anchor.CentreLeft,
Origin = Anchor.CentreLeft
},
}
},
new RoomName
{
Anchor = Anchor.CentreLeft,
@ -184,7 +202,7 @@ namespace osu.Game.Screens.OnlinePlay.Lounge.Components
Spacing = new Vector2(4),
Children = new Drawable[]
{
new PlaylistInfoPill
new PlaylistCountPill
{
Anchor = Anchor.CentreLeft,
Origin = Anchor.CentreLeft,