2020-07-07 13:46:17 +00:00
|
|
|
|
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
|
|
|
|
// See the LICENCE file in the repository root for full licence text.
|
|
|
|
|
|
2022-06-17 07:37:17 +00:00
|
|
|
|
#nullable disable
|
|
|
|
|
|
2020-07-07 13:46:17 +00:00
|
|
|
|
using System;
|
|
|
|
|
using osu.Framework.Allocation;
|
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
|
using osu.Framework.Graphics.Containers;
|
|
|
|
|
using osu.Framework.Graphics.Cursor;
|
|
|
|
|
using osu.Framework.Graphics.Shapes;
|
|
|
|
|
using osu.Game.Graphics.Sprites;
|
|
|
|
|
using osuTK;
|
|
|
|
|
|
|
|
|
|
namespace osu.Game.Graphics
|
|
|
|
|
{
|
2021-08-30 07:04:54 +00:00
|
|
|
|
public class DateTooltip : VisibilityContainer, ITooltip<DateTimeOffset>
|
2020-07-07 13:46:17 +00:00
|
|
|
|
{
|
|
|
|
|
private readonly OsuSpriteText dateText, timeText;
|
|
|
|
|
private readonly Box background;
|
|
|
|
|
|
|
|
|
|
public DateTooltip()
|
|
|
|
|
{
|
|
|
|
|
AutoSizeAxes = Axes.Both;
|
|
|
|
|
Masking = true;
|
|
|
|
|
CornerRadius = 5;
|
|
|
|
|
|
|
|
|
|
Children = new Drawable[]
|
|
|
|
|
{
|
|
|
|
|
background = new Box
|
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.Both
|
|
|
|
|
},
|
|
|
|
|
new FillFlowContainer
|
|
|
|
|
{
|
|
|
|
|
AutoSizeAxes = Axes.Both,
|
|
|
|
|
Direction = FillDirection.Horizontal,
|
|
|
|
|
Padding = new MarginPadding(10),
|
|
|
|
|
Children = new Drawable[]
|
|
|
|
|
{
|
|
|
|
|
dateText = new OsuSpriteText
|
|
|
|
|
{
|
|
|
|
|
Font = OsuFont.GetFont(size: 12, weight: FontWeight.Bold),
|
|
|
|
|
Anchor = Anchor.BottomLeft,
|
|
|
|
|
Origin = Anchor.BottomLeft,
|
|
|
|
|
},
|
|
|
|
|
timeText = new OsuSpriteText
|
|
|
|
|
{
|
|
|
|
|
Font = OsuFont.GetFont(size: 12, weight: FontWeight.Regular),
|
|
|
|
|
Anchor = Anchor.BottomLeft,
|
|
|
|
|
Origin = Anchor.BottomLeft,
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[BackgroundDependencyLoader]
|
|
|
|
|
private void load(OsuColour colours)
|
|
|
|
|
{
|
2021-12-10 05:15:00 +00:00
|
|
|
|
background.Colour = colours.GreySeaFoamDarker;
|
2020-07-07 13:46:17 +00:00
|
|
|
|
timeText.Colour = colours.BlueLighter;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void PopIn() => this.FadeIn(200, Easing.OutQuint);
|
|
|
|
|
protected override void PopOut() => this.FadeOut(200, Easing.OutQuint);
|
|
|
|
|
|
2021-08-30 07:04:54 +00:00
|
|
|
|
public void SetContent(DateTimeOffset date)
|
2020-07-07 13:46:17 +00:00
|
|
|
|
{
|
2021-12-16 05:34:59 +00:00
|
|
|
|
DateTimeOffset localDate = date.ToLocalTime();
|
|
|
|
|
|
|
|
|
|
dateText.Text = $"{localDate:d MMMM yyyy} ";
|
|
|
|
|
timeText.Text = $"{localDate:HH:mm:ss \"UTC\"z}";
|
2020-07-07 13:46:17 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void Move(Vector2 pos) => Position = pos;
|
|
|
|
|
}
|
|
|
|
|
}
|