2022-03-15 02:31:13 +08: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.
|
|
|
|
|
|
|
|
#nullable enable
|
|
|
|
|
|
|
|
using System.Linq;
|
|
|
|
using osu.Framework.Allocation;
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
using osu.Framework.Graphics.Containers;
|
|
|
|
using osu.Framework.Graphics.Sprites;
|
|
|
|
using osu.Game.Online.Chat;
|
|
|
|
using osu.Game.Users.Drawables;
|
|
|
|
using osuTK;
|
|
|
|
|
|
|
|
namespace osu.Game.Overlays.Chat.ChannelControl
|
|
|
|
{
|
|
|
|
public class ControlItemAvatar : CircularContainer
|
|
|
|
{
|
|
|
|
private readonly Channel channel;
|
|
|
|
|
2022-03-15 04:37:54 +08:00
|
|
|
private SpriteIcon? placeholder;
|
2022-03-15 04:14:04 +08:00
|
|
|
private DrawableAvatar? avatar;
|
|
|
|
|
2022-03-15 02:31:13 +08:00
|
|
|
public ControlItemAvatar(Channel channel)
|
|
|
|
{
|
|
|
|
this.channel = channel;
|
|
|
|
}
|
|
|
|
|
|
|
|
[BackgroundDependencyLoader]
|
|
|
|
private void load()
|
|
|
|
{
|
|
|
|
Size = new Vector2(20);
|
|
|
|
Margin = new MarginPadding { Right = 5 };
|
|
|
|
Masking = true;
|
|
|
|
|
|
|
|
Children = new Drawable[]
|
|
|
|
{
|
2022-03-15 04:37:54 +08:00
|
|
|
placeholder = new SpriteIcon
|
2022-03-15 02:31:13 +08:00
|
|
|
{
|
|
|
|
Icon = FontAwesome.Solid.At,
|
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
Origin = Anchor.Centre,
|
2022-03-15 04:37:54 +08:00
|
|
|
Colour = Colour4.White,
|
2022-03-15 02:31:13 +08:00
|
|
|
RelativeSizeAxes = Axes.Both,
|
2022-03-15 04:37:54 +08:00
|
|
|
Alpha = 0.5f,
|
2022-03-15 02:31:13 +08:00
|
|
|
},
|
|
|
|
new DelayedLoadWrapper(avatar = new DrawableAvatar(channel.Users.First())
|
|
|
|
{
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
Origin = Anchor.Centre,
|
|
|
|
}),
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
protected override void LoadComplete()
|
|
|
|
{
|
|
|
|
base.LoadComplete();
|
2022-03-15 04:37:54 +08:00
|
|
|
avatar!.OnLoadComplete += _ => placeholder!.FadeOut(250);
|
2022-03-15 02:31:13 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|