Skip to content

Commit daf85c3

Browse files
authored
Merge pull request #22237 from mk56-spn/LeaderBoardScore_clean
New leaderboard score card design implementation
2 parents 7fc6ad5 + 5f8f6ca commit daf85c3

File tree

4 files changed

+943
-9
lines changed

4 files changed

+943
-9
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,184 @@
1+
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
2+
// See the LICENCE file in the repository root for full licence text.
3+
4+
using System;
5+
using System.Linq;
6+
using NUnit.Framework;
7+
using osu.Framework.Allocation;
8+
using osu.Framework.Graphics;
9+
using osu.Framework.Graphics.Containers;
10+
using osu.Framework.Testing;
11+
using osu.Framework.Utils;
12+
using osu.Game.Configuration;
13+
using osu.Game.Graphics.Sprites;
14+
using osu.Game.Online.API.Requests.Responses;
15+
using osu.Game.Overlays;
16+
using osu.Game.Rulesets.Mania;
17+
using osu.Game.Rulesets.Mods;
18+
using osu.Game.Rulesets.Osu;
19+
using osu.Game.Rulesets.Osu.Mods;
20+
using osu.Game.Rulesets.Scoring;
21+
using osu.Game.Scoring;
22+
using osu.Game.Screens.SelectV2.Leaderboards;
23+
using osu.Game.Tests.Resources;
24+
using osu.Game.Users;
25+
using osuTK;
26+
27+
namespace osu.Game.Tests.Visual.SongSelect
28+
{
29+
public partial class TestSceneLeaderboardScoreV2 : OsuTestScene
30+
{
31+
[Cached]
32+
private OverlayColourProvider colourProvider { get; set; } = new OverlayColourProvider(OverlayColourScheme.Aquamarine);
33+
34+
[Resolved]
35+
private OsuConfigManager config { get; set; } = null!;
36+
37+
private FillFlowContainer? fillFlow;
38+
private OsuSpriteText? drawWidthText;
39+
private float relativeWidth;
40+
41+
[BackgroundDependencyLoader]
42+
private void load()
43+
{
44+
// TODO: invalidation seems to be one-off when clicking slider to a certain value, so drag for now
45+
// doesn't seem to happen in-game (when toggling window mode)
46+
AddSliderStep("change relative width", 0, 1f, 0.6f, v =>
47+
{
48+
relativeWidth = v;
49+
if (fillFlow != null) fillFlow.Width = v;
50+
});
51+
}
52+
53+
[SetUp]
54+
public void Setup() => Schedule(() =>
55+
{
56+
Children = new Drawable[]
57+
{
58+
fillFlow = new FillFlowContainer
59+
{
60+
Width = relativeWidth,
61+
Anchor = Anchor.Centre,
62+
Origin = Anchor.Centre,
63+
RelativeSizeAxes = Axes.X,
64+
AutoSizeAxes = Axes.Y,
65+
Spacing = new Vector2(0f, 2f),
66+
Shear = new Vector2(OsuGame.SHEAR, 0)
67+
},
68+
drawWidthText = new OsuSpriteText(),
69+
};
70+
71+
foreach (var scoreInfo in getTestScores())
72+
{
73+
fillFlow.Add(new LeaderboardScoreV2(scoreInfo, scoreInfo.Position, scoreInfo.User.Id == 2)
74+
{
75+
Shear = Vector2.Zero,
76+
});
77+
}
78+
79+
foreach (var score in fillFlow.Children)
80+
score.Show();
81+
});
82+
83+
[SetUpSteps]
84+
public void SetUpSteps()
85+
{
86+
AddToggleStep("toggle scoring mode", v => config.SetValue(OsuSetting.ScoreDisplayMode, v ? ScoringMode.Classic : ScoringMode.Standardised));
87+
}
88+
89+
protected override void UpdateAfterChildren()
90+
{
91+
base.UpdateAfterChildren();
92+
93+
if (drawWidthText != null) drawWidthText.Text = $"DrawWidth: {fillFlow?.DrawWidth}";
94+
}
95+
96+
private static ScoreInfo[] getTestScores()
97+
{
98+
var scores = new[]
99+
{
100+
new ScoreInfo
101+
{
102+
Position = 999,
103+
Rank = ScoreRank.X,
104+
Accuracy = 1,
105+
MaxCombo = 244,
106+
TotalScore = RNG.Next(1_800_000, 2_000_000),
107+
MaximumStatistics = { { HitResult.Great, 3000 } },
108+
Ruleset = new OsuRuleset().RulesetInfo,
109+
User = new APIUser
110+
{
111+
Id = 6602580,
112+
Username = @"waaiiru",
113+
CountryCode = CountryCode.ES,
114+
CoverUrl = @"https://osu.ppy.sh/images/headers/profile-covers/c1.jpg",
115+
},
116+
Date = DateTimeOffset.Now.AddYears(-2),
117+
},
118+
new ScoreInfo
119+
{
120+
Position = 22333,
121+
Rank = ScoreRank.S,
122+
Accuracy = 0.1f,
123+
MaxCombo = 32040,
124+
TotalScore = RNG.Next(1_200_000, 1_500_000),
125+
MaximumStatistics = { { HitResult.Great, 3000 } },
126+
Ruleset = new OsuRuleset().RulesetInfo,
127+
User = new APIUser
128+
{
129+
Id = 1541390,
130+
Username = @"Toukai",
131+
CountryCode = CountryCode.CA,
132+
CoverUrl = @"https://osu.ppy.sh/images/headers/profile-covers/c2.jpg",
133+
},
134+
Date = DateTimeOffset.Now.AddMonths(-6),
135+
},
136+
TestResources.CreateTestScoreInfo(),
137+
new ScoreInfo
138+
{
139+
Position = 110000,
140+
Rank = ScoreRank.B,
141+
Accuracy = 1,
142+
MaxCombo = 244,
143+
TotalScore = RNG.Next(1_000_000, 1_200_000),
144+
MaximumStatistics = { { HitResult.Great, 3000 } },
145+
Ruleset = new ManiaRuleset().RulesetInfo,
146+
User = new APIUser
147+
{
148+
Username = @"No cover",
149+
CountryCode = CountryCode.BR,
150+
},
151+
Date = DateTimeOffset.Now,
152+
},
153+
new ScoreInfo
154+
{
155+
Position = 110000,
156+
Rank = ScoreRank.D,
157+
Accuracy = 1,
158+
MaxCombo = 244,
159+
TotalScore = RNG.Next(500_000, 1_000_000),
160+
MaximumStatistics = { { HitResult.Great, 3000 } },
161+
Ruleset = new ManiaRuleset().RulesetInfo,
162+
User = new APIUser
163+
{
164+
Id = 226597,
165+
Username = @"WWWWWWWWWWWWWWWWWWWW",
166+
CountryCode = CountryCode.US,
167+
},
168+
Date = DateTimeOffset.Now,
169+
},
170+
};
171+
172+
scores[2].Rank = ScoreRank.A;
173+
scores[2].TotalScore = RNG.Next(120_000, 400_000);
174+
scores[2].MaximumStatistics[HitResult.Great] = 3000;
175+
176+
scores[1].Mods = new Mod[] { new OsuModHidden(), new OsuModDoubleTime(), new OsuModHardRock(), new OsuModFlashlight() };
177+
scores[2].Mods = new Mod[] { new OsuModHidden(), new OsuModDoubleTime(), new OsuModHardRock(), new OsuModFlashlight(), new OsuModClassic() };
178+
scores[3].Mods = new Mod[] { new OsuModHidden(), new OsuModDoubleTime(), new OsuModHardRock(), new OsuModFlashlight(), new OsuModClassic(), new OsuModDifficultyAdjust() };
179+
scores[4].Mods = new ManiaRuleset().CreateAllMods().ToArray();
180+
181+
return scores;
182+
}
183+
}
184+
}

osu.Game/Online/Leaderboards/DrawableRank.cs

+2-6
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,8 @@ namespace osu.Game.Online.Leaderboards
1818
{
1919
public partial class DrawableRank : CompositeDrawable
2020
{
21-
private readonly ScoreRank rank;
22-
2321
public DrawableRank(ScoreRank rank)
2422
{
25-
this.rank = rank;
26-
2723
RelativeSizeAxes = Axes.Both;
2824
FillMode = FillMode.Fit;
2925
FillAspectRatio = 2;
@@ -57,7 +53,7 @@ public DrawableRank(ScoreRank rank)
5753
Origin = Anchor.Centre,
5854
Spacing = new Vector2(-3, 0),
5955
Padding = new MarginPadding { Top = 5 },
60-
Colour = getRankNameColour(),
56+
Colour = GetRankNameColour(rank),
6157
Font = OsuFont.Numeric.With(size: 25),
6258
Text = GetRankName(rank),
6359
ShadowColour = Color4.Black.Opacity(0.3f),
@@ -74,7 +70,7 @@ public DrawableRank(ScoreRank rank)
7470
/// <summary>
7571
/// Retrieves the grade text colour.
7672
/// </summary>
77-
private ColourInfo getRankNameColour()
73+
public static ColourInfo GetRankNameColour(ScoreRank rank)
7874
{
7975
switch (rank)
8076
{

osu.Game/Rulesets/UI/ModSwitchTiny.cs

+3-3
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ public partial class ModSwitchTiny : CompositeDrawable
2222
public BindableBool Active { get; } = new BindableBool();
2323

2424
public const float DEFAULT_HEIGHT = 30;
25-
private const float width = 73;
25+
public const float WIDTH = 73;
2626

2727
protected readonly IMod Mod;
2828
private readonly bool showExtendedInformation;
@@ -56,7 +56,7 @@ public ModSwitchTiny(IMod mod, bool showExtendedInformation = false)
5656
Width = 100 + DEFAULT_HEIGHT / 2,
5757
RelativeSizeAxes = Axes.Y,
5858
Masking = true,
59-
X = width,
59+
X = WIDTH,
6060
Margin = new MarginPadding { Left = -DEFAULT_HEIGHT },
6161
Children = new Drawable[]
6262
{
@@ -77,7 +77,7 @@ public ModSwitchTiny(IMod mod, bool showExtendedInformation = false)
7777
},
7878
new CircularContainer
7979
{
80-
Width = width,
80+
Width = WIDTH,
8181
RelativeSizeAxes = Axes.Y,
8282
Masking = true,
8383
Children = new Drawable[]

0 commit comments

Comments
 (0)