osu/osu.Game/Overlays/Chat/Tabs/PrivateChannelTabItem.cs

97 lines
3.3 KiB
C#
Raw Normal View History

// 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.
2018-04-14 11:32:48 +00:00
using System;
using System.Linq;
using osu.Framework.Allocation;
using osu.Framework.Extensions.Color4Extensions;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Sprites;
2018-04-14 11:32:48 +00:00
using osu.Game.Graphics;
using osu.Game.Online.Chat;
using osu.Game.Users.Drawables;
2018-11-20 07:51:59 +00:00
using osuTK;
2018-04-14 11:32:48 +00:00
namespace osu.Game.Overlays.Chat.Tabs
2018-04-14 11:32:48 +00:00
{
public class PrivateChannelTabItem : ChannelTabItem
2018-04-14 11:32:48 +00:00
{
2019-04-02 10:55:24 +00:00
protected override IconUsage DisplayIcon => FontAwesome.Solid.At;
2018-04-14 11:32:48 +00:00
2018-07-24 03:17:57 +00:00
public PrivateChannelTabItem(Channel value)
2018-04-14 11:32:48 +00:00
: base(value)
{
if (value.Type != ChannelType.PM)
2018-04-14 11:32:48 +00:00
throw new ArgumentException("Argument value needs to have the targettype user!");
2020-12-26 12:54:10 +00:00
ClickableAvatar avatar;
2019-03-17 04:43:23 +00:00
AddRange(new Drawable[]
2018-04-14 11:32:48 +00:00
{
new Container
{
RelativeSizeAxes = Axes.Y,
AutoSizeAxes = Axes.X,
Margin = new MarginPadding
2018-04-14 11:32:48 +00:00
{
Horizontal = 3
},
Origin = Anchor.BottomLeft,
Anchor = Anchor.BottomLeft,
Children = new Drawable[]
{
new CircularContainer
2018-04-14 11:32:48 +00:00
{
Scale = new Vector2(0.95f),
Size = new Vector2(ChatOverlay.TAB_AREA_HEIGHT),
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Masking = true,
2020-12-26 12:54:10 +00:00
Child = new DelayedLoadWrapper(avatar = new ClickableAvatar(value.Users.First())
2018-04-14 11:32:48 +00:00
{
RelativeSizeAxes = Axes.Both,
2018-12-22 10:30:52 +00:00
OpenOnClick = { Value = false },
})
2018-04-14 11:32:48 +00:00
{
RelativeSizeAxes = Axes.Both,
}
},
2018-04-14 11:32:48 +00:00
}
},
});
2019-03-17 04:43:23 +00:00
avatar.OnLoadComplete += d => d.FadeInFromZero(300, Easing.OutQuint);
2018-04-14 11:32:48 +00:00
}
2019-07-28 17:47:26 +00:00
protected override float LeftTextPadding => base.LeftTextPadding + ChatOverlay.TAB_AREA_HEIGHT;
protected override bool ShowCloseOnHover => false;
2018-04-14 11:32:48 +00:00
protected override void FadeActive()
2018-04-14 11:32:48 +00:00
{
base.FadeActive();
2018-04-14 11:32:48 +00:00
this.ResizeWidthTo(200, TRANSITION_LENGTH, Easing.OutQuint);
CloseButton.FadeIn(TRANSITION_LENGTH, Easing.OutQuint);
2018-04-14 11:32:48 +00:00
}
protected override void FadeInactive()
2018-04-14 11:32:48 +00:00
{
base.FadeInactive();
2018-04-14 11:32:48 +00:00
this.ResizeWidthTo(ChatOverlay.TAB_AREA_HEIGHT + 10, TRANSITION_LENGTH, Easing.OutQuint);
CloseButton.FadeOut(TRANSITION_LENGTH, Easing.OutQuint);
2018-04-14 11:32:48 +00:00
}
[BackgroundDependencyLoader]
private void load(OsuColour colours)
{
var user = Value.Users.First();
2018-04-14 11:32:48 +00:00
BackgroundActive = user.Colour != null ? Color4Extensions.FromHex(user.Colour) : colours.BlueDark;
BackgroundInactive = BackgroundActive.Darken(0.5f);
2018-04-14 11:32:48 +00:00
}
}
}