2017-05-21 05:06:25 +08:00
|
|
|
|
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
|
|
|
|
|
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
|
|
|
|
|
|
|
|
|
using OpenTK;
|
|
|
|
|
using OpenTK.Graphics;
|
|
|
|
|
using osu.Framework.Allocation;
|
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
|
using osu.Framework.Graphics.Containers;
|
|
|
|
|
using osu.Game.Graphics;
|
|
|
|
|
using osu.Game.Graphics.Sprites;
|
2017-05-21 05:29:57 +08:00
|
|
|
|
using osu.Game.Online.Chat;
|
2017-05-21 05:06:25 +08:00
|
|
|
|
|
|
|
|
|
namespace osu.Game.Overlays.Chat
|
|
|
|
|
{
|
|
|
|
|
public class ChannelListItem : ClickableContainer
|
|
|
|
|
{
|
2017-05-21 05:29:57 +08:00
|
|
|
|
private const float width_padding = 5;
|
2017-05-21 05:06:25 +08:00
|
|
|
|
private const float channel_width = 150;
|
|
|
|
|
private const float topic_width = 380;
|
|
|
|
|
private const float text_size = 15;
|
|
|
|
|
private const float transition_duration = 100;
|
|
|
|
|
|
|
|
|
|
private readonly OsuSpriteText topic;
|
2017-05-21 06:37:11 +08:00
|
|
|
|
private readonly OsuSpriteText name;
|
2017-05-21 05:06:25 +08:00
|
|
|
|
private readonly TextAwesome joinedCheckmark;
|
|
|
|
|
|
|
|
|
|
private Color4? joinedColour;
|
|
|
|
|
private Color4? topicColour;
|
|
|
|
|
|
2017-05-21 06:37:11 +08:00
|
|
|
|
private Channel channel;
|
|
|
|
|
public Channel Channel
|
2017-05-21 05:06:25 +08:00
|
|
|
|
{
|
2017-05-21 06:37:11 +08:00
|
|
|
|
get { return channel; }
|
2017-05-21 05:06:25 +08:00
|
|
|
|
set
|
|
|
|
|
{
|
2017-05-21 06:37:11 +08:00
|
|
|
|
if (value == channel) return;
|
|
|
|
|
channel = value;
|
2017-05-21 05:06:25 +08:00
|
|
|
|
|
2017-05-21 06:37:11 +08:00
|
|
|
|
name.Text = Channel.ToString();
|
|
|
|
|
topic.Text = Channel.Topic;
|
2017-05-21 05:06:25 +08:00
|
|
|
|
updateColour();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2017-05-21 06:37:11 +08:00
|
|
|
|
public ChannelListItem()
|
2017-05-21 05:06:25 +08:00
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.X;
|
|
|
|
|
AutoSizeAxes = Axes.Y;
|
|
|
|
|
|
|
|
|
|
Children = new Drawable[]
|
|
|
|
|
{
|
|
|
|
|
new FillFlowContainer
|
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.X,
|
|
|
|
|
AutoSizeAxes = Axes.Y,
|
|
|
|
|
Direction = FillDirection.Horizontal,
|
|
|
|
|
Children = new Drawable[]
|
|
|
|
|
{
|
|
|
|
|
new Container
|
|
|
|
|
{
|
|
|
|
|
Children = new[]
|
|
|
|
|
{
|
|
|
|
|
joinedCheckmark = new TextAwesome
|
|
|
|
|
{
|
|
|
|
|
Anchor = Anchor.TopRight,
|
|
|
|
|
Origin = Anchor.TopRight,
|
|
|
|
|
Icon = FontAwesome.fa_check_circle,
|
|
|
|
|
TextSize = text_size,
|
|
|
|
|
Margin = new MarginPadding { Right = 10f },
|
|
|
|
|
Alpha = 0f,
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
new Container
|
|
|
|
|
{
|
|
|
|
|
Width = channel_width,
|
|
|
|
|
AutoSizeAxes = Axes.Y,
|
|
|
|
|
Children = new[]
|
|
|
|
|
{
|
2017-05-21 06:37:11 +08:00
|
|
|
|
name = new OsuSpriteText
|
2017-05-21 05:06:25 +08:00
|
|
|
|
{
|
|
|
|
|
TextSize = text_size,
|
|
|
|
|
Font = @"Exo2.0-Bold",
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
new Container
|
|
|
|
|
{
|
|
|
|
|
Width = topic_width,
|
|
|
|
|
AutoSizeAxes = Axes.Y,
|
2017-05-21 05:29:57 +08:00
|
|
|
|
Margin = new MarginPadding { Left = width_padding },
|
2017-05-21 05:06:25 +08:00
|
|
|
|
Children = new[]
|
|
|
|
|
{
|
|
|
|
|
topic = new OsuSpriteText
|
|
|
|
|
{
|
|
|
|
|
TextSize = text_size,
|
|
|
|
|
Font = @"Exo2.0-SemiBold",
|
|
|
|
|
Alpha = 0.8f,
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
new FillFlowContainer
|
|
|
|
|
{
|
|
|
|
|
AutoSizeAxes = Axes.Both,
|
|
|
|
|
Direction = FillDirection.Horizontal,
|
2017-05-21 05:29:57 +08:00
|
|
|
|
Margin = new MarginPadding { Left = width_padding },
|
2017-05-21 05:06:25 +08:00
|
|
|
|
Spacing = new Vector2(3f, 0f),
|
|
|
|
|
Children = new Drawable[]
|
|
|
|
|
{
|
|
|
|
|
new TextAwesome
|
|
|
|
|
{
|
|
|
|
|
Icon = FontAwesome.fa_user,
|
|
|
|
|
TextSize = text_size - 2,
|
|
|
|
|
Margin = new MarginPadding { Top = 1 },
|
|
|
|
|
},
|
|
|
|
|
new OsuSpriteText
|
|
|
|
|
{
|
2017-05-21 06:30:40 +08:00
|
|
|
|
Text = @"0",
|
2017-05-21 05:06:25 +08:00
|
|
|
|
TextSize = text_size,
|
|
|
|
|
Font = @"Exo2.0-SemiBold",
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[BackgroundDependencyLoader]
|
|
|
|
|
private void load(OsuColour colours)
|
|
|
|
|
{
|
|
|
|
|
topicColour = colours.Gray9;
|
|
|
|
|
joinedColour = colours.Blue;
|
|
|
|
|
|
|
|
|
|
updateColour();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void updateColour()
|
2017-05-21 05:29:57 +08:00
|
|
|
|
{
|
2017-05-21 06:37:11 +08:00
|
|
|
|
joinedCheckmark.FadeTo(Channel.Joined ? 1f : 0f, transition_duration);
|
|
|
|
|
topic.FadeTo(Channel.Joined ? 0.8f : 1f, transition_duration);
|
|
|
|
|
topic.FadeColour(Channel.Joined ? Color4.White : topicColour ?? Color4.White, transition_duration);
|
|
|
|
|
FadeColour(Channel.Joined ? joinedColour ?? Color4.White : Color4.White, transition_duration);
|
2017-05-21 05:06:25 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|