mirror of
https://github.com/ppy/osu.git
synced 2025-03-05 13:13:22 +08:00
Merge branch 'master' into fix-leaderboard-user-handling
This commit is contained in:
commit
a376a23ed7
@ -43,6 +43,16 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
|||||||
AddAssert("two unique panels", () => this.ChildrenOfType<ParticipantPanel>().Select(p => p.User).Distinct().Count() == 2);
|
AddAssert("two unique panels", () => this.ChildrenOfType<ParticipantPanel>().Select(p => p.User).Distinct().Count() == 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestAddNullUser()
|
||||||
|
{
|
||||||
|
AddAssert("one unique panel", () => this.ChildrenOfType<ParticipantPanel>().Select(p => p.User).Distinct().Count() == 1);
|
||||||
|
|
||||||
|
AddStep("add non-resolvable user", () => Client.AddNullUser(-3));
|
||||||
|
|
||||||
|
AddUntilStep("two unique panels", () => this.ChildrenOfType<ParticipantPanel>().Select(p => p.User).Distinct().Count() == 2);
|
||||||
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void TestRemoveUser()
|
public void TestRemoveUser()
|
||||||
{
|
{
|
||||||
|
@ -80,6 +80,7 @@ namespace osu.Game.Database
|
|||||||
var request = new GetUsersRequest(userTasks.Keys.ToArray());
|
var request = new GetUsersRequest(userTasks.Keys.ToArray());
|
||||||
|
|
||||||
// rather than queueing, we maintain our own single-threaded request stream.
|
// rather than queueing, we maintain our own single-threaded request stream.
|
||||||
|
// todo: we probably want retry logic here.
|
||||||
api.Perform(request);
|
api.Perform(request);
|
||||||
|
|
||||||
// Create a new request task if there's still more users to query.
|
// Create a new request task if there's still more users to query.
|
||||||
@ -90,14 +91,19 @@ namespace osu.Game.Database
|
|||||||
createNewTask();
|
createNewTask();
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (var user in request.Result.Users)
|
List<User> foundUsers = request.Result?.Users;
|
||||||
{
|
|
||||||
if (userTasks.TryGetValue(user.Id, out var tasks))
|
|
||||||
{
|
|
||||||
foreach (var task in tasks)
|
|
||||||
task.SetResult(user);
|
|
||||||
|
|
||||||
userTasks.Remove(user.Id);
|
if (foundUsers != null)
|
||||||
|
{
|
||||||
|
foreach (var user in foundUsers)
|
||||||
|
{
|
||||||
|
if (userTasks.TryGetValue(user.Id, out var tasks))
|
||||||
|
{
|
||||||
|
foreach (var task in tasks)
|
||||||
|
task.SetResult(user);
|
||||||
|
|
||||||
|
userTasks.Remove(user.Id);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||||
// See the LICENCE file in the repository root for full licence text.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
using System.Diagnostics;
|
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Extensions.Color4Extensions;
|
using osu.Framework.Extensions.Color4Extensions;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
@ -45,7 +44,7 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer.Participants
|
|||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
private void load()
|
private void load()
|
||||||
{
|
{
|
||||||
Debug.Assert(User.User != null);
|
var user = User.User;
|
||||||
|
|
||||||
var backgroundColour = Color4Extensions.FromHex("#33413C");
|
var backgroundColour = Color4Extensions.FromHex("#33413C");
|
||||||
|
|
||||||
@ -82,7 +81,7 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer.Participants
|
|||||||
Origin = Anchor.CentreRight,
|
Origin = Anchor.CentreRight,
|
||||||
RelativeSizeAxes = Axes.Both,
|
RelativeSizeAxes = Axes.Both,
|
||||||
Width = 0.75f,
|
Width = 0.75f,
|
||||||
User = User.User,
|
User = user,
|
||||||
Colour = ColourInfo.GradientHorizontal(Color4.White.Opacity(0), Color4.White.Opacity(0.25f))
|
Colour = ColourInfo.GradientHorizontal(Color4.White.Opacity(0), Color4.White.Opacity(0.25f))
|
||||||
},
|
},
|
||||||
new FillFlowContainer
|
new FillFlowContainer
|
||||||
@ -98,28 +97,28 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer.Participants
|
|||||||
Origin = Anchor.CentreLeft,
|
Origin = Anchor.CentreLeft,
|
||||||
RelativeSizeAxes = Axes.Both,
|
RelativeSizeAxes = Axes.Both,
|
||||||
FillMode = FillMode.Fit,
|
FillMode = FillMode.Fit,
|
||||||
User = User.User
|
User = user
|
||||||
},
|
},
|
||||||
new UpdateableFlag
|
new UpdateableFlag
|
||||||
{
|
{
|
||||||
Anchor = Anchor.CentreLeft,
|
Anchor = Anchor.CentreLeft,
|
||||||
Origin = Anchor.CentreLeft,
|
Origin = Anchor.CentreLeft,
|
||||||
Size = new Vector2(30, 20),
|
Size = new Vector2(30, 20),
|
||||||
Country = User.User.Country
|
Country = user?.Country
|
||||||
},
|
},
|
||||||
new OsuSpriteText
|
new OsuSpriteText
|
||||||
{
|
{
|
||||||
Anchor = Anchor.CentreLeft,
|
Anchor = Anchor.CentreLeft,
|
||||||
Origin = Anchor.CentreLeft,
|
Origin = Anchor.CentreLeft,
|
||||||
Font = OsuFont.GetFont(weight: FontWeight.Bold, size: 18),
|
Font = OsuFont.GetFont(weight: FontWeight.Bold, size: 18),
|
||||||
Text = User.User.Username
|
Text = user?.Username
|
||||||
},
|
},
|
||||||
new OsuSpriteText
|
new OsuSpriteText
|
||||||
{
|
{
|
||||||
Anchor = Anchor.CentreLeft,
|
Anchor = Anchor.CentreLeft,
|
||||||
Origin = Anchor.CentreLeft,
|
Origin = Anchor.CentreLeft,
|
||||||
Font = OsuFont.GetFont(size: 14),
|
Font = OsuFont.GetFont(size: 14),
|
||||||
Text = User.User.CurrentModeRank != null ? $"#{User.User.CurrentModeRank}" : string.Empty
|
Text = user?.CurrentModeRank != null ? $"#{user.CurrentModeRank}" : string.Empty
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -28,6 +28,8 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
|||||||
|
|
||||||
public void AddUser(User user) => ((IMultiplayerClient)this).UserJoined(new MultiplayerRoomUser(user.Id) { User = user });
|
public void AddUser(User user) => ((IMultiplayerClient)this).UserJoined(new MultiplayerRoomUser(user.Id) { User = user });
|
||||||
|
|
||||||
|
public void AddNullUser(int userId) => ((IMultiplayerClient)this).UserJoined(new MultiplayerRoomUser(userId));
|
||||||
|
|
||||||
public void RemoveUser(User user)
|
public void RemoveUser(User user)
|
||||||
{
|
{
|
||||||
Debug.Assert(Room != null);
|
Debug.Assert(Room != null);
|
||||||
|
Loading…
Reference in New Issue
Block a user