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

Merge branch 'master' into remove-current-item

This commit is contained in:
Dean Herbert 2020-02-13 21:41:23 +09:00 committed by GitHub
commit 4a04b434a9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 28 additions and 20 deletions

View File

@ -16,7 +16,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
Add(new Participants { RelativeSizeAxes = Axes.Both });
AddStep(@"set max to null", () => Room.MaxParticipants.Value = null);
AddStep(@"set users", () => Room.Participants.Value = new[]
AddStep(@"set users", () => Room.Participants.AddRange(new[]
{
new User
{
@ -42,10 +42,10 @@ namespace osu.Game.Tests.Visual.Multiplayer
CoverUrl = @"https://assets.ppy.sh/user-profile-covers/5287410/5cfeaa9dd41cbce038ecdc9d781396ed4b0108089170bf7f50492ef8eadeb368.jpeg",
IsSupporter = true,
},
});
}));
AddStep(@"set max", () => Room.MaxParticipants.Value = 10);
AddStep(@"clear users", () => Room.Participants.Value = System.Array.Empty<User>());
AddStep(@"clear users", () => Room.Participants.Clear());
AddStep(@"set max to null", () => Room.MaxParticipants.Value = null);
}
}

View File

@ -61,7 +61,7 @@ namespace osu.Game.Online.Multiplayer
[Cached]
[JsonIgnore]
public Bindable<IEnumerable<User>> Participants { get; private set; } = new Bindable<IEnumerable<User>>(Enumerable.Empty<User>());
public BindableList<User> Participants { get; private set; } = new BindableList<User>();
[Cached]
public Bindable<int> ParticipantCount { get; private set; } = new Bindable<int>();
@ -114,7 +114,6 @@ namespace osu.Game.Online.Multiplayer
Type.Value = other.Type.Value;
MaxParticipants.Value = other.MaxParticipants.Value;
ParticipantCount.Value = other.ParticipantCount.Value;
Participants.Value = other.Participants.Value.ToArray();
EndDate.Value = other.EndDate.Value;
if (DateTimeOffset.Now >= EndDate.Value)
@ -124,6 +123,10 @@ namespace osu.Game.Online.Multiplayer
Playlist.Remove(removedItem);
Playlist.AddRange(other.Playlist.Except(Playlist).ToArray());
foreach (var removedItem in Participants.Except(other.Participants).ToArray())
Participants.Remove(removedItem);
Participants.AddRange(other.Participants.Except(Participants).ToArray());
Position = other.Position;
}

View File

@ -51,9 +51,9 @@ namespace osu.Game.Screens.Multi.Match.Components
},
};
Participants.BindValueChanged(participants =>
Participants.ItemsAdded += users =>
{
usersFlow.Children = participants.NewValue.Select(u =>
usersFlow.AddRange(users.Select(u =>
{
var panel = new UserPanel(u)
{
@ -65,8 +65,13 @@ namespace osu.Game.Screens.Multi.Match.Components
panel.OnLoadComplete += d => d.FadeInFromZero(60);
return panel;
}).ToList();
}, true);
}).ToList());
};
Participants.ItemsRemoved += users =>
{
usersFlow.RemoveAll(p => users.Contains(p.User));
};
}
}
}

View File

@ -2,7 +2,6 @@
// See the LICENCE file in the repository root for full licence text.
using System;
using System.Collections.Generic;
using osu.Framework.Allocation;
using osu.Framework.Bindables;
using osu.Framework.Graphics.Containers;
@ -32,7 +31,7 @@ namespace osu.Game.Screens.Multi
protected BindableList<PlaylistItem> Playlist { get; private set; }
[Resolved(typeof(Room))]
protected Bindable<IEnumerable<User>> Participants { get; private set; }
protected BindableList<User> Participants { get; private set; }
[Resolved(typeof(Room))]
protected Bindable<int> ParticipantCount { get; private set; }

View File

@ -26,11 +26,12 @@ namespace osu.Game.Users
{
public class UserPanel : OsuClickableContainer, IHasContextMenu
{
private readonly User user;
private const float height = 100;
private const float content_padding = 10;
private const float status_height = 30;
public readonly User User;
[Resolved(canBeNull: true)]
private OsuColour colours { get; set; }
@ -54,7 +55,7 @@ namespace osu.Game.Users
if (user == null)
throw new ArgumentNullException(nameof(user));
this.user = user;
User = user;
Height = height - status_height;
}
@ -86,7 +87,7 @@ namespace osu.Game.Users
RelativeSizeAxes = Axes.Both,
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
User = user,
User = User,
}, 300, 5000)
{
RelativeSizeAxes = Axes.Both,
@ -106,7 +107,7 @@ namespace osu.Game.Users
new UpdateableAvatar
{
Size = new Vector2(height - status_height - content_padding * 2),
User = user,
User = User,
Masking = true,
CornerRadius = 5,
OpenOnClick = { Value = false },
@ -125,7 +126,7 @@ namespace osu.Game.Users
{
new OsuSpriteText
{
Text = user.Username,
Text = User.Username,
Font = OsuFont.GetFont(weight: FontWeight.SemiBold, size: 18, italics: true),
},
infoContainer = new FillFlowContainer
@ -138,7 +139,7 @@ namespace osu.Game.Users
Spacing = new Vector2(5f, 0f),
Children = new Drawable[]
{
new UpdateableFlag(user.Country)
new UpdateableFlag(User.Country)
{
Width = 30f,
RelativeSizeAxes = Axes.Y,
@ -191,12 +192,12 @@ namespace osu.Game.Users
}
});
if (user.IsSupporter)
if (User.IsSupporter)
{
infoContainer.Add(new SupporterIcon
{
Height = 20f,
SupportLevel = user.SupportLevel
SupportLevel = User.SupportLevel
});
}
@ -206,7 +207,7 @@ namespace osu.Game.Users
base.Action = ViewProfile = () =>
{
Action?.Invoke();
profile?.ShowUser(user);
profile?.ShowUser(User);
};
}