Use a local lookup cache for better usernames

This commit is contained in:
Dean Herbert
2020-12-16 15:53:05 +09:00
parent 09d0ceb766
commit c1ba0f4642
2 changed files with 34 additions and 1 deletions

View File

@ -9,12 +9,14 @@ using osu.Framework.Allocation;
using osu.Framework.Bindables; using osu.Framework.Bindables;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Utils; using osu.Framework.Utils;
using osu.Game.Database;
using osu.Game.Online.Spectator; using osu.Game.Online.Spectator;
using osu.Game.Replays.Legacy; using osu.Game.Replays.Legacy;
using osu.Game.Rulesets.Osu.Scoring; using osu.Game.Rulesets.Osu.Scoring;
using osu.Game.Rulesets.Scoring; using osu.Game.Rulesets.Scoring;
using osu.Game.Scoring; using osu.Game.Scoring;
using osu.Game.Screens.Play.HUD; using osu.Game.Screens.Play.HUD;
using osu.Game.Tests.Visual.Online;
namespace osu.Game.Tests.Visual.Gameplay namespace osu.Game.Tests.Visual.Gameplay
{ {
@ -23,6 +25,9 @@ namespace osu.Game.Tests.Visual.Gameplay
[Cached(typeof(SpectatorStreamingClient))] [Cached(typeof(SpectatorStreamingClient))]
private TestMultiplayerStreaming streamingClient = new TestMultiplayerStreaming(16); private TestMultiplayerStreaming streamingClient = new TestMultiplayerStreaming(16);
[Cached(typeof(UserLookupCache))]
private UserLookupCache lookupCache = new TestSceneCurrentlyPlayingDisplay.TestUserLookupCache();
// used just to show beatmap card for the time being. // used just to show beatmap card for the time being.
protected override bool UseOnlineAPI => true; protected override bool UseOnlineAPI => true;
@ -35,6 +40,8 @@ namespace osu.Game.Tests.Visual.Gameplay
Children = new Drawable[] Children = new Drawable[]
{ {
streamingClient,
lookupCache,
scoreProcessor = new OsuScoreProcessor(), scoreProcessor = new OsuScoreProcessor(),
new MultiplayerGameplayLeaderboard(scoreProcessor) new MultiplayerGameplayLeaderboard(scoreProcessor)
{ {

View File

@ -69,8 +69,34 @@ namespace osu.Game.Tests.Visual.Online
internal class TestUserLookupCache : UserLookupCache internal class TestUserLookupCache : UserLookupCache
{ {
private static readonly string[] usernames =
{
"fieryrage",
"Kerensa",
"MillhioreF",
"Player01",
"smoogipoo",
"Ephemeral",
"BTMC",
"Cilvery",
"m980",
"HappyStick",
"LittleEndu",
"frenzibyte",
"Zallius",
"BanchoBot",
"rocketminer210",
"pishifat"
};
private int id;
protected override Task<User> ComputeValueAsync(int lookup, CancellationToken token = default) protected override Task<User> ComputeValueAsync(int lookup, CancellationToken token = default)
=> Task.FromResult(new User { Username = "peppy", Id = 2 }); => Task.FromResult(new User
{
Id = id++,
Username = usernames[id % usernames.Length],
});
} }
} }
} }