Skip to content

Commit 3757c4f

Browse files
authored
Merge pull request #306 from stanriders/add-first-places
Add first place scores to Profile screen
2 parents a1e560b + 4339f81 commit 3757c4f

1 file changed

Lines changed: 22 additions & 2 deletions

File tree

PerformanceCalculatorGUI/Screens/ProfileScreen.cs

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ public partial class ProfileScreen : PerformanceCalculatorScreen
4040

4141
private StatefulButton calculationButton = null!;
4242
private SwitchButton includePinnedCheckbox = null!;
43+
private SwitchButton includeFirstsCheckbox = null!;
4344
private SwitchButton onlyDisplayBestCheckbox = null!;
4445
private VerboseLoadingLayer loadingLayer = null!;
4546

@@ -183,6 +184,20 @@ private void load()
183184
UseFullGlyphHeight = false,
184185
Text = "Include pinned scores"
185186
},
187+
includeFirstsCheckbox = new SwitchButton
188+
{
189+
Anchor = Anchor.CentreLeft,
190+
Origin = Anchor.CentreLeft,
191+
Current = { Value = false },
192+
},
193+
new OsuSpriteText
194+
{
195+
Anchor = Anchor.CentreLeft,
196+
Origin = Anchor.CentreLeft,
197+
Font = OsuFont.Torus.With(weight: FontWeight.SemiBold, size: 14),
198+
UseFullGlyphHeight = false,
199+
Text = "Include first place scores"
200+
},
186201
onlyDisplayBestCheckbox = new SwitchButton
187202
{
188203
Anchor = Anchor.CentreLeft,
@@ -233,8 +248,6 @@ private void load()
233248

234249
usernameTextBox.OnCommit += (_, _) => { calculateProfiles(usernameTextBox.Current.Value.Split(",", StringSplitOptions.RemoveEmptyEntries | StringSplitOptions.TrimEntries)); };
235250
sorting.ValueChanged += e => { updateSorting(e.NewValue); };
236-
includePinnedCheckbox.Current.ValueChanged += e => { calculateProfiles(currentUsers); };
237-
onlyDisplayBestCheckbox.Current.ValueChanged += e => { calculateProfiles(currentUsers); };
238251

239252
if (RuntimeInfo.IsDesktop)
240253
HotReloadCallbackReceiver.CompilationFinished += _ => Schedule(() => { calculateProfiles(currentUsers); });
@@ -313,6 +326,13 @@ private void calculateProfiles(string[] usernames)
313326
apiScores = apiScores.Concat(pinnedScores.Where(p => apiScores.All(b => b.ID != p.ID)).ToArray()).ToList();
314327
}
315328

329+
if (includeFirstsCheckbox.Current.Value)
330+
{
331+
var firstScores = await apiManager.GetJsonFromApi<List<SoloScoreInfo>>($"users/{player.OnlineID}/scores/firsts?mode={ruleset.Value.ShortName}&limit={max_api_scores_in_one_query}")
332+
.ConfigureAwait(false);
333+
apiScores = apiScores.Concat(firstScores.Where(p => apiScores.All(b => b.ID != p.ID)).ToArray()).ToList();
334+
}
335+
316336
foreach (var score in apiScores)
317337
{
318338
if (token.IsCancellationRequested)

0 commit comments

Comments
 (0)