Move the date next to the flag icon

This commit is contained in:
dekrain
2022-02-17 10:12:35 +01:00
parent 333a305af3
commit 7bd731ae08

View File

@ -44,7 +44,6 @@ namespace osu.Game.Online.Leaderboards
private const float edge_margin = 5; private const float edge_margin = 5;
private const float background_alpha = 0.25f; private const float background_alpha = 0.25f;
private const float rank_width = 35; private const float rank_width = 35;
private const float date_width = 35;
protected Container RankContainer { get; private set; } protected Container RankContainer { get; private set; }
@ -59,7 +58,7 @@ namespace osu.Game.Online.Leaderboards
public GlowingSpriteText ScoreText { get; private set; } public GlowingSpriteText ScoreText { get; private set; }
private Container flagBadgeContainer; private FillFlowContainer flagBadgeAndDateContainer;
private FillFlowContainer<ModIcon> modsContainer; private FillFlowContainer<ModIcon> modsContainer;
private List<ScoreComponentLabel> statisticsLabels; private List<ScoreComponentLabel> statisticsLabels;
@ -103,18 +102,10 @@ namespace osu.Game.Online.Leaderboards
RelativeSizeAxes = Axes.Y, RelativeSizeAxes = Axes.Y,
Width = rank_width, Width = rank_width,
}, },
new Container
{
Anchor = Anchor.TopRight,
Origin = Anchor.TopRight,
RelativeSizeAxes = Axes.Y,
Width = date_width,
Child = new DateLabel(Score.Date),
},
content = new Container content = new Container
{ {
RelativeSizeAxes = Axes.Both, RelativeSizeAxes = Axes.Both,
Padding = new MarginPadding { Left = rank_width, Right = date_width, }, Padding = new MarginPadding { Left = rank_width },
Children = new Drawable[] Children = new Drawable[]
{ {
new Container new Container
@ -176,10 +167,12 @@ namespace osu.Game.Online.Leaderboards
Spacing = new Vector2(10f, 0f), Spacing = new Vector2(10f, 0f),
Children = new Drawable[] Children = new Drawable[]
{ {
flagBadgeContainer = new Container flagBadgeAndDateContainer = new FillFlowContainer
{ {
Origin = Anchor.BottomLeft, Origin = Anchor.BottomLeft,
Anchor = Anchor.BottomLeft, Anchor = Anchor.BottomLeft,
Direction = FillDirection.Horizontal,
Spacing = new Vector2(5f, 0f),
Size = new Vector2(87f, 20f), Size = new Vector2(87f, 20f),
Masking = true, Masking = true,
Children = new Drawable[] Children = new Drawable[]
@ -189,6 +182,10 @@ namespace osu.Game.Online.Leaderboards
Width = 30, Width = 30,
RelativeSizeAxes = Axes.Y, RelativeSizeAxes = Axes.Y,
}, },
new DateLabel(Score.Date)
{
RelativeSizeAxes = Axes.Y,
},
}, },
}, },
new FillFlowContainer new FillFlowContainer
@ -254,7 +251,7 @@ namespace osu.Game.Online.Leaderboards
public override void Show() public override void Show()
{ {
foreach (var d in new[] { avatar, nameLabel, ScoreText, scoreRank, flagBadgeContainer, modsContainer }.Concat(statisticsLabels)) foreach (var d in new[] { avatar, nameLabel, ScoreText, scoreRank, flagBadgeAndDateContainer, modsContainer }.Concat(statisticsLabels))
d.FadeOut(); d.FadeOut();
Alpha = 0; Alpha = 0;
@ -281,7 +278,7 @@ namespace osu.Game.Online.Leaderboards
using (BeginDelayedSequence(50)) using (BeginDelayedSequence(50))
{ {
var drawables = new Drawable[] { flagBadgeContainer, modsContainer }.Concat(statisticsLabels).ToArray(); var drawables = new Drawable[] { flagBadgeAndDateContainer, modsContainer }.Concat(statisticsLabels).ToArray();
for (int i = 0; i < drawables.Length; i++) for (int i = 0; i < drawables.Length; i++)
drawables[i].FadeIn(100 + i * 50); drawables[i].FadeIn(100 + i * 50);
} }
@ -391,10 +388,9 @@ namespace osu.Game.Online.Leaderboards
private class DateLabel : DrawableDate private class DateLabel : DrawableDate
{ {
public DateLabel(DateTimeOffset date) public DateLabel(DateTimeOffset date)
: base(date, 20) : base(date)
{ {
Anchor = Anchor.Centre; Font = OsuFont.GetFont(size: 17, weight: FontWeight.Bold, italics: true);
Origin = Anchor.Centre;
} }
protected override string Format() protected override string Format()
@ -411,7 +407,7 @@ namespace osu.Game.Online.Leaderboards
return $@"{Math.Floor(difference.TotalMinutes)}min"; return $@"{Math.Floor(difference.TotalMinutes)}min";
if (difference.TotalDays < 1) if (difference.TotalDays < 1)
return $@"{Math.Floor(difference.TotalHours)}h"; return $@"{Math.Floor(difference.TotalHours)}h";
if (difference.TotalDays < 7) if (difference.TotalDays < 3)
return $@"{Math.Floor(difference.TotalDays)}d"; return $@"{Math.Floor(difference.TotalDays)}d";
return string.Empty; return string.Empty;