mirror of
https://github.com/ppy/osu.git
synced 2024-12-14 21:02:55 +08:00
Merge pull request #2616 from HoutarouOreki/unifyDates
Make profile dates match style of website
This commit is contained in:
commit
e4d494fb15
@ -12,14 +12,14 @@ namespace osu.Game.Graphics
|
||||
{
|
||||
public class DrawableDate : OsuSpriteText, IHasTooltip
|
||||
{
|
||||
private readonly DateTimeOffset date;
|
||||
protected readonly DateTimeOffset Date;
|
||||
|
||||
public DrawableDate(DateTimeOffset date)
|
||||
{
|
||||
AutoSizeAxes = Axes.Both;
|
||||
Font = "Exo2.0-RegularItalic";
|
||||
|
||||
this.date = date.ToLocalTime();
|
||||
Date = date.ToLocalTime();
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
@ -38,7 +38,7 @@ namespace osu.Game.Graphics
|
||||
{
|
||||
updateTime();
|
||||
|
||||
var diffToNow = DateTimeOffset.Now.Subtract(date);
|
||||
var diffToNow = DateTimeOffset.Now.Subtract(Date);
|
||||
|
||||
double timeUntilNextUpdate = 1000;
|
||||
if (diffToNow.TotalSeconds > 60)
|
||||
@ -58,8 +58,10 @@ namespace osu.Game.Graphics
|
||||
|
||||
public override bool HandleMouseInput => true;
|
||||
|
||||
private void updateTime() => Text = date.Humanize();
|
||||
protected virtual string Format() => Date.Humanize();
|
||||
|
||||
public string TooltipText => date.ToString();
|
||||
private void updateTime() => Text = Format();
|
||||
|
||||
public virtual string TooltipText => string.Format($"{Date:MMMM d, yyyy h:mm tt \"UTC\"z}");
|
||||
}
|
||||
}
|
||||
|
20
osu.Game/Overlays/Profile/Components/DrawableJoinDate.cs
Normal file
20
osu.Game/Overlays/Profile/Components/DrawableJoinDate.cs
Normal file
@ -0,0 +1,20 @@
|
||||
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
|
||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||
|
||||
using System;
|
||||
using osu.Game.Graphics;
|
||||
|
||||
namespace osu.Game.Overlays.Profile.Components
|
||||
{
|
||||
public class DrawableJoinDate : DrawableDate
|
||||
{
|
||||
public DrawableJoinDate(DateTimeOffset date)
|
||||
: base(date)
|
||||
{
|
||||
}
|
||||
|
||||
protected override string Format() => Text = Date.ToUniversalTime().Year < 2008 ? "Here since the beginning" : $"{Date:MMMM yyyy}";
|
||||
|
||||
public override string TooltipText => $"{Date:MMMM d, yyyy}";
|
||||
}
|
||||
}
|
50
osu.Game/Overlays/Profile/Components/GradeBadge.cs
Normal file
50
osu.Game/Overlays/Profile/Components/GradeBadge.cs
Normal file
@ -0,0 +1,50 @@
|
||||
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
|
||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Sprites;
|
||||
using osu.Framework.Graphics.Textures;
|
||||
using osu.Game.Graphics.Sprites;
|
||||
|
||||
namespace osu.Game.Overlays.Profile.Components
|
||||
{
|
||||
public class GradeBadge : Container
|
||||
{
|
||||
private const float width = 50;
|
||||
private readonly string grade;
|
||||
private readonly Sprite badge;
|
||||
private readonly SpriteText numberText;
|
||||
|
||||
public int DisplayCount
|
||||
{
|
||||
set => numberText.Text = value.ToString(@"#,0");
|
||||
}
|
||||
|
||||
public GradeBadge(string grade)
|
||||
{
|
||||
this.grade = grade;
|
||||
Width = width;
|
||||
Height = 41;
|
||||
Add(badge = new Sprite
|
||||
{
|
||||
Width = width,
|
||||
Height = 26
|
||||
});
|
||||
Add(numberText = new OsuSpriteText
|
||||
{
|
||||
Anchor = Anchor.BottomCentre,
|
||||
Origin = Anchor.BottomCentre,
|
||||
TextSize = 14,
|
||||
Font = @"Exo2.0-Bold"
|
||||
});
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(TextureStore textures)
|
||||
{
|
||||
badge.Texture = textures.Get($"Grades/{grade}");
|
||||
}
|
||||
}
|
||||
}
|
@ -16,6 +16,7 @@ using osu.Game.Graphics;
|
||||
using osu.Game.Graphics.Containers;
|
||||
using osu.Game.Graphics.Sprites;
|
||||
using osu.Game.Graphics.UserInterface;
|
||||
using osu.Game.Overlays.Profile.Components;
|
||||
using osu.Game.Overlays.Profile.Header;
|
||||
using osu.Game.Users;
|
||||
|
||||
@ -375,12 +376,12 @@ namespace osu.Game.Overlays.Profile
|
||||
|
||||
if (user.JoinDate.ToUniversalTime().Year < 2008)
|
||||
{
|
||||
infoTextLeft.AddText("Here since the beginning", boldItalic);
|
||||
infoTextLeft.AddText(new DrawableJoinDate(user.JoinDate), lightText);
|
||||
}
|
||||
else
|
||||
{
|
||||
infoTextLeft.AddText("Joined ", lightText);
|
||||
infoTextLeft.AddText(new DrawableDate(user.JoinDate), boldItalic);
|
||||
infoTextLeft.AddText(new DrawableJoinDate(user.JoinDate), boldItalic);
|
||||
}
|
||||
|
||||
infoTextLeft.NewLine();
|
||||
@ -470,43 +471,5 @@ namespace osu.Game.Overlays.Profile
|
||||
|
||||
infoTextRight.NewLine();
|
||||
}
|
||||
|
||||
private class GradeBadge : Container
|
||||
{
|
||||
private const float width = 50;
|
||||
private readonly string grade;
|
||||
private readonly Sprite badge;
|
||||
private readonly SpriteText numberText;
|
||||
|
||||
public int DisplayCount
|
||||
{
|
||||
set { numberText.Text = value.ToString(@"#,0"); }
|
||||
}
|
||||
|
||||
public GradeBadge(string grade)
|
||||
{
|
||||
this.grade = grade;
|
||||
Width = width;
|
||||
Height = 41;
|
||||
Add(badge = new Sprite
|
||||
{
|
||||
Width = width,
|
||||
Height = 26
|
||||
});
|
||||
Add(numberText = new OsuSpriteText
|
||||
{
|
||||
Anchor = Anchor.BottomCentre,
|
||||
Origin = Anchor.BottomCentre,
|
||||
TextSize = 14,
|
||||
Font = @"Exo2.0-Bold"
|
||||
});
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(TextureStore textures)
|
||||
{
|
||||
badge.Texture = textures.Get($"Grades/{grade}");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user