1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-14 02:22:56 +08:00

Add spacing between RankingsTable rows to match osu-web

This commit is contained in:
TheWildTree 2020-02-27 22:25:49 +01:00
parent f03ada65dd
commit 9e4a6a9cf3
2 changed files with 17 additions and 13 deletions

View File

@ -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.
using osu.Framework.Graphics;
@ -20,7 +20,8 @@ namespace osu.Game.Overlays.Rankings.Tables
{
protected const int TEXT_SIZE = 12;
private const float horizontal_inset = 20;
private const float row_height = 25;
private const float row_height = 32;
private const float row_spacing = 3;
private const int items_per_page = 50;
private readonly int page;
@ -35,7 +36,7 @@ namespace osu.Game.Overlays.Rankings.Tables
AutoSizeAxes = Axes.Y;
Padding = new MarginPadding { Horizontal = horizontal_inset };
RowSize = new Dimension(GridSizeMode.Absolute, row_height);
RowSize = new Dimension(GridSizeMode.Absolute, row_height + row_spacing);
}
[BackgroundDependencyLoader]
@ -47,10 +48,11 @@ namespace osu.Game.Overlays.Rankings.Tables
{
RelativeSizeAxes = Axes.Both,
Depth = 1f,
Margin = new MarginPadding { Top = row_height }
Margin = new MarginPadding { Top = row_height + row_spacing },
Spacing = new Vector2(0, row_spacing),
});
rankings.ForEach(_ => backgroundFlow.Add(new TableRowBackground()));
rankings.ForEach(_ => backgroundFlow.Add(new TableRowBackground(row_height)));
Columns = mainHeaders.Concat(CreateAdditionalHeaders()).ToArray();
Content = rankings.Select((s, i) => createContent((page - 1) * items_per_page + i, s)).ToArray().ToRectangular();
@ -68,13 +70,13 @@ namespace osu.Game.Overlays.Rankings.Tables
protected abstract Drawable[] CreateAdditionalContent(TModel item);
protected override Drawable CreateHeader(int index, TableColumn column) => new HeaderText(column?.Header ?? string.Empty, HighlightedColumn());
protected override Drawable CreateHeader(int index, TableColumn column) => new HeaderText(column?.Header ?? string.Empty, HighlightedColumn(), GradeColumns());
protected abstract Country GetCountry(TModel item);
protected abstract Drawable CreateFlagContent(TModel item);
private OsuSpriteText createIndexDrawable(int index) => new OsuSpriteText
private OsuSpriteText createIndexDrawable(int index) => new RowText
{
Text = $"#{index + 1}",
Font = OsuFont.GetFont(size: TEXT_SIZE, weight: FontWeight.SemiBold)
@ -84,12 +86,13 @@ namespace osu.Game.Overlays.Rankings.Tables
{
AutoSizeAxes = Axes.Both,
Direction = FillDirection.Horizontal,
Spacing = new Vector2(7, 0),
Spacing = new Vector2(10, 0),
Margin = new MarginPadding { Bottom = row_spacing },
Children = new[]
{
new UpdateableFlag(GetCountry(item))
{
Size = new Vector2(20, 13),
Size = new Vector2(30, 20),
ShowPlaceholderOnNull = false,
},
CreateFlagContent(item)
@ -128,7 +131,7 @@ namespace osu.Game.Overlays.Rankings.Tables
public RowText()
{
Font = OsuFont.GetFont(size: TEXT_SIZE);
Margin = new MarginPadding { Horizontal = 10 };
Margin = new MarginPadding { Horizontal = 10, Bottom = row_spacing };
}
}

View File

@ -19,13 +19,14 @@ namespace osu.Game.Overlays.Rankings.Tables
private Color4 idleColour;
private Color4 hoverColour;
public TableRowBackground()
public TableRowBackground(float height)
{
RelativeSizeAxes = Axes.X;
Height = 25;
Height = height;
CornerRadius = 3;
CornerRadius = 4;
Masking = true;
MaskingSmoothness = 0.5f;
InternalChild = background = new Box
{