1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-14 08:33:21 +08:00

Participants

This commit is contained in:
Dean Herbert 2018-12-26 21:58:14 +09:00
parent bf9954aede
commit a1fa914c66
7 changed files with 27 additions and 7 deletions

View File

@ -49,6 +49,9 @@ namespace osu.Game.Online.Multiplayer
[JsonIgnore]
public Bindable<IEnumerable<User>> Participants { get; private set; } = new Bindable<IEnumerable<User>>(Enumerable.Empty<User>());
[JsonProperty("participant_count")]
public Bindable<int> ParticipantCount { get; private set; } = new Bindable<int>();
[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;

View File

@ -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<IEnumerable<User>> Participants = new Bindable<IEnumerable<User>>();
public readonly IBindable<int> ParticipantCount = new Bindable<int>();
public readonly IBindable<int?> MaxParticipants = new Bindable<int?>();
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()

View File

@ -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);

View File

@ -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<User> Host = new Bindable<User>();
public readonly IBindable<IEnumerable<User>> Participants = new Bindable<IEnumerable<User>>();
public readonly IBindable<int> ParticipantCount = new Bindable<int>();
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);

View File

@ -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);

View File

@ -16,12 +16,13 @@ namespace osu.Game.Screens.Multi.Match.Components
public class Participants : CompositeDrawable
{
public readonly IBindable<IEnumerable<User>> Users = new Bindable<IEnumerable<User>>();
public readonly IBindable<int> ParticipantCount = new Bindable<int>();
public readonly IBindable<int?> MaxParticipants = new Bindable<int?>();
public Participants()
{
FillFlowContainer<UserPanel> 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 =>

View File

@ -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<GameType> Type = new Bindable<GameType>();
public readonly BindableCollection<PlaylistItem> Playlist = new BindableCollection<PlaylistItem>();
public readonly Bindable<IEnumerable<User>> Participants = new Bindable<IEnumerable<User>>();
public readonly Bindable<int> ParticipantCount = new Bindable<int>();
public readonly Bindable<int?> MaxParticipants = new Bindable<int?>();
public readonly Bindable<DateTimeOffset> EndDate = new Bindable<DateTimeOffset>();
public readonly Bindable<RoomAvailability> Availability = new Bindable<RoomAvailability>();