2023-10-02 21:10:51 +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 osu.Framework.Allocation;
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
using osu.Framework.Graphics.Containers;
|
|
|
|
using osu.Framework.Graphics.Shapes;
|
|
|
|
using osu.Framework.Graphics.Sprites;
|
|
|
|
using osu.Framework.Localisation;
|
|
|
|
using osu.Game.Graphics;
|
|
|
|
using osu.Game.Graphics.Containers;
|
|
|
|
using osu.Game.Online.API.Requests.Responses;
|
|
|
|
using osu.Game.Users.Drawables;
|
|
|
|
|
|
|
|
namespace osu.Game.Overlays.Notifications
|
|
|
|
{
|
|
|
|
public partial class UserAvatarNotification : Notification
|
|
|
|
{
|
|
|
|
private LocalisableString text;
|
|
|
|
|
|
|
|
public override LocalisableString Text
|
|
|
|
{
|
|
|
|
get => text;
|
|
|
|
set
|
|
|
|
{
|
|
|
|
text = value;
|
|
|
|
if (textDrawable != null)
|
|
|
|
textDrawable.Text = text;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private TextFlowContainer? textDrawable;
|
|
|
|
|
2023-10-03 22:20:07 +00:00
|
|
|
private readonly APIUser user;
|
2023-10-02 21:10:51 +00:00
|
|
|
|
|
|
|
public UserAvatarNotification(APIUser user, LocalisableString text)
|
|
|
|
{
|
|
|
|
this.user = user;
|
|
|
|
Text = text;
|
|
|
|
}
|
|
|
|
|
|
|
|
protected override IconUsage CloseButtonIcon => FontAwesome.Solid.Times;
|
|
|
|
|
|
|
|
[BackgroundDependencyLoader]
|
2023-10-12 07:05:48 +00:00
|
|
|
private void load(OsuColour colours, OverlayColourProvider colourProvider)
|
2023-10-02 21:10:51 +00:00
|
|
|
{
|
2023-10-12 07:05:48 +00:00
|
|
|
Light.Colour = colours.Orange2;
|
|
|
|
|
2023-10-12 07:02:19 +00:00
|
|
|
Content.Add(textDrawable = new OsuTextFlowContainer(t => t.Font = t.Font.With(size: 14, weight: FontWeight.Medium))
|
|
|
|
{
|
|
|
|
AutoSizeAxes = Axes.Y,
|
|
|
|
RelativeSizeAxes = Axes.X,
|
|
|
|
Text = text
|
|
|
|
});
|
2023-10-02 21:10:51 +00:00
|
|
|
|
2023-10-12 07:02:19 +00:00
|
|
|
IconContent.Masking = true;
|
|
|
|
IconContent.CornerRadius = CORNER_RADIUS;
|
2023-10-02 21:10:51 +00:00
|
|
|
|
|
|
|
IconContent.AddRange(new Drawable[]
|
|
|
|
{
|
2023-10-12 07:02:19 +00:00
|
|
|
new Box
|
2023-10-02 21:10:51 +00:00
|
|
|
{
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
Colour = colourProvider.Background5,
|
|
|
|
},
|
|
|
|
});
|
|
|
|
|
2023-10-12 07:02:19 +00:00
|
|
|
LoadComponentAsync(new DrawableAvatar(user)
|
2023-10-02 21:10:51 +00:00
|
|
|
{
|
|
|
|
FillMode = FillMode.Fill,
|
2023-10-12 07:02:19 +00:00
|
|
|
}, IconContent.Add);
|
2023-10-02 21:10:51 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|