mirror of
https://github.com/ppy/osu.git
synced 2025-01-28 09:02:58 +08:00
Add spacing between RankingsTable rows to match osu-web
This commit is contained in:
parent
f03ada65dd
commit
9e4a6a9cf3
@ -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.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
@ -20,7 +20,8 @@ namespace osu.Game.Overlays.Rankings.Tables
|
|||||||
{
|
{
|
||||||
protected const int TEXT_SIZE = 12;
|
protected const int TEXT_SIZE = 12;
|
||||||
private const float horizontal_inset = 20;
|
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 const int items_per_page = 50;
|
||||||
|
|
||||||
private readonly int page;
|
private readonly int page;
|
||||||
@ -35,7 +36,7 @@ namespace osu.Game.Overlays.Rankings.Tables
|
|||||||
AutoSizeAxes = Axes.Y;
|
AutoSizeAxes = Axes.Y;
|
||||||
|
|
||||||
Padding = new MarginPadding { Horizontal = horizontal_inset };
|
Padding = new MarginPadding { Horizontal = horizontal_inset };
|
||||||
RowSize = new Dimension(GridSizeMode.Absolute, row_height);
|
RowSize = new Dimension(GridSizeMode.Absolute, row_height + row_spacing);
|
||||||
}
|
}
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
@ -47,10 +48,11 @@ namespace osu.Game.Overlays.Rankings.Tables
|
|||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.Both,
|
RelativeSizeAxes = Axes.Both,
|
||||||
Depth = 1f,
|
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();
|
Columns = mainHeaders.Concat(CreateAdditionalHeaders()).ToArray();
|
||||||
Content = rankings.Select((s, i) => createContent((page - 1) * items_per_page + i, s)).ToArray().ToRectangular();
|
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 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 Country GetCountry(TModel item);
|
||||||
|
|
||||||
protected abstract Drawable CreateFlagContent(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}",
|
Text = $"#{index + 1}",
|
||||||
Font = OsuFont.GetFont(size: TEXT_SIZE, weight: FontWeight.SemiBold)
|
Font = OsuFont.GetFont(size: TEXT_SIZE, weight: FontWeight.SemiBold)
|
||||||
@ -84,12 +86,13 @@ namespace osu.Game.Overlays.Rankings.Tables
|
|||||||
{
|
{
|
||||||
AutoSizeAxes = Axes.Both,
|
AutoSizeAxes = Axes.Both,
|
||||||
Direction = FillDirection.Horizontal,
|
Direction = FillDirection.Horizontal,
|
||||||
Spacing = new Vector2(7, 0),
|
Spacing = new Vector2(10, 0),
|
||||||
|
Margin = new MarginPadding { Bottom = row_spacing },
|
||||||
Children = new[]
|
Children = new[]
|
||||||
{
|
{
|
||||||
new UpdateableFlag(GetCountry(item))
|
new UpdateableFlag(GetCountry(item))
|
||||||
{
|
{
|
||||||
Size = new Vector2(20, 13),
|
Size = new Vector2(30, 20),
|
||||||
ShowPlaceholderOnNull = false,
|
ShowPlaceholderOnNull = false,
|
||||||
},
|
},
|
||||||
CreateFlagContent(item)
|
CreateFlagContent(item)
|
||||||
@ -128,7 +131,7 @@ namespace osu.Game.Overlays.Rankings.Tables
|
|||||||
public RowText()
|
public RowText()
|
||||||
{
|
{
|
||||||
Font = OsuFont.GetFont(size: TEXT_SIZE);
|
Font = OsuFont.GetFont(size: TEXT_SIZE);
|
||||||
Margin = new MarginPadding { Horizontal = 10 };
|
Margin = new MarginPadding { Horizontal = 10, Bottom = row_spacing };
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -19,13 +19,14 @@ namespace osu.Game.Overlays.Rankings.Tables
|
|||||||
private Color4 idleColour;
|
private Color4 idleColour;
|
||||||
private Color4 hoverColour;
|
private Color4 hoverColour;
|
||||||
|
|
||||||
public TableRowBackground()
|
public TableRowBackground(float height)
|
||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.X;
|
RelativeSizeAxes = Axes.X;
|
||||||
Height = 25;
|
Height = height;
|
||||||
|
|
||||||
CornerRadius = 3;
|
CornerRadius = 4;
|
||||||
Masking = true;
|
Masking = true;
|
||||||
|
MaskingSmoothness = 0.5f;
|
||||||
|
|
||||||
InternalChild = background = new Box
|
InternalChild = background = new Box
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user