2019-01-24 16:43:03 +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.
|
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.Game.Graphics;
|
|
|
|
|
using osu.Game.Graphics.Sprites;
|
|
|
|
|
using osu.Game.Online.Chat;
|
|
|
|
|
using osu.Game.Users;
|
2018-11-20 15:51:59 +08:00
|
|
|
|
using osuTK;
|
2018-04-14 19:32:48 +08:00
|
|
|
|
|
2018-07-10 01:42:57 +08:00
|
|
|
|
namespace osu.Game.Overlays.Chat.Tabs
|
2018-04-14 19:32:48 +08:00
|
|
|
|
{
|
2018-09-06 15:21:31 +08:00
|
|
|
|
public class PrivateChannelTabItem : ChannelTabItem
|
2018-04-14 19:32:48 +08:00
|
|
|
|
{
|
|
|
|
|
private readonly OsuSpriteText username;
|
|
|
|
|
private readonly Avatar avatarContainer;
|
2018-09-06 15:21:31 +08:00
|
|
|
|
|
|
|
|
|
protected override FontAwesome DisplayIcon => FontAwesome.fa_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)
|
|
|
|
|
{
|
2018-11-13 14:20:40 +08:00
|
|
|
|
if (value.Type != ChannelType.PM)
|
2018-04-14 19:32:48 +08:00
|
|
|
|
throw new ArgumentException("Argument value needs to have the targettype user!");
|
|
|
|
|
|
2018-09-06 15:21:31 +08:00
|
|
|
|
AddRange(new Drawable[]
|
2018-04-14 19:32:48 +08:00
|
|
|
|
{
|
|
|
|
|
new Container
|
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.Y,
|
|
|
|
|
AutoSizeAxes = Axes.X,
|
2018-09-06 15:21:31 +08:00
|
|
|
|
Margin = new MarginPadding
|
2018-04-14 19:32:48 +08:00
|
|
|
|
{
|
2018-09-06 15:21:31 +08:00
|
|
|
|
Horizontal = 3
|
|
|
|
|
},
|
|
|
|
|
Origin = Anchor.BottomLeft,
|
|
|
|
|
Anchor = Anchor.BottomLeft,
|
|
|
|
|
Children = new Drawable[]
|
|
|
|
|
{
|
|
|
|
|
new CircularContainer
|
2018-04-14 19:32:48 +08:00
|
|
|
|
{
|
2018-09-06 15:21:31 +08:00
|
|
|
|
Scale = new Vector2(0.95f),
|
|
|
|
|
Size = new Vector2(ChatOverlay.TAB_AREA_HEIGHT),
|
|
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
|
Origin = Anchor.Centre,
|
|
|
|
|
Masking = true,
|
2018-11-13 14:20:40 +08:00
|
|
|
|
Child = new DelayedLoadWrapper(new Avatar(value.Users.First())
|
2018-04-14 19:32:48 +08:00
|
|
|
|
{
|
2018-09-06 15:21:31 +08:00
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
2018-12-22 18:30:52 +08:00
|
|
|
|
OpenOnClick = { Value = false },
|
2018-09-06 15:21:31 +08:00
|
|
|
|
OnLoadComplete = d => d.FadeInFromZero(300, Easing.OutQuint),
|
|
|
|
|
})
|
2018-04-14 19:32:48 +08:00
|
|
|
|
{
|
2018-09-06 15:21:31 +08:00
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
|
}
|
|
|
|
|
},
|
2018-04-14 19:32:48 +08:00
|
|
|
|
}
|
2018-09-06 15:21:31 +08:00
|
|
|
|
},
|
|
|
|
|
});
|
2018-07-10 05:12:41 +08:00
|
|
|
|
|
2018-09-06 15:21:31 +08:00
|
|
|
|
Text.X = ChatOverlay.TAB_AREA_HEIGHT;
|
|
|
|
|
TextBold.X = ChatOverlay.TAB_AREA_HEIGHT;
|
2018-04-14 19:32:48 +08:00
|
|
|
|
}
|
|
|
|
|
|
2018-09-06 15:21:31 +08:00
|
|
|
|
protected override bool ShowCloseOnHover => false;
|
2018-04-14 19:32:48 +08:00
|
|
|
|
|
2018-09-06 15:21:31 +08:00
|
|
|
|
protected override void FadeActive()
|
2018-04-14 19:32:48 +08:00
|
|
|
|
{
|
2018-09-06 15:21:31 +08:00
|
|
|
|
base.FadeActive();
|
2018-04-14 19:32:48 +08:00
|
|
|
|
|
2018-09-06 16:22:51 +08:00
|
|
|
|
this.ResizeWidthTo(200, TRANSITION_LENGTH, Easing.OutQuint);
|
2018-09-06 15:21:31 +08:00
|
|
|
|
CloseButton.FadeIn(TRANSITION_LENGTH, Easing.OutQuint);
|
2018-04-14 19:32:48 +08:00
|
|
|
|
}
|
|
|
|
|
|
2018-09-06 15:21:31 +08:00
|
|
|
|
protected override void FadeInactive()
|
2018-04-14 19:32:48 +08:00
|
|
|
|
{
|
2018-09-06 15:21:31 +08:00
|
|
|
|
base.FadeInactive();
|
2018-04-14 19:32:48 +08:00
|
|
|
|
|
2018-09-06 15:21:31 +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)
|
|
|
|
|
{
|
2018-11-13 14:20:40 +08:00
|
|
|
|
var user = Value.Users.First();
|
2018-04-14 19:32:48 +08:00
|
|
|
|
|
2018-09-06 15:21:31 +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
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|