osu/osu.Desktop.VisualTests/Tests/TestCaseLeaderboard.cs

65 lines
1.9 KiB
C#
Raw Normal View History

2017-03-04 07:37:34 +00:00
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using OpenTK;
using System;
using System.Linq;
using System.Collections.Generic;
2017-03-04 07:37:34 +00:00
using osu.Framework.Graphics.Containers;
using osu.Framework.Screens.Testing;
using osu.Framework.Graphics;
2017-03-04 08:05:31 +00:00
using osu.Framework.Graphics.Textures;
using osu.Framework.Allocation;
using osu.Framework.MathUtils;
using osu.Game.Screens.Select.Leaderboards;
2017-03-04 08:05:31 +00:00
using osu.Game.Modes;
2017-03-04 07:37:34 +00:00
namespace osu.Desktop.VisualTests
{
2017-03-04 08:05:31 +00:00
class TestCaseLeaderboard : TestCase
2017-03-04 07:37:34 +00:00
{
public override string Name => @"Leaderboard";
public override string Description => @"From song select";
2017-03-04 08:05:31 +00:00
private Leaderboard leaderboard;
private void newScores()
{
var scores = new List<Score>();
2017-03-04 08:05:31 +00:00
for (int i = 0; i < 10; i++)
{
scores.Add(new Score
2017-03-04 08:05:31 +00:00
{
Accuracy = Math.Round(RNG.NextDouble(0, 100), 2),
MaxCombo = RNG.Next(0, 3000),
TotalScore = RNG.Next(1, 1000000),
Mods = Ruleset.GetRuleset(PlayMode.Osu).GetModsFor(ModType.DifficultyIncrease).ToArray(),
User = new Game.Users.User
{
Id = 2,
Username = @"peppy",
FlagName = @"AU",
},
2017-03-04 08:05:31 +00:00
});
}
leaderboard.Scores = scores.ToArray();
}
2017-03-04 07:37:34 +00:00
public override void Reset()
{
base.Reset();
2017-03-04 08:05:31 +00:00
Add(leaderboard = new Leaderboard
2017-03-04 07:37:34 +00:00
{
Origin = Anchor.Centre,
Anchor = Anchor.Centre,
Size = new Vector2(550f, 450f),
});
2017-03-04 08:05:31 +00:00
AddButton(@"New Scores", () => newScores());
newScores();
2017-03-04 07:37:34 +00:00
}
}
}