mirror of
https://github.com/osukey/osukey.git
synced 2025-08-03 22:56:36 +09:00
Uncouple display logic from text in rankings overlay tables
This commit is contained in:
@ -55,29 +55,24 @@ namespace osu.Game.Overlays.Rankings.Tables
|
||||
|
||||
rankings.ForEach(_ => backgroundFlow.Add(new TableRowBackground { Height = row_height }));
|
||||
|
||||
Columns = mainHeaders.Concat(CreateAdditionalHeaders()).ToArray();
|
||||
Columns = mainHeaders.Concat(CreateAdditionalHeaders()).Cast<TableColumn>().ToArray();
|
||||
Content = rankings.Select((s, i) => createContent((page - 1) * items_per_page + i, s)).ToArray().ToRectangular();
|
||||
}
|
||||
|
||||
private Drawable[] createContent(int index, TModel item) => new Drawable[] { createIndexDrawable(index), createMainContent(item) }.Concat(CreateAdditionalContent(item)).ToArray();
|
||||
|
||||
private static TableColumn[] mainHeaders => new[]
|
||||
private static RankingsTableColumn[] mainHeaders => new[]
|
||||
{
|
||||
new TableColumn(string.Empty, Anchor.Centre, new Dimension(GridSizeMode.Absolute, 40)), // place
|
||||
new TableColumn(string.Empty, Anchor.CentreLeft, new Dimension()), // flag and username (country name)
|
||||
new RankingsTableColumn(string.Empty, Anchor.Centre, new Dimension(GridSizeMode.Absolute, 40)), // place
|
||||
new RankingsTableColumn(string.Empty, Anchor.CentreLeft, new Dimension()), // flag and username (country name)
|
||||
};
|
||||
|
||||
protected abstract TableColumn[] CreateAdditionalHeaders();
|
||||
protected abstract RankingsTableColumn[] CreateAdditionalHeaders();
|
||||
|
||||
protected abstract Drawable[] CreateAdditionalContent(TModel item);
|
||||
|
||||
protected virtual string HighlightedColumn => @"Performance";
|
||||
|
||||
protected override Drawable CreateHeader(int index, TableColumn column)
|
||||
{
|
||||
var title = column?.Header ?? default;
|
||||
return new HeaderText(title, title == HighlightedColumn);
|
||||
}
|
||||
protected sealed override Drawable CreateHeader(int index, TableColumn column)
|
||||
=> (column as RankingsTableColumn)?.CreateHeaderText() ?? new HeaderText(column?.Header ?? default, false);
|
||||
|
||||
protected abstract Country GetCountry(TModel item);
|
||||
|
||||
@ -106,6 +101,19 @@ namespace osu.Game.Overlays.Rankings.Tables
|
||||
}
|
||||
};
|
||||
|
||||
protected class RankingsTableColumn : TableColumn
|
||||
{
|
||||
protected readonly bool Highlighted;
|
||||
|
||||
public RankingsTableColumn(LocalisableString? header = null, Anchor anchor = Anchor.TopLeft, Dimension dimension = null, bool highlighted = false)
|
||||
: base(header, anchor, dimension)
|
||||
{
|
||||
Highlighted = highlighted;
|
||||
}
|
||||
|
||||
public virtual HeaderText CreateHeaderText() => new HeaderText(Header, Highlighted);
|
||||
}
|
||||
|
||||
protected class HeaderText : OsuSpriteText
|
||||
{
|
||||
private readonly bool isHighlighted;
|
||||
|
Reference in New Issue
Block a user