mirror of
https://github.com/ppy/osu.git
synced 2024-12-25 16:52:55 +08:00
2f635fa854
Refactors `ChatLine` component to use more sensible override properties and layout using grid container. Moves creation of username component into its own method to simplify BDL. Updates padding of base `DrawableChannel` flow padding. Removes usage of `ChatOverlayDrawableChannel` since it's overrides are no longer needed. Updates usage of `StandAloneChatDisplay` to use new override properties of `DrawableChannel`.
106 lines
3.9 KiB
C#
106 lines
3.9 KiB
C#
// 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.
|
|
|
|
#nullable enable
|
|
|
|
using System;
|
|
using osu.Framework.Allocation;
|
|
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 class DaySeparator : Container
|
|
{
|
|
protected virtual float TextSize => 15;
|
|
|
|
protected virtual float LineHeight => 2;
|
|
|
|
protected virtual float DateAlign => 205;
|
|
|
|
protected virtual float Spacing => 15;
|
|
|
|
private readonly DateTimeOffset time;
|
|
|
|
[Resolved(CanBeNull = true)]
|
|
private OverlayColourProvider? colourProvider { get; set; }
|
|
|
|
public DaySeparator(DateTimeOffset time)
|
|
{
|
|
this.time = time;
|
|
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,
|
|
Text = time.ToLocalTime().ToString("dd MMMM yyyy").ToUpper(),
|
|
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,
|
|
},
|
|
}
|
|
}
|
|
};
|
|
}
|
|
}
|
|
}
|