mirror of
https://github.com/ppy/osu.git
synced 2025-03-05 17:23:21 +08:00
Improve HeaderText highlight and spacing logic
This commit is contained in:
parent
276a90fb84
commit
06642dc7ff
@ -70,7 +70,14 @@ 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(), GradeColumns());
|
protected override Drawable CreateHeader(int index, TableColumn column)
|
||||||
|
{
|
||||||
|
var title = column?.Header ?? string.Empty;
|
||||||
|
var isHighlighted = HighlightedColumn() == title;
|
||||||
|
var isGrade = GradeColumns().Contains(title);
|
||||||
|
|
||||||
|
return new HeaderText(title, isHighlighted) { Margin = new MarginPadding { Vertical = 5, Horizontal = isGrade ? 20 : 10 } };
|
||||||
|
}
|
||||||
|
|
||||||
protected abstract Country GetCountry(TModel item);
|
protected abstract Country GetCountry(TModel item);
|
||||||
|
|
||||||
@ -105,23 +112,20 @@ namespace osu.Game.Overlays.Rankings.Tables
|
|||||||
|
|
||||||
private class HeaderText : OsuSpriteText
|
private class HeaderText : OsuSpriteText
|
||||||
{
|
{
|
||||||
private readonly string highlighted;
|
private readonly bool isHighlighted;
|
||||||
|
|
||||||
public HeaderText(string text, string highlighted, IEnumerable<string> gradeColumns)
|
public HeaderText(string text, bool isHighlighted)
|
||||||
{
|
{
|
||||||
this.highlighted = highlighted;
|
this.isHighlighted = isHighlighted;
|
||||||
|
|
||||||
Text = text;
|
Text = text;
|
||||||
Font = OsuFont.GetFont(size: 12);
|
Font = OsuFont.GetFont(size: 12);
|
||||||
|
|
||||||
var isGrade = gradeColumns.Contains(text);
|
|
||||||
Margin = new MarginPadding { Vertical = 5, Horizontal = isGrade ? 20 : 10 };
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
private void load(OverlayColourProvider colourProvider)
|
private void load(OverlayColourProvider colourProvider)
|
||||||
{
|
{
|
||||||
if (Text != highlighted)
|
if (isHighlighted)
|
||||||
Colour = colourProvider.Foreground1;
|
Colour = colourProvider.Foreground1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user