diff --git a/osu.Game/Overlays/Chat/ChannelListItem.cs b/osu.Game/Overlays/Chat/ChannelListItem.cs index 23dba69c90..8b0c3778c3 100644 --- a/osu.Game/Overlays/Chat/ChannelListItem.cs +++ b/osu.Game/Overlays/Chat/ChannelListItem.cs @@ -21,13 +21,12 @@ public class ChannelListItem : ClickableContainer, IFilterable private const float transition_duration = 100; private readonly OsuSpriteText topic; - private readonly OsuSpriteText name; private readonly TextAwesome joinedCheckmark; private Color4? joinedColour; private Color4? topicColour; - public string[] FilterTerms => new[] { Channel.Name }; + public string[] FilterTerms => new[] { channel.Name }; public bool MatchingCurrentFilter { set @@ -40,28 +39,15 @@ public bool MatchingCurrentFilter public Action OnRequestLeave; private Channel channel; - public Channel Channel - { - get { return channel; } - set - { - if (value == channel) return; - if (channel != null) channel.Joined.ValueChanged -= updateColour; - channel = value; - name.Text = Channel.ToString(); - topic.Text = Channel.Topic; - channel.Joined.ValueChanged += updateColour; - updateColour(Channel.Joined); - } - } - - public ChannelListItem() + public ChannelListItem(Channel channel) { + this.channel = channel; + RelativeSizeAxes = Axes.X; AutoSizeAxes = Axes.Y; - Action = () => { (Channel.Joined ? OnRequestLeave : OnRequestJoin)?.Invoke(Channel); }; + Action = () => { (channel.Joined ? OnRequestLeave : OnRequestJoin)?.Invoke(channel); }; Children = new Drawable[] { @@ -94,8 +80,9 @@ public ChannelListItem() AutoSizeAxes = Axes.Y, Children = new[] { - name = new OsuSpriteText + new OsuSpriteText { + Text = channel.ToString(), TextSize = text_size, Font = @"Exo2.0-Bold", Shadow = false, @@ -112,6 +99,7 @@ public ChannelListItem() { topic = new OsuSpriteText { + Text = channel.Topic, TextSize = text_size, Font = @"Exo2.0-SemiBold", Shadow = false, @@ -146,6 +134,8 @@ public ChannelListItem() }, }, }; + + channel.Joined.ValueChanged += updateColour; } [BackgroundDependencyLoader] @@ -154,7 +144,7 @@ private void load(OsuColour colours) topicColour = colours.Gray9; joinedColour = colours.Blue; - updateColour(Channel.Joined); + updateColour(channel.Joined); } protected override void Dispose(bool isDisposing) diff --git a/osu.Game/Overlays/Chat/ChannelSection.cs b/osu.Game/Overlays/Chat/ChannelSection.cs index e5fce2667e..c0391c7113 100644 --- a/osu.Game/Overlays/Chat/ChannelSection.cs +++ b/osu.Game/Overlays/Chat/ChannelSection.cs @@ -35,7 +35,7 @@ public string Header public IEnumerable Channels { - set { ChannelFlow.Children = value.Select(c => new ChannelListItem { Channel = c }); } + set { ChannelFlow.Children = value.Select(c => new ChannelListItem(c)); } } public ChannelSection()