Add end date to the drawable room too

This commit is contained in:
smoogipoo
2018-12-19 15:20:23 +09:00
parent a8d88dea3b
commit c544a5b9f0
3 changed files with 59 additions and 33 deletions

View File

@ -47,7 +47,7 @@ namespace osu.Game.Screens.Multi.Match.Components
BeatmapTypeInfo beatmapTypeInfo;
OsuSpriteText name;
ModDisplay modDisplay;
DrawableDate date;
EndDateInfo endDate;
Children = new Drawable[]
{
@ -79,7 +79,7 @@ namespace osu.Game.Screens.Multi.Match.Components
{
name = new OsuSpriteText { TextSize = 30 },
availabilityStatus = new OsuSpriteText { TextSize = 14 },
date = new MatchDate { TextSize = 14 }
endDate = new EndDateInfo { TextSize = 14 }
}
},
new FillFlowContainer
@ -129,7 +129,7 @@ namespace osu.Game.Screens.Multi.Match.Components
Availability.BindValueChanged(_ => updateAvailabilityStatus());
Status.BindValueChanged(_ => updateAvailabilityStatus());
Name.BindValueChanged(n => name.Text = n);
EndDate.BindValueChanged(d => date.Date = d);
EndDate.BindValueChanged(d => endDate.Date = d);
}
[BackgroundDependencyLoader]
@ -156,29 +156,5 @@ namespace osu.Game.Screens.Multi.Match.Components
availabilityStatus.Text = $"{Availability.Value.GetDescription()}, {Status.Value.Message}";
}
}
private class MatchDate : DrawableDate
{
public MatchDate()
: base(DateTimeOffset.UtcNow)
{
}
protected override string Format()
{
var diffToNow = Date.Subtract(DateTimeOffset.Now);
if (diffToNow.TotalSeconds < -5)
return $"Closed {base.Format()}";
if (diffToNow.TotalSeconds < 0)
return "Closed";
if (diffToNow.TotalSeconds < 5)
return "Closing soon";
return $"Closing {base.Format()}";
}
}
}
}