Use UpdateableAvatar and remove redundant ControlItemAvatar class

This commit is contained in:
Jai Sharma 2022-03-19 21:36:11 +00:00
parent 5373c3066f
commit 653bb47dd5
2 changed files with 8 additions and 63 deletions

View File

@ -4,6 +4,7 @@
#nullable enable
using System;
using System.Linq;
using osu.Framework.Allocation;
using osu.Framework.Bindables;
using osu.Framework.Graphics;
@ -14,6 +15,8 @@ using osu.Game.Graphics;
using osu.Game.Graphics.Containers;
using osu.Game.Graphics.Sprites;
using osu.Game.Online.Chat;
using osu.Game.Users.Drawables;
using osuTK;
namespace osu.Game.Overlays.Chat.ChannelControl
{
@ -154,10 +157,14 @@ namespace osu.Game.Overlays.Chat.ChannelControl
if (channel.Type != ChannelType.PM)
return Drawable.Empty();
return new ControlItemAvatar(channel)
return new UpdateableAvatar(channel.Users.First(), false, false, true)
{
Size = new Vector2(20),
Margin = new MarginPadding { Right = 5 },
Anchor = Anchor.CentreLeft,
Origin = Anchor.CentreLeft,
CornerRadius = 10,
Masking = true,
};
}
}

View File

@ -1,62 +0,0 @@
// 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;
private SpriteIcon? placeholder;
private DrawableAvatar? avatar;
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[]
{
placeholder = new SpriteIcon
{
Icon = FontAwesome.Solid.At,
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Colour = Colour4.White,
RelativeSizeAxes = Axes.Both,
Alpha = 0.5f,
},
new DelayedLoadWrapper(avatar = new DrawableAvatar(channel.Users.First())
{
RelativeSizeAxes = Axes.Both,
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
}),
};
}
protected override void LoadComplete()
{
base.LoadComplete();
avatar!.OnLoadComplete += _ => placeholder!.FadeOut(250);
}
}
}