mirror of
https://github.com/ppy/osu.git
synced 2025-01-27 13:23:05 +08:00
Create Format(), override TooltipText..
This commit is contained in:
parent
a446b627da
commit
3efb51e464
@ -13,7 +13,6 @@ namespace osu.Game.Graphics
|
|||||||
public class DrawableDate : OsuSpriteText, IHasTooltip
|
public class DrawableDate : OsuSpriteText, IHasTooltip
|
||||||
{
|
{
|
||||||
private readonly DateTimeOffset date;
|
private readonly DateTimeOffset date;
|
||||||
private readonly string dateFormat;
|
|
||||||
|
|
||||||
/// <param name="dateFormat">The string to format the date text with.
|
/// <param name="dateFormat">The string to format the date text with.
|
||||||
/// May be null if the humanized format should be used.</param>
|
/// May be null if the humanized format should be used.</param>
|
||||||
@ -23,7 +22,6 @@ namespace osu.Game.Graphics
|
|||||||
Font = "Exo2.0-RegularItalic";
|
Font = "Exo2.0-RegularItalic";
|
||||||
|
|
||||||
this.date = date.ToLocalTime();
|
this.date = date.ToLocalTime();
|
||||||
this.dateFormat = dateFormat;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
@ -62,9 +60,9 @@ namespace osu.Game.Graphics
|
|||||||
|
|
||||||
public override bool HandleMouseInput => true;
|
public override bool HandleMouseInput => true;
|
||||||
|
|
||||||
private void updateTime() => Text = string.IsNullOrEmpty(dateFormat) ?
|
protected virtual string Format() => Text = date.Humanize();
|
||||||
date.Humanize() :
|
|
||||||
string.Format(dateFormat, date);
|
private void updateTime() => Format();
|
||||||
|
|
||||||
public virtual string TooltipText => string.Format("{0:d MMMM yyyy H:mm \"UTC\"z}", date);
|
public virtual string TooltipText => string.Format("{0:d MMMM yyyy H:mm \"UTC\"z}", date);
|
||||||
}
|
}
|
||||||
|
@ -6,9 +6,15 @@ namespace osu.Game.Graphics
|
|||||||
{
|
{
|
||||||
public class DrawableJoinDate : DrawableDate
|
public class DrawableJoinDate : DrawableDate
|
||||||
{
|
{
|
||||||
|
private readonly DateTimeOffset date;
|
||||||
|
|
||||||
public DrawableJoinDate(DateTimeOffset date) : base(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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -364,7 +364,7 @@ namespace osu.Game.Overlays.Profile
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
infoTextLeft.AddText("Joined ", lightText);
|
infoTextLeft.AddText("Joined ", lightText);
|
||||||
infoTextLeft.AddText(new DrawableDate(user.JoinDate), boldItalic);
|
infoTextLeft.AddText(new DrawableJoinDate(user.JoinDate), boldItalic);
|
||||||
}
|
}
|
||||||
|
|
||||||
infoTextLeft.NewLine();
|
infoTextLeft.NewLine();
|
||||||
|
Loading…
Reference in New Issue
Block a user