From a1fa914c66fdb41209bcfeb019381296ee5fb07d Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Wed, 26 Dec 2018 21:58:14 +0900 Subject: [PATCH] Participants --- osu.Game/Online/Multiplayer/Room.cs | 4 ++++ osu.Game/Screens/Multi/Components/ParticipantCount.cs | 6 ++++-- osu.Game/Screens/Multi/Lounge/Components/DrawableRoom.cs | 1 + .../Screens/Multi/Lounge/Components/ParticipantInfo.cs | 7 ++++++- osu.Game/Screens/Multi/Lounge/Components/RoomInspector.cs | 7 +++++-- osu.Game/Screens/Multi/Match/Components/Participants.cs | 6 ++++-- osu.Game/Screens/Multi/RoomBindings.cs | 3 +++ 7 files changed, 27 insertions(+), 7 deletions(-) diff --git a/osu.Game/Online/Multiplayer/Room.cs b/osu.Game/Online/Multiplayer/Room.cs index b17d08320c..d7898297c9 100644 --- a/osu.Game/Online/Multiplayer/Room.cs +++ b/osu.Game/Online/Multiplayer/Room.cs @@ -49,6 +49,9 @@ namespace osu.Game.Online.Multiplayer [JsonIgnore] public Bindable> Participants { get; private set; } = new Bindable>(Enumerable.Empty()); + [JsonProperty("participant_count")] + public Bindable ParticipantCount { get; private set; } = new Bindable(); + [JsonProperty("duration")] private int duration { @@ -85,6 +88,7 @@ namespace osu.Game.Online.Multiplayer Type.Value = other.Type; MaxParticipants.Value = other.MaxParticipants; + ParticipantCount.Value = other.ParticipantCount.Value; Participants.Value = other.Participants.Value.ToArray(); EndDate.Value = other.EndDate; diff --git a/osu.Game/Screens/Multi/Components/ParticipantCount.cs b/osu.Game/Screens/Multi/Components/ParticipantCount.cs index 8665678562..fc19039872 100644 --- a/osu.Game/Screens/Multi/Components/ParticipantCount.cs +++ b/osu.Game/Screens/Multi/Components/ParticipantCount.cs @@ -11,7 +11,7 @@ using osu.Game.Users; namespace osu.Game.Screens.Multi.Components { - public class ParticipantCount : CompositeDrawable + public class ParticipantCountDisplay : CompositeDrawable { private const float text_size = 30; private const float transition_duration = 100; @@ -19,9 +19,10 @@ namespace osu.Game.Screens.Multi.Components private readonly OsuSpriteText slash, maxText; public readonly IBindable> Participants = new Bindable>(); + public readonly IBindable ParticipantCount = new Bindable(); public readonly IBindable MaxParticipants = new Bindable(); - public ParticipantCount() + public ParticipantCountDisplay() { AutoSizeAxes = Axes.Both; @@ -55,6 +56,7 @@ namespace osu.Game.Screens.Multi.Components Participants.BindValueChanged(v => count.Text = v.Count().ToString()); MaxParticipants.BindValueChanged(_ => updateMax(), true); + ParticipantCount.BindValueChanged(v => count.Text = v.ToString("#,0")); } private void updateMax() diff --git a/osu.Game/Screens/Multi/Lounge/Components/DrawableRoom.cs b/osu.Game/Screens/Multi/Lounge/Components/DrawableRoom.cs index d62b628389..0540eed1aa 100644 --- a/osu.Game/Screens/Multi/Lounge/Components/DrawableRoom.cs +++ b/osu.Game/Screens/Multi/Lounge/Components/DrawableRoom.cs @@ -217,6 +217,7 @@ namespace osu.Game.Screens.Multi.Lounge.Components modeTypeInfo.Type.BindTo(bindings.Type); participantInfo.Host.BindTo(bindings.Host); participantInfo.Participants.BindTo(bindings.Participants); + participantInfo.ParticipantCount.BindTo(bindings.ParticipantCount); bindings.Name.BindValueChanged(n => name.Text = n, true); bindings.EndDate.BindValueChanged(d => endDate.Date = d, true); diff --git a/osu.Game/Screens/Multi/Lounge/Components/ParticipantInfo.cs b/osu.Game/Screens/Multi/Lounge/Components/ParticipantInfo.cs index 1bc6d5aec0..34fc7fe886 100644 --- a/osu.Game/Screens/Multi/Lounge/Components/ParticipantInfo.cs +++ b/osu.Game/Screens/Multi/Lounge/Components/ParticipantInfo.cs @@ -2,6 +2,7 @@ // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE using System.Collections.Generic; +using Humanizer; using osu.Framework.Allocation; using osu.Framework.Configuration; using osu.Framework.Graphics; @@ -21,9 +22,11 @@ namespace osu.Game.Screens.Multi.Lounge.Components public readonly IBindable Host = new Bindable(); public readonly IBindable> Participants = new Bindable>(); + public readonly IBindable ParticipantCount = new Bindable(); public ParticipantInfo() { + OsuSpriteText summary; RelativeSizeAxes = Axes.X; Height = 15f; @@ -78,7 +81,7 @@ namespace osu.Game.Screens.Multi.Lounge.Components Direction = FillDirection.Horizontal, Children = new[] { - new OsuSpriteText + summary = new OsuSpriteText { Text = "0 participants", TextSize = 14, @@ -96,6 +99,8 @@ namespace osu.Game.Screens.Multi.Lounge.Components flagContainer.Child = new DrawableFlag(v.Country) { RelativeSizeAxes = Axes.Both }; }); + ParticipantCount.BindValueChanged(v => summary.Text = $"{v:#,0}{" participant".Pluralize(v == 1)}"); + /*Participants.BindValueChanged(v => { var ranks = v.Select(u => u.Statistics.Ranks.Global); diff --git a/osu.Game/Screens/Multi/Lounge/Components/RoomInspector.cs b/osu.Game/Screens/Multi/Lounge/Components/RoomInspector.cs index be16d89255..a7fa592323 100644 --- a/osu.Game/Screens/Multi/Lounge/Components/RoomInspector.cs +++ b/osu.Game/Screens/Multi/Lounge/Components/RoomInspector.cs @@ -36,7 +36,7 @@ namespace osu.Game.Screens.Multi.Lounge.Components private OsuColour colours; private Box statusStrip; private UpdateableBeatmapBackgroundSprite background; - private ParticipantCount participantCount; + private ParticipantCountDisplay participantCount; private FillFlowContainer topFlow, participantsFlow; private OsuSpriteText name, status; private BeatmapTypeInfo beatmapTypeInfo; @@ -84,7 +84,7 @@ namespace osu.Game.Screens.Multi.Lounge.Components Padding = new MarginPadding(20), Children = new Drawable[] { - participantCount = new ParticipantCount + participantCount = new ParticipantCountDisplay { Anchor = Anchor.TopRight, Origin = Anchor.TopRight, @@ -167,9 +167,12 @@ namespace osu.Game.Screens.Multi.Lounge.Components }; participantInfo.Host.BindTo(bindings.Host); + participantInfo.ParticipantCount.BindTo(bindings.ParticipantCount); participantInfo.Participants.BindTo(bindings.Participants); + participantCount.Participants.BindTo(bindings.Participants); participantCount.MaxParticipants.BindTo(bindings.MaxParticipants); + beatmapTypeInfo.Type.BindTo(bindings.Type); background.Beatmap.BindTo(bindings.CurrentBeatmap); beatmapTypeInfo.Beatmap.BindTo(bindings.CurrentBeatmap); diff --git a/osu.Game/Screens/Multi/Match/Components/Participants.cs b/osu.Game/Screens/Multi/Match/Components/Participants.cs index 4f18fc9f4c..56c8c3e8fc 100644 --- a/osu.Game/Screens/Multi/Match/Components/Participants.cs +++ b/osu.Game/Screens/Multi/Match/Components/Participants.cs @@ -16,12 +16,13 @@ namespace osu.Game.Screens.Multi.Match.Components public class Participants : CompositeDrawable { public readonly IBindable> Users = new Bindable>(); + public readonly IBindable ParticipantCount = new Bindable(); public readonly IBindable MaxParticipants = new Bindable(); public Participants() { FillFlowContainer usersFlow; - ParticipantCount count; + ParticipantCountDisplay count; InternalChild = new Container { @@ -35,7 +36,7 @@ namespace osu.Game.Screens.Multi.Match.Components Padding = new MarginPadding { Top = 10 }, Children = new Drawable[] { - count = new ParticipantCount + count = new ParticipantCountDisplay { Anchor = Anchor.TopRight, Origin = Anchor.TopRight, @@ -55,6 +56,7 @@ namespace osu.Game.Screens.Multi.Match.Components }; count.Participants.BindTo(Users); + count.ParticipantCount.BindTo(ParticipantCount); count.MaxParticipants.BindTo(MaxParticipants); Users.BindValueChanged(v => diff --git a/osu.Game/Screens/Multi/RoomBindings.cs b/osu.Game/Screens/Multi/RoomBindings.cs index e84fa9c261..9a38ba1f60 100644 --- a/osu.Game/Screens/Multi/RoomBindings.cs +++ b/osu.Game/Screens/Multi/RoomBindings.cs @@ -45,6 +45,7 @@ namespace osu.Game.Screens.Multi Type.UnbindFrom(room.Type); Playlist.UnbindFrom(room.Playlist); Participants.UnbindFrom(room.Participants); + ParticipantCount.UnbindFrom(room.ParticipantCount); MaxParticipants.UnbindFrom(room.MaxParticipants); EndDate.UnbindFrom(room.EndDate); Availability.UnbindFrom(room.Availability); @@ -61,6 +62,7 @@ namespace osu.Game.Screens.Multi Type.BindTo(room.Type); Playlist.BindTo(room.Playlist); Participants.BindTo(room.Participants); + ParticipantCount.BindTo(room.ParticipantCount); MaxParticipants.BindTo(room.MaxParticipants); EndDate.BindTo(room.EndDate); Availability.BindTo(room.Availability); @@ -86,6 +88,7 @@ namespace osu.Game.Screens.Multi public readonly Bindable Type = new Bindable(); public readonly BindableCollection Playlist = new BindableCollection(); public readonly Bindable> Participants = new Bindable>(); + public readonly Bindable ParticipantCount = new Bindable(); public readonly Bindable MaxParticipants = new Bindable(); public readonly Bindable EndDate = new Bindable(); public readonly Bindable Availability = new Bindable();