diff --git a/osu.Game/Overlays/Chat/ChannelControl/ControlItem.cs b/osu.Game/Overlays/Chat/ChannelControl/ControlItem.cs index bf4d60d4e2..df857a6dce 100644 --- a/osu.Game/Overlays/Chat/ChannelControl/ControlItem.cs +++ b/osu.Game/Overlays/Chat/ChannelControl/ControlItem.cs @@ -10,7 +10,9 @@ using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Shapes; using osu.Framework.Input.Events; +using osu.Game.Graphics; using osu.Game.Graphics.Containers; +using osu.Game.Graphics.Sprites; using osu.Game.Online.Chat; namespace osu.Game.Overlays.Chat.ChannelControl @@ -28,18 +30,22 @@ namespace osu.Game.Overlays.Chat.ChannelControl private Box? hoverBox; private Box? selectBox; + private OsuSpriteText? text; private ControlItemClose? close; [Resolved] private Bindable selectedChannel { get; set; } = null!; + [Resolved] + private OverlayColourProvider colourProvider { get; set; } = null!; + public ControlItem(Channel channel) { this.channel = channel; } [BackgroundDependencyLoader] - private void load(OverlayColourProvider colourProvider) + private void load() { Height = 30; RelativeSizeAxes = Axes.X; @@ -77,11 +83,16 @@ namespace osu.Game.Overlays.Chat.ChannelControl new[] { createIcon(), - new ControlItemText(channel) + text = new OsuSpriteText { Anchor = Anchor.CentreLeft, Origin = Anchor.CentreLeft, - Unread = { BindTarget = Unread }, + Text = channel.Type == ChannelType.Public ? $"# {channel.Name.Substring(1)}" : channel.Name, + Font = OsuFont.Torus.With(size: 17, weight: FontWeight.SemiBold), + Colour = colourProvider.Light3, + Margin = new MarginPadding { Bottom = 2 }, + RelativeSizeAxes = Axes.X, + Truncate = true, }, new ControlItemMention { @@ -117,6 +128,11 @@ namespace osu.Game.Overlays.Chat.ChannelControl else selectBox?.Hide(); }, true); + + Unread.BindValueChanged(change => + { + text!.Colour = change.NewValue ? colourProvider.Content1 : colourProvider.Light3; + }, true); } protected override bool OnHover(HoverEvent e) diff --git a/osu.Game/Overlays/Chat/ChannelControl/ControlItemText.cs b/osu.Game/Overlays/Chat/ChannelControl/ControlItemText.cs deleted file mode 100644 index 490edb5d28..0000000000 --- a/osu.Game/Overlays/Chat/ChannelControl/ControlItemText.cs +++ /dev/null @@ -1,59 +0,0 @@ -// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. -// See the LICENCE file in the repository root for full licence text. - -#nullable enable - -using osu.Framework.Allocation; -using osu.Framework.Bindables; -using osu.Framework.Graphics; -using osu.Framework.Graphics.Containers; -using osu.Game.Graphics; -using osu.Game.Graphics.Sprites; -using osu.Game.Online.Chat; - -namespace osu.Game.Overlays.Chat.ChannelControl -{ - public class ControlItemText : Container - { - public readonly BindableBool Unread = new BindableBool(); - - private readonly Channel channel; - - private OsuSpriteText? text; - - [Resolved] - private OverlayColourProvider colourProvider { get; set; } = null!; - - public ControlItemText(Channel channel) - { - this.channel = channel; - } - - [BackgroundDependencyLoader] - private void load() - { - RelativeSizeAxes = Axes.Both; - Child = text = new OsuSpriteText - { - Anchor = Anchor.CentreLeft, - Origin = Anchor.CentreLeft, - Text = channel.Type == ChannelType.Public ? $"# {channel.Name.Substring(1)}" : channel.Name, - Font = OsuFont.Torus.With(size: 17, weight: FontWeight.SemiBold), - Colour = colourProvider.Light3, - Margin = new MarginPadding { Bottom = 2 }, - RelativeSizeAxes = Axes.X, - Truncate = true, - }; - } - - protected override void LoadComplete() - { - base.LoadComplete(); - - Unread.BindValueChanged(change => - { - text!.Colour = change.NewValue ? colourProvider.Content1 : colourProvider.Light3; - }, true); - } - } -}