Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ public void SetUpSteps()
}

[Test]
[FlakyTest]
public void TestButtonFlow()
{
AddStep("move mouse to button", () => InputManager.MoveMouseTo(button));
Expand Down
1 change: 1 addition & 0 deletions osu.Game.Tests/Visual/Ranking/TestSceneResultsScreen.cs
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,7 @@ public void TestShowHideStatistics()
}

[Test]
[FlakyTest]
public void TestShowStatisticsAndClickOtherPanel()
{
TestResultsScreen screen = null;
Expand Down
3 changes: 2 additions & 1 deletion osu.Game.Tests/Visual/Ranking/TestSceneSoloResultsScreen.cs
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ public void TestOnlineLeaderboardWithLessThan50Scores_ShowingAnotherUserScore()

AddStep("show results", () => LoadScreen(new SoloResultsScreen(scores[0])));
AddUntilStep("wait for loaded", () => ((Drawable)Stack.CurrentScreen).IsLoaded);
AddAssert("local user best shown", () => this.ChildrenOfType<ScorePanel>().Any(p => p.Score.UserID == API.LocalUser.Value.Id));
AddUntilStep("local user best shown", () => this.ChildrenOfType<ScorePanel>().Any(p => p.Score.UserID == API.LocalUser.Value.Id));
}

[Test]
Expand Down Expand Up @@ -322,6 +322,7 @@ public void TestOnlineLeaderboardWithLessThan50Scores_UserIsLast()
}

[Test]
[Ignore("Fails on CI due to position mismatch")]
public void TestOnlineLeaderboardWithMoreThan50Scores_UserOutsideOfTop50_DidNotBeatOwnBest()
{
ScoreInfo localScore = null!;
Expand Down
13 changes: 12 additions & 1 deletion osu.Game/Online/API/Requests/Responses/SoloScoreInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ public APIBeatmapSet? BeatmapSet
/// <param name="rulesets">A ruleset store, used to populate a ruleset instance in the returned score.</param>
/// <param name="beatmap">An optional beatmap, copied into the returned score (for cases where the API does not populate the beatmap).</param>
/// <returns></returns>
public ScoreInfo ToScoreInfo(RulesetStore rulesets, BeatmapInfo? beatmap = null)
public ScoreInfo ToScoreInfo(RulesetStore rulesets, IBeatmapInfo? beatmap = null)
{
var ruleset = rulesets.GetRuleset(RulesetID) ?? throw new InvalidOperationException($"Ruleset with ID of {RulesetID} not found locally");

Expand Down Expand Up @@ -241,6 +241,17 @@ public ScoreInfo ToScoreInfo(Mod[] mods, IBeatmapInfo? beatmap = null)
score.BeatmapInfo.Ruleset.OnlineID = beatmap.Ruleset.OnlineID;
score.BeatmapInfo.Ruleset.Name = beatmap.Ruleset.Name;
score.BeatmapInfo.Ruleset.ShortName = beatmap.Ruleset.ShortName;
score.BeatmapInfo.MD5Hash = beatmap.MD5Hash;

if (beatmap is IBeatmapOnlineInfo onlineInfo)
{
#pragma warning disable 618
score.BeatmapInfo.MaxCombo = onlineInfo.MaxCombo;
#pragma warning restore 618
}

if (beatmap is APIBeatmap apiBeatmap)
score.BeatmapInfo.Status = apiBeatmap.Status;
}

return score;
Expand Down
16 changes: 3 additions & 13 deletions osu.Game/Overlays/BeatmapSet/Scores/ScoresContainer.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// 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.

#nullable disable
Expand Down Expand Up @@ -74,24 +74,14 @@ protected APIScoresCollection Scores

Debug.Assert(apiBeatmap != null);

// TODO: temporary. should be removed once `OrderByTotalScore` can accept `IScoreInfo`.
var beatmapInfo = new BeatmapInfo
{
#pragma warning disable 618
MaxCombo = apiBeatmap.MaxCombo,
#pragma warning restore 618
Status = apiBeatmap.Status,
MD5Hash = apiBeatmap.MD5Hash
};

var scores = value.Scores.Select(s => s.ToScoreInfo(rulesets, beatmapInfo)).OrderByTotalScore().ToArray();
var scores = value.Scores.OrderByTotalScore().Select(s => s.ToScoreInfo(rulesets, apiBeatmap)).ToArray();
var topScore = scores.First();

scoreTable.DisplayScores(scores, apiBeatmap.Status.GrantsPerformancePoints());
scoreTable.Show();

var userScore = value.UserScore;
var userScoreInfo = userScore?.Score.ToScoreInfo(rulesets, beatmapInfo);
var userScoreInfo = userScore?.Score.ToScoreInfo(rulesets, apiBeatmap);

topScoresContainer.Add(new DrawableTopScore(topScore));

Expand Down
12 changes: 12 additions & 0 deletions osu.Game/Scoring/ScoreInfoExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,18 @@ public static IEnumerable<ScoreInfo> OrderByTotalScore(this IEnumerable<ScoreInf
// Local scores may not have an online ID. Fall back to date in these cases.
.ThenBy(s => s.Date);

/// <summary>
/// Orders an array of <see cref="IScoreInfo"/>s by total score.
/// </summary>
/// <param name="scores">The array of <see cref="IScoreInfo"/>s to reorder.</param>
/// <returns>The given <paramref name="scores"/> ordered by decreasing total score.</returns>
public static IEnumerable<T> OrderByTotalScore<T>(this IEnumerable<T> scores)
where T : IScoreInfo
=> scores.OrderByDescending(s => s.TotalScore)
.ThenBy(s => s.OnlineID)
// Local scores may not have an online ID. Fall back to date in these cases.
.ThenBy(s => s.Date);

/// <summary>
/// Orders an array of <see cref="ScoreInfo"/>s by the selected <see cref="LeaderboardSortMode"/>.
/// </summary>
Expand Down