1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-26 16:12:54 +08:00

Create Format(), override TooltipText..

This commit is contained in:
HoutarouOreki 2018-05-25 14:00:32 +02:00
parent a446b627da
commit 3efb51e464
3 changed files with 11 additions and 7 deletions

View File

@ -13,7 +13,6 @@ namespace osu.Game.Graphics
public class DrawableDate : OsuSpriteText, IHasTooltip
{
private readonly DateTimeOffset date;
private readonly string dateFormat;
/// <param name="dateFormat">The string to format the date text with.
/// May be null if the humanized format should be used.</param>
@ -23,7 +22,6 @@ namespace osu.Game.Graphics
Font = "Exo2.0-RegularItalic";
this.date = date.ToLocalTime();
this.dateFormat = dateFormat;
}
[BackgroundDependencyLoader]
@ -62,9 +60,9 @@ namespace osu.Game.Graphics
public override bool HandleMouseInput => true;
private void updateTime() => Text = string.IsNullOrEmpty(dateFormat) ?
date.Humanize() :
string.Format(dateFormat, date);
protected virtual string Format() => Text = date.Humanize();
private void updateTime() => Format();
public virtual string TooltipText => string.Format("{0:d MMMM yyyy H:mm \"UTC\"z}", date);
}

View File

@ -6,9 +6,15 @@ namespace osu.Game.Graphics
{
public class DrawableJoinDate : DrawableDate
{
private readonly DateTimeOffset date;
public DrawableJoinDate(DateTimeOffset date) : base(date)
{
this.date = date;
}
protected override string Format() => Text = string.Format("{0:MMMM yyyy}", date);
public override string TooltipText => string.Format("{0:d MMMM yyyy}", date);
}
}

View File

@ -364,7 +364,7 @@ namespace osu.Game.Overlays.Profile
else
{
infoTextLeft.AddText("Joined ", lightText);
infoTextLeft.AddText(new DrawableDate(user.JoinDate), boldItalic);
infoTextLeft.AddText(new DrawableJoinDate(user.JoinDate), boldItalic);
}
infoTextLeft.NewLine();