1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-29 02:12:57 +08:00

Add fallback handling for item count to support different request types

This commit is contained in:
Dean Herbert 2022-02-21 19:37:36 +09:00
parent b5348e0407
commit ffa5291b74

View File

@ -3,12 +3,10 @@
using Humanizer; using Humanizer;
using osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Framework.Bindables;
using osu.Framework.Extensions.LocalisationExtensions; using osu.Framework.Extensions.LocalisationExtensions;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Game.Graphics; using osu.Game.Graphics;
using osu.Game.Graphics.Containers; using osu.Game.Graphics.Containers;
using osu.Game.Online.Rooms;
namespace osu.Game.Screens.OnlinePlay.Lounge.Components namespace osu.Game.Screens.OnlinePlay.Lounge.Components
{ {
@ -42,12 +40,13 @@ namespace osu.Game.Screens.OnlinePlay.Lounge.Components
{ {
base.LoadComplete(); base.LoadComplete();
PlaylistItemStats.BindValueChanged(updateCount, true); PlaylistItemStats.BindValueChanged(_ => updateCount(), true);
Playlist.BindCollectionChanged((_, __) => updateCount(), true);
} }
private void updateCount(ValueChangedEvent<Room.RoomPlaylistItemStats> valueChangedEvent) private void updateCount()
{ {
int activeItems = valueChangedEvent.NewValue.CountActive; int activeItems = PlaylistItemStats.Value?.CountActive ?? Playlist.Count;
count.Clear(); count.Clear();
count.AddText(activeItems.ToLocalisableString(), s => s.Font = s.Font.With(weight: FontWeight.Bold)); count.AddText(activeItems.ToLocalisableString(), s => s.Font = s.Font.With(weight: FontWeight.Bold));