Make beatmap scores also support null position

This commit is contained in:
smoogipoo 2020-02-20 15:04:12 +09:00
parent 1a689231c2
commit d79ca97fe9
4 changed files with 33 additions and 8 deletions

View File

@ -195,6 +195,29 @@ namespace osu.Game.Tests.Visual.Online
Position = 1337, Position = 1337,
}; };
var myBestScoreWithNullPosition = 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 = null,
};
var oneScore = new APILegacyScores var oneScore = new APILegacyScores
{ {
Scores = new List<APILegacyScoreInfo> Scores = new List<APILegacyScoreInfo>
@ -250,6 +273,12 @@ namespace osu.Game.Tests.Visual.Online
allScores.UserScore = myBestScore; allScores.UserScore = myBestScore;
scoresContainer.Scores = allScores; scoresContainer.Scores = allScores;
}); });
AddStep("Load scores with null my best position", () =>
{
allScores.UserScore = myBestScoreWithNullPosition;
scoresContainer.Scores = allScores;
});
} }
private class TestScoresContainer : ScoresContainer private class TestScoresContainer : ScoresContainer

View File

@ -17,7 +17,7 @@ namespace osu.Game.Overlays.BeatmapSet.Scores
{ {
private readonly Box background; private readonly Box background;
public DrawableTopScore(ScoreInfo score, int position = 1) public DrawableTopScore(ScoreInfo score, int? position = 1)
{ {
RelativeSizeAxes = Axes.X; RelativeSizeAxes = Axes.X;
AutoSizeAxes = Axes.Y; AutoSizeAxes = Axes.Y;

View File

@ -1,7 +1,6 @@
// 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. // See the LICENCE file in the repository root for full licence text.
using System.Diagnostics;
using osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Containers;
@ -71,10 +70,7 @@ namespace osu.Game.Overlays.BeatmapSet.Scores
topScoresContainer.Add(new DrawableTopScore(topScore)); topScoresContainer.Add(new DrawableTopScore(topScore));
if (userScoreInfo != null && userScoreInfo.OnlineScoreID != topScore.OnlineScoreID) if (userScoreInfo != null && userScoreInfo.OnlineScoreID != topScore.OnlineScoreID)
{ topScoresContainer.Add(new DrawableTopScore(userScoreInfo, userScore.Position));
Debug.Assert(userScore.Position != null);
topScoresContainer.Add(new DrawableTopScore(userScoreInfo, userScore.Position.Value));
}
}); });
} }

View File

@ -112,9 +112,9 @@ namespace osu.Game.Overlays.BeatmapSet.Scores
}; };
} }
public int ScorePosition public int? ScorePosition
{ {
set => rankText.Text = $"#{value}"; set => rankText.Text = value == null ? "-" : $"#{value}";
} }
/// <summary> /// <summary>