1
0
mirror of https://github.com/ppy/osu.git synced 2024-09-30 20:17:34 +08:00
osu-lazer/osu.Game/Overlays/Chat/ChannelControl/ControlItemAvatar.cs
Jai Sharma 39c30516d0 Implement ChannelControlItem for new chat design
Adds new component `ChannelControlItem` and it's child components to be
used as the clickable control in the new chat sidebar for joined
channels.

Has public properties `HasUnread` and `MentionCount` to control the
display of the channel having unread messages or mentions of the user.

Channel select/join requests are exposed via `OnRequestSelect` and
`OnRequestLeave` events respectively which should be handled by a parent
component.

Requires a cached `Bindable<Channel>` instance to be managed by a parent
component.

Requires a cached `OveralayColourScheme` instance to be provided by a
parent component.
2022-03-14 18:55:27 +00:00

61 lines
1.7 KiB
C#

// 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 DrawableAvatar? avatar;
private readonly Channel channel;
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[]
{
new SpriteIcon
{
Icon = FontAwesome.Solid.At,
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Colour = Colour4.Black,
RelativeSizeAxes = Axes.Both,
Alpha = 0.2f,
},
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 += d => d.FadeInFromZero(300, Easing.OutQuint);
}
}
}