Merge pull request #8038 from thewildtree/adjust-rankings-overlay

Adjust rankings overlay elements to better match osu-web
This commit is contained in:
Dean Herbert
2021-07-07 20:24:11 +09:00
committed by GitHub
8 changed files with 109 additions and 69 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 { Height = 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,19 @@ 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 virtual string HighlightedColumn => @"Performance";
protected override Drawable CreateHeader(int index, TableColumn column)
{
var title = column?.Header ?? string.Empty;
return new HeaderText(title, title == HighlightedColumn);
}
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,37 +92,36 @@ 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)
}
};
protected virtual string HighlightedColumn() => @"Performance";
private class HeaderText : OsuSpriteText
protected class HeaderText : OsuSpriteText
{
private readonly string highlighted;
private readonly bool isHighlighted;
public HeaderText(string text, string highlighted)
public HeaderText(string text, bool isHighlighted)
{
this.highlighted = highlighted;
this.isHighlighted = isHighlighted;
Text = text;
Font = OsuFont.GetFont(size: 12);
Margin = new MarginPadding { Horizontal = 10 };
Margin = new MarginPadding { Vertical = 5, Horizontal = 10 };
}
[BackgroundDependencyLoader]
private void load(OverlayColourProvider colourProvider)
{
if (Text != highlighted)
if (!isHighlighted)
Colour = colourProvider.Foreground1;
}
}
@ -124,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 };
}
}