mirror of
https://github.com/osukey/osukey.git
synced 2025-08-08 09:03:50 +09:00
Use a local lookup cache for better usernames
This commit is contained in:
@ -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)
|
||||||
{
|
{
|
||||||
|
@ -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],
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user