2019-12-03 06:28:10 +00:00
|
|
|
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
2019-01-24 08:43:03 +00:00
|
|
|
// See the LICENCE file in the repository root for full licence text.
|
2018-04-13 09:19:50 +00:00
|
|
|
|
2019-03-26 01:21:34 +00:00
|
|
|
using System;
|
2019-03-24 16:02:36 +00:00
|
|
|
using System.Collections.Generic;
|
2020-02-04 11:52:26 +00:00
|
|
|
using osu.Framework.Allocation;
|
2018-04-13 09:19:50 +00:00
|
|
|
using osu.Framework.Graphics;
|
2019-03-24 16:02:36 +00:00
|
|
|
using osu.Framework.Graphics.Containers;
|
2018-04-13 09:19:50 +00:00
|
|
|
using osu.Framework.Graphics.Shapes;
|
2020-01-09 04:43:44 +00:00
|
|
|
using osu.Framework.Utils;
|
2019-07-08 09:02:10 +00:00
|
|
|
using osu.Game.Online.API.Requests.Responses;
|
2020-02-04 11:52:26 +00:00
|
|
|
using osu.Game.Overlays;
|
2018-04-13 09:19:50 +00:00
|
|
|
using osu.Game.Overlays.BeatmapSet.Scores;
|
|
|
|
using osu.Game.Rulesets.Osu.Mods;
|
2018-11-28 07:12:57 +00:00
|
|
|
using osu.Game.Scoring;
|
2019-03-24 16:02:36 +00:00
|
|
|
using osu.Game.Users;
|
2019-07-09 09:16:58 +00:00
|
|
|
using osuTK.Graphics;
|
2018-04-13 09:19:50 +00:00
|
|
|
|
2019-04-03 09:14:59 +00:00
|
|
|
namespace osu.Game.Tests.Visual.Online
|
2018-04-13 09:19:50 +00:00
|
|
|
{
|
2019-05-14 19:37:25 +00:00
|
|
|
public class TestSceneScoresContainer : OsuTestScene
|
2018-04-13 09:19:50 +00:00
|
|
|
{
|
2019-03-26 01:21:34 +00:00
|
|
|
public override IReadOnlyList<Type> RequiredTypes => new[]
|
|
|
|
{
|
2019-04-03 06:20:38 +00:00
|
|
|
typeof(DrawableTopScore),
|
2019-04-03 07:36:38 +00:00
|
|
|
typeof(TopScoreUserSection),
|
|
|
|
typeof(TopScoreStatisticsSection),
|
2019-03-26 01:21:34 +00:00
|
|
|
typeof(ScoreTable),
|
2019-03-26 08:38:56 +00:00
|
|
|
typeof(ScoreTableRowBackground),
|
2019-03-26 01:21:34 +00:00
|
|
|
};
|
|
|
|
|
2020-02-04 11:52:26 +00:00
|
|
|
[Cached]
|
|
|
|
private readonly OverlayColourProvider colourProvider = new OverlayColourProvider(OverlayColourScheme.Blue);
|
|
|
|
|
2019-05-14 19:37:25 +00:00
|
|
|
public TestSceneScoresContainer()
|
2018-04-13 09:19:50 +00:00
|
|
|
{
|
2019-07-10 16:40:29 +00:00
|
|
|
TestScoresContainer scoresContainer;
|
2018-04-13 09:19:50 +00:00
|
|
|
|
2019-03-08 07:44:39 +00:00
|
|
|
Child = new Container
|
2018-04-13 09:19:50 +00:00
|
|
|
{
|
|
|
|
Anchor = Anchor.TopCentre,
|
|
|
|
Origin = Anchor.TopCentre,
|
2019-06-19 20:15:00 +00:00
|
|
|
RelativeSizeAxes = Axes.Both,
|
2018-04-13 09:19:50 +00:00
|
|
|
Width = 0.8f,
|
|
|
|
Children = new Drawable[]
|
|
|
|
{
|
2019-07-09 09:28:59 +00:00
|
|
|
new Box
|
2019-07-09 09:16:58 +00:00
|
|
|
{
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
Colour = Color4.Black,
|
|
|
|
},
|
2019-07-10 16:40:29 +00:00
|
|
|
scoresContainer = new TestScoresContainer(),
|
2018-04-13 09:19:50 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2019-07-09 05:05:34 +00:00
|
|
|
var allScores = new APILegacyScores
|
2018-04-13 09:19:50 +00:00
|
|
|
{
|
2019-07-09 05:05:34 +00:00
|
|
|
Scores = new List<APILegacyScoreInfo>
|
2018-04-13 09:19:50 +00:00
|
|
|
{
|
2019-07-09 05:05:34 +00:00
|
|
|
new APILegacyScoreInfo
|
2018-04-13 09:19:50 +00:00
|
|
|
{
|
2019-07-09 05:05:34 +00:00
|
|
|
User = new User
|
2018-04-13 09:19:50 +00:00
|
|
|
{
|
2019-07-09 05:05:34 +00:00
|
|
|
Id = 6602580,
|
|
|
|
Username = @"waaiiru",
|
|
|
|
Country = new Country
|
|
|
|
{
|
|
|
|
FullName = @"Spain",
|
|
|
|
FlagName = @"ES",
|
|
|
|
},
|
2018-04-13 09:19:50 +00:00
|
|
|
},
|
2019-12-03 06:28:10 +00:00
|
|
|
Mods = new[]
|
2018-04-13 09:19:50 +00:00
|
|
|
{
|
2019-12-03 06:28:10 +00:00
|
|
|
new OsuModDoubleTime().Acronym,
|
|
|
|
new OsuModHidden().Acronym,
|
|
|
|
new OsuModFlashlight().Acronym,
|
|
|
|
new OsuModHardRock().Acronym,
|
2018-04-13 09:19:50 +00:00
|
|
|
},
|
2019-07-09 05:05:34 +00:00
|
|
|
Rank = ScoreRank.XH,
|
|
|
|
PP = 200,
|
|
|
|
MaxCombo = 1234,
|
|
|
|
TotalScore = 1234567890,
|
|
|
|
Accuracy = 1,
|
2018-04-13 09:19:50 +00:00
|
|
|
},
|
2019-07-09 05:05:34 +00:00
|
|
|
new APILegacyScoreInfo
|
2018-04-13 09:19:50 +00:00
|
|
|
{
|
2019-07-09 05:05:34 +00:00
|
|
|
User = new User
|
|
|
|
{
|
|
|
|
Id = 4608074,
|
|
|
|
Username = @"Skycries",
|
|
|
|
Country = new Country
|
|
|
|
{
|
|
|
|
FullName = @"Brazil",
|
|
|
|
FlagName = @"BR",
|
|
|
|
},
|
|
|
|
},
|
2019-12-03 06:28:10 +00:00
|
|
|
Mods = new[]
|
2018-04-13 09:19:50 +00:00
|
|
|
{
|
2019-12-03 06:28:10 +00:00
|
|
|
new OsuModDoubleTime().Acronym,
|
|
|
|
new OsuModHidden().Acronym,
|
|
|
|
new OsuModFlashlight().Acronym,
|
2018-04-13 09:19:50 +00:00
|
|
|
},
|
2019-07-09 05:05:34 +00:00
|
|
|
Rank = ScoreRank.S,
|
|
|
|
PP = 190,
|
|
|
|
MaxCombo = 1234,
|
|
|
|
TotalScore = 1234789,
|
|
|
|
Accuracy = 0.9997,
|
2018-04-13 09:19:50 +00:00
|
|
|
},
|
2019-07-09 05:05:34 +00:00
|
|
|
new APILegacyScoreInfo
|
2018-04-13 09:19:50 +00:00
|
|
|
{
|
2019-07-09 05:05:34 +00:00
|
|
|
User = new User
|
2018-04-13 09:19:50 +00:00
|
|
|
{
|
2019-07-09 05:05:34 +00:00
|
|
|
Id = 1014222,
|
|
|
|
Username = @"eLy",
|
|
|
|
Country = new Country
|
|
|
|
{
|
|
|
|
FullName = @"Japan",
|
|
|
|
FlagName = @"JP",
|
|
|
|
},
|
2018-04-13 09:19:50 +00:00
|
|
|
},
|
2019-12-03 06:28:10 +00:00
|
|
|
Mods = new[]
|
2019-07-09 05:05:34 +00:00
|
|
|
{
|
2019-12-03 06:28:10 +00:00
|
|
|
new OsuModDoubleTime().Acronym,
|
|
|
|
new OsuModHidden().Acronym,
|
2019-07-09 05:05:34 +00:00
|
|
|
},
|
|
|
|
Rank = ScoreRank.B,
|
|
|
|
PP = 180,
|
|
|
|
MaxCombo = 1234,
|
|
|
|
TotalScore = 12345678,
|
|
|
|
Accuracy = 0.9854,
|
2018-04-13 09:19:50 +00:00
|
|
|
},
|
2019-07-09 05:05:34 +00:00
|
|
|
new APILegacyScoreInfo
|
2018-04-13 09:19:50 +00:00
|
|
|
{
|
2019-07-09 05:05:34 +00:00
|
|
|
User = new User
|
|
|
|
{
|
|
|
|
Id = 1541390,
|
|
|
|
Username = @"Toukai",
|
|
|
|
Country = new Country
|
|
|
|
{
|
|
|
|
FullName = @"Canada",
|
|
|
|
FlagName = @"CA",
|
|
|
|
},
|
|
|
|
},
|
2019-12-03 06:28:10 +00:00
|
|
|
Mods = new[]
|
2019-07-09 05:05:34 +00:00
|
|
|
{
|
2019-12-03 06:28:10 +00:00
|
|
|
new OsuModDoubleTime().Acronym,
|
2019-07-09 05:05:34 +00:00
|
|
|
},
|
|
|
|
Rank = ScoreRank.C,
|
|
|
|
PP = 170,
|
|
|
|
MaxCombo = 1234,
|
|
|
|
TotalScore = 1234567,
|
|
|
|
Accuracy = 0.8765,
|
2018-04-13 09:19:50 +00:00
|
|
|
},
|
2019-07-09 05:05:34 +00:00
|
|
|
new APILegacyScoreInfo
|
2018-04-13 09:19:50 +00:00
|
|
|
{
|
2019-07-09 05:05:34 +00:00
|
|
|
User = new User
|
2018-04-13 09:19:50 +00:00
|
|
|
{
|
2019-07-09 05:05:34 +00:00
|
|
|
Id = 7151382,
|
|
|
|
Username = @"Mayuri Hana",
|
|
|
|
Country = new Country
|
|
|
|
{
|
|
|
|
FullName = @"Thailand",
|
|
|
|
FlagName = @"TH",
|
|
|
|
},
|
2018-04-13 09:19:50 +00:00
|
|
|
},
|
2019-07-09 05:05:34 +00:00
|
|
|
Rank = ScoreRank.D,
|
|
|
|
PP = 160,
|
|
|
|
MaxCombo = 1234,
|
|
|
|
TotalScore = 123456,
|
|
|
|
Accuracy = 0.6543,
|
2018-04-13 09:19:50 +00:00
|
|
|
},
|
2019-07-09 05:05:34 +00:00
|
|
|
}
|
2018-04-13 09:19:50 +00:00
|
|
|
};
|
2019-02-27 12:07:17 +00:00
|
|
|
|
2019-07-08 09:02:10 +00:00
|
|
|
var myBestScore = new APILegacyUserTopScoreInfo
|
|
|
|
{
|
|
|
|
Score = new APILegacyScoreInfo
|
|
|
|
{
|
|
|
|
User = new User
|
|
|
|
{
|
|
|
|
Id = 7151382,
|
|
|
|
Username = @"Mayuri Hana",
|
|
|
|
Country = new Country
|
|
|
|
{
|
|
|
|
FullName = @"Thailand",
|
|
|
|
FlagName = @"TH",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
Rank = ScoreRank.D,
|
|
|
|
PP = 160,
|
|
|
|
MaxCombo = 1234,
|
|
|
|
TotalScore = 123456,
|
|
|
|
Accuracy = 0.6543,
|
|
|
|
},
|
|
|
|
Position = 1337,
|
|
|
|
};
|
|
|
|
|
2019-07-09 05:05:34 +00:00
|
|
|
var oneScore = new APILegacyScores
|
|
|
|
{
|
|
|
|
Scores = new List<APILegacyScoreInfo>
|
|
|
|
{
|
|
|
|
new APILegacyScoreInfo
|
|
|
|
{
|
|
|
|
User = new User
|
|
|
|
{
|
|
|
|
Id = 6602580,
|
|
|
|
Username = @"waaiiru",
|
|
|
|
Country = new Country
|
|
|
|
{
|
|
|
|
FullName = @"Spain",
|
|
|
|
FlagName = @"ES",
|
|
|
|
},
|
|
|
|
},
|
2019-12-03 06:28:10 +00:00
|
|
|
Mods = new[]
|
2019-07-09 05:05:34 +00:00
|
|
|
{
|
2019-12-03 06:28:10 +00:00
|
|
|
new OsuModDoubleTime().Acronym,
|
|
|
|
new OsuModHidden().Acronym,
|
|
|
|
new OsuModFlashlight().Acronym,
|
|
|
|
new OsuModHardRock().Acronym,
|
2019-07-09 05:05:34 +00:00
|
|
|
},
|
|
|
|
Rank = ScoreRank.XH,
|
|
|
|
PP = 200,
|
|
|
|
MaxCombo = 1234,
|
|
|
|
TotalScore = 1234567890,
|
|
|
|
Accuracy = 1,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
foreach (var s in allScores.Scores)
|
2018-04-13 09:19:50 +00:00
|
|
|
{
|
2019-12-03 07:18:36 +00:00
|
|
|
s.Statistics = new Dictionary<string, int>
|
|
|
|
{
|
|
|
|
{ "count_300", RNG.Next(2000) },
|
|
|
|
{ "count_100", RNG.Next(2000) },
|
|
|
|
{ "count_50", RNG.Next(2000) },
|
|
|
|
{ "count_miss", RNG.Next(2000) }
|
|
|
|
};
|
2018-04-13 09:19:50 +00:00
|
|
|
}
|
|
|
|
|
2019-07-08 09:02:10 +00:00
|
|
|
AddStep("Load all scores", () =>
|
|
|
|
{
|
2019-07-09 05:05:34 +00:00
|
|
|
allScores.UserScore = null;
|
|
|
|
scoresContainer.Scores = allScores;
|
2019-07-08 09:02:10 +00:00
|
|
|
});
|
2019-07-09 05:05:34 +00:00
|
|
|
AddStep("Load null scores", () => scoresContainer.Scores = null);
|
|
|
|
AddStep("Load only one score", () => scoresContainer.Scores = oneScore);
|
|
|
|
AddStep("Load scores with my best", () =>
|
2019-07-08 09:02:10 +00:00
|
|
|
{
|
2019-07-09 05:05:34 +00:00
|
|
|
allScores.UserScore = myBestScore;
|
|
|
|
scoresContainer.Scores = allScores;
|
2019-07-08 09:02:10 +00:00
|
|
|
});
|
2018-04-13 09:19:50 +00:00
|
|
|
}
|
2019-07-10 16:40:29 +00:00
|
|
|
|
|
|
|
private class TestScoresContainer : ScoresContainer
|
|
|
|
{
|
|
|
|
public new APILegacyScores Scores
|
|
|
|
{
|
|
|
|
set => base.Scores = value;
|
|
|
|
}
|
|
|
|
}
|
2018-04-13 09:19:50 +00:00
|
|
|
}
|
|
|
|
}
|