1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-14 19:22:54 +08:00

Fix score table using 300/100/50

This commit is contained in:
smoogipoo 2019-04-03 16:09:19 +09:00
parent d6b15f040a
commit 2c18b6df1c
6 changed files with 41 additions and 49 deletions

View File

@ -53,7 +53,7 @@ namespace osu.Game.Tests.Visual.SongSelect
} }
}; };
IEnumerable<ScoreInfo> scores = new[] var scores = new List<ScoreInfo>
{ {
new ScoreInfo new ScoreInfo
{ {

View File

@ -9,6 +9,6 @@ namespace osu.Game.Online.API.Requests.Responses
public class APILegacyScores public class APILegacyScores
{ {
[JsonProperty(@"scores")] [JsonProperty(@"scores")]
public IEnumerable<APILegacyScoreInfo> Scores; public List<APILegacyScoreInfo> Scores;
} }
} }

View File

@ -48,25 +48,28 @@ namespace osu.Game.Overlays.BeatmapSet.Scores
}; };
} }
public IEnumerable<ScoreInfo> Scores public IReadOnlyList<ScoreInfo> Scores
{ {
set set
{ {
if (value == null || !value.Any()) if (value == null || !value.Any())
return; return;
var content = new List<Drawable[]> { new ScoreTableHeaderRow().CreateDrawables().ToArray() }; var content = new List<Drawable[]>
{
int index = 0; new ScoreTableHeaderRow(value.First()).CreateDrawables().ToArray()
foreach (var s in value) };
content.Add(new ScoreTableScoreRow(index++, s).CreateDrawables().ToArray());
scoresGrid.Content = content.ToArray();
backgroundFlow.Clear(); backgroundFlow.Clear();
for (int i = 0; i < index; i++)
for (int i = 0; i < value.Count; i++)
{
content.Add(new ScoreTableScoreRow(i, value[i]).CreateDrawables().ToArray());
backgroundFlow.Add(new ScoreTableRowBackground(i)); backgroundFlow.Add(new ScoreTableRowBackground(i));
} }
scoresGrid.Content = content.ToArray();
}
} }
private class ScoresGrid : GridContainer private class ScoresGrid : GridContainer

View File

@ -2,15 +2,24 @@
// 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.Collections.Generic; using System.Collections.Generic;
using osu.Framework.Extensions;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Containers;
using osu.Game.Graphics; using osu.Game.Graphics;
using osu.Game.Graphics.Sprites; using osu.Game.Graphics.Sprites;
using osu.Game.Scoring;
namespace osu.Game.Overlays.BeatmapSet.Scores namespace osu.Game.Overlays.BeatmapSet.Scores
{ {
public class ScoreTableHeaderRow : ScoreTableRow public class ScoreTableHeaderRow : ScoreTableRow
{ {
private readonly ScoreInfo score;
public ScoreTableHeaderRow(ScoreInfo score)
{
this.score = score;
}
protected override Drawable CreateIndexCell() => new CellText("rank"); protected override Drawable CreateIndexCell() => new CellText("rank");
protected override Drawable CreateRankCell() => new Container(); protected override Drawable CreateRankCell() => new Container();
@ -21,14 +30,13 @@ namespace osu.Game.Overlays.BeatmapSet.Scores
protected override Drawable CreatePlayerCell() => new CellText("player"); protected override Drawable CreatePlayerCell() => new CellText("player");
protected override IEnumerable<Drawable> CreateStatisticsCells() => new[] protected override IEnumerable<Drawable> CreateStatisticsCells()
{ {
new CellText("max combo"), yield return new CellText("max combo");
new CellText("300"),
new CellText("100"), foreach (var kvp in score.Statistics)
new CellText("50"), yield return new CellText(kvp.Key.GetDescription());
new CellText("miss"), }
};
protected override Drawable CreatePpCell() => new CellText("pp"); protected override Drawable CreatePpCell() => new CellText("pp");

View File

@ -10,7 +10,6 @@ using osu.Framework.Input.Events;
using osu.Game.Graphics; using osu.Game.Graphics;
using osu.Game.Graphics.Sprites; using osu.Game.Graphics.Sprites;
using osu.Game.Online.Leaderboards; using osu.Game.Online.Leaderboards;
using osu.Game.Rulesets.Scoring;
using osu.Game.Rulesets.UI; using osu.Game.Rulesets.UI;
using osu.Game.Scoring; using osu.Game.Scoring;
using osu.Game.Users; using osu.Game.Users;
@ -74,34 +73,16 @@ namespace osu.Game.Overlays.BeatmapSet.Scores
Font = OsuFont.GetFont(size: TEXT_SIZE) Font = OsuFont.GetFont(size: TEXT_SIZE)
}; };
foreach (var kvp in score.Statistics)
{
yield return new OsuSpriteText yield return new OsuSpriteText
{ {
Text = $"{score.Statistics[HitResult.Great]}", Text = $"{kvp.Value}",
Font = OsuFont.GetFont(size: TEXT_SIZE), Font = OsuFont.GetFont(size: TEXT_SIZE),
Colour = score.Statistics[HitResult.Great] == 0 ? Color4.Gray : Color4.White Colour = kvp.Value == 0 ? Color4.Gray : Color4.White
};
yield return new OsuSpriteText
{
Text = $"{score.Statistics[HitResult.Good]}",
Font = OsuFont.GetFont(size: TEXT_SIZE),
Colour = score.Statistics[HitResult.Good] == 0 ? Color4.Gray : Color4.White
};
yield return new OsuSpriteText
{
Text = $"{score.Statistics[HitResult.Meh]}",
Font = OsuFont.GetFont(size: TEXT_SIZE),
Colour = score.Statistics[HitResult.Meh] == 0 ? Color4.Gray : Color4.White
};
yield return new OsuSpriteText
{
Text = $"{score.Statistics[HitResult.Miss]}",
Font = OsuFont.GetFont(size: TEXT_SIZE),
Colour = score.Statistics[HitResult.Miss] == 0 ? Color4.Gray : Color4.White
}; };
} }
}
protected override Drawable CreatePpCell() => new OsuSpriteText protected override Drawable CreatePpCell() => new OsuSpriteText
{ {

View File

@ -83,9 +83,9 @@ namespace osu.Game.Overlays.BeatmapSet.Scores
} }
private GetScoresRequest getScoresRequest; private GetScoresRequest getScoresRequest;
private IEnumerable<ScoreInfo> scores; private IReadOnlyList<ScoreInfo> scores;
public IEnumerable<ScoreInfo> Scores public IReadOnlyList<ScoreInfo> Scores
{ {
get => scores; get => scores;
set set
@ -121,11 +121,11 @@ namespace osu.Game.Overlays.BeatmapSet.Scores
private void updateDisplay() private void updateDisplay()
{ {
scoreTable.Scores = Enumerable.Empty<ScoreInfo>(); scoreTable.Scores = new List<ScoreInfo>();
loading = false; loading = false;
var scoreCount = scores?.Count() ?? 0; var scoreCount = scores?.Count ?? 0;
if (scoreCount == 0) if (scoreCount == 0)
{ {