From aee8ba789c1f4f022eaa3abf90173afce1fcc591 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 12 Oct 2023 16:02:19 +0900 Subject: [PATCH] Tidy up `UserAvatarNotification` implementation --- .../Overlays/Notifications/Notification.cs | 4 +- .../Notifications/UserAvatarNotification.cs | 39 ++++++++----------- 2 files changed, 20 insertions(+), 23 deletions(-) diff --git a/osu.Game/Overlays/Notifications/Notification.cs b/osu.Game/Overlays/Notifications/Notification.cs index 8cdc373417..d619d1d3c3 100644 --- a/osu.Game/Overlays/Notifications/Notification.cs +++ b/osu.Game/Overlays/Notifications/Notification.cs @@ -53,6 +53,8 @@ namespace osu.Game.Overlays.Notifications public virtual string PopInSampleName => "UI/notification-default"; public virtual string PopOutSampleName => "UI/overlay-pop-out"; + protected const float CORNER_RADIUS = 6; + protected NotificationLight Light; protected Container IconContent; @@ -128,7 +130,7 @@ namespace osu.Game.Overlays.Notifications AutoSizeAxes = Axes.Y, }.WithChild(MainContent = new Container { - CornerRadius = 6, + CornerRadius = CORNER_RADIUS, Masking = true, RelativeSizeAxes = Axes.X, AutoSizeAxes = Axes.Y, diff --git a/osu.Game/Overlays/Notifications/UserAvatarNotification.cs b/osu.Game/Overlays/Notifications/UserAvatarNotification.cs index af881a5008..04766f7743 100644 --- a/osu.Game/Overlays/Notifications/UserAvatarNotification.cs +++ b/osu.Game/Overlays/Notifications/UserAvatarNotification.cs @@ -39,39 +39,34 @@ namespace osu.Game.Overlays.Notifications Text = text; } - private DrawableAvatar? avatar; - protected override IconUsage CloseButtonIcon => FontAwesome.Solid.Times; [BackgroundDependencyLoader] private void load(OverlayColourProvider colourProvider) { - IconContent.Masking = true; - - // Workaround for the corner radius on parent's mask breaking if we add masking to IconContent - IconContent.CornerRadius = 6; - - IconContent.AddRange(new Drawable[] - { - new Box() - { - RelativeSizeAxes = Axes.Both, - Colour = colourProvider.Background5, - }, - }); - - avatar = new DrawableAvatar(user) - { - FillMode = FillMode.Fill, - }; - LoadComponentAsync(avatar, IconContent.Add); - Content.Add(textDrawable = new OsuTextFlowContainer(t => t.Font = t.Font.With(size: 14, weight: FontWeight.Medium)) { AutoSizeAxes = Axes.Y, RelativeSizeAxes = Axes.X, Text = text }); + + IconContent.Masking = true; + IconContent.CornerRadius = CORNER_RADIUS; + + IconContent.AddRange(new Drawable[] + { + new Box + { + RelativeSizeAxes = Axes.Both, + Colour = colourProvider.Background5, + }, + }); + + LoadComponentAsync(new DrawableAvatar(user) + { + FillMode = FillMode.Fill, + }, IconContent.Add); } } }