1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-18 10:22:56 +08:00
osu-lazer/osu.Game.Tests/Visual/Online/TestSceneRankingsTables.cs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

176 lines
5.5 KiB
C#
Raw Normal View History

2019-09-28 00:33:52 +08:00
// 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.
2022-06-17 15:37:17 +08:00
#nullable disable
using System.Collections.Generic;
2019-09-28 00:33:52 +08:00
using osu.Framework.Graphics.Containers;
using osu.Game.Overlays.Rankings.Tables;
using osu.Framework.Graphics;
using System.Threading;
using osu.Framework.Allocation;
using osu.Game.Graphics.UserInterface;
using osu.Game.Online.API.Requests.Responses;
2020-02-04 02:22:37 +08:00
using osu.Game.Overlays;
using osu.Game.Users;
2019-09-28 00:33:52 +08:00
namespace osu.Game.Tests.Visual.Online
{
public class TestSceneRankingsTables : OsuTestScene
{
2020-02-04 02:22:37 +08:00
[Cached]
private readonly OverlayColourProvider colourProvider = new OverlayColourProvider(OverlayColourScheme.Green);
2019-09-28 00:33:52 +08:00
private readonly BasicScrollContainer scrollFlow;
private readonly LoadingLayer loading;
2019-09-28 00:33:52 +08:00
private CancellationTokenSource cancellationToken;
public TestSceneRankingsTables()
{
Children = new Drawable[]
{
scrollFlow = new BasicScrollContainer
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
RelativeSizeAxes = Axes.Both,
Width = 0.8f,
},
loading = new LoadingLayer(),
2019-09-28 00:33:52 +08:00
};
}
protected override void LoadComplete()
{
base.LoadComplete();
AddStep("User performance", createPerformanceTable);
AddStep("User scores", createScoreTable);
AddStep("Country scores", createCountryTable);
2019-09-28 00:33:52 +08:00
}
private void createCountryTable()
2019-09-28 00:33:52 +08:00
{
2019-11-28 04:40:52 +08:00
onLoadStarted();
2019-09-28 00:33:52 +08:00
var countries = new List<CountryStatistics>
2019-09-28 00:33:52 +08:00
{
new CountryStatistics
{
Country = new Country { FlagName = "US", FullName = "United States" },
FlagName = "US",
ActiveUsers = 2_972_623,
PlayCount = 3_086_515_743,
RankedScore = 449_407_643_332_546,
Performance = 371_974_024
},
new CountryStatistics
{
Country = new Country { FlagName = "RU", FullName = "Russian Federation" },
FlagName = "RU",
ActiveUsers = 1_609_989,
PlayCount = 1_637_052_841,
RankedScore = 221_660_827_473_004,
Performance = 163_426_476
}
};
2019-09-28 00:33:52 +08:00
var table = new CountriesTable(1, countries);
loadTable(table);
2019-09-28 00:33:52 +08:00
}
private static List<UserStatistics> createUserStatistics() => new List<UserStatistics>
2019-09-28 00:33:52 +08:00
{
new UserStatistics
2019-09-28 00:33:52 +08:00
{
User = new APIUser
{
Username = "first active user",
Country = new Country { FlagName = "JP" },
Active = true,
},
Accuracy = 0.9972,
PlayCount = 233_215,
TotalScore = 983_231_234_656,
RankedScore = 593_231_345_897,
PP = 23_934,
GradesCount = new UserStatistics.Grades
{
SS = 35_132,
S = 23_345,
A = 12_234
}
},
new UserStatistics
{
User = new APIUser
{
Username = "inactive user",
Country = new Country { FlagName = "AU" },
Active = false,
},
Accuracy = 0.9831,
PlayCount = 195_342,
TotalScore = 683_231_234_656,
RankedScore = 393_231_345_897,
PP = 20_934,
GradesCount = new UserStatistics.Grades
{
SS = 32_132,
S = 20_345,
A = 9_234
}
},
new UserStatistics
{
User = new APIUser
{
Username = "second active user",
Country = new Country { FlagName = "PL" },
Active = true,
},
Accuracy = 0.9584,
PlayCount = 100_903,
TotalScore = 97_242_983_434,
RankedScore = 3_156_345_897,
PP = 9_568,
GradesCount = new UserStatistics.Grades
{
SS = 13_152,
S = 24_375,
A = 9_960
}
},
};
private void createPerformanceTable()
2019-09-28 00:33:52 +08:00
{
2019-11-28 04:40:52 +08:00
onLoadStarted();
loadTable(new PerformanceTable(1, createUserStatistics()));
2019-09-28 00:33:52 +08:00
}
2019-11-28 04:40:52 +08:00
private void createScoreTable()
{
onLoadStarted();
loadTable(new ScoresTable(1, createUserStatistics()));
}
2019-11-28 04:40:52 +08:00
private void onLoadStarted()
{
loading.Show();
cancellationToken?.Cancel();
cancellationToken = new CancellationTokenSource();
}
private void loadTable(Drawable table)
{
LoadComponentAsync(table, t =>
{
scrollFlow.Clear();
scrollFlow.Add(t);
loading.Hide();
}, cancellationToken.Token);
}
2019-09-28 00:33:52 +08:00
}
}