From 39c30516d0874b025d3e8e0610bd6ab096ebd2a6 Mon Sep 17 00:00:00 2001 From: Jai Sharma Date: Mon, 14 Mar 2022 18:31:13 +0000 Subject: [PATCH 01/38] Implement `ChannelControlItem` for new chat design Adds new component `ChannelControlItem` and it's child components to be used as the clickable control in the new chat sidebar for joined channels. Has public properties `HasUnread` and `MentionCount` to control the display of the channel having unread messages or mentions of the user. Channel select/join requests are exposed via `OnRequestSelect` and `OnRequestLeave` events respectively which should be handled by a parent component. Requires a cached `Bindable` instance to be managed by a parent component. Requires a cached `OveralayColourScheme` instance to be provided by a parent component. --- .../Online/TestSceneChannelControlItem.cs | 145 +++++++++++++++ .../Chat/ChannelControl/ControlItem.cs | 167 ++++++++++++++++++ .../Chat/ChannelControl/ControlItemAvatar.cs | 60 +++++++ .../Chat/ChannelControl/ControlItemClose.cs | 55 ++++++ .../Chat/ChannelControl/ControlItemMention.cs | 77 ++++++++ .../Chat/ChannelControl/ControlItemText.cs | 71 ++++++++ 6 files changed, 575 insertions(+) create mode 100644 osu.Game.Tests/Visual/Online/TestSceneChannelControlItem.cs create mode 100644 osu.Game/Overlays/Chat/ChannelControl/ControlItem.cs create mode 100644 osu.Game/Overlays/Chat/ChannelControl/ControlItemAvatar.cs create mode 100644 osu.Game/Overlays/Chat/ChannelControl/ControlItemClose.cs create mode 100644 osu.Game/Overlays/Chat/ChannelControl/ControlItemMention.cs create mode 100644 osu.Game/Overlays/Chat/ChannelControl/ControlItemText.cs diff --git a/osu.Game.Tests/Visual/Online/TestSceneChannelControlItem.cs b/osu.Game.Tests/Visual/Online/TestSceneChannelControlItem.cs new file mode 100644 index 0000000000..a1431f696b --- /dev/null +++ b/osu.Game.Tests/Visual/Online/TestSceneChannelControlItem.cs @@ -0,0 +1,145 @@ +// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. +// See the LICENCE file in the repository root for full licence text. + +using NUnit.Framework; +using System.Collections.Generic; +using osu.Framework.Allocation; +using osu.Framework.Bindables; +using osu.Framework.Graphics; +using osu.Framework.Graphics.Containers; +using osu.Framework.Graphics.Shapes; +using osu.Game.Graphics.Sprites; +using osu.Game.Online.API.Requests.Responses; +using osu.Game.Online.Chat; +using osu.Game.Overlays; +using osu.Game.Overlays.Chat.ChannelControl; +using osuTK; + +namespace osu.Game.Tests.Visual.Online +{ + [TestFixture] + public class TestSceneChannelControlItem : OsuTestScene + { + [Cached] + private readonly OverlayColourProvider colourProvider = new OverlayColourProvider(OverlayColourScheme.Pink); + + [Cached] + private readonly Bindable selected = new Bindable(); + + private static List channels = new List + { + createPublicChannel("#public-channel"), + createPublicChannel("#public-channel-long-name"), + createPrivateChannel("test user", 2), + createPrivateChannel("test user long name", 3), + }; + + private readonly Dictionary channelMap = new Dictionary(); + + private FillFlowContainer flow; + private OsuSpriteText selectedText; + private OsuSpriteText leaveText; + + [SetUp] + public void SetUp() + { + Schedule(() => + { + Children = new Drawable[] + { + selectedText = new OsuSpriteText + { + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + Y = -140, + }, + leaveText = new OsuSpriteText + { + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + Y = -120, + }, + new Container + { + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + Size = new Vector2(190, 200), + Children = new Drawable[] + { + new Box + { + RelativeSizeAxes = Axes.Both, + Colour = colourProvider.Background6, + }, + flow = new FillFlowContainer + { + Spacing = new Vector2(20), + RelativeSizeAxes = Axes.Both, + }, + }, + }, + }; + + selected.BindValueChanged(change => + { + selectedText.Text = $"Selected Channel: {change.NewValue?.Name ?? "[null]"}"; + }, true); + + foreach (var channel in channels) + { + var item = new ControlItem(channel); + flow.Add(item); + channelMap.Add(channel, item); + item.OnRequestSelect += channel => selected.Value = channel; + item.OnRequestLeave += leaveChannel; + } + }); + } + + [Test] + public void TestVisual() + { + AddStep("Unread Selected", () => + { + if (selected.Value != null) + channelMap[selected.Value].HasUnread = true; + }); + + AddStep("Read Selected", () => + { + if (selected.Value != null) + channelMap[selected.Value].HasUnread = false; + }); + + AddStep("Add Mention Selected", () => + { + if (selected.Value != null) + channelMap[selected.Value].MentionCount++; + }); + + AddStep("Add 98 Mentions Selected", () => + { + if (selected.Value != null) + channelMap[selected.Value].MentionCount += 98; + }); + + AddStep("Clear Mentions Selected", () => + { + if (selected.Value != null) + channelMap[selected.Value].MentionCount = 0; + }); + } + + private void leaveChannel(Channel channel) + { + leaveText.Text = $"OnRequestLeave: {channel.Name}"; + leaveText.FadeIn().Then().FadeOut(1000, Easing.InQuint); + } + + private static Channel createPublicChannel(string name) => + new Channel { Name = name, Type = ChannelType.Public, Id = 1234 }; + + private static Channel createPrivateChannel(string username, int id) + => new Channel(new APIUser { Id = id, Username = username }); + } +} diff --git a/osu.Game/Overlays/Chat/ChannelControl/ControlItem.cs b/osu.Game/Overlays/Chat/ChannelControl/ControlItem.cs new file mode 100644 index 0000000000..559f75f198 --- /dev/null +++ b/osu.Game/Overlays/Chat/ChannelControl/ControlItem.cs @@ -0,0 +1,167 @@ +// 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 System; +using osu.Framework.Allocation; +using osu.Framework.Bindables; +using osu.Framework.Graphics; +using osu.Framework.Graphics.Containers; +using osu.Framework.Graphics.Shapes; +using osu.Framework.Input.Events; +using osu.Game.Graphics.Containers; +using osu.Game.Online.Chat; + +namespace osu.Game.Overlays.Chat.ChannelControl +{ + public class ControlItem : OsuClickableContainer + { + public event Action? OnRequestSelect; + public event Action? OnRequestLeave; + + public int MentionCount + { + get => mention?.MentionCount ?? 0; + set + { + if (mention != null) + mention.MentionCount = value; + } + } + + public bool HasUnread + { + get => text?.HasUnread ?? false; + set + { + if (text != null) + text.HasUnread = value; + } + } + + private Box? hoverBox; + private Box? selectBox; + private ControlItemText? text; + private ControlItemMention? mention; + private ControlItemClose? close; + + [Resolved] + private Bindable? selectedChannel { get; set; } + + [Resolved] + private OverlayColourProvider? colourProvider { get; set; } + + private readonly Channel channel; + + public ControlItem(Channel channel) + { + this.channel = channel; + } + + [BackgroundDependencyLoader] + private void load() + { + Height = 30; + RelativeSizeAxes = Axes.X; + + Children = new Drawable[] + { + hoverBox = new Box + { + RelativeSizeAxes = Axes.Both, + Colour = colourProvider!.Background3, + Alpha = 0f, + }, + selectBox = new Box + { + RelativeSizeAxes = Axes.Both, + Colour = colourProvider!.Background4, + Alpha = 0f, + }, + new Container + { + RelativeSizeAxes = Axes.Both, + Padding = new MarginPadding { Left = 18, Right = 5 }, + Child = new GridContainer + { + RelativeSizeAxes = Axes.Both, + ColumnDimensions = new[] + { + new Dimension(GridSizeMode.AutoSize), + new Dimension(), + new Dimension(GridSizeMode.AutoSize), + new Dimension(GridSizeMode.AutoSize), + }, + Content = new[] + { + new Drawable[] + { + createAvatar(), + text = new ControlItemText(channel) + { + Anchor = Anchor.CentreLeft, + Origin = Anchor.CentreLeft, + }, + mention = new ControlItemMention + { + Anchor = Anchor.CentreLeft, + Origin = Anchor.CentreLeft, + Margin = new MarginPadding { Right = 3 }, + }, + close = new ControlItemClose + { + Anchor = Anchor.CentreLeft, + Origin = Anchor.CentreLeft, + Margin = new MarginPadding { Right = 3 }, + } + } + }, + }, + }, + }; + } + + protected override void LoadComplete() + { + base.LoadComplete(); + + selectedChannel?.BindValueChanged(change => + { + if (change.NewValue == channel) + selectBox?.Show(); + else + selectBox?.Hide(); + }, true); + + Action = () => OnRequestSelect?.Invoke(channel); + close!.Action = () => OnRequestLeave?.Invoke(channel); + } + + protected override bool OnHover(HoverEvent e) + { + hoverBox?.Show(); + close?.Show(); + return base.OnHover(e); + } + + protected override void OnHoverLost(HoverLostEvent e) + { + hoverBox?.Hide(); + close?.Hide(); + base.OnHoverLost(e); + } + + private Drawable createAvatar() + { + if (channel.Type != ChannelType.PM) + return Drawable.Empty(); + + return new ControlItemAvatar(channel) + { + Anchor = Anchor.CentreLeft, + Origin = Anchor.CentreLeft, + }; + } + } +} diff --git a/osu.Game/Overlays/Chat/ChannelControl/ControlItemAvatar.cs b/osu.Game/Overlays/Chat/ChannelControl/ControlItemAvatar.cs new file mode 100644 index 0000000000..9192f20cb1 --- /dev/null +++ b/osu.Game/Overlays/Chat/ChannelControl/ControlItemAvatar.cs @@ -0,0 +1,60 @@ +// 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 System.Linq; +using osu.Framework.Allocation; +using osu.Framework.Graphics; +using osu.Framework.Graphics.Containers; +using osu.Framework.Graphics.Sprites; +using osu.Game.Online.Chat; +using osu.Game.Users.Drawables; +using osuTK; + +namespace osu.Game.Overlays.Chat.ChannelControl +{ + public class ControlItemAvatar : CircularContainer + { + private DrawableAvatar? avatar; + private readonly Channel channel; + + public ControlItemAvatar(Channel channel) + { + this.channel = channel; + } + + [BackgroundDependencyLoader] + private void load() + { + Size = new Vector2(20); + Margin = new MarginPadding { Right = 5 }; + Masking = true; + + Children = new Drawable[] + { + new SpriteIcon + { + Icon = FontAwesome.Solid.At, + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + Colour = Colour4.Black, + RelativeSizeAxes = Axes.Both, + Alpha = 0.2f, + }, + new DelayedLoadWrapper(avatar = new DrawableAvatar(channel.Users.First()) + { + RelativeSizeAxes = Axes.Both, + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + }), + }; + } + + protected override void LoadComplete() + { + base.LoadComplete(); + avatar!.OnLoadComplete += d => d.FadeInFromZero(300, Easing.OutQuint); + } + } +} diff --git a/osu.Game/Overlays/Chat/ChannelControl/ControlItemClose.cs b/osu.Game/Overlays/Chat/ChannelControl/ControlItemClose.cs new file mode 100644 index 0000000000..4b190e18fd --- /dev/null +++ b/osu.Game/Overlays/Chat/ChannelControl/ControlItemClose.cs @@ -0,0 +1,55 @@ +// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. +// See the LICENCE file in the repository root for full licence text. + +using osu.Framework.Graphics; +using osu.Framework.Graphics.Sprites; +using osu.Framework.Input.Events; +using osu.Game.Graphics.Containers; +using osuTK; +using osuTK.Graphics; + +namespace osu.Game.Overlays.Chat.ChannelControl +{ + public class ControlItemClose : OsuClickableContainer + { + private readonly SpriteIcon icon; + + public ControlItemClose() + { + Alpha = 0f; + Size = new Vector2(20); + Child = icon = new SpriteIcon + { + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + Scale = new Vector2(0.75f), + Icon = FontAwesome.Solid.TimesCircle, + RelativeSizeAxes = Axes.Both, + }; + } + + protected override bool OnMouseDown(MouseDownEvent e) + { + icon.ScaleTo(0.5f, 1000, Easing.OutQuint); + return base.OnMouseDown(e); + } + + protected override void OnMouseUp(MouseUpEvent e) + { + icon.ScaleTo(0.75f, 1000, Easing.OutElastic); + base.OnMouseUp(e); + } + + protected override bool OnHover(HoverEvent e) + { + icon.FadeColour(Color4.Red, 200, Easing.OutQuint); + return base.OnHover(e); + } + + protected override void OnHoverLost(HoverLostEvent e) + { + icon.FadeColour(Color4.White, 200, Easing.OutQuint); + base.OnHoverLost(e); + } + } +} diff --git a/osu.Game/Overlays/Chat/ChannelControl/ControlItemMention.cs b/osu.Game/Overlays/Chat/ChannelControl/ControlItemMention.cs new file mode 100644 index 0000000000..12de154faa --- /dev/null +++ b/osu.Game/Overlays/Chat/ChannelControl/ControlItemMention.cs @@ -0,0 +1,77 @@ +// 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.Graphics; +using osu.Framework.Graphics.Containers; +using osu.Framework.Graphics.Shapes; +using osu.Game.Graphics; +using osu.Game.Graphics.Sprites; +using osuTK; + +namespace osu.Game.Overlays.Chat.ChannelControl +{ + public class ControlItemMention : CircularContainer + { + private int mentionCount = 0; + public int MentionCount + { + get => mentionCount; + set + { + if (value == mentionCount) + return; + + mentionCount = value; + updateText(); + } + } + + private OsuSpriteText? countText; + + [Resolved] + private OverlayColourProvider? colourProvider { get; set; } + + [BackgroundDependencyLoader] + private void load() + { + Masking = true; + Size = new Vector2(20, 12); + Alpha = 0f; + + Children = new Drawable[] + { + new Box + { + RelativeSizeAxes = Axes.Both, + Colour = colourProvider!.Colour1, + }, + countText = new OsuSpriteText + { + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + Font = OsuFont.Torus.With(size: 11, weight: FontWeight.Bold), + Margin = new MarginPadding { Bottom = 1 }, + Colour = colourProvider.Background5, + }, + }; + + updateText(); + } + + private void updateText() + { + if (mentionCount > 99) + countText!.Text = "99+"; + else + countText!.Text = mentionCount.ToString(); + + if (mentionCount > 0) + this.Show(); + else + this.Hide(); + } + } +} diff --git a/osu.Game/Overlays/Chat/ChannelControl/ControlItemText.cs b/osu.Game/Overlays/Chat/ChannelControl/ControlItemText.cs new file mode 100644 index 0000000000..2b8f50e184 --- /dev/null +++ b/osu.Game/Overlays/Chat/ChannelControl/ControlItemText.cs @@ -0,0 +1,71 @@ +// 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.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 bool HasUnread + { + get => hasUnread; + set + { + if (hasUnread == value) + return; + + hasUnread = value; + updateText(); + } + } + + private bool hasUnread = false; + private OsuSpriteText? text; + + [Resolved] + private OverlayColourProvider? colourProvider { get; set; } + + private readonly Channel channel; + + 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, + }; + } + + private void updateText() + { + if (!IsLoaded) + return; + + if (HasUnread) + text!.Colour = Colour4.White; + else + text!.Colour = colourProvider!.Light3; + } + } +} From c0d82dfb41478a97e633a60fe847930bf85bf7ca Mon Sep 17 00:00:00 2001 From: Jai Sharma Date: Mon, 14 Mar 2022 19:42:55 +0000 Subject: [PATCH 02/38] Code quality fixes --- .../Visual/Online/TestSceneChannelControlItem.cs | 4 ++-- osu.Game/Overlays/Chat/ChannelControl/ControlItem.cs | 2 +- .../Chat/ChannelControl/ControlItemMention.cs | 12 +++++------- .../Overlays/Chat/ChannelControl/ControlItemText.cs | 3 ++- 4 files changed, 10 insertions(+), 11 deletions(-) diff --git a/osu.Game.Tests/Visual/Online/TestSceneChannelControlItem.cs b/osu.Game.Tests/Visual/Online/TestSceneChannelControlItem.cs index a1431f696b..64ad924ecb 100644 --- a/osu.Game.Tests/Visual/Online/TestSceneChannelControlItem.cs +++ b/osu.Game.Tests/Visual/Online/TestSceneChannelControlItem.cs @@ -26,7 +26,7 @@ namespace osu.Game.Tests.Visual.Online [Cached] private readonly Bindable selected = new Bindable(); - private static List channels = new List + private static readonly List channels = new List { createPublicChannel("#public-channel"), createPublicChannel("#public-channel-long-name"), @@ -90,7 +90,7 @@ namespace osu.Game.Tests.Visual.Online var item = new ControlItem(channel); flow.Add(item); channelMap.Add(channel, item); - item.OnRequestSelect += channel => selected.Value = channel; + item.OnRequestSelect += c => selected.Value = c; item.OnRequestLeave += leaveChannel; } }); diff --git a/osu.Game/Overlays/Chat/ChannelControl/ControlItem.cs b/osu.Game/Overlays/Chat/ChannelControl/ControlItem.cs index 559f75f198..e475ac7821 100644 --- a/osu.Game/Overlays/Chat/ChannelControl/ControlItem.cs +++ b/osu.Game/Overlays/Chat/ChannelControl/ControlItem.cs @@ -95,7 +95,7 @@ namespace osu.Game.Overlays.Chat.ChannelControl }, Content = new[] { - new Drawable[] + new[] { createAvatar(), text = new ControlItemText(channel) diff --git a/osu.Game/Overlays/Chat/ChannelControl/ControlItemMention.cs b/osu.Game/Overlays/Chat/ChannelControl/ControlItemMention.cs index 12de154faa..6af2e26af8 100644 --- a/osu.Game/Overlays/Chat/ChannelControl/ControlItemMention.cs +++ b/osu.Game/Overlays/Chat/ChannelControl/ControlItemMention.cs @@ -15,7 +15,8 @@ namespace osu.Game.Overlays.Chat.ChannelControl { public class ControlItemMention : CircularContainer { - private int mentionCount = 0; + private int mentionCount; + public int MentionCount { get => mentionCount; @@ -63,15 +64,12 @@ namespace osu.Game.Overlays.Chat.ChannelControl private void updateText() { - if (mentionCount > 99) - countText!.Text = "99+"; - else - countText!.Text = mentionCount.ToString(); + countText!.Text = MentionCount > 99 ? "99+" : MentionCount.ToString(); if (mentionCount > 0) - this.Show(); + Show(); else - this.Hide(); + Hide(); } } } diff --git a/osu.Game/Overlays/Chat/ChannelControl/ControlItemText.cs b/osu.Game/Overlays/Chat/ChannelControl/ControlItemText.cs index 2b8f50e184..bb88d733d4 100644 --- a/osu.Game/Overlays/Chat/ChannelControl/ControlItemText.cs +++ b/osu.Game/Overlays/Chat/ChannelControl/ControlItemText.cs @@ -14,6 +14,8 @@ namespace osu.Game.Overlays.Chat.ChannelControl { public class ControlItemText : Container { + private bool hasUnread; + public bool HasUnread { get => hasUnread; @@ -27,7 +29,6 @@ namespace osu.Game.Overlays.Chat.ChannelControl } } - private bool hasUnread = false; private OsuSpriteText? text; [Resolved] From e9f0ad33efca61ccbbb0a09c14f88615d3e2f819 Mon Sep 17 00:00:00 2001 From: Jai Sharma Date: Mon, 14 Mar 2022 20:06:31 +0000 Subject: [PATCH 03/38] Use autosizing for ChannelControlItem test scene --- .../Online/TestSceneChannelControlItem.cs | 63 +++++++++++-------- 1 file changed, 37 insertions(+), 26 deletions(-) diff --git a/osu.Game.Tests/Visual/Online/TestSceneChannelControlItem.cs b/osu.Game.Tests/Visual/Online/TestSceneChannelControlItem.cs index 64ad924ecb..7f76dca013 100644 --- a/osu.Game.Tests/Visual/Online/TestSceneChannelControlItem.cs +++ b/osu.Game.Tests/Visual/Online/TestSceneChannelControlItem.cs @@ -45,36 +45,47 @@ namespace osu.Game.Tests.Visual.Online { Schedule(() => { - Children = new Drawable[] + Child = new FillFlowContainer { - selectedText = new OsuSpriteText + Direction = FillDirection.Vertical, + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + AutoSizeAxes = Axes.Both, + Spacing = new Vector2(10), + Children = new Drawable[] { - Anchor = Anchor.Centre, - Origin = Anchor.Centre, - Y = -140, - }, - leaveText = new OsuSpriteText - { - Anchor = Anchor.Centre, - Origin = Anchor.Centre, - Y = -120, - }, - new Container - { - Anchor = Anchor.Centre, - Origin = Anchor.Centre, - Size = new Vector2(190, 200), - Children = new Drawable[] + selectedText = new OsuSpriteText { - new Box + Anchor = Anchor.TopCentre, + Origin = Anchor.TopCentre, + }, + leaveText = new OsuSpriteText + { + Anchor = Anchor.TopCentre, + Origin = Anchor.TopCentre, + Height = 16, + AlwaysPresent = true, + }, + new Container + { + Anchor = Anchor.TopCentre, + Origin = Anchor.TopCentre, + AutoSizeAxes = Axes.Y, + Width = 190, + Children = new Drawable[] { - RelativeSizeAxes = Axes.Both, - Colour = colourProvider.Background6, - }, - flow = new FillFlowContainer - { - Spacing = new Vector2(20), - RelativeSizeAxes = Axes.Both, + new Box + { + RelativeSizeAxes = Axes.Both, + Colour = colourProvider.Background6, + }, + flow = new FillFlowContainer + { + Direction = FillDirection.Vertical, + Spacing = new Vector2(20), + RelativeSizeAxes = Axes.X, + AutoSizeAxes = Axes.Y, + }, }, }, }, From 12472593cc4f2c7b36a8682c7d63d17315e7a9cf Mon Sep 17 00:00:00 2001 From: Jai Sharma Date: Mon, 14 Mar 2022 20:14:04 +0000 Subject: [PATCH 04/38] Mark required dependencies as non-nullable --- .../Overlays/Chat/ChannelControl/ControlItem.cs | 14 +++++++------- .../Chat/ChannelControl/ControlItemAvatar.cs | 3 ++- .../Chat/ChannelControl/ControlItemMention.cs | 4 ++-- .../Chat/ChannelControl/ControlItemText.cs | 8 ++++---- 4 files changed, 15 insertions(+), 14 deletions(-) diff --git a/osu.Game/Overlays/Chat/ChannelControl/ControlItem.cs b/osu.Game/Overlays/Chat/ChannelControl/ControlItem.cs index e475ac7821..073173f2ff 100644 --- a/osu.Game/Overlays/Chat/ChannelControl/ControlItem.cs +++ b/osu.Game/Overlays/Chat/ChannelControl/ControlItem.cs @@ -40,6 +40,8 @@ namespace osu.Game.Overlays.Chat.ChannelControl } } + private readonly Channel channel; + private Box? hoverBox; private Box? selectBox; private ControlItemText? text; @@ -47,12 +49,10 @@ namespace osu.Game.Overlays.Chat.ChannelControl private ControlItemClose? close; [Resolved] - private Bindable? selectedChannel { get; set; } + private Bindable selectedChannel { get; set; } = null!; [Resolved] - private OverlayColourProvider? colourProvider { get; set; } - - private readonly Channel channel; + private OverlayColourProvider colourProvider { get; set; } = null!; public ControlItem(Channel channel) { @@ -70,13 +70,13 @@ namespace osu.Game.Overlays.Chat.ChannelControl hoverBox = new Box { RelativeSizeAxes = Axes.Both, - Colour = colourProvider!.Background3, + Colour = colourProvider.Background3, Alpha = 0f, }, selectBox = new Box { RelativeSizeAxes = Axes.Both, - Colour = colourProvider!.Background4, + Colour = colourProvider.Background4, Alpha = 0f, }, new Container @@ -126,7 +126,7 @@ namespace osu.Game.Overlays.Chat.ChannelControl { base.LoadComplete(); - selectedChannel?.BindValueChanged(change => + selectedChannel.BindValueChanged(change => { if (change.NewValue == channel) selectBox?.Show(); diff --git a/osu.Game/Overlays/Chat/ChannelControl/ControlItemAvatar.cs b/osu.Game/Overlays/Chat/ChannelControl/ControlItemAvatar.cs index 9192f20cb1..62b893f3bc 100644 --- a/osu.Game/Overlays/Chat/ChannelControl/ControlItemAvatar.cs +++ b/osu.Game/Overlays/Chat/ChannelControl/ControlItemAvatar.cs @@ -16,9 +16,10 @@ namespace osu.Game.Overlays.Chat.ChannelControl { public class ControlItemAvatar : CircularContainer { - private DrawableAvatar? avatar; private readonly Channel channel; + private DrawableAvatar? avatar; + public ControlItemAvatar(Channel channel) { this.channel = channel; diff --git a/osu.Game/Overlays/Chat/ChannelControl/ControlItemMention.cs b/osu.Game/Overlays/Chat/ChannelControl/ControlItemMention.cs index 6af2e26af8..693fb68217 100644 --- a/osu.Game/Overlays/Chat/ChannelControl/ControlItemMention.cs +++ b/osu.Game/Overlays/Chat/ChannelControl/ControlItemMention.cs @@ -33,7 +33,7 @@ namespace osu.Game.Overlays.Chat.ChannelControl private OsuSpriteText? countText; [Resolved] - private OverlayColourProvider? colourProvider { get; set; } + private OverlayColourProvider colourProvider { get; set; } = null!; [BackgroundDependencyLoader] private void load() @@ -47,7 +47,7 @@ namespace osu.Game.Overlays.Chat.ChannelControl new Box { RelativeSizeAxes = Axes.Both, - Colour = colourProvider!.Colour1, + Colour = colourProvider.Colour1, }, countText = new OsuSpriteText { diff --git a/osu.Game/Overlays/Chat/ChannelControl/ControlItemText.cs b/osu.Game/Overlays/Chat/ChannelControl/ControlItemText.cs index bb88d733d4..9b0f5011fc 100644 --- a/osu.Game/Overlays/Chat/ChannelControl/ControlItemText.cs +++ b/osu.Game/Overlays/Chat/ChannelControl/ControlItemText.cs @@ -29,12 +29,12 @@ namespace osu.Game.Overlays.Chat.ChannelControl } } + private readonly Channel channel; + private OsuSpriteText? text; [Resolved] - private OverlayColourProvider? colourProvider { get; set; } - - private readonly Channel channel; + private OverlayColourProvider colourProvider { get; set; } = null!; public ControlItemText(Channel channel) { @@ -51,7 +51,7 @@ namespace osu.Game.Overlays.Chat.ChannelControl 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, + Colour = colourProvider.Light3, Margin = new MarginPadding { Bottom = 2 }, RelativeSizeAxes = Axes.X, Truncate = true, From e91af664ef080c250fbfd6997dd5aa1033f502d1 Mon Sep 17 00:00:00 2001 From: Jai Sharma Date: Mon, 14 Mar 2022 20:37:54 +0000 Subject: [PATCH 05/38] Adjust ControlItemAvatar placeholder animation and colour --- .../Overlays/Chat/ChannelControl/ControlItemAvatar.cs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/osu.Game/Overlays/Chat/ChannelControl/ControlItemAvatar.cs b/osu.Game/Overlays/Chat/ChannelControl/ControlItemAvatar.cs index 62b893f3bc..bb3109ec1f 100644 --- a/osu.Game/Overlays/Chat/ChannelControl/ControlItemAvatar.cs +++ b/osu.Game/Overlays/Chat/ChannelControl/ControlItemAvatar.cs @@ -18,6 +18,7 @@ namespace osu.Game.Overlays.Chat.ChannelControl { private readonly Channel channel; + private SpriteIcon? placeholder; private DrawableAvatar? avatar; public ControlItemAvatar(Channel channel) @@ -34,14 +35,14 @@ namespace osu.Game.Overlays.Chat.ChannelControl Children = new Drawable[] { - new SpriteIcon + placeholder = new SpriteIcon { Icon = FontAwesome.Solid.At, Anchor = Anchor.Centre, Origin = Anchor.Centre, - Colour = Colour4.Black, + Colour = Colour4.White, RelativeSizeAxes = Axes.Both, - Alpha = 0.2f, + Alpha = 0.5f, }, new DelayedLoadWrapper(avatar = new DrawableAvatar(channel.Users.First()) { @@ -55,7 +56,7 @@ namespace osu.Game.Overlays.Chat.ChannelControl protected override void LoadComplete() { base.LoadComplete(); - avatar!.OnLoadComplete += d => d.FadeInFromZero(300, Easing.OutQuint); + avatar!.OnLoadComplete += _ => placeholder!.FadeOut(250); } } } From 9621ef9437ca389fde4295e507d8681ee14ee3bb Mon Sep 17 00:00:00 2001 From: Jai Sharma Date: Mon, 14 Mar 2022 21:10:39 +0000 Subject: [PATCH 06/38] Use OsuColour.Red1 for ControlItemClose hover colour --- .../Visual/Online/TestSceneChannelControlItem.cs | 4 ++++ .../Overlays/Chat/ChannelControl/ControlItemClose.cs | 10 +++++++--- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/osu.Game.Tests/Visual/Online/TestSceneChannelControlItem.cs b/osu.Game.Tests/Visual/Online/TestSceneChannelControlItem.cs index 7f76dca013..9464d244be 100644 --- a/osu.Game.Tests/Visual/Online/TestSceneChannelControlItem.cs +++ b/osu.Game.Tests/Visual/Online/TestSceneChannelControlItem.cs @@ -8,6 +8,7 @@ using osu.Framework.Bindables; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Shapes; +using osu.Game.Graphics; using osu.Game.Graphics.Sprites; using osu.Game.Online.API.Requests.Responses; using osu.Game.Online.Chat; @@ -23,6 +24,9 @@ namespace osu.Game.Tests.Visual.Online [Cached] private readonly OverlayColourProvider colourProvider = new OverlayColourProvider(OverlayColourScheme.Pink); + [Cached] + private readonly OsuColour osuColour = new OsuColour(); + [Cached] private readonly Bindable selected = new Bindable(); diff --git a/osu.Game/Overlays/Chat/ChannelControl/ControlItemClose.cs b/osu.Game/Overlays/Chat/ChannelControl/ControlItemClose.cs index 4b190e18fd..4730d7b72d 100644 --- a/osu.Game/Overlays/Chat/ChannelControl/ControlItemClose.cs +++ b/osu.Game/Overlays/Chat/ChannelControl/ControlItemClose.cs @@ -1,12 +1,13 @@ // Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. +using osu.Framework.Allocation; using osu.Framework.Graphics; using osu.Framework.Graphics.Sprites; using osu.Framework.Input.Events; +using osu.Game.Graphics; using osu.Game.Graphics.Containers; using osuTK; -using osuTK.Graphics; namespace osu.Game.Overlays.Chat.ChannelControl { @@ -14,6 +15,9 @@ namespace osu.Game.Overlays.Chat.ChannelControl { private readonly SpriteIcon icon; + [Resolved] + private OsuColour osuColour { get; set; } = null!; + public ControlItemClose() { Alpha = 0f; @@ -42,13 +46,13 @@ namespace osu.Game.Overlays.Chat.ChannelControl protected override bool OnHover(HoverEvent e) { - icon.FadeColour(Color4.Red, 200, Easing.OutQuint); + icon.FadeColour(osuColour.Red1, 200, Easing.OutQuint); return base.OnHover(e); } protected override void OnHoverLost(HoverLostEvent e) { - icon.FadeColour(Color4.White, 200, Easing.OutQuint); + icon.FadeColour(Colour4.White, 200, Easing.OutQuint); base.OnHoverLost(e); } } From 3aa343b9870dc3487013151889880f282b29cafe Mon Sep 17 00:00:00 2001 From: Jai Sharma Date: Mon, 14 Mar 2022 21:14:33 +0000 Subject: [PATCH 07/38] Use OsuColour.YellowLight for ControlItemMention background --- osu.Game/Overlays/Chat/ChannelControl/ControlItemMention.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/osu.Game/Overlays/Chat/ChannelControl/ControlItemMention.cs b/osu.Game/Overlays/Chat/ChannelControl/ControlItemMention.cs index 693fb68217..370c435266 100644 --- a/osu.Game/Overlays/Chat/ChannelControl/ControlItemMention.cs +++ b/osu.Game/Overlays/Chat/ChannelControl/ControlItemMention.cs @@ -32,6 +32,9 @@ namespace osu.Game.Overlays.Chat.ChannelControl private OsuSpriteText? countText; + [Resolved] + private OsuColour osuColour { get; set; } = null!; + [Resolved] private OverlayColourProvider colourProvider { get; set; } = null!; @@ -47,7 +50,7 @@ namespace osu.Game.Overlays.Chat.ChannelControl new Box { RelativeSizeAxes = Axes.Both, - Colour = colourProvider.Colour1, + Colour = osuColour.YellowLight, }, countText = new OsuSpriteText { From 1f0f6990f096d15a064eda731bd2dbad876ff786 Mon Sep 17 00:00:00 2001 From: Jai Sharma Date: Mon, 14 Mar 2022 21:16:28 +0000 Subject: [PATCH 08/38] Use ColourProvider.Content1 for ControlItemText colour --- osu.Game/Overlays/Chat/ChannelControl/ControlItemText.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/osu.Game/Overlays/Chat/ChannelControl/ControlItemText.cs b/osu.Game/Overlays/Chat/ChannelControl/ControlItemText.cs index 9b0f5011fc..0c91903f6b 100644 --- a/osu.Game/Overlays/Chat/ChannelControl/ControlItemText.cs +++ b/osu.Game/Overlays/Chat/ChannelControl/ControlItemText.cs @@ -64,9 +64,9 @@ namespace osu.Game.Overlays.Chat.ChannelControl return; if (HasUnread) - text!.Colour = Colour4.White; + text!.Colour = colourProvider.Content1; else - text!.Colour = colourProvider!.Light3; + text!.Colour = colourProvider.Light3; } } } From b01a809d551efcb342e59046ae087d46309323fe Mon Sep 17 00:00:00 2001 From: Jai Sharma Date: Mon, 14 Mar 2022 21:26:33 +0000 Subject: [PATCH 09/38] Refactor ControlItemMention to use bindable flow --- .../Online/TestSceneChannelControlItem.cs | 6 +-- .../Chat/ChannelControl/ControlItem.cs | 11 +---- .../Chat/ChannelControl/ControlItemMention.cs | 41 ++++++++----------- 3 files changed, 23 insertions(+), 35 deletions(-) diff --git a/osu.Game.Tests/Visual/Online/TestSceneChannelControlItem.cs b/osu.Game.Tests/Visual/Online/TestSceneChannelControlItem.cs index 9464d244be..2e5c2cc2cb 100644 --- a/osu.Game.Tests/Visual/Online/TestSceneChannelControlItem.cs +++ b/osu.Game.Tests/Visual/Online/TestSceneChannelControlItem.cs @@ -129,19 +129,19 @@ namespace osu.Game.Tests.Visual.Online AddStep("Add Mention Selected", () => { if (selected.Value != null) - channelMap[selected.Value].MentionCount++; + channelMap[selected.Value].Mentions.Value++; }); AddStep("Add 98 Mentions Selected", () => { if (selected.Value != null) - channelMap[selected.Value].MentionCount += 98; + channelMap[selected.Value].Mentions.Value += 98; }); AddStep("Clear Mentions Selected", () => { if (selected.Value != null) - channelMap[selected.Value].MentionCount = 0; + channelMap[selected.Value].Mentions.Value = 0; }); } diff --git a/osu.Game/Overlays/Chat/ChannelControl/ControlItem.cs b/osu.Game/Overlays/Chat/ChannelControl/ControlItem.cs index 073173f2ff..d88a99c484 100644 --- a/osu.Game/Overlays/Chat/ChannelControl/ControlItem.cs +++ b/osu.Game/Overlays/Chat/ChannelControl/ControlItem.cs @@ -20,15 +20,8 @@ namespace osu.Game.Overlays.Chat.ChannelControl public event Action? OnRequestSelect; public event Action? OnRequestLeave; - public int MentionCount - { - get => mention?.MentionCount ?? 0; - set - { - if (mention != null) - mention.MentionCount = value; - } - } + [Cached] + public readonly BindableInt Mentions = new BindableInt(); public bool HasUnread { diff --git a/osu.Game/Overlays/Chat/ChannelControl/ControlItemMention.cs b/osu.Game/Overlays/Chat/ChannelControl/ControlItemMention.cs index 370c435266..594a52b8a7 100644 --- a/osu.Game/Overlays/Chat/ChannelControl/ControlItemMention.cs +++ b/osu.Game/Overlays/Chat/ChannelControl/ControlItemMention.cs @@ -4,6 +4,7 @@ #nullable enable using osu.Framework.Allocation; +using osu.Framework.Bindables; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Shapes; @@ -15,23 +16,11 @@ namespace osu.Game.Overlays.Chat.ChannelControl { public class ControlItemMention : CircularContainer { - private int mentionCount; - - public int MentionCount - { - get => mentionCount; - set - { - if (value == mentionCount) - return; - - mentionCount = value; - updateText(); - } - } - private OsuSpriteText? countText; + [Resolved] + private BindableInt mentions { get; set; } = null!; + [Resolved] private OsuColour osuColour { get; set; } = null!; @@ -61,18 +50,24 @@ namespace osu.Game.Overlays.Chat.ChannelControl Colour = colourProvider.Background5, }, }; - - updateText(); } - private void updateText() + protected override void LoadComplete() { - countText!.Text = MentionCount > 99 ? "99+" : MentionCount.ToString(); + base.LoadComplete(); - if (mentionCount > 0) - Show(); - else - Hide(); + mentions.BindValueChanged(change => + { + int mentionCount = change.NewValue; + + countText!.Text = mentionCount > 99 ? "99+" : mentionCount.ToString(); + + if (mentionCount > 0) + Show(); + else + Hide(); + }, true); } + } } From 75958bf2702778784caee4c70ed3040170f16a5e Mon Sep 17 00:00:00 2001 From: Jai Sharma Date: Mon, 14 Mar 2022 21:32:30 +0000 Subject: [PATCH 10/38] Refactor ControlItemText to use bindable flow for unread state --- .../Online/TestSceneChannelControlItem.cs | 4 +-- .../Chat/ChannelControl/ControlItem.cs | 11 ++---- .../Chat/ChannelControl/ControlItemText.cs | 35 +++++++------------ 3 files changed, 17 insertions(+), 33 deletions(-) diff --git a/osu.Game.Tests/Visual/Online/TestSceneChannelControlItem.cs b/osu.Game.Tests/Visual/Online/TestSceneChannelControlItem.cs index 2e5c2cc2cb..9af3b7613b 100644 --- a/osu.Game.Tests/Visual/Online/TestSceneChannelControlItem.cs +++ b/osu.Game.Tests/Visual/Online/TestSceneChannelControlItem.cs @@ -117,13 +117,13 @@ namespace osu.Game.Tests.Visual.Online AddStep("Unread Selected", () => { if (selected.Value != null) - channelMap[selected.Value].HasUnread = true; + channelMap[selected.Value].Unread.Value = true; }); AddStep("Read Selected", () => { if (selected.Value != null) - channelMap[selected.Value].HasUnread = false; + channelMap[selected.Value].Unread.Value = false; }); AddStep("Add Mention Selected", () => diff --git a/osu.Game/Overlays/Chat/ChannelControl/ControlItem.cs b/osu.Game/Overlays/Chat/ChannelControl/ControlItem.cs index d88a99c484..4b1bbaec82 100644 --- a/osu.Game/Overlays/Chat/ChannelControl/ControlItem.cs +++ b/osu.Game/Overlays/Chat/ChannelControl/ControlItem.cs @@ -23,15 +23,8 @@ namespace osu.Game.Overlays.Chat.ChannelControl [Cached] public readonly BindableInt Mentions = new BindableInt(); - public bool HasUnread - { - get => text?.HasUnread ?? false; - set - { - if (text != null) - text.HasUnread = value; - } - } + [Cached] + public readonly BindableBool Unread = new BindableBool(); private readonly Channel channel; diff --git a/osu.Game/Overlays/Chat/ChannelControl/ControlItemText.cs b/osu.Game/Overlays/Chat/ChannelControl/ControlItemText.cs index 0c91903f6b..3573c72846 100644 --- a/osu.Game/Overlays/Chat/ChannelControl/ControlItemText.cs +++ b/osu.Game/Overlays/Chat/ChannelControl/ControlItemText.cs @@ -4,6 +4,7 @@ #nullable enable using osu.Framework.Allocation; +using osu.Framework.Bindables; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Game.Graphics; @@ -14,25 +15,13 @@ namespace osu.Game.Overlays.Chat.ChannelControl { public class ControlItemText : Container { - private bool hasUnread; - - public bool HasUnread - { - get => hasUnread; - set - { - if (hasUnread == value) - return; - - hasUnread = value; - updateText(); - } - } - private readonly Channel channel; private OsuSpriteText? text; + [Resolved] + private BindableBool unread { get; set; } = null!; + [Resolved] private OverlayColourProvider colourProvider { get; set; } = null!; @@ -58,15 +47,17 @@ namespace osu.Game.Overlays.Chat.ChannelControl }; } - private void updateText() + protected override void LoadComplete() { - if (!IsLoaded) - return; + base.LoadComplete(); - if (HasUnread) - text!.Colour = colourProvider.Content1; - else - text!.Colour = colourProvider.Light3; + unread.BindValueChanged(change => + { + if (change.NewValue) + text!.Colour = colourProvider.Content1; + else + text!.Colour = colourProvider.Light3; + }, true); } } } From ec61b88ec27796836ae380c5e845101e1f06f589 Mon Sep 17 00:00:00 2001 From: Jai Sharma Date: Mon, 14 Mar 2022 21:39:57 +0000 Subject: [PATCH 11/38] Adjust ControlItem padding --- osu.Game/Overlays/Chat/ChannelControl/ControlItem.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Overlays/Chat/ChannelControl/ControlItem.cs b/osu.Game/Overlays/Chat/ChannelControl/ControlItem.cs index 4b1bbaec82..e944bf4c28 100644 --- a/osu.Game/Overlays/Chat/ChannelControl/ControlItem.cs +++ b/osu.Game/Overlays/Chat/ChannelControl/ControlItem.cs @@ -68,7 +68,7 @@ namespace osu.Game.Overlays.Chat.ChannelControl new Container { RelativeSizeAxes = Axes.Both, - Padding = new MarginPadding { Left = 18, Right = 5 }, + Padding = new MarginPadding { Left = 18, Right = 10 }, Child = new GridContainer { RelativeSizeAxes = Axes.Both, From 73a0373b4ed0d2de982c84b236dafae6c02ee677 Mon Sep 17 00:00:00 2001 From: Jai Sharma Date: Mon, 14 Mar 2022 21:56:56 +0000 Subject: [PATCH 12/38] Code quality fixes --- osu.Game/Overlays/Chat/ChannelControl/ControlItem.cs | 6 ++---- osu.Game/Overlays/Chat/ChannelControl/ControlItemMention.cs | 1 - osu.Game/Overlays/Chat/ChannelControl/ControlItemText.cs | 5 +---- 3 files changed, 3 insertions(+), 9 deletions(-) diff --git a/osu.Game/Overlays/Chat/ChannelControl/ControlItem.cs b/osu.Game/Overlays/Chat/ChannelControl/ControlItem.cs index e944bf4c28..f2bab64371 100644 --- a/osu.Game/Overlays/Chat/ChannelControl/ControlItem.cs +++ b/osu.Game/Overlays/Chat/ChannelControl/ControlItem.cs @@ -30,8 +30,6 @@ namespace osu.Game.Overlays.Chat.ChannelControl private Box? hoverBox; private Box? selectBox; - private ControlItemText? text; - private ControlItemMention? mention; private ControlItemClose? close; [Resolved] @@ -84,12 +82,12 @@ namespace osu.Game.Overlays.Chat.ChannelControl new[] { createAvatar(), - text = new ControlItemText(channel) + new ControlItemText(channel) { Anchor = Anchor.CentreLeft, Origin = Anchor.CentreLeft, }, - mention = new ControlItemMention + new ControlItemMention { Anchor = Anchor.CentreLeft, Origin = Anchor.CentreLeft, diff --git a/osu.Game/Overlays/Chat/ChannelControl/ControlItemMention.cs b/osu.Game/Overlays/Chat/ChannelControl/ControlItemMention.cs index 594a52b8a7..e9172d99ba 100644 --- a/osu.Game/Overlays/Chat/ChannelControl/ControlItemMention.cs +++ b/osu.Game/Overlays/Chat/ChannelControl/ControlItemMention.cs @@ -68,6 +68,5 @@ namespace osu.Game.Overlays.Chat.ChannelControl Hide(); }, true); } - } } diff --git a/osu.Game/Overlays/Chat/ChannelControl/ControlItemText.cs b/osu.Game/Overlays/Chat/ChannelControl/ControlItemText.cs index 3573c72846..89845dfef8 100644 --- a/osu.Game/Overlays/Chat/ChannelControl/ControlItemText.cs +++ b/osu.Game/Overlays/Chat/ChannelControl/ControlItemText.cs @@ -53,10 +53,7 @@ namespace osu.Game.Overlays.Chat.ChannelControl unread.BindValueChanged(change => { - if (change.NewValue) - text!.Colour = colourProvider.Content1; - else - text!.Colour = colourProvider.Light3; + text!.Colour = change.NewValue ? colourProvider.Content1 : colourProvider.Light3; }, true); } } From 6628b7c654789619617475f7114c84b35acde86a Mon Sep 17 00:00:00 2001 From: Jai Sharma Date: Mon, 14 Mar 2022 22:21:18 +0000 Subject: [PATCH 13/38] Ensure existing items are expired and cleared in ChannelControlItem test setup --- osu.Game.Tests/Visual/Online/TestSceneChannelControlItem.cs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/osu.Game.Tests/Visual/Online/TestSceneChannelControlItem.cs b/osu.Game.Tests/Visual/Online/TestSceneChannelControlItem.cs index 9af3b7613b..e496ef60d7 100644 --- a/osu.Game.Tests/Visual/Online/TestSceneChannelControlItem.cs +++ b/osu.Game.Tests/Visual/Online/TestSceneChannelControlItem.cs @@ -49,6 +49,11 @@ namespace osu.Game.Tests.Visual.Online { Schedule(() => { + foreach (var item in channelMap.Values) + item.Expire(); + + channelMap.Clear(); + Child = new FillFlowContainer { Direction = FillDirection.Vertical, From 7621e779fa8667110e1b477c5fba3481627ea7f1 Mon Sep 17 00:00:00 2001 From: Jai Sharma Date: Tue, 15 Mar 2022 22:19:58 +0000 Subject: [PATCH 14/38] Move `ControlItem` Action assignments into BDL --- osu.Game/Overlays/Chat/ChannelControl/ControlItem.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/osu.Game/Overlays/Chat/ChannelControl/ControlItem.cs b/osu.Game/Overlays/Chat/ChannelControl/ControlItem.cs index f2bab64371..d886e8b45a 100644 --- a/osu.Game/Overlays/Chat/ChannelControl/ControlItem.cs +++ b/osu.Game/Overlays/Chat/ChannelControl/ControlItem.cs @@ -98,12 +98,15 @@ namespace osu.Game.Overlays.Chat.ChannelControl Anchor = Anchor.CentreLeft, Origin = Anchor.CentreLeft, Margin = new MarginPadding { Right = 3 }, + Action = () => OnRequestLeave?.Invoke(channel), } } }, }, }, }; + + Action = () => OnRequestSelect?.Invoke(channel); } protected override void LoadComplete() @@ -117,9 +120,6 @@ namespace osu.Game.Overlays.Chat.ChannelControl else selectBox?.Hide(); }, true); - - Action = () => OnRequestSelect?.Invoke(channel); - close!.Action = () => OnRequestLeave?.Invoke(channel); } protected override bool OnHover(HoverEvent e) From 481b8fe80bc043b6a70ad1b799fefd94ba58af06 Mon Sep 17 00:00:00 2001 From: Jai Sharma Date: Tue, 15 Mar 2022 22:22:32 +0000 Subject: [PATCH 15/38] Use `Orange1` for `ControlItemMention` background colour --- osu.Game/Overlays/Chat/ChannelControl/ControlItemMention.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Overlays/Chat/ChannelControl/ControlItemMention.cs b/osu.Game/Overlays/Chat/ChannelControl/ControlItemMention.cs index e9172d99ba..5118386977 100644 --- a/osu.Game/Overlays/Chat/ChannelControl/ControlItemMention.cs +++ b/osu.Game/Overlays/Chat/ChannelControl/ControlItemMention.cs @@ -39,7 +39,7 @@ namespace osu.Game.Overlays.Chat.ChannelControl new Box { RelativeSizeAxes = Axes.Both, - Colour = osuColour.YellowLight, + Colour = osuColour.Orange1, }, countText = new OsuSpriteText { From 49b74d78670d85ef7a3b159b43b9504c5ff7156a Mon Sep 17 00:00:00 2001 From: Jai Sharma Date: Tue, 15 Mar 2022 22:33:36 +0000 Subject: [PATCH 16/38] Use `BindTarget` instead of caching for `ControlItem` mentions bindable flow --- osu.Game/Overlays/Chat/ChannelControl/ControlItem.cs | 2 +- .../Overlays/Chat/ChannelControl/ControlItemMention.cs | 7 +++---- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/osu.Game/Overlays/Chat/ChannelControl/ControlItem.cs b/osu.Game/Overlays/Chat/ChannelControl/ControlItem.cs index d886e8b45a..d73ebed817 100644 --- a/osu.Game/Overlays/Chat/ChannelControl/ControlItem.cs +++ b/osu.Game/Overlays/Chat/ChannelControl/ControlItem.cs @@ -20,7 +20,6 @@ namespace osu.Game.Overlays.Chat.ChannelControl public event Action? OnRequestSelect; public event Action? OnRequestLeave; - [Cached] public readonly BindableInt Mentions = new BindableInt(); [Cached] @@ -92,6 +91,7 @@ namespace osu.Game.Overlays.Chat.ChannelControl Anchor = Anchor.CentreLeft, Origin = Anchor.CentreLeft, Margin = new MarginPadding { Right = 3 }, + Mentions = { BindTarget = Mentions }, }, close = new ControlItemClose { diff --git a/osu.Game/Overlays/Chat/ChannelControl/ControlItemMention.cs b/osu.Game/Overlays/Chat/ChannelControl/ControlItemMention.cs index 5118386977..beb2713c92 100644 --- a/osu.Game/Overlays/Chat/ChannelControl/ControlItemMention.cs +++ b/osu.Game/Overlays/Chat/ChannelControl/ControlItemMention.cs @@ -16,10 +16,9 @@ namespace osu.Game.Overlays.Chat.ChannelControl { public class ControlItemMention : CircularContainer { - private OsuSpriteText? countText; + public readonly BindableInt Mentions = new BindableInt(); - [Resolved] - private BindableInt mentions { get; set; } = null!; + private OsuSpriteText? countText; [Resolved] private OsuColour osuColour { get; set; } = null!; @@ -56,7 +55,7 @@ namespace osu.Game.Overlays.Chat.ChannelControl { base.LoadComplete(); - mentions.BindValueChanged(change => + Mentions.BindValueChanged(change => { int mentionCount = change.NewValue; From e38d9eafa053a4ddc0e374cbead1063a3f194d8c Mon Sep 17 00:00:00 2001 From: Jai Sharma Date: Tue, 15 Mar 2022 22:37:15 +0000 Subject: [PATCH 17/38] Use `BindTarget` instead of caching for `ControlItem` unread flow --- osu.Game/Overlays/Chat/ChannelControl/ControlItem.cs | 2 +- osu.Game/Overlays/Chat/ChannelControl/ControlItemText.cs | 7 +++---- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/osu.Game/Overlays/Chat/ChannelControl/ControlItem.cs b/osu.Game/Overlays/Chat/ChannelControl/ControlItem.cs index d73ebed817..cc00550965 100644 --- a/osu.Game/Overlays/Chat/ChannelControl/ControlItem.cs +++ b/osu.Game/Overlays/Chat/ChannelControl/ControlItem.cs @@ -22,7 +22,6 @@ namespace osu.Game.Overlays.Chat.ChannelControl public readonly BindableInt Mentions = new BindableInt(); - [Cached] public readonly BindableBool Unread = new BindableBool(); private readonly Channel channel; @@ -85,6 +84,7 @@ namespace osu.Game.Overlays.Chat.ChannelControl { Anchor = Anchor.CentreLeft, Origin = Anchor.CentreLeft, + Unread = { BindTarget = Unread }, }, new ControlItemMention { diff --git a/osu.Game/Overlays/Chat/ChannelControl/ControlItemText.cs b/osu.Game/Overlays/Chat/ChannelControl/ControlItemText.cs index 89845dfef8..490edb5d28 100644 --- a/osu.Game/Overlays/Chat/ChannelControl/ControlItemText.cs +++ b/osu.Game/Overlays/Chat/ChannelControl/ControlItemText.cs @@ -15,13 +15,12 @@ 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 BindableBool unread { get; set; } = null!; - [Resolved] private OverlayColourProvider colourProvider { get; set; } = null!; @@ -51,7 +50,7 @@ namespace osu.Game.Overlays.Chat.ChannelControl { base.LoadComplete(); - unread.BindValueChanged(change => + Unread.BindValueChanged(change => { text!.Colour = change.NewValue ? colourProvider.Content1 : colourProvider.Light3; }, true); From c2e4779c2ed429a5e54dd405938e80347f1d2bab Mon Sep 17 00:00:00 2001 From: Jai Sharma Date: Wed, 16 Mar 2022 11:57:11 +0000 Subject: [PATCH 18/38] Remove redundant spacing in `ControlItem` test scene --- osu.Game.Tests/Visual/Online/TestSceneChannelControlItem.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/osu.Game.Tests/Visual/Online/TestSceneChannelControlItem.cs b/osu.Game.Tests/Visual/Online/TestSceneChannelControlItem.cs index e496ef60d7..8289be033a 100644 --- a/osu.Game.Tests/Visual/Online/TestSceneChannelControlItem.cs +++ b/osu.Game.Tests/Visual/Online/TestSceneChannelControlItem.cs @@ -91,7 +91,6 @@ namespace osu.Game.Tests.Visual.Online flow = new FillFlowContainer { Direction = FillDirection.Vertical, - Spacing = new Vector2(20), RelativeSizeAxes = Axes.X, AutoSizeAxes = Axes.Y, }, From 03d3969b38ebd37e03e8b09c4f6eed5218f4766d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Dach?= Date: Wed, 16 Mar 2022 21:46:02 +0100 Subject: [PATCH 19/38] Remove unnecessary `OsuColour` cache One is already cached at `OsuGameBase` level. --- osu.Game.Tests/Visual/Online/TestSceneChannelControlItem.cs | 4 ---- 1 file changed, 4 deletions(-) diff --git a/osu.Game.Tests/Visual/Online/TestSceneChannelControlItem.cs b/osu.Game.Tests/Visual/Online/TestSceneChannelControlItem.cs index 8289be033a..3465e7dfec 100644 --- a/osu.Game.Tests/Visual/Online/TestSceneChannelControlItem.cs +++ b/osu.Game.Tests/Visual/Online/TestSceneChannelControlItem.cs @@ -8,7 +8,6 @@ using osu.Framework.Bindables; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Shapes; -using osu.Game.Graphics; using osu.Game.Graphics.Sprites; using osu.Game.Online.API.Requests.Responses; using osu.Game.Online.Chat; @@ -24,9 +23,6 @@ namespace osu.Game.Tests.Visual.Online [Cached] private readonly OverlayColourProvider colourProvider = new OverlayColourProvider(OverlayColourScheme.Pink); - [Cached] - private readonly OsuColour osuColour = new OsuColour(); - [Cached] private readonly Bindable selected = new Bindable(); From a8cefca685f9ec5faed81112a70f894c838f7f54 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Dach?= Date: Wed, 16 Mar 2022 21:49:04 +0100 Subject: [PATCH 20/38] Simplify fade-out transform --- osu.Game.Tests/Visual/Online/TestSceneChannelControlItem.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game.Tests/Visual/Online/TestSceneChannelControlItem.cs b/osu.Game.Tests/Visual/Online/TestSceneChannelControlItem.cs index 3465e7dfec..e66092bf27 100644 --- a/osu.Game.Tests/Visual/Online/TestSceneChannelControlItem.cs +++ b/osu.Game.Tests/Visual/Online/TestSceneChannelControlItem.cs @@ -148,7 +148,7 @@ namespace osu.Game.Tests.Visual.Online private void leaveChannel(Channel channel) { leaveText.Text = $"OnRequestLeave: {channel.Name}"; - leaveText.FadeIn().Then().FadeOut(1000, Easing.InQuint); + leaveText.FadeOutFromOne(1000, Easing.InQuint); } private static Channel createPublicChannel(string name) => From b21fa78cbfa57b749138fdcd36a256ea727bc610 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Dach?= Date: Wed, 16 Mar 2022 21:55:36 +0100 Subject: [PATCH 21/38] Move dependencies out of fields to BDL args where possible --- osu.Game/Overlays/Chat/ChannelControl/ControlItem.cs | 5 +---- .../Overlays/Chat/ChannelControl/ControlItemMention.cs | 8 +------- 2 files changed, 2 insertions(+), 11 deletions(-) diff --git a/osu.Game/Overlays/Chat/ChannelControl/ControlItem.cs b/osu.Game/Overlays/Chat/ChannelControl/ControlItem.cs index cc00550965..c27d5fdf5d 100644 --- a/osu.Game/Overlays/Chat/ChannelControl/ControlItem.cs +++ b/osu.Game/Overlays/Chat/ChannelControl/ControlItem.cs @@ -33,16 +33,13 @@ namespace osu.Game.Overlays.Chat.ChannelControl [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() + private void load(OverlayColourProvider colourProvider) { Height = 30; RelativeSizeAxes = Axes.X; diff --git a/osu.Game/Overlays/Chat/ChannelControl/ControlItemMention.cs b/osu.Game/Overlays/Chat/ChannelControl/ControlItemMention.cs index beb2713c92..34e1e33c87 100644 --- a/osu.Game/Overlays/Chat/ChannelControl/ControlItemMention.cs +++ b/osu.Game/Overlays/Chat/ChannelControl/ControlItemMention.cs @@ -20,14 +20,8 @@ namespace osu.Game.Overlays.Chat.ChannelControl private OsuSpriteText? countText; - [Resolved] - private OsuColour osuColour { get; set; } = null!; - - [Resolved] - private OverlayColourProvider colourProvider { get; set; } = null!; - [BackgroundDependencyLoader] - private void load() + private void load(OsuColour osuColour, OverlayColourProvider colourProvider) { Masking = true; Size = new Vector2(20, 12); From d1fd14e287eb7ff00e36d87e3b76f53df2207912 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 18 Mar 2022 13:57:36 +0900 Subject: [PATCH 22/38] Add missing `nullable` --- osu.Game/Overlays/Chat/ChannelControl/ControlItemClose.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/osu.Game/Overlays/Chat/ChannelControl/ControlItemClose.cs b/osu.Game/Overlays/Chat/ChannelControl/ControlItemClose.cs index 4730d7b72d..c0f419f619 100644 --- a/osu.Game/Overlays/Chat/ChannelControl/ControlItemClose.cs +++ b/osu.Game/Overlays/Chat/ChannelControl/ControlItemClose.cs @@ -1,6 +1,8 @@ // 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.Graphics; using osu.Framework.Graphics.Sprites; From 5d940ded09d91d1e1d217b173fa598ed5196985e Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 18 Mar 2022 13:59:03 +0900 Subject: [PATCH 23/38] Fix incorrect usage of nullable in `ControlItemMention` --- osu.Game/Overlays/Chat/ChannelControl/ControlItemMention.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/osu.Game/Overlays/Chat/ChannelControl/ControlItemMention.cs b/osu.Game/Overlays/Chat/ChannelControl/ControlItemMention.cs index 34e1e33c87..f4d65e3cef 100644 --- a/osu.Game/Overlays/Chat/ChannelControl/ControlItemMention.cs +++ b/osu.Game/Overlays/Chat/ChannelControl/ControlItemMention.cs @@ -18,7 +18,7 @@ namespace osu.Game.Overlays.Chat.ChannelControl { public readonly BindableInt Mentions = new BindableInt(); - private OsuSpriteText? countText; + private OsuSpriteText countText = null!; [BackgroundDependencyLoader] private void load(OsuColour osuColour, OverlayColourProvider colourProvider) @@ -53,7 +53,7 @@ namespace osu.Game.Overlays.Chat.ChannelControl { int mentionCount = change.NewValue; - countText!.Text = mentionCount > 99 ? "99+" : mentionCount.ToString(); + countText.Text = mentionCount > 99 ? "99+" : mentionCount.ToString(); if (mentionCount > 0) Show(); From dfda093f4b8a74726eb1a0dfda261c01de98e3db Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 18 Mar 2022 14:03:52 +0900 Subject: [PATCH 24/38] Rename icon creation method --- osu.Game/Overlays/Chat/ChannelControl/ControlItem.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/osu.Game/Overlays/Chat/ChannelControl/ControlItem.cs b/osu.Game/Overlays/Chat/ChannelControl/ControlItem.cs index c27d5fdf5d..bf4d60d4e2 100644 --- a/osu.Game/Overlays/Chat/ChannelControl/ControlItem.cs +++ b/osu.Game/Overlays/Chat/ChannelControl/ControlItem.cs @@ -76,7 +76,7 @@ namespace osu.Game.Overlays.Chat.ChannelControl { new[] { - createAvatar(), + createIcon(), new ControlItemText(channel) { Anchor = Anchor.CentreLeft, @@ -133,7 +133,7 @@ namespace osu.Game.Overlays.Chat.ChannelControl base.OnHoverLost(e); } - private Drawable createAvatar() + private Drawable createIcon() { if (channel.Type != ChannelType.PM) return Drawable.Empty(); From a293e0c7664f74aec797793bb930119bc42ccba0 Mon Sep 17 00:00:00 2001 From: Jai Sharma Date: Sat, 19 Mar 2022 16:44:58 +0000 Subject: [PATCH 25/38] Remove redundant `ControlItemText` class --- .../Chat/ChannelControl/ControlItem.cs | 22 ++++++- .../Chat/ChannelControl/ControlItemText.cs | 59 ------------------- 2 files changed, 19 insertions(+), 62 deletions(-) delete mode 100644 osu.Game/Overlays/Chat/ChannelControl/ControlItemText.cs 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); - } - } -} From 5373c3066ffc070476c1402b7032aa3e8f3846c6 Mon Sep 17 00:00:00 2001 From: Jai Sharma Date: Sat, 19 Mar 2022 17:23:59 +0000 Subject: [PATCH 26/38] Use `OsuAnimatedButton` as base for `ControlItemClose` --- .../Chat/ChannelControl/ControlItemClose.cs | 42 ++++--------------- 1 file changed, 7 insertions(+), 35 deletions(-) diff --git a/osu.Game/Overlays/Chat/ChannelControl/ControlItemClose.cs b/osu.Game/Overlays/Chat/ChannelControl/ControlItemClose.cs index c0f419f619..6064e3790d 100644 --- a/osu.Game/Overlays/Chat/ChannelControl/ControlItemClose.cs +++ b/osu.Game/Overlays/Chat/ChannelControl/ControlItemClose.cs @@ -6,56 +6,28 @@ using osu.Framework.Allocation; using osu.Framework.Graphics; using osu.Framework.Graphics.Sprites; -using osu.Framework.Input.Events; using osu.Game.Graphics; -using osu.Game.Graphics.Containers; +using osu.Game.Graphics.UserInterface; using osuTK; namespace osu.Game.Overlays.Chat.ChannelControl { - public class ControlItemClose : OsuClickableContainer + public class ControlItemClose : OsuAnimatedButton { - private readonly SpriteIcon icon; - - [Resolved] - private OsuColour osuColour { get; set; } = null!; - - public ControlItemClose() + [BackgroundDependencyLoader] + private void load(OsuColour osuColour) { Alpha = 0f; Size = new Vector2(20); - Child = icon = new SpriteIcon + Add(new SpriteIcon { Anchor = Anchor.Centre, Origin = Anchor.Centre, Scale = new Vector2(0.75f), Icon = FontAwesome.Solid.TimesCircle, RelativeSizeAxes = Axes.Both, - }; - } - - protected override bool OnMouseDown(MouseDownEvent e) - { - icon.ScaleTo(0.5f, 1000, Easing.OutQuint); - return base.OnMouseDown(e); - } - - protected override void OnMouseUp(MouseUpEvent e) - { - icon.ScaleTo(0.75f, 1000, Easing.OutElastic); - base.OnMouseUp(e); - } - - protected override bool OnHover(HoverEvent e) - { - icon.FadeColour(osuColour.Red1, 200, Easing.OutQuint); - return base.OnHover(e); - } - - protected override void OnHoverLost(HoverLostEvent e) - { - icon.FadeColour(Colour4.White, 200, Easing.OutQuint); - base.OnHoverLost(e); + Colour = osuColour.Red1, + }); } } } From 653bb47dd587d8feac0f48b5465a9fccd3f66ca0 Mon Sep 17 00:00:00 2001 From: Jai Sharma Date: Sat, 19 Mar 2022 21:36:11 +0000 Subject: [PATCH 27/38] Use `UpdateableAvatar` and remove redundant `ControlItemAvatar` class --- .../Chat/ChannelControl/ControlItem.cs | 9 ++- .../Chat/ChannelControl/ControlItemAvatar.cs | 62 ------------------- 2 files changed, 8 insertions(+), 63 deletions(-) delete mode 100644 osu.Game/Overlays/Chat/ChannelControl/ControlItemAvatar.cs diff --git a/osu.Game/Overlays/Chat/ChannelControl/ControlItem.cs b/osu.Game/Overlays/Chat/ChannelControl/ControlItem.cs index df857a6dce..a388ebc52f 100644 --- a/osu.Game/Overlays/Chat/ChannelControl/ControlItem.cs +++ b/osu.Game/Overlays/Chat/ChannelControl/ControlItem.cs @@ -4,6 +4,7 @@ #nullable enable using System; +using System.Linq; using osu.Framework.Allocation; using osu.Framework.Bindables; using osu.Framework.Graphics; @@ -14,6 +15,8 @@ using osu.Game.Graphics; using osu.Game.Graphics.Containers; using osu.Game.Graphics.Sprites; using osu.Game.Online.Chat; +using osu.Game.Users.Drawables; +using osuTK; namespace osu.Game.Overlays.Chat.ChannelControl { @@ -154,10 +157,14 @@ namespace osu.Game.Overlays.Chat.ChannelControl if (channel.Type != ChannelType.PM) return Drawable.Empty(); - return new ControlItemAvatar(channel) + return new UpdateableAvatar(channel.Users.First(), false, false, true) { + Size = new Vector2(20), + Margin = new MarginPadding { Right = 5 }, Anchor = Anchor.CentreLeft, Origin = Anchor.CentreLeft, + CornerRadius = 10, + Masking = true, }; } } diff --git a/osu.Game/Overlays/Chat/ChannelControl/ControlItemAvatar.cs b/osu.Game/Overlays/Chat/ChannelControl/ControlItemAvatar.cs deleted file mode 100644 index bb3109ec1f..0000000000 --- a/osu.Game/Overlays/Chat/ChannelControl/ControlItemAvatar.cs +++ /dev/null @@ -1,62 +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 System.Linq; -using osu.Framework.Allocation; -using osu.Framework.Graphics; -using osu.Framework.Graphics.Containers; -using osu.Framework.Graphics.Sprites; -using osu.Game.Online.Chat; -using osu.Game.Users.Drawables; -using osuTK; - -namespace osu.Game.Overlays.Chat.ChannelControl -{ - public class ControlItemAvatar : CircularContainer - { - private readonly Channel channel; - - private SpriteIcon? placeholder; - private DrawableAvatar? avatar; - - public ControlItemAvatar(Channel channel) - { - this.channel = channel; - } - - [BackgroundDependencyLoader] - private void load() - { - Size = new Vector2(20); - Margin = new MarginPadding { Right = 5 }; - Masking = true; - - Children = new Drawable[] - { - placeholder = new SpriteIcon - { - Icon = FontAwesome.Solid.At, - Anchor = Anchor.Centre, - Origin = Anchor.Centre, - Colour = Colour4.White, - RelativeSizeAxes = Axes.Both, - Alpha = 0.5f, - }, - new DelayedLoadWrapper(avatar = new DrawableAvatar(channel.Users.First()) - { - RelativeSizeAxes = Axes.Both, - Anchor = Anchor.Centre, - Origin = Anchor.Centre, - }), - }; - } - - protected override void LoadComplete() - { - base.LoadComplete(); - avatar!.OnLoadComplete += _ => placeholder!.FadeOut(250); - } - } -} From ba5a43b5260536275e00d97720a0d05e81529bb9 Mon Sep 17 00:00:00 2001 From: Jai Sharma Date: Sat, 19 Mar 2022 21:49:14 +0000 Subject: [PATCH 28/38] Rename `ControlItem` -> `ChannelListItem` and associated classes --- ...nelControlItem.cs => TestSceneChannelListItem.cs} | 8 ++++---- .../ChannelListItem.cs} | 12 ++++++------ .../ChannelListItemClose.cs} | 4 ++-- .../ChannelListItemMention.cs} | 4 ++-- 4 files changed, 14 insertions(+), 14 deletions(-) rename osu.Game.Tests/Visual/Online/{TestSceneChannelControlItem.cs => TestSceneChannelListItem.cs} (95%) rename osu.Game/Overlays/Chat/{ChannelControl/ControlItem.cs => ChannelList/ChannelListItem.cs} (94%) rename osu.Game/Overlays/Chat/{ChannelControl/ControlItemClose.cs => ChannelList/ChannelListItemClose.cs} (89%) rename osu.Game/Overlays/Chat/{ChannelControl/ControlItemMention.cs => ChannelList/ChannelListItemMention.cs} (94%) diff --git a/osu.Game.Tests/Visual/Online/TestSceneChannelControlItem.cs b/osu.Game.Tests/Visual/Online/TestSceneChannelListItem.cs similarity index 95% rename from osu.Game.Tests/Visual/Online/TestSceneChannelControlItem.cs rename to osu.Game.Tests/Visual/Online/TestSceneChannelListItem.cs index e66092bf27..ac829f8cbc 100644 --- a/osu.Game.Tests/Visual/Online/TestSceneChannelControlItem.cs +++ b/osu.Game.Tests/Visual/Online/TestSceneChannelListItem.cs @@ -12,13 +12,13 @@ using osu.Game.Graphics.Sprites; using osu.Game.Online.API.Requests.Responses; using osu.Game.Online.Chat; using osu.Game.Overlays; -using osu.Game.Overlays.Chat.ChannelControl; +using osu.Game.Overlays.Chat.ChannelList; using osuTK; namespace osu.Game.Tests.Visual.Online { [TestFixture] - public class TestSceneChannelControlItem : OsuTestScene + public class TestSceneChannelListItem : OsuTestScene { [Cached] private readonly OverlayColourProvider colourProvider = new OverlayColourProvider(OverlayColourScheme.Pink); @@ -34,7 +34,7 @@ namespace osu.Game.Tests.Visual.Online createPrivateChannel("test user long name", 3), }; - private readonly Dictionary channelMap = new Dictionary(); + private readonly Dictionary channelMap = new Dictionary(); private FillFlowContainer flow; private OsuSpriteText selectedText; @@ -102,7 +102,7 @@ namespace osu.Game.Tests.Visual.Online foreach (var channel in channels) { - var item = new ControlItem(channel); + var item = new ChannelListItem(channel); flow.Add(item); channelMap.Add(channel, item); item.OnRequestSelect += c => selected.Value = c; diff --git a/osu.Game/Overlays/Chat/ChannelControl/ControlItem.cs b/osu.Game/Overlays/Chat/ChannelList/ChannelListItem.cs similarity index 94% rename from osu.Game/Overlays/Chat/ChannelControl/ControlItem.cs rename to osu.Game/Overlays/Chat/ChannelList/ChannelListItem.cs index a388ebc52f..247b04688c 100644 --- a/osu.Game/Overlays/Chat/ChannelControl/ControlItem.cs +++ b/osu.Game/Overlays/Chat/ChannelList/ChannelListItem.cs @@ -18,9 +18,9 @@ using osu.Game.Online.Chat; using osu.Game.Users.Drawables; using osuTK; -namespace osu.Game.Overlays.Chat.ChannelControl +namespace osu.Game.Overlays.Chat.ChannelList { - public class ControlItem : OsuClickableContainer + public class ChannelListItem : OsuClickableContainer { public event Action? OnRequestSelect; public event Action? OnRequestLeave; @@ -34,7 +34,7 @@ namespace osu.Game.Overlays.Chat.ChannelControl private Box? hoverBox; private Box? selectBox; private OsuSpriteText? text; - private ControlItemClose? close; + private ChannelListItemClose? close; [Resolved] private Bindable selectedChannel { get; set; } = null!; @@ -42,7 +42,7 @@ namespace osu.Game.Overlays.Chat.ChannelControl [Resolved] private OverlayColourProvider colourProvider { get; set; } = null!; - public ControlItem(Channel channel) + public ChannelListItem(Channel channel) { this.channel = channel; } @@ -97,14 +97,14 @@ namespace osu.Game.Overlays.Chat.ChannelControl RelativeSizeAxes = Axes.X, Truncate = true, }, - new ControlItemMention + new ChannelListItemMention { Anchor = Anchor.CentreLeft, Origin = Anchor.CentreLeft, Margin = new MarginPadding { Right = 3 }, Mentions = { BindTarget = Mentions }, }, - close = new ControlItemClose + close = new ChannelListItemClose { Anchor = Anchor.CentreLeft, Origin = Anchor.CentreLeft, diff --git a/osu.Game/Overlays/Chat/ChannelControl/ControlItemClose.cs b/osu.Game/Overlays/Chat/ChannelList/ChannelListItemClose.cs similarity index 89% rename from osu.Game/Overlays/Chat/ChannelControl/ControlItemClose.cs rename to osu.Game/Overlays/Chat/ChannelList/ChannelListItemClose.cs index 6064e3790d..37a1fcdde7 100644 --- a/osu.Game/Overlays/Chat/ChannelControl/ControlItemClose.cs +++ b/osu.Game/Overlays/Chat/ChannelList/ChannelListItemClose.cs @@ -10,9 +10,9 @@ using osu.Game.Graphics; using osu.Game.Graphics.UserInterface; using osuTK; -namespace osu.Game.Overlays.Chat.ChannelControl +namespace osu.Game.Overlays.Chat.ChannelList { - public class ControlItemClose : OsuAnimatedButton + public class ChannelListItemClose : OsuAnimatedButton { [BackgroundDependencyLoader] private void load(OsuColour osuColour) diff --git a/osu.Game/Overlays/Chat/ChannelControl/ControlItemMention.cs b/osu.Game/Overlays/Chat/ChannelList/ChannelListItemMention.cs similarity index 94% rename from osu.Game/Overlays/Chat/ChannelControl/ControlItemMention.cs rename to osu.Game/Overlays/Chat/ChannelList/ChannelListItemMention.cs index f4d65e3cef..3a1c3b7619 100644 --- a/osu.Game/Overlays/Chat/ChannelControl/ControlItemMention.cs +++ b/osu.Game/Overlays/Chat/ChannelList/ChannelListItemMention.cs @@ -12,9 +12,9 @@ using osu.Game.Graphics; using osu.Game.Graphics.Sprites; using osuTK; -namespace osu.Game.Overlays.Chat.ChannelControl +namespace osu.Game.Overlays.Chat.ChannelList { - public class ControlItemMention : CircularContainer + public class ChannelListItemMention : CircularContainer { public readonly BindableInt Mentions = new BindableInt(); From f3702fbefbb9f42041d68c7d73d8a63a33f61d94 Mon Sep 17 00:00:00 2001 From: Jai Sharma Date: Sat, 19 Mar 2022 22:20:17 +0000 Subject: [PATCH 29/38] Pass correct params to `UpdateableAvatar` ctor in `ChannelListItem` --- osu.Game/Overlays/Chat/ChannelList/ChannelListItem.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Overlays/Chat/ChannelList/ChannelListItem.cs b/osu.Game/Overlays/Chat/ChannelList/ChannelListItem.cs index 247b04688c..583493181b 100644 --- a/osu.Game/Overlays/Chat/ChannelList/ChannelListItem.cs +++ b/osu.Game/Overlays/Chat/ChannelList/ChannelListItem.cs @@ -157,7 +157,7 @@ namespace osu.Game.Overlays.Chat.ChannelList if (channel.Type != ChannelType.PM) return Drawable.Empty(); - return new UpdateableAvatar(channel.Users.First(), false, false, true) + return new UpdateableAvatar(channel.Users.First(), isInteractive: false) { Size = new Vector2(20), Margin = new MarginPadding { Right = 5 }, From f922a6b55607148c40189e29b6f3447fb1773dcc Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Mon, 21 Mar 2022 14:15:22 +0900 Subject: [PATCH 30/38] Rename renaming button/pill classes --- osu.Game/Overlays/Chat/ChannelList/ChannelListItem.cs | 6 +++--- ...hannelListItemClose.cs => ChannelListItemCloseButton.cs} | 2 +- ...nnelListItemMention.cs => ChannelListItemMentionPill.cs} | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) rename osu.Game/Overlays/Chat/ChannelList/{ChannelListItemClose.cs => ChannelListItemCloseButton.cs} (93%) rename osu.Game/Overlays/Chat/ChannelList/{ChannelListItemMention.cs => ChannelListItemMentionPill.cs} (96%) diff --git a/osu.Game/Overlays/Chat/ChannelList/ChannelListItem.cs b/osu.Game/Overlays/Chat/ChannelList/ChannelListItem.cs index 583493181b..006cfdea3b 100644 --- a/osu.Game/Overlays/Chat/ChannelList/ChannelListItem.cs +++ b/osu.Game/Overlays/Chat/ChannelList/ChannelListItem.cs @@ -34,7 +34,7 @@ namespace osu.Game.Overlays.Chat.ChannelList private Box? hoverBox; private Box? selectBox; private OsuSpriteText? text; - private ChannelListItemClose? close; + private ChannelListItemCloseButton? close; [Resolved] private Bindable selectedChannel { get; set; } = null!; @@ -97,14 +97,14 @@ namespace osu.Game.Overlays.Chat.ChannelList RelativeSizeAxes = Axes.X, Truncate = true, }, - new ChannelListItemMention + new ChannelListItemMentionPill { Anchor = Anchor.CentreLeft, Origin = Anchor.CentreLeft, Margin = new MarginPadding { Right = 3 }, Mentions = { BindTarget = Mentions }, }, - close = new ChannelListItemClose + close = new ChannelListItemCloseButton { Anchor = Anchor.CentreLeft, Origin = Anchor.CentreLeft, diff --git a/osu.Game/Overlays/Chat/ChannelList/ChannelListItemClose.cs b/osu.Game/Overlays/Chat/ChannelList/ChannelListItemCloseButton.cs similarity index 93% rename from osu.Game/Overlays/Chat/ChannelList/ChannelListItemClose.cs rename to osu.Game/Overlays/Chat/ChannelList/ChannelListItemCloseButton.cs index 37a1fcdde7..3e595093b4 100644 --- a/osu.Game/Overlays/Chat/ChannelList/ChannelListItemClose.cs +++ b/osu.Game/Overlays/Chat/ChannelList/ChannelListItemCloseButton.cs @@ -12,7 +12,7 @@ using osuTK; namespace osu.Game.Overlays.Chat.ChannelList { - public class ChannelListItemClose : OsuAnimatedButton + public class ChannelListItemCloseButton : OsuAnimatedButton { [BackgroundDependencyLoader] private void load(OsuColour osuColour) diff --git a/osu.Game/Overlays/Chat/ChannelList/ChannelListItemMention.cs b/osu.Game/Overlays/Chat/ChannelList/ChannelListItemMentionPill.cs similarity index 96% rename from osu.Game/Overlays/Chat/ChannelList/ChannelListItemMention.cs rename to osu.Game/Overlays/Chat/ChannelList/ChannelListItemMentionPill.cs index 3a1c3b7619..165756cfcd 100644 --- a/osu.Game/Overlays/Chat/ChannelList/ChannelListItemMention.cs +++ b/osu.Game/Overlays/Chat/ChannelList/ChannelListItemMentionPill.cs @@ -14,7 +14,7 @@ using osuTK; namespace osu.Game.Overlays.Chat.ChannelList { - public class ChannelListItemMention : CircularContainer + public class ChannelListItemMentionPill : CircularContainer { public readonly BindableInt Mentions = new BindableInt(); From 9eda2f2df126f28079b05e9c87955fb08dd63364 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Mon, 21 Mar 2022 14:25:29 +0900 Subject: [PATCH 31/38] Remove box surrounding close button --- .../ChannelList/ChannelListItemCloseButton.cs | 43 +++++++++++++++++-- 1 file changed, 39 insertions(+), 4 deletions(-) diff --git a/osu.Game/Overlays/Chat/ChannelList/ChannelListItemCloseButton.cs b/osu.Game/Overlays/Chat/ChannelList/ChannelListItemCloseButton.cs index 3e595093b4..a5876c8ad8 100644 --- a/osu.Game/Overlays/Chat/ChannelList/ChannelListItemCloseButton.cs +++ b/osu.Game/Overlays/Chat/ChannelList/ChannelListItemCloseButton.cs @@ -6,28 +6,63 @@ using osu.Framework.Allocation; using osu.Framework.Graphics; using osu.Framework.Graphics.Sprites; +using osu.Framework.Input.Events; using osu.Game.Graphics; -using osu.Game.Graphics.UserInterface; +using osu.Game.Graphics.Containers; using osuTK; +using osuTK.Graphics; namespace osu.Game.Overlays.Chat.ChannelList { - public class ChannelListItemCloseButton : OsuAnimatedButton + public class ChannelListItemCloseButton : OsuClickableContainer { + private SpriteIcon icon = null!; + + private Color4 normalColour; + private Color4 hoveredColour; + [BackgroundDependencyLoader] private void load(OsuColour osuColour) { + normalColour = osuColour.Red2; + hoveredColour = Color4.White; + Alpha = 0f; Size = new Vector2(20); - Add(new SpriteIcon + Add(icon = new SpriteIcon { Anchor = Anchor.Centre, Origin = Anchor.Centre, Scale = new Vector2(0.75f), Icon = FontAwesome.Solid.TimesCircle, RelativeSizeAxes = Axes.Both, - Colour = osuColour.Red1, + Colour = normalColour, }); } + + // Transforms matching OsuAnimatedButton + protected override bool OnHover(HoverEvent e) + { + icon.FadeColour(hoveredColour, 300, Easing.OutQuint); + return base.OnHover(e); + } + + protected override void OnHoverLost(HoverLostEvent e) + { + icon.FadeColour(normalColour, 300, Easing.OutQuint); + base.OnHoverLost(e); + } + + protected override bool OnMouseDown(MouseDownEvent e) + { + icon.ScaleTo(0.75f, 2000, Easing.OutQuint); + return base.OnMouseDown(e); + } + + protected override void OnMouseUp(MouseUpEvent e) + { + icon.ScaleTo(1, 1000, Easing.OutElastic); + base.OnMouseUp(e); + } } } From 11b050b66b66d189c9f84a740709ff72b7674aa2 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Mon, 21 Mar 2022 14:28:12 +0900 Subject: [PATCH 32/38] Add slight fade when hovering `ChannelListItem`s --- osu.Game/Overlays/Chat/ChannelList/ChannelListItem.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/osu.Game/Overlays/Chat/ChannelList/ChannelListItem.cs b/osu.Game/Overlays/Chat/ChannelList/ChannelListItem.cs index 006cfdea3b..9dc0529ce4 100644 --- a/osu.Game/Overlays/Chat/ChannelList/ChannelListItem.cs +++ b/osu.Game/Overlays/Chat/ChannelList/ChannelListItem.cs @@ -140,15 +140,15 @@ namespace osu.Game.Overlays.Chat.ChannelList protected override bool OnHover(HoverEvent e) { - hoverBox?.Show(); - close?.Show(); + hoverBox?.FadeIn(300, Easing.OutQuint); + close?.FadeIn(300, Easing.OutQuint); return base.OnHover(e); } protected override void OnHoverLost(HoverLostEvent e) { - hoverBox?.Hide(); - close?.Hide(); + hoverBox?.FadeOut(200, Easing.OutQuint); + close?.FadeOut(200, Easing.OutQuint); base.OnHoverLost(e); } From 692362131ef80b4990d2b7437c5b10c818513b02 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Mon, 21 Mar 2022 14:31:51 +0900 Subject: [PATCH 33/38] Add animation when mention pill appears (or a new message arrives) --- .../Chat/ChannelList/ChannelListItemMentionPill.cs | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/osu.Game/Overlays/Chat/ChannelList/ChannelListItemMentionPill.cs b/osu.Game/Overlays/Chat/ChannelList/ChannelListItemMentionPill.cs index 165756cfcd..5018c8cd64 100644 --- a/osu.Game/Overlays/Chat/ChannelList/ChannelListItemMentionPill.cs +++ b/osu.Game/Overlays/Chat/ChannelList/ChannelListItemMentionPill.cs @@ -11,6 +11,7 @@ using osu.Framework.Graphics.Shapes; using osu.Game.Graphics; using osu.Game.Graphics.Sprites; using osuTK; +using osuTK.Graphics; namespace osu.Game.Overlays.Chat.ChannelList { @@ -20,6 +21,8 @@ namespace osu.Game.Overlays.Chat.ChannelList private OsuSpriteText countText = null!; + private Box box = null!; + [BackgroundDependencyLoader] private void load(OsuColour osuColour, OverlayColourProvider colourProvider) { @@ -29,7 +32,7 @@ namespace osu.Game.Overlays.Chat.ChannelList Children = new Drawable[] { - new Box + box = new Box { RelativeSizeAxes = Axes.Both, Colour = osuColour.Orange1, @@ -56,9 +59,12 @@ namespace osu.Game.Overlays.Chat.ChannelList countText.Text = mentionCount > 99 ? "99+" : mentionCount.ToString(); if (mentionCount > 0) - Show(); + { + this.FadeIn(1000, Easing.OutQuint); + box.FlashColour(Color4.White, 500, Easing.OutQuint); + } else - Hide(); + this.FadeOut(100, Easing.OutQuint); }, true); } } From 5104e4db21ef5eec39bf463ea59cc2f1dfafc96f Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Mon, 21 Mar 2022 14:33:50 +0900 Subject: [PATCH 34/38] Add step to `TestSceneChannelListItem` to actually select an item --- osu.Game.Tests/Visual/Online/TestSceneChannelListItem.cs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/osu.Game.Tests/Visual/Online/TestSceneChannelListItem.cs b/osu.Game.Tests/Visual/Online/TestSceneChannelListItem.cs index ac829f8cbc..af419c8b91 100644 --- a/osu.Game.Tests/Visual/Online/TestSceneChannelListItem.cs +++ b/osu.Game.Tests/Visual/Online/TestSceneChannelListItem.cs @@ -3,6 +3,7 @@ using NUnit.Framework; using System.Collections.Generic; +using System.Linq; using osu.Framework.Allocation; using osu.Framework.Bindables; using osu.Framework.Graphics; @@ -114,6 +115,8 @@ namespace osu.Game.Tests.Visual.Online [Test] public void TestVisual() { + AddStep("Select second item", () => selected.Value = channels.Skip(1).First()); + AddStep("Unread Selected", () => { if (selected.Value != null) From 16caf2d30b989917100589f6fe072354995bf9b4 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Mon, 21 Mar 2022 14:34:54 +0900 Subject: [PATCH 35/38] Add slight animation when highlighting an unread channel --- osu.Game/Overlays/Chat/ChannelList/ChannelListItem.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Overlays/Chat/ChannelList/ChannelListItem.cs b/osu.Game/Overlays/Chat/ChannelList/ChannelListItem.cs index 9dc0529ce4..8cf37fd0d5 100644 --- a/osu.Game/Overlays/Chat/ChannelList/ChannelListItem.cs +++ b/osu.Game/Overlays/Chat/ChannelList/ChannelListItem.cs @@ -134,7 +134,7 @@ namespace osu.Game.Overlays.Chat.ChannelList Unread.BindValueChanged(change => { - text!.Colour = change.NewValue ? colourProvider.Content1 : colourProvider.Light3; + text!.FadeColour(change.NewValue ? colourProvider.Content1 : colourProvider.Light3, 300, Easing.OutQuint); }, true); } From 428e439f40e1a1c0c4cf665d3e3138ebe785ec34 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Mon, 21 Mar 2022 14:36:55 +0900 Subject: [PATCH 36/38] Remove space between '#' and channel name This was in flyte's design (he was following discord) but doesn't feel too correct when it's not aligned with anything else. We can revisit this if/when we have better glyphs to represent channel types. --- osu.Game/Overlays/Chat/ChannelList/ChannelListItem.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Overlays/Chat/ChannelList/ChannelListItem.cs b/osu.Game/Overlays/Chat/ChannelList/ChannelListItem.cs index 8cf37fd0d5..f3bbe101de 100644 --- a/osu.Game/Overlays/Chat/ChannelList/ChannelListItem.cs +++ b/osu.Game/Overlays/Chat/ChannelList/ChannelListItem.cs @@ -90,7 +90,7 @@ namespace osu.Game.Overlays.Chat.ChannelList { Anchor = Anchor.CentreLeft, Origin = Anchor.CentreLeft, - Text = channel.Type == ChannelType.Public ? $"# {channel.Name.Substring(1)}" : channel.Name, + Text = channel.Name, Font = OsuFont.Torus.With(size: 17, weight: FontWeight.SemiBold), Colour = colourProvider.Light3, Margin = new MarginPadding { Bottom = 2 }, From 7ca3beb7cc5ef647e51a1d2aa9f858b25c44cedd Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Mon, 21 Mar 2022 14:41:42 +0900 Subject: [PATCH 37/38] Also add fade to `ChannelItem` selected box --- osu.Game/Overlays/Chat/ChannelList/ChannelListItem.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/osu.Game/Overlays/Chat/ChannelList/ChannelListItem.cs b/osu.Game/Overlays/Chat/ChannelList/ChannelListItem.cs index f3bbe101de..43574351ed 100644 --- a/osu.Game/Overlays/Chat/ChannelList/ChannelListItem.cs +++ b/osu.Game/Overlays/Chat/ChannelList/ChannelListItem.cs @@ -127,9 +127,9 @@ namespace osu.Game.Overlays.Chat.ChannelList selectedChannel.BindValueChanged(change => { if (change.NewValue == channel) - selectBox?.Show(); + selectBox?.FadeIn(300, Easing.OutQuint); else - selectBox?.Hide(); + selectBox?.FadeOut(200, Easing.OutQuint); }, true); Unread.BindValueChanged(change => From 3bb01fd59583939aa46e5e8e18189375cc222d24 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Mon, 21 Mar 2022 14:41:57 +0900 Subject: [PATCH 38/38] Fix close button animation not being applied correct on mouse down due to conflicting scales --- .../Overlays/Chat/ChannelList/ChannelListItemCloseButton.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Overlays/Chat/ChannelList/ChannelListItemCloseButton.cs b/osu.Game/Overlays/Chat/ChannelList/ChannelListItemCloseButton.cs index a5876c8ad8..65b9c4a79b 100644 --- a/osu.Game/Overlays/Chat/ChannelList/ChannelListItemCloseButton.cs +++ b/osu.Game/Overlays/Chat/ChannelList/ChannelListItemCloseButton.cs @@ -33,7 +33,7 @@ namespace osu.Game.Overlays.Chat.ChannelList { Anchor = Anchor.Centre, Origin = Anchor.Centre, - Scale = new Vector2(0.75f), + Size = new Vector2(0.75f), Icon = FontAwesome.Solid.TimesCircle, RelativeSizeAxes = Axes.Both, Colour = normalColour,