From c0643cae751fa27e49b5929b2e3ffba0737604b9 Mon Sep 17 00:00:00 2001 From: Jai Sharma Date: Sat, 7 May 2022 23:24:34 +0100 Subject: [PATCH] Create `ChatOverlayDaySeparator` and use in `ChatOverlayDrawableChannel` --- osu.Game/Overlays/ChatOverlayV2.cs | 59 +++++++++++++++++++++++++++--- 1 file changed, 54 insertions(+), 5 deletions(-) diff --git a/osu.Game/Overlays/ChatOverlayV2.cs b/osu.Game/Overlays/ChatOverlayV2.cs index 1f2fb9724b..b0f81c217a 100644 --- a/osu.Game/Overlays/ChatOverlayV2.cs +++ b/osu.Game/Overlays/ChatOverlayV2.cs @@ -17,7 +17,9 @@ using osu.Framework.Graphics.Shapes; using osu.Framework.Input.Events; using osu.Framework.Localisation; using osu.Game.Configuration; +using osu.Game.Graphics; using osu.Game.Graphics.Containers; +using osu.Game.Graphics.Sprites; using osu.Game.Graphics.UserInterface; using osu.Game.Localisation; using osu.Game.Online.Chat; @@ -326,11 +328,58 @@ namespace osu.Game.Overlays ChatLineFlow.Padding = new MarginPadding(0); } - protected override Drawable CreateDaySeparator(DateTimeOffset time) => new DaySeparator(time) + protected override Drawable CreateDaySeparator(DateTimeOffset time) => new ChatOverlayDaySeparator(time); + + private class ChatOverlayDaySeparator : Container { - Colour = Colour4.White, - Margin = new MarginPadding { Vertical = 10 }, - Padding = new MarginPadding { Horizontal = 15 }, - }; + private readonly DateTimeOffset time; + + public ChatOverlayDaySeparator(DateTimeOffset time) + { + this.time = time; + } + + [BackgroundDependencyLoader] + private void load(OverlayColourProvider colourProvider) + { + RelativeSizeAxes = Axes.X; + AutoSizeAxes = Axes.Y; + Padding = new MarginPadding(15); + Child = new GridContainer + { + RelativeSizeAxes = Axes.X, + AutoSizeAxes = Axes.Y, + RowDimensions = new[] { new Dimension(GridSizeMode.AutoSize) }, + ColumnDimensions = new[] + { + new Dimension(GridSizeMode.Absolute, 215), + new Dimension(GridSizeMode.AutoSize), + new Dimension(), + }, + Content = new[] + { + new Drawable[] + { + Drawable.Empty(), + new OsuSpriteText + { + Text = time.ToLocalTime().ToString("dd MMMM yyyy").ToUpper(), + Font = OsuFont.Torus.With(size: 15, weight: FontWeight.SemiBold), + Colour = colourProvider.Content1, + Margin = new MarginPadding { Right = 10 }, + }, + new Box + { + Anchor = Anchor.CentreLeft, + Origin = Anchor.CentreLeft, + Colour = colourProvider.Background5, + RelativeSizeAxes = Axes.X, + Height = 2, + }, + }, + }, + }; + } + } } }