mirror of
https://github.com/ppy/osu.git
synced 2025-02-13 20:33:11 +08:00
Move grade column spacing logic to UserBasedTable
This commit is contained in:
parent
f1e54d2745
commit
db55b98ed3
@ -70,16 +70,12 @@ namespace osu.Game.Overlays.Rankings.Tables
|
|||||||
|
|
||||||
protected abstract Drawable[] CreateAdditionalContent(TModel item);
|
protected abstract Drawable[] CreateAdditionalContent(TModel item);
|
||||||
|
|
||||||
|
protected virtual string HighlightedColumn => @"Performance";
|
||||||
|
|
||||||
protected override Drawable CreateHeader(int index, TableColumn column)
|
protected override Drawable CreateHeader(int index, TableColumn column)
|
||||||
{
|
{
|
||||||
var title = column?.Header ?? string.Empty;
|
var title = column?.Header ?? string.Empty;
|
||||||
var isHighlighted = HighlightedColumn() == title;
|
return new HeaderText(title, title == HighlightedColumn);
|
||||||
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);
|
||||||
@ -109,11 +105,7 @@ namespace osu.Game.Overlays.Rankings.Tables
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
protected virtual IEnumerable<string> GradeColumns() => new List<string>();
|
protected class HeaderText : OsuSpriteText
|
||||||
|
|
||||||
protected virtual string HighlightedColumn() => @"Performance";
|
|
||||||
|
|
||||||
private class HeaderText : OsuSpriteText
|
|
||||||
{
|
{
|
||||||
private readonly bool isHighlighted;
|
private readonly bool isHighlighted;
|
||||||
|
|
||||||
@ -123,6 +115,7 @@ namespace osu.Game.Overlays.Rankings.Tables
|
|||||||
|
|
||||||
Text = text;
|
Text = text;
|
||||||
Font = OsuFont.GetFont(size: 12);
|
Font = OsuFont.GetFont(size: 12);
|
||||||
|
Margin = new MarginPadding { Vertical = 5, Horizontal = 10 };
|
||||||
}
|
}
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
|
@ -33,6 +33,6 @@ namespace osu.Game.Overlays.Rankings.Tables
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
protected override string HighlightedColumn() => @"Ranked Score";
|
protected override string HighlightedColumn => @"Ranked Score";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -19,17 +19,20 @@ namespace osu.Game.Overlays.Rankings.Tables
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override IEnumerable<string> GradeColumns() => new List<string> { "SS", "S", "A" };
|
protected virtual IEnumerable<string> GradeColumns => new List<string> { "SS", "S", "A" };
|
||||||
|
|
||||||
protected override TableColumn[] CreateAdditionalHeaders()
|
protected override TableColumn[] CreateAdditionalHeaders() => new[]
|
||||||
{
|
|
||||||
var gradeColumns = GradeColumns().Select(grade => new TableColumn(grade, Anchor.Centre, new Dimension(GridSizeMode.AutoSize)));
|
|
||||||
|
|
||||||
return new[]
|
|
||||||
{
|
{
|
||||||
new TableColumn("Accuracy", Anchor.Centre, new Dimension(GridSizeMode.AutoSize)),
|
new TableColumn("Accuracy", Anchor.Centre, new Dimension(GridSizeMode.AutoSize)),
|
||||||
new TableColumn("Play Count", Anchor.Centre, new Dimension(GridSizeMode.AutoSize)),
|
new TableColumn("Play Count", Anchor.Centre, new Dimension(GridSizeMode.AutoSize)),
|
||||||
}.Concat(CreateUniqueHeaders()).Concat(gradeColumns).ToArray();
|
}.Concat(CreateUniqueHeaders())
|
||||||
|
.Concat(GradeColumns.Select(grade => new TableColumn(grade, Anchor.Centre, new Dimension(GridSizeMode.AutoSize))))
|
||||||
|
.ToArray();
|
||||||
|
|
||||||
|
protected override Drawable CreateHeader(int index, TableColumn column)
|
||||||
|
{
|
||||||
|
var title = column?.Header ?? string.Empty;
|
||||||
|
return new UserTableHeaderText(title, HighlightedColumn == title, GradeColumns.Contains(title));
|
||||||
}
|
}
|
||||||
|
|
||||||
protected sealed override Country GetCountry(UserStatistics item) => item.User.Country;
|
protected sealed override Country GetCountry(UserStatistics item) => item.User.Country;
|
||||||
@ -60,5 +63,19 @@ namespace osu.Game.Overlays.Rankings.Tables
|
|||||||
protected abstract TableColumn[] CreateUniqueHeaders();
|
protected abstract TableColumn[] CreateUniqueHeaders();
|
||||||
|
|
||||||
protected abstract Drawable[] CreateUniqueContent(UserStatistics item);
|
protected abstract Drawable[] CreateUniqueContent(UserStatistics item);
|
||||||
|
|
||||||
|
private class UserTableHeaderText : HeaderText
|
||||||
|
{
|
||||||
|
public UserTableHeaderText(string text, bool isHighlighted, bool isGrade)
|
||||||
|
: base(text, isHighlighted)
|
||||||
|
{
|
||||||
|
Margin = new MarginPadding
|
||||||
|
{
|
||||||
|
// Grade columns have extra horizontal padding for readibility
|
||||||
|
Horizontal = isGrade ? 20 : 10,
|
||||||
|
Vertical = 5
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user