2023-01-16 23:57:18 +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.
|
|
|
|
|
2023-09-23 10:56:33 +08:00
|
|
|
using System;
|
2023-10-11 10:17:50 +08:00
|
|
|
using System.Linq;
|
2023-10-11 11:41:19 +08:00
|
|
|
using NUnit.Framework;
|
2023-01-16 23:57:18 +08:00
|
|
|
using osu.Framework.Allocation;
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
using osu.Framework.Graphics.Containers;
|
2024-05-25 22:09:02 +08:00
|
|
|
using osu.Framework.Utils;
|
|
|
|
using osu.Game.Configuration;
|
2023-10-11 06:05:34 +08:00
|
|
|
using osu.Game.Graphics.Sprites;
|
2023-01-17 00:35:27 +08:00
|
|
|
using osu.Game.Online.API.Requests.Responses;
|
2023-09-24 10:40:57 +08:00
|
|
|
using osu.Game.Overlays;
|
2023-01-23 18:35:42 +08:00
|
|
|
using osu.Game.Rulesets.Mania;
|
2023-01-17 00:35:27 +08:00
|
|
|
using osu.Game.Rulesets.Mods;
|
|
|
|
using osu.Game.Rulesets.Osu;
|
|
|
|
using osu.Game.Rulesets.Osu.Mods;
|
2024-05-25 22:09:02 +08:00
|
|
|
using osu.Game.Rulesets.Scoring;
|
2023-01-17 00:35:27 +08:00
|
|
|
using osu.Game.Scoring;
|
2024-05-25 22:18:51 +08:00
|
|
|
using osu.Game.Screens.SelectV2.Leaderboards;
|
2023-10-11 05:58:22 +08:00
|
|
|
using osu.Game.Tests.Resources;
|
2023-01-17 00:35:27 +08:00
|
|
|
using osu.Game.Users;
|
2023-01-17 00:15:37 +08:00
|
|
|
using osuTK;
|
2023-01-16 23:57:18 +08:00
|
|
|
|
2024-08-14 14:51:07 +08:00
|
|
|
namespace osu.Game.Tests.Visual.SongSelectV2
|
2023-01-16 23:57:18 +08:00
|
|
|
{
|
2024-08-14 20:09:28 +08:00
|
|
|
public partial class TestSceneLeaderboardScore : SongSelectComponentsTestScene
|
2023-01-16 23:57:18 +08:00
|
|
|
{
|
2023-09-24 10:40:57 +08:00
|
|
|
[Cached]
|
|
|
|
private OverlayColourProvider colourProvider { get; set; } = new OverlayColourProvider(OverlayColourScheme.Aquamarine);
|
|
|
|
|
2024-05-25 22:09:02 +08:00
|
|
|
[Resolved]
|
|
|
|
private OsuConfigManager config { get; set; } = null!;
|
|
|
|
|
2023-10-11 11:41:19 +08:00
|
|
|
private FillFlowContainer? fillFlow;
|
|
|
|
private OsuSpriteText? drawWidthText;
|
|
|
|
|
2024-06-06 17:06:22 +08:00
|
|
|
[Test]
|
|
|
|
public void TestSheared()
|
2023-10-11 05:58:22 +08:00
|
|
|
{
|
2024-06-06 17:06:22 +08:00
|
|
|
AddStep("create content", () =>
|
2023-10-11 05:58:22 +08:00
|
|
|
{
|
2024-06-06 17:06:22 +08:00
|
|
|
Children = new Drawable[]
|
2023-10-11 06:05:34 +08:00
|
|
|
{
|
2024-06-06 17:06:22 +08:00
|
|
|
fillFlow = new FillFlowContainer
|
|
|
|
{
|
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
Origin = Anchor.Centre,
|
|
|
|
RelativeSizeAxes = Axes.X,
|
|
|
|
AutoSizeAxes = Axes.Y,
|
|
|
|
Spacing = new Vector2(0f, 2f),
|
|
|
|
Shear = new Vector2(OsuGame.SHEAR, 0)
|
|
|
|
},
|
|
|
|
drawWidthText = new OsuSpriteText(),
|
|
|
|
};
|
2023-10-11 05:58:22 +08:00
|
|
|
|
2024-06-06 17:06:22 +08:00
|
|
|
foreach (var scoreInfo in getTestScores())
|
|
|
|
{
|
|
|
|
fillFlow.Add(new LeaderboardScoreV2(scoreInfo)
|
|
|
|
{
|
|
|
|
Rank = scoreInfo.Position,
|
|
|
|
IsPersonalBest = scoreInfo.User.Id == 2,
|
|
|
|
Shear = Vector2.Zero,
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
foreach (var score in fillFlow.Children)
|
|
|
|
score.Show();
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
public void TestNonSheared()
|
|
|
|
{
|
|
|
|
AddStep("create content", () =>
|
2024-05-25 17:36:09 +08:00
|
|
|
{
|
2024-06-06 17:06:22 +08:00
|
|
|
Children = new Drawable[]
|
|
|
|
{
|
|
|
|
fillFlow = new FillFlowContainer
|
|
|
|
{
|
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
Origin = Anchor.Centre,
|
|
|
|
RelativeSizeAxes = Axes.X,
|
|
|
|
AutoSizeAxes = Axes.Y,
|
|
|
|
Spacing = new Vector2(0f, 2f),
|
|
|
|
},
|
|
|
|
drawWidthText = new OsuSpriteText(),
|
|
|
|
};
|
|
|
|
|
|
|
|
foreach (var scoreInfo in getTestScores())
|
2024-05-25 17:36:09 +08:00
|
|
|
{
|
2024-06-06 17:06:22 +08:00
|
|
|
fillFlow.Add(new LeaderboardScoreV2(scoreInfo)
|
|
|
|
{
|
|
|
|
Rank = scoreInfo.Position,
|
|
|
|
IsPersonalBest = scoreInfo.User.Id == 2,
|
|
|
|
});
|
|
|
|
}
|
2023-10-11 05:58:22 +08:00
|
|
|
|
2024-06-06 17:06:22 +08:00
|
|
|
foreach (var score in fillFlow.Children)
|
|
|
|
score.Show();
|
|
|
|
});
|
|
|
|
}
|
2023-10-11 05:58:22 +08:00
|
|
|
|
2024-08-14 20:09:28 +08:00
|
|
|
public override void SetUpSteps()
|
2024-05-25 22:28:03 +08:00
|
|
|
{
|
|
|
|
AddToggleStep("toggle scoring mode", v => config.SetValue(OsuSetting.ScoreDisplayMode, v ? ScoringMode.Classic : ScoringMode.Standardised));
|
|
|
|
}
|
|
|
|
|
2023-10-11 06:05:34 +08:00
|
|
|
protected override void UpdateAfterChildren()
|
|
|
|
{
|
|
|
|
base.UpdateAfterChildren();
|
|
|
|
|
2023-10-11 11:41:19 +08:00
|
|
|
if (drawWidthText != null) drawWidthText.Text = $"DrawWidth: {fillFlow?.DrawWidth}";
|
2023-10-11 06:05:34 +08:00
|
|
|
}
|
|
|
|
|
2023-10-11 05:58:22 +08:00
|
|
|
private static ScoreInfo[] getTestScores()
|
2023-01-16 23:57:18 +08:00
|
|
|
{
|
2023-01-17 00:35:27 +08:00
|
|
|
var scores = new[]
|
|
|
|
{
|
|
|
|
new ScoreInfo
|
|
|
|
{
|
|
|
|
Position = 999,
|
2023-10-11 10:17:50 +08:00
|
|
|
Rank = ScoreRank.X,
|
2023-01-17 00:35:27 +08:00
|
|
|
Accuracy = 1,
|
|
|
|
MaxCombo = 244,
|
2024-05-25 22:09:02 +08:00
|
|
|
TotalScore = RNG.Next(1_800_000, 2_000_000),
|
|
|
|
MaximumStatistics = { { HitResult.Great, 3000 } },
|
2023-01-17 00:35:27 +08:00
|
|
|
Ruleset = new OsuRuleset().RulesetInfo,
|
|
|
|
User = new APIUser
|
|
|
|
{
|
|
|
|
Id = 6602580,
|
|
|
|
Username = @"waaiiru",
|
|
|
|
CountryCode = CountryCode.ES,
|
2023-09-23 07:34:06 +08:00
|
|
|
CoverUrl = @"https://osu.ppy.sh/images/headers/profile-covers/c1.jpg",
|
2023-01-17 00:35:27 +08:00
|
|
|
},
|
2023-09-23 10:56:33 +08:00
|
|
|
Date = DateTimeOffset.Now.AddYears(-2),
|
2023-01-17 00:35:27 +08:00
|
|
|
},
|
|
|
|
new ScoreInfo
|
|
|
|
{
|
|
|
|
Position = 22333,
|
|
|
|
Rank = ScoreRank.S,
|
2023-01-17 02:03:17 +08:00
|
|
|
Accuracy = 0.1f,
|
2023-01-18 03:13:50 +08:00
|
|
|
MaxCombo = 32040,
|
2024-05-25 22:09:02 +08:00
|
|
|
TotalScore = RNG.Next(1_200_000, 1_500_000),
|
|
|
|
MaximumStatistics = { { HitResult.Great, 3000 } },
|
2023-01-17 00:35:27 +08:00
|
|
|
Ruleset = new OsuRuleset().RulesetInfo,
|
|
|
|
User = new APIUser
|
|
|
|
{
|
|
|
|
Id = 1541390,
|
|
|
|
Username = @"Toukai",
|
|
|
|
CountryCode = CountryCode.CA,
|
2023-09-23 07:34:06 +08:00
|
|
|
CoverUrl = @"https://osu.ppy.sh/images/headers/profile-covers/c2.jpg",
|
2023-01-17 00:35:27 +08:00
|
|
|
},
|
2023-09-23 10:56:33 +08:00
|
|
|
Date = DateTimeOffset.Now.AddMonths(-6),
|
2023-01-23 18:35:42 +08:00
|
|
|
},
|
2024-05-25 22:09:02 +08:00
|
|
|
TestResources.CreateTestScoreInfo(),
|
2023-01-23 18:35:42 +08:00
|
|
|
new ScoreInfo
|
|
|
|
{
|
|
|
|
Position = 110000,
|
2024-05-25 22:09:02 +08:00
|
|
|
Rank = ScoreRank.B,
|
2023-01-23 18:35:42 +08:00
|
|
|
Accuracy = 1,
|
|
|
|
MaxCombo = 244,
|
2024-05-25 22:09:02 +08:00
|
|
|
TotalScore = RNG.Next(1_000_000, 1_200_000),
|
|
|
|
MaximumStatistics = { { HitResult.Great, 3000 } },
|
2023-01-23 18:35:42 +08:00
|
|
|
Ruleset = new ManiaRuleset().RulesetInfo,
|
|
|
|
User = new APIUser
|
|
|
|
{
|
2023-09-23 07:34:06 +08:00
|
|
|
Username = @"No cover",
|
2023-01-23 18:35:42 +08:00
|
|
|
CountryCode = CountryCode.BR,
|
|
|
|
},
|
2023-09-23 10:56:33 +08:00
|
|
|
Date = DateTimeOffset.Now,
|
2023-01-23 18:35:42 +08:00
|
|
|
},
|
2023-10-11 09:02:59 +08:00
|
|
|
new ScoreInfo
|
|
|
|
{
|
|
|
|
Position = 110000,
|
2024-05-25 22:09:02 +08:00
|
|
|
Rank = ScoreRank.D,
|
2023-10-11 09:02:59 +08:00
|
|
|
Accuracy = 1,
|
|
|
|
MaxCombo = 244,
|
2024-05-25 22:09:02 +08:00
|
|
|
TotalScore = RNG.Next(500_000, 1_000_000),
|
|
|
|
MaximumStatistics = { { HitResult.Great, 3000 } },
|
2023-10-11 09:02:59 +08:00
|
|
|
Ruleset = new ManiaRuleset().RulesetInfo,
|
|
|
|
User = new APIUser
|
|
|
|
{
|
|
|
|
Id = 226597,
|
|
|
|
Username = @"WWWWWWWWWWWWWWWWWWWW",
|
|
|
|
CountryCode = CountryCode.US,
|
|
|
|
},
|
|
|
|
Date = DateTimeOffset.Now,
|
|
|
|
},
|
2023-01-17 00:35:27 +08:00
|
|
|
};
|
|
|
|
|
2024-05-25 22:09:02 +08:00
|
|
|
scores[2].Rank = ScoreRank.A;
|
|
|
|
scores[2].TotalScore = RNG.Next(120_000, 400_000);
|
|
|
|
scores[2].MaximumStatistics[HitResult.Great] = 3000;
|
2023-10-12 03:38:46 +08:00
|
|
|
|
2024-05-25 21:11:24 +08:00
|
|
|
scores[1].Mods = new Mod[] { new OsuModHidden(), new OsuModDoubleTime(), new OsuModHardRock(), new OsuModFlashlight() };
|
|
|
|
scores[2].Mods = new Mod[] { new OsuModHidden(), new OsuModDoubleTime(), new OsuModHardRock(), new OsuModFlashlight(), new OsuModClassic() };
|
|
|
|
scores[3].Mods = new Mod[] { new OsuModHidden(), new OsuModDoubleTime(), new OsuModHardRock(), new OsuModFlashlight(), new OsuModClassic(), new OsuModDifficultyAdjust() };
|
2024-05-25 22:09:02 +08:00
|
|
|
scores[4].Mods = new ManiaRuleset().CreateAllMods().ToArray();
|
2023-10-11 10:17:50 +08:00
|
|
|
|
2023-10-11 05:58:22 +08:00
|
|
|
return scores;
|
2023-01-16 23:57:18 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|