mirror of
https://github.com/ppy/osu.git
synced 2025-02-22 20:12:56 +08:00
Move DateTooltip to it's on file
This commit is contained in:
parent
447cd17cf6
commit
bdec13d4a4
78
osu.Game/Graphics/DateTooltip.cs
Normal file
78
osu.Game/Graphics/DateTooltip.cs
Normal file
@ -0,0 +1,78 @@
|
|||||||
|
// 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.
|
||||||
|
|
||||||
|
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
|
||||||
|
{
|
||||||
|
public class DateTooltip : VisibilityContainer, ITooltip
|
||||||
|
{
|
||||||
|
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)
|
||||||
|
{
|
||||||
|
background.Colour = colours.GreySeafoamDarker;
|
||||||
|
timeText.Colour = colours.BlueLighter;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void PopIn() => this.FadeIn(200, Easing.OutQuint);
|
||||||
|
protected override void PopOut() => this.FadeOut(200, Easing.OutQuint);
|
||||||
|
|
||||||
|
public bool SetContent(object content)
|
||||||
|
{
|
||||||
|
if (!(content is DateTimeOffset date))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
dateText.Text = $"{date:d MMMM yyyy} ";
|
||||||
|
timeText.Text = $"{date:HH:mm:ss \"UTC\"z}";
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Move(Vector2 pos) => Position = pos;
|
||||||
|
}
|
||||||
|
}
|
@ -4,12 +4,9 @@
|
|||||||
using System;
|
using System;
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Graphics.Containers;
|
|
||||||
using osu.Framework.Graphics.Cursor;
|
using osu.Framework.Graphics.Cursor;
|
||||||
using osu.Framework.Graphics.Shapes;
|
|
||||||
using osu.Game.Graphics.Sprites;
|
using osu.Game.Graphics.Sprites;
|
||||||
using osu.Game.Utils;
|
using osu.Game.Utils;
|
||||||
using osuTK;
|
|
||||||
|
|
||||||
namespace osu.Game.Graphics
|
namespace osu.Game.Graphics
|
||||||
{
|
{
|
||||||
@ -81,69 +78,5 @@ namespace osu.Game.Graphics
|
|||||||
public ITooltip GetCustomTooltip() => new DateTooltip();
|
public ITooltip GetCustomTooltip() => new DateTooltip();
|
||||||
|
|
||||||
public object TooltipContent => Date;
|
public object TooltipContent => Date;
|
||||||
|
|
||||||
public class DateTooltip : VisibilityContainer, ITooltip
|
|
||||||
{
|
|
||||||
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)
|
|
||||||
{
|
|
||||||
background.Colour = colours.GreySeafoamDarker;
|
|
||||||
timeText.Colour = colours.BlueLighter;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override void PopIn() => this.FadeIn(200, Easing.OutQuint);
|
|
||||||
protected override void PopOut() => this.FadeOut(200, Easing.OutQuint);
|
|
||||||
|
|
||||||
public bool SetContent(object content)
|
|
||||||
{
|
|
||||||
if (!(content is DateTimeOffset date))
|
|
||||||
return false;
|
|
||||||
|
|
||||||
dateText.Text = $"{date:d MMMM yyyy} ";
|
|
||||||
timeText.Text = $"{date:HH:mm:ss \"UTC\"z}";
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void Move(Vector2 pos) => Position = pos;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -158,7 +158,7 @@ namespace osu.Game.Overlays.News
|
|||||||
|
|
||||||
private class DateContainer : CircularContainer, IHasCustomTooltip
|
private class DateContainer : CircularContainer, IHasCustomTooltip
|
||||||
{
|
{
|
||||||
public ITooltip GetCustomTooltip() => new DrawableDate.DateTooltip();
|
public ITooltip GetCustomTooltip() => new DateTooltip();
|
||||||
|
|
||||||
public object TooltipContent => date;
|
public object TooltipContent => date;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user