2022-06-04 15:11:49 +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.
|
|
|
|
|
|
|
|
using System;
|
|
|
|
using osu.Framework.Allocation;
|
2022-06-20 12:39:47 +00:00
|
|
|
using osu.Framework.Extensions.LocalisationExtensions;
|
2022-06-04 15:11:49 +00:00
|
|
|
using osu.Framework.Graphics;
|
|
|
|
using osu.Framework.Graphics.Containers;
|
|
|
|
using osu.Framework.Graphics.Shapes;
|
|
|
|
using osu.Game.Graphics;
|
|
|
|
using osu.Game.Graphics.Sprites;
|
|
|
|
|
|
|
|
namespace osu.Game.Overlays.Chat
|
|
|
|
{
|
|
|
|
public partial class DaySeparator : Container
|
|
|
|
{
|
|
|
|
protected virtual float TextSize => 15;
|
|
|
|
|
|
|
|
protected virtual float LineHeight => 2;
|
|
|
|
|
2022-06-07 00:37:46 +00:00
|
|
|
protected virtual float DateAlign => 205;
|
2022-06-04 15:11:49 +00:00
|
|
|
|
|
|
|
protected virtual float Spacing => 15;
|
|
|
|
|
2022-11-21 19:30:42 +00:00
|
|
|
public readonly DateTimeOffset Date;
|
2022-06-04 15:11:49 +00:00
|
|
|
|
|
|
|
[Resolved(CanBeNull = true)]
|
|
|
|
private OverlayColourProvider? colourProvider { get; set; }
|
|
|
|
|
2022-11-21 19:30:42 +00:00
|
|
|
public DaySeparator(DateTimeOffset date)
|
2022-06-04 15:11:49 +00:00
|
|
|
{
|
2022-11-21 19:30:42 +00:00
|
|
|
Date = date;
|
2022-06-04 15:11:49 +00:00
|
|
|
Height = 40;
|
|
|
|
}
|
|
|
|
|
|
|
|
[BackgroundDependencyLoader]
|
|
|
|
private void load()
|
|
|
|
{
|
|
|
|
RelativeSizeAxes = Axes.X;
|
|
|
|
Child = new GridContainer
|
|
|
|
{
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
Anchor = Anchor.CentreLeft,
|
|
|
|
Origin = Anchor.CentreLeft,
|
|
|
|
RowDimensions = new[] { new Dimension() },
|
|
|
|
ColumnDimensions = new[]
|
|
|
|
{
|
|
|
|
new Dimension(GridSizeMode.Absolute, DateAlign),
|
|
|
|
new Dimension(GridSizeMode.Absolute, Spacing),
|
|
|
|
new Dimension(),
|
|
|
|
},
|
|
|
|
Content = new[]
|
|
|
|
{
|
|
|
|
new[]
|
|
|
|
{
|
|
|
|
new GridContainer
|
|
|
|
{
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
RowDimensions = new[] { new Dimension() },
|
|
|
|
ColumnDimensions = new[]
|
|
|
|
{
|
|
|
|
new Dimension(),
|
|
|
|
new Dimension(GridSizeMode.Absolute, Spacing),
|
|
|
|
new Dimension(GridSizeMode.AutoSize),
|
|
|
|
},
|
|
|
|
Content = new[]
|
|
|
|
{
|
|
|
|
new[]
|
|
|
|
{
|
|
|
|
new Circle
|
|
|
|
{
|
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
Origin = Anchor.Centre,
|
|
|
|
RelativeSizeAxes = Axes.X,
|
|
|
|
Height = LineHeight,
|
|
|
|
Colour = colourProvider?.Background5 ?? Colour4.White,
|
|
|
|
},
|
|
|
|
Drawable.Empty(),
|
|
|
|
new OsuSpriteText
|
|
|
|
{
|
|
|
|
Anchor = Anchor.CentreRight,
|
|
|
|
Origin = Anchor.CentreRight,
|
2022-11-21 19:30:42 +00:00
|
|
|
Text = Date.ToLocalTime().ToLocalisableString(@"dd MMMM yyyy").ToUpper(),
|
2022-06-04 15:11:49 +00:00
|
|
|
Font = OsuFont.Torus.With(size: TextSize, weight: FontWeight.SemiBold),
|
|
|
|
Colour = colourProvider?.Content1 ?? Colour4.White,
|
|
|
|
},
|
|
|
|
}
|
|
|
|
},
|
|
|
|
},
|
|
|
|
Drawable.Empty(),
|
|
|
|
new Circle
|
|
|
|
{
|
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
Origin = Anchor.Centre,
|
|
|
|
RelativeSizeAxes = Axes.X,
|
|
|
|
Height = LineHeight,
|
|
|
|
Colour = colourProvider?.Background5 ?? Colour4.White,
|
|
|
|
},
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|