1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-15 19:02:57 +08:00

Moved test data to visual test

This commit is contained in:
DrabWeb 2017-03-04 04:05:31 -04:00
parent a112b354f0
commit d6f53c8b77
2 changed files with 54 additions and 19 deletions

View File

@ -6,24 +6,62 @@ using osu.Framework.Screens.Testing;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Game.Screens.Select.Leaderboards; using osu.Game.Screens.Select.Leaderboards;
using OpenTK; using OpenTK;
using osu.Framework.Graphics.Textures;
using osu.Framework.Allocation;
using System;
using osu.Framework.MathUtils;
using osu.Game.Modes;
using System.Collections.Generic;
namespace osu.Desktop.VisualTests namespace osu.Desktop.VisualTests
{ {
public class TestCaseLeaderboard : TestCase class TestCaseLeaderboard : TestCase
{ {
public override string Name => @"Leaderboard"; public override string Name => @"Leaderboard";
public override string Description => @"From song select"; public override string Description => @"From song select";
private Leaderboard leaderboard;
private TextureStore ts;
[BackgroundDependencyLoader]
private void load(TextureStore textures)
{
ts = textures;
}
private void newScores()
{
var scores = new List<LeaderboardScore>();
for (int i = 0; i < 10; i++)
{
scores.Add(new LeaderboardScore
{
Avatar = ts.Get(@"Online/avatar-guest"),
Flag = ts.Get(@"Flags/__"),
Name = @"ultralaserxx",
MaxCombo = RNG.Next(0, 3000),
Accuracy = Math.Round(RNG.NextDouble(0, 100), 2),
Score = RNG.Next(0, 1000000),
Mods = new Mod[] { },
});
}
leaderboard.Scores = scores.ToArray();
}
public override void Reset() public override void Reset()
{ {
base.Reset(); base.Reset();
Add(new Leaderboard Add(leaderboard = new Leaderboard
{ {
Origin = Anchor.Centre, Origin = Anchor.Centre,
Anchor = Anchor.Centre, Anchor = Anchor.Centre,
Size = new Vector2(550f, 450f), Size = new Vector2(550f, 450f),
}); });
AddButton(@"New Scores", () => newScores());
newScores();
} }
} }
} }

View File

@ -7,31 +7,28 @@ using osu.Framework.Graphics.Containers;
using System.Collections.Generic; using System.Collections.Generic;
using osu.Game.Modes; using osu.Game.Modes;
using osu.Framework.Graphics.Textures; using osu.Framework.Graphics.Textures;
using osu.Framework.Allocation;
using osu.Framework.MathUtils;
using System;
namespace osu.Game.Screens.Select.Leaderboards namespace osu.Game.Screens.Select.Leaderboards
{ {
public class Leaderboard : Container public class Leaderboard : Container
{ {
private FillFlowContainer scrollFlow; private FillFlowContainer<LeaderboardScoreDisplay> scrollFlow;
[BackgroundDependencyLoader] private LeaderboardScore[] scores;
private void load(TextureStore textures) public LeaderboardScore[] Scores
{ {
for (int i = 0; i < 10; i++) get { return scores; }
set
{ {
scrollFlow.Add(new LeaderboardScoreDisplay(new LeaderboardScore scores = value;
var scoreDisplays = new List<LeaderboardScoreDisplay>();
for (int i = 0; i < value.Length; i++)
{ {
Avatar = textures.Get(@"Online/avatar-guest"), scoreDisplays.Add(new LeaderboardScoreDisplay(value[i], i + 1));
Flag = textures.Get(@"Flags/__"), }
Name = @"ultralaserxx",
MaxCombo = RNG.Next(0, 3000), scrollFlow.Children = scoreDisplays;
Accuracy = Math.Round(RNG.NextDouble(0, 100), 2),
Score = RNG.Next(0, 1000000),
Mods = new Mod[] { },
}, i + 1));
} }
} }
@ -45,7 +42,7 @@ namespace osu.Game.Screens.Select.Leaderboards
ScrollDraggerVisible = false, ScrollDraggerVisible = false,
Children = new Drawable[] Children = new Drawable[]
{ {
scrollFlow = new FillFlowContainer scrollFlow = new FillFlowContainer<LeaderboardScoreDisplay>
{ {
RelativeSizeAxes = Axes.X, RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y, AutoSizeAxes = Axes.Y,