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

Add Match Participants, change Room.Users to IEnumerable.

This commit is contained in:
DrabWeb 2018-05-29 02:42:52 -03:00
parent 77ff0640c2
commit 3915cb7f2f
7 changed files with 133 additions and 4 deletions

View File

@ -6,6 +6,7 @@ using osu.Game.Beatmaps;
using osu.Game.Online.Multiplayer; using osu.Game.Online.Multiplayer;
using osu.Game.Rulesets; using osu.Game.Rulesets;
using osu.Game.Screens.Multi.Screens.Match; using osu.Game.Screens.Multi.Screens.Match;
using osu.Game.Users;
namespace osu.Game.Tests.Visual namespace osu.Game.Tests.Visual
{ {
@ -44,6 +45,43 @@ namespace osu.Game.Tests.Visual
}, },
}, },
}, },
MaxParticipants = { Value = 5 },
Participants =
{
Value = new[]
{
new User
{
Username = @"eiri-",
Id = 3388410,
Country = new Country { FlagName = @"US" },
CoverUrl = @"https://assets.ppy.sh/user-profile-covers/3388410/00a8486a247831e1cc4375db519f611ac970bda8bc0057d78b0f540ea38c3e58.jpeg",
IsSupporter = true,
},
new User
{
Username = @"Nepuri",
Id = 6637817,
Country = new Country { FlagName = @"DE" },
CoverUrl = @"https://assets.ppy.sh/user-profile-covers/6637817/9085fc60248b6b5327a72c1dcdecf2dbedba810ae0ab6bcf7224e46b1339632a.jpeg",
IsSupporter = true,
},
new User
{
Username = @"goheegy",
Id = 8057655,
Country = new Country { FlagName = @"GB" },
CoverUrl = @"https://assets.ppy.sh/user-profile-covers/8057655/21cec27c25a11dc197a4ec6a74253dbabb495949b0e0697113352f12007018c5.jpeg",
},
new User
{
Username = @"Alumetri",
Id = 5371497,
Country = new Country { FlagName = @"RU" },
CoverUrl = @"https://assets.ppy.sh/user-profile-covers/5371497/e023b8c7fbe3613e64bd4856703517ea50fbed8a5805dc9acda9efe9897c67e2.jpeg",
},
}
},
}; };
Match match = new Match(room); Match match = new Match(room);

View File

@ -1,6 +1,7 @@
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>. // Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using System.Collections.Generic;
using osu.Framework.Configuration; using osu.Framework.Configuration;
using osu.Game.Beatmaps; using osu.Game.Beatmaps;
using osu.Game.Users; using osu.Game.Users;
@ -16,6 +17,6 @@ namespace osu.Game.Online.Multiplayer
public Bindable<GameType> Type = new Bindable<GameType>(); public Bindable<GameType> Type = new Bindable<GameType>();
public Bindable<BeatmapInfo> Beatmap = new Bindable<BeatmapInfo>(); public Bindable<BeatmapInfo> Beatmap = new Bindable<BeatmapInfo>();
public Bindable<int?> MaxParticipants = new Bindable<int?>(); public Bindable<int?> MaxParticipants = new Bindable<int?>();
public Bindable<User[]> Participants = new Bindable<User[]>(); public Bindable<IEnumerable<User>> Participants = new Bindable<IEnumerable<User>>();
} }
} }

View File

@ -41,7 +41,7 @@ namespace osu.Game.Screens.Multi.Components
private readonly Bindable<RoomStatus> statusBind = new Bindable<RoomStatus>(); private readonly Bindable<RoomStatus> statusBind = new Bindable<RoomStatus>();
private readonly Bindable<GameType> typeBind = new Bindable<GameType>(); private readonly Bindable<GameType> typeBind = new Bindable<GameType>();
private readonly Bindable<BeatmapInfo> beatmapBind = new Bindable<BeatmapInfo>(); private readonly Bindable<BeatmapInfo> beatmapBind = new Bindable<BeatmapInfo>();
private readonly Bindable<User[]> participantsBind = new Bindable<User[]>(); private readonly Bindable<IEnumerable<User>> participantsBind = new Bindable<IEnumerable<User>>();
public readonly Room Room; public readonly Room Room;

View File

@ -1,6 +1,7 @@
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>. // Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using System.Collections.Generic;
using System.Linq; using System.Linq;
using osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Framework.Configuration; using osu.Framework.Configuration;
@ -33,7 +34,7 @@ namespace osu.Game.Screens.Multi.Components
private readonly Bindable<GameType> typeBind = new Bindable<GameType>(); private readonly Bindable<GameType> typeBind = new Bindable<GameType>();
private readonly Bindable<BeatmapInfo> beatmapBind = new Bindable<BeatmapInfo>(); private readonly Bindable<BeatmapInfo> beatmapBind = new Bindable<BeatmapInfo>();
private readonly Bindable<int?> maxParticipantsBind = new Bindable<int?>(); private readonly Bindable<int?> maxParticipantsBind = new Bindable<int?>();
private readonly Bindable<User[]> participantsBind = new Bindable<User[]>(); private readonly Bindable<IEnumerable<User>> participantsBind = new Bindable<IEnumerable<User>>();
private OsuColour colours; private OsuColour colours;
private Box statusStrip; private Box statusStrip;
@ -214,7 +215,7 @@ namespace osu.Game.Screens.Multi.Components
participantsBind.ValueChanged += p => participantsBind.ValueChanged += p =>
{ {
participantCount.Count = p.Length; participantCount.Count = p.Count();
participantInfo.Participants = p; participantInfo.Participants = p;
participantsFlow.ChildrenEnumerable = p.Select(u => new UserTile(u)); participantsFlow.ChildrenEnumerable = p.Select(u => new UserTile(u));
}; };

View File

@ -1,23 +1,31 @@
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>. // Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using System.Collections.Generic;
using osu.Framework.Configuration; using osu.Framework.Configuration;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Game.Beatmaps; using osu.Game.Beatmaps;
using osu.Game.Online.Multiplayer; using osu.Game.Online.Multiplayer;
using osu.Game.Screens.Select; using osu.Game.Screens.Select;
using osu.Game.Users;
namespace osu.Game.Screens.Multi.Screens.Match namespace osu.Game.Screens.Multi.Screens.Match
{ {
public class Match : MultiplayerScreen public class Match : MultiplayerScreen
{ {
private readonly Room room; private readonly Room room;
private readonly Participants participants;
private readonly Bindable<string> nameBind = new Bindable<string>(); private readonly Bindable<string> nameBind = new Bindable<string>();
private readonly Bindable<RoomStatus> statusBind = new Bindable<RoomStatus>(); private readonly Bindable<RoomStatus> statusBind = new Bindable<RoomStatus>();
private readonly Bindable<RoomAvailability> availabilityBind = new Bindable<RoomAvailability>(); private readonly Bindable<RoomAvailability> availabilityBind = new Bindable<RoomAvailability>();
private readonly Bindable<GameType> typeBind = new Bindable<GameType>(); private readonly Bindable<GameType> typeBind = new Bindable<GameType>();
private readonly Bindable<BeatmapInfo> beatmapBind = new Bindable<BeatmapInfo>(); private readonly Bindable<BeatmapInfo> beatmapBind = new Bindable<BeatmapInfo>();
private readonly Bindable<int?> maxParticipantsBind = new Bindable<int?>();
private readonly Bindable<IEnumerable<User>> participantsBind = new Bindable<IEnumerable<User>>();
protected override Container<Drawable> TransitionContent => participants;
public override string Title => room.Name.Value; public override string Title => room.Name.Value;
@ -34,6 +42,11 @@ namespace osu.Game.Screens.Multi.Screens.Match
{ {
Margin = new MarginPadding { Top = Header.HEIGHT }, Margin = new MarginPadding { Top = Header.HEIGHT },
}, },
participants = new Participants
{
RelativeSizeAxes = Axes.Both,
Padding = new MarginPadding { Top = Header.HEIGHT + Info.HEIGHT },
},
}; };
header.BeatmapButton.Action = () => Push(new MatchSongSelect()); header.BeatmapButton.Action = () => Push(new MatchSongSelect());
@ -41,6 +54,8 @@ namespace osu.Game.Screens.Multi.Screens.Match
statusBind.ValueChanged += s => info.Status = s; statusBind.ValueChanged += s => info.Status = s;
availabilityBind.ValueChanged += a => info.Availability = a; availabilityBind.ValueChanged += a => info.Availability = a;
typeBind.ValueChanged += t => info.Type = t; typeBind.ValueChanged += t => info.Type = t;
maxParticipantsBind.ValueChanged += m => { participants.Max = m; };
participantsBind.ValueChanged += p => participants.Users = p;
beatmapBind.ValueChanged += b => beatmapBind.ValueChanged += b =>
{ {
@ -53,6 +68,8 @@ namespace osu.Game.Screens.Multi.Screens.Match
availabilityBind.BindTo(room.Availability); availabilityBind.BindTo(room.Availability);
typeBind.BindTo(room.Type); typeBind.BindTo(room.Type);
beatmapBind.BindTo(room.Beatmap); beatmapBind.BindTo(room.Beatmap);
maxParticipantsBind.BindTo(room.MaxParticipants);
participantsBind.BindTo(room.Participants);
} }
} }
} }

View File

@ -0,0 +1,71 @@
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using System.Collections.Generic;
using System.Linq;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Game.Overlays.SearchableList;
using osu.Game.Screens.Multi.Components;
using osu.Game.Users;
using OpenTK;
namespace osu.Game.Screens.Multi.Screens.Match
{
public class Participants : Container
{
private readonly ParticipantCount count;
private readonly FillFlowContainer<UserPanel> usersFlow;
public IEnumerable<User> Users
{
set {
usersFlow.Children = value.Select(u => new UserPanel(u)
{
Anchor = Anchor.TopCentre,
Origin = Anchor.TopCentre,
Width = 300,
}).ToList();
count.Count = value.Count();
}
}
public int? Max
{
set { count.Max = value; }
}
public Participants()
{
Child = new Container
{
RelativeSizeAxes = Axes.Both,
Padding = new MarginPadding { Horizontal = SearchableListOverlay.WIDTH_PADDING },
Children = new Drawable[]
{
new ScrollContainer
{
RelativeSizeAxes = Axes.Both,
Padding = new MarginPadding { Top = 10 },
Children = new Drawable[]
{
count = new ParticipantCount
{
Anchor = Anchor.TopRight,
Origin = Anchor.TopRight,
},
usersFlow = new FillFlowContainer<UserPanel>
{
RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y,
Spacing = new Vector2(5),
Padding = new MarginPadding { Top = 40 },
},
},
},
},
};
}
}
}

View File

@ -21,6 +21,7 @@ namespace osu.Game.Screens.Multi.Screens
TransitionContent.MoveToX(200); TransitionContent.MoveToX(200);
Content.FadeInFromZero(WaveContainer.APPEAR_DURATION, in_easing);
TransitionContent.FadeInFromZero(WaveContainer.APPEAR_DURATION, in_easing); TransitionContent.FadeInFromZero(WaveContainer.APPEAR_DURATION, in_easing);
TransitionContent.MoveToX(0, WaveContainer.APPEAR_DURATION, in_easing); TransitionContent.MoveToX(0, WaveContainer.APPEAR_DURATION, in_easing);
} }