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