From 9d62206176732dbc9b6e96b1f0258ee87dffe489 Mon Sep 17 00:00:00 2001 From: Jai Sharma Date: Fri, 6 May 2022 22:56:35 +0100 Subject: [PATCH 01/16] Update new chat overlay day separator colours and spacing Updates the `DaySeparator` component to have separately settable colours for the text and the lines. Updates existing overrides of the `DaySeparator` to use the new colour setter. Create new `ChatOverlayDrawableChannel` with adjusted spacing and new `DaySeparator` colours. --- .../Visual/Online/TestSceneChatOverlayV2.cs | 6 ++-- osu.Game/Online/Chat/StandAloneChatDisplay.cs | 33 ++++++++----------- osu.Game/Overlays/Chat/ChatTextBar.cs | 2 +- osu.Game/Overlays/Chat/DrawableChannel.cs | 18 +++++++++- osu.Game/Overlays/ChatOverlayV2.cs | 33 +++++++++++++++++-- 5 files changed, 64 insertions(+), 28 deletions(-) diff --git a/osu.Game.Tests/Visual/Online/TestSceneChatOverlayV2.cs b/osu.Game.Tests/Visual/Online/TestSceneChatOverlayV2.cs index 7c77ac925e..9d894314f8 100644 --- a/osu.Game.Tests/Visual/Online/TestSceneChatOverlayV2.cs +++ b/osu.Game.Tests/Visual/Online/TestSceneChatOverlayV2.cs @@ -365,7 +365,7 @@ namespace osu.Game.Tests.Visual.Online AddAssert("TextBox is focused", () => InputManager.FocusedDrawable == chatOverlayTextBox); AddStep("Click listing", () => clickDrawable(chatOverlay.ChildrenOfType().Single())); AddAssert("TextBox is focused", () => InputManager.FocusedDrawable == chatOverlayTextBox); - AddStep("Click drawable channel", () => clickDrawable(chatOverlay.ChildrenOfType().Single())); + AddStep("Click drawable channel", () => clickDrawable(chatOverlay.ChildrenOfType().Single())); AddAssert("TextBox is focused", () => InputManager.FocusedDrawable == chatOverlayTextBox); AddStep("Click channel list", () => clickDrawable(chatOverlay.ChildrenOfType().Single())); AddAssert("TextBox is focused", () => InputManager.FocusedDrawable == chatOverlayTextBox); @@ -381,8 +381,8 @@ namespace osu.Game.Tests.Visual.Online private Visibility loadingVisibility => chatOverlay.ChildrenOfType().Single().State.Value; - private DrawableChannel currentDrawableChannel => - chatOverlay.ChildrenOfType>().Single().Child; + private ChatOverlayDrawableChannel currentDrawableChannel => + chatOverlay.ChildrenOfType>().Single().Child; private ChannelListItem getChannelListItem(Channel channel) => chatOverlay.ChildrenOfType().Single(item => item.Channel == channel); diff --git a/osu.Game/Online/Chat/StandAloneChatDisplay.cs b/osu.Game/Online/Chat/StandAloneChatDisplay.cs index df210fcaf8..c03cd938a5 100644 --- a/osu.Game/Online/Chat/StandAloneChatDisplay.cs +++ b/osu.Game/Online/Chat/StandAloneChatDisplay.cs @@ -155,9 +155,7 @@ namespace osu.Game.Online.Chat { public Func CreateChatLineAction; - protected override ChatLine CreateChatLine(Message m) => CreateChatLineAction(m); - - protected override DaySeparator CreateDaySeparator(DateTimeOffset time) => new CustomDaySeparator(time); + private Colour4 daySepColour; public StandAloneDrawableChannel(Channel channel) : base(channel) @@ -165,28 +163,23 @@ namespace osu.Game.Online.Chat } [BackgroundDependencyLoader] - private void load() + private void load(OsuColour colours) { ChatLineFlow.Padding = new MarginPadding { Horizontal = 0 }; + daySepColour = colours.Yellow; } - private class CustomDaySeparator : DaySeparator + protected override ChatLine CreateChatLine(Message m) => CreateChatLineAction(m); + + protected override DaySeparator CreateDaySeparator(DateTimeOffset time) => new DaySeparator(time) { - public CustomDaySeparator(DateTimeOffset time) - : base(time) - { - } - - [BackgroundDependencyLoader] - private void load(OsuColour colours) - { - Colour = colours.Yellow; - TextSize = 14; - LineHeight = 1; - Padding = new MarginPadding { Horizontal = 10 }; - Margin = new MarginPadding { Vertical = 5 }; - } - } + TextSize = 14, + TextColour = daySepColour, + LineHeight = 1, + LineColour = daySepColour, + Padding = new MarginPadding { Horizontal = 10 }, + Margin = new MarginPadding { Vertical = 5 }, + }; } protected class StandAloneMessage : ChatLine diff --git a/osu.Game/Overlays/Chat/ChatTextBar.cs b/osu.Game/Overlays/Chat/ChatTextBar.cs index 0fa3613d38..404d686d91 100644 --- a/osu.Game/Overlays/Chat/ChatTextBar.cs +++ b/osu.Game/Overlays/Chat/ChatTextBar.cs @@ -38,7 +38,7 @@ namespace osu.Game.Overlays.Chat private Container searchIconContainer = null!; private ChatTextBox chatTextBox = null!; - private const float chatting_text_width = 240; + private const float chatting_text_width = 220; private const float search_icon_width = 40; [BackgroundDependencyLoader] diff --git a/osu.Game/Overlays/Chat/DrawableChannel.cs b/osu.Game/Overlays/Chat/DrawableChannel.cs index 161fe1d5be..7e4e936bee 100644 --- a/osu.Game/Overlays/Chat/DrawableChannel.cs +++ b/osu.Game/Overlays/Chat/DrawableChannel.cs @@ -9,6 +9,7 @@ using osu.Framework.Allocation; using osu.Framework.Bindables; using osu.Framework.Extensions.Color4Extensions; using osu.Framework.Graphics; +using osu.Framework.Graphics.Colour; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Shapes; using osu.Framework.Graphics.Sprites; @@ -123,8 +124,9 @@ namespace osu.Game.Overlays.Chat protected virtual DaySeparator CreateDaySeparator(DateTimeOffset time) => new DaySeparator(time) { + TextColour = colours.ChatBlue.Lighten(0.7f), + LineColour = colours.ChatBlue.Lighten(0.7f), Margin = new MarginPadding { Vertical = 10 }, - Colour = colours.ChatBlue.Lighten(0.7f), }; private void newMessagesArrived(IEnumerable newMessages) => Schedule(() => @@ -212,6 +214,12 @@ namespace osu.Game.Overlays.Chat set => text.Font = text.Font.With(size: value); } + public ColourInfo TextColour + { + get => text.Colour; + set => text.Colour = value; + } + private float lineHeight = 2; public float LineHeight @@ -220,6 +228,14 @@ namespace osu.Game.Overlays.Chat set => lineHeight = leftBox.Height = rightBox.Height = value; } + private ColourInfo lineColour; + + public ColourInfo LineColour + { + get => lineColour; + set => lineColour = leftBox.Colour = rightBox.Colour = value; + } + private readonly SpriteText text; private readonly Box leftBox; private readonly Box rightBox; diff --git a/osu.Game/Overlays/ChatOverlayV2.cs b/osu.Game/Overlays/ChatOverlayV2.cs index 4c7fa0f802..cc050a0760 100644 --- a/osu.Game/Overlays/ChatOverlayV2.cs +++ b/osu.Game/Overlays/ChatOverlayV2.cs @@ -3,6 +3,7 @@ #nullable enable +using System; using System.Collections; using System.Collections.Generic; using System.Collections.Specialized; @@ -37,7 +38,7 @@ namespace osu.Game.Overlays private LoadingLayer loading = null!; private ChannelListing channelListing = null!; private ChatTextBar textBar = null!; - private Container currentChannelContainer = null!; + private Container currentChannelContainer = null!; private readonly BindableFloat chatHeight = new BindableFloat(); @@ -120,7 +121,7 @@ namespace osu.Game.Overlays RelativeSizeAxes = Axes.Both, Colour = colourProvider.Background4, }, - currentChannelContainer = new Container + currentChannelContainer = new Container { RelativeSizeAxes = Axes.Both, }, @@ -268,7 +269,7 @@ namespace osu.Game.Overlays return; } - LoadComponentAsync(new DrawableChannel(newChannel), loaded => + LoadComponentAsync(new ChatOverlayDrawableChannel(newChannel), loaded => { currentChannelContainer.Clear(); currentChannelContainer.Add(loaded); @@ -311,4 +312,30 @@ namespace osu.Game.Overlays channelManager.PostMessage(message); } } + + public class ChatOverlayDrawableChannel : DrawableChannel + { + private Colour4 daySepTextColour; + private Colour4 daySepLineColour; + + public ChatOverlayDrawableChannel(Channel channel) + : base(channel) + { } + + [BackgroundDependencyLoader] + private void load(OverlayColourProvider colourProvider) + { + ChatLineFlow.Padding = new MarginPadding(0); + daySepTextColour = colourProvider.Content1; + daySepLineColour = colourProvider.Background5; + } + + protected override DaySeparator CreateDaySeparator(DateTimeOffset time) => new DaySeparator(time) + { + TextColour = daySepTextColour, + LineColour = daySepLineColour, + Margin = new MarginPadding { Vertical = 10 }, + Padding = new MarginPadding { Horizontal = 15 }, + }; + } } From 6fc808be22cb8bf32e8f1bd497f88efa7f89340c Mon Sep 17 00:00:00 2001 From: Jai Sharma Date: Fri, 6 May 2022 23:17:59 +0100 Subject: [PATCH 02/16] Code quality --- osu.Game/Overlays/ChatOverlayV2.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/osu.Game/Overlays/ChatOverlayV2.cs b/osu.Game/Overlays/ChatOverlayV2.cs index cc050a0760..e1ac71a125 100644 --- a/osu.Game/Overlays/ChatOverlayV2.cs +++ b/osu.Game/Overlays/ChatOverlayV2.cs @@ -320,7 +320,8 @@ namespace osu.Game.Overlays public ChatOverlayDrawableChannel(Channel channel) : base(channel) - { } + { + } [BackgroundDependencyLoader] private void load(OverlayColourProvider colourProvider) From bec28c5b28219a9eccfedeed3818e97d41c291ea Mon Sep 17 00:00:00 2001 From: Jai Sharma Date: Sat, 7 May 2022 22:16:11 +0100 Subject: [PATCH 03/16] Remove virtual `ColourInfo` properties from `DaySeparator` --- osu.Game/Online/Chat/StandAloneChatDisplay.cs | 3 +-- osu.Game/Overlays/Chat/DrawableChannel.cs | 18 +----------------- osu.Game/Overlays/ChatOverlayV2.cs | 10 ++-------- 3 files changed, 4 insertions(+), 27 deletions(-) diff --git a/osu.Game/Online/Chat/StandAloneChatDisplay.cs b/osu.Game/Online/Chat/StandAloneChatDisplay.cs index c03cd938a5..ac6bc190ca 100644 --- a/osu.Game/Online/Chat/StandAloneChatDisplay.cs +++ b/osu.Game/Online/Chat/StandAloneChatDisplay.cs @@ -174,9 +174,8 @@ namespace osu.Game.Online.Chat protected override DaySeparator CreateDaySeparator(DateTimeOffset time) => new DaySeparator(time) { TextSize = 14, - TextColour = daySepColour, + Colour = daySepColour, LineHeight = 1, - LineColour = daySepColour, Padding = new MarginPadding { Horizontal = 10 }, Margin = new MarginPadding { Vertical = 5 }, }; diff --git a/osu.Game/Overlays/Chat/DrawableChannel.cs b/osu.Game/Overlays/Chat/DrawableChannel.cs index 7e4e936bee..0dcb52c60a 100644 --- a/osu.Game/Overlays/Chat/DrawableChannel.cs +++ b/osu.Game/Overlays/Chat/DrawableChannel.cs @@ -9,7 +9,6 @@ using osu.Framework.Allocation; using osu.Framework.Bindables; using osu.Framework.Extensions.Color4Extensions; using osu.Framework.Graphics; -using osu.Framework.Graphics.Colour; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Shapes; using osu.Framework.Graphics.Sprites; @@ -124,8 +123,7 @@ namespace osu.Game.Overlays.Chat protected virtual DaySeparator CreateDaySeparator(DateTimeOffset time) => new DaySeparator(time) { - TextColour = colours.ChatBlue.Lighten(0.7f), - LineColour = colours.ChatBlue.Lighten(0.7f), + Colour = colours.ChatBlue.Lighten(0.7f), Margin = new MarginPadding { Vertical = 10 }, }; @@ -214,12 +212,6 @@ namespace osu.Game.Overlays.Chat set => text.Font = text.Font.With(size: value); } - public ColourInfo TextColour - { - get => text.Colour; - set => text.Colour = value; - } - private float lineHeight = 2; public float LineHeight @@ -228,14 +220,6 @@ namespace osu.Game.Overlays.Chat set => lineHeight = leftBox.Height = rightBox.Height = value; } - private ColourInfo lineColour; - - public ColourInfo LineColour - { - get => lineColour; - set => lineColour = leftBox.Colour = rightBox.Colour = value; - } - private readonly SpriteText text; private readonly Box leftBox; private readonly Box rightBox; diff --git a/osu.Game/Overlays/ChatOverlayV2.cs b/osu.Game/Overlays/ChatOverlayV2.cs index e1ac71a125..18a2f593dd 100644 --- a/osu.Game/Overlays/ChatOverlayV2.cs +++ b/osu.Game/Overlays/ChatOverlayV2.cs @@ -315,26 +315,20 @@ namespace osu.Game.Overlays public class ChatOverlayDrawableChannel : DrawableChannel { - private Colour4 daySepTextColour; - private Colour4 daySepLineColour; - public ChatOverlayDrawableChannel(Channel channel) : base(channel) { } [BackgroundDependencyLoader] - private void load(OverlayColourProvider colourProvider) + private void load() { ChatLineFlow.Padding = new MarginPadding(0); - daySepTextColour = colourProvider.Content1; - daySepLineColour = colourProvider.Background5; } protected override DaySeparator CreateDaySeparator(DateTimeOffset time) => new DaySeparator(time) { - TextColour = daySepTextColour, - LineColour = daySepLineColour, + Colour = Colour4.White, Margin = new MarginPadding { Vertical = 10 }, Padding = new MarginPadding { Horizontal = 15 }, }; From f4acfbd0df4380f1ddf9800abae74135027119cf Mon Sep 17 00:00:00 2001 From: Jai Sharma Date: Sat, 7 May 2022 22:23:46 +0100 Subject: [PATCH 04/16] Change return type of `CreateDaySeparator` to `Drawable` --- osu.Game/Online/Chat/StandAloneChatDisplay.cs | 2 +- osu.Game/Overlays/Chat/DrawableChannel.cs | 2 +- osu.Game/Overlays/ChatOverlayV2.cs | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/osu.Game/Online/Chat/StandAloneChatDisplay.cs b/osu.Game/Online/Chat/StandAloneChatDisplay.cs index ac6bc190ca..79c4ed6068 100644 --- a/osu.Game/Online/Chat/StandAloneChatDisplay.cs +++ b/osu.Game/Online/Chat/StandAloneChatDisplay.cs @@ -171,7 +171,7 @@ namespace osu.Game.Online.Chat protected override ChatLine CreateChatLine(Message m) => CreateChatLineAction(m); - protected override DaySeparator CreateDaySeparator(DateTimeOffset time) => new DaySeparator(time) + protected override Drawable CreateDaySeparator(DateTimeOffset time) => new DaySeparator(time) { TextSize = 14, Colour = daySepColour, diff --git a/osu.Game/Overlays/Chat/DrawableChannel.cs b/osu.Game/Overlays/Chat/DrawableChannel.cs index 0dcb52c60a..f2d4a3e301 100644 --- a/osu.Game/Overlays/Chat/DrawableChannel.cs +++ b/osu.Game/Overlays/Chat/DrawableChannel.cs @@ -121,7 +121,7 @@ namespace osu.Game.Overlays.Chat protected virtual ChatLine CreateChatLine(Message m) => new ChatLine(m); - protected virtual DaySeparator CreateDaySeparator(DateTimeOffset time) => new DaySeparator(time) + protected virtual Drawable CreateDaySeparator(DateTimeOffset time) => new DaySeparator(time) { Colour = colours.ChatBlue.Lighten(0.7f), Margin = new MarginPadding { Vertical = 10 }, diff --git a/osu.Game/Overlays/ChatOverlayV2.cs b/osu.Game/Overlays/ChatOverlayV2.cs index 18a2f593dd..1f2fb9724b 100644 --- a/osu.Game/Overlays/ChatOverlayV2.cs +++ b/osu.Game/Overlays/ChatOverlayV2.cs @@ -326,7 +326,7 @@ namespace osu.Game.Overlays ChatLineFlow.Padding = new MarginPadding(0); } - protected override DaySeparator CreateDaySeparator(DateTimeOffset time) => new DaySeparator(time) + protected override Drawable CreateDaySeparator(DateTimeOffset time) => new DaySeparator(time) { Colour = Colour4.White, Margin = new MarginPadding { Vertical = 10 }, From c0643cae751fa27e49b5929b2e3ffba0737604b9 Mon Sep 17 00:00:00 2001 From: Jai Sharma Date: Sat, 7 May 2022 23:24:34 +0100 Subject: [PATCH 05/16] Create `ChatOverlayDaySeparator` and use in `ChatOverlayDrawableChannel` --- osu.Game/Overlays/ChatOverlayV2.cs | 59 +++++++++++++++++++++++++++--- 1 file changed, 54 insertions(+), 5 deletions(-) diff --git a/osu.Game/Overlays/ChatOverlayV2.cs b/osu.Game/Overlays/ChatOverlayV2.cs index 1f2fb9724b..b0f81c217a 100644 --- a/osu.Game/Overlays/ChatOverlayV2.cs +++ b/osu.Game/Overlays/ChatOverlayV2.cs @@ -17,7 +17,9 @@ using osu.Framework.Graphics.Shapes; using osu.Framework.Input.Events; using osu.Framework.Localisation; using osu.Game.Configuration; +using osu.Game.Graphics; using osu.Game.Graphics.Containers; +using osu.Game.Graphics.Sprites; using osu.Game.Graphics.UserInterface; using osu.Game.Localisation; using osu.Game.Online.Chat; @@ -326,11 +328,58 @@ namespace osu.Game.Overlays ChatLineFlow.Padding = new MarginPadding(0); } - protected override Drawable CreateDaySeparator(DateTimeOffset time) => new DaySeparator(time) + protected override Drawable CreateDaySeparator(DateTimeOffset time) => new ChatOverlayDaySeparator(time); + + private class ChatOverlayDaySeparator : Container { - Colour = Colour4.White, - Margin = new MarginPadding { Vertical = 10 }, - Padding = new MarginPadding { Horizontal = 15 }, - }; + private readonly DateTimeOffset time; + + public ChatOverlayDaySeparator(DateTimeOffset time) + { + this.time = time; + } + + [BackgroundDependencyLoader] + private void load(OverlayColourProvider colourProvider) + { + RelativeSizeAxes = Axes.X; + AutoSizeAxes = Axes.Y; + Padding = new MarginPadding(15); + Child = new GridContainer + { + RelativeSizeAxes = Axes.X, + AutoSizeAxes = Axes.Y, + RowDimensions = new[] { new Dimension(GridSizeMode.AutoSize) }, + ColumnDimensions = new[] + { + new Dimension(GridSizeMode.Absolute, 215), + new Dimension(GridSizeMode.AutoSize), + new Dimension(), + }, + Content = new[] + { + new Drawable[] + { + Drawable.Empty(), + new OsuSpriteText + { + Text = time.ToLocalTime().ToString("dd MMMM yyyy").ToUpper(), + Font = OsuFont.Torus.With(size: 15, weight: FontWeight.SemiBold), + Colour = colourProvider.Content1, + Margin = new MarginPadding { Right = 10 }, + }, + new Box + { + Anchor = Anchor.CentreLeft, + Origin = Anchor.CentreLeft, + Colour = colourProvider.Background5, + RelativeSizeAxes = Axes.X, + Height = 2, + }, + }, + }, + }; + } + } } } From 8da7bbd32271d782d2b65d7f84878a2b46c9552a Mon Sep 17 00:00:00 2001 From: Jai Sharma Date: Sat, 7 May 2022 23:30:46 +0100 Subject: [PATCH 06/16] Code quality --- osu.Game/Overlays/ChatOverlayV2.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Overlays/ChatOverlayV2.cs b/osu.Game/Overlays/ChatOverlayV2.cs index b0f81c217a..0702b3ad97 100644 --- a/osu.Game/Overlays/ChatOverlayV2.cs +++ b/osu.Game/Overlays/ChatOverlayV2.cs @@ -358,7 +358,7 @@ namespace osu.Game.Overlays }, Content = new[] { - new Drawable[] + new[] { Drawable.Empty(), new OsuSpriteText From 5f80e344c3f1bcf4953dedd6092d18c1d7d366eb Mon Sep 17 00:00:00 2001 From: Jai Sharma Date: Mon, 9 May 2022 00:15:08 +0100 Subject: [PATCH 07/16] Update day separator date text to right align against username --- osu.Game/Overlays/ChatOverlayV2.cs | 45 +++++++++++++++++++++++------- 1 file changed, 35 insertions(+), 10 deletions(-) diff --git a/osu.Game/Overlays/ChatOverlayV2.cs b/osu.Game/Overlays/ChatOverlayV2.cs index 0702b3ad97..8c832baa38 100644 --- a/osu.Game/Overlays/ChatOverlayV2.cs +++ b/osu.Game/Overlays/ChatOverlayV2.cs @@ -349,26 +349,51 @@ namespace osu.Game.Overlays { RelativeSizeAxes = Axes.X, AutoSizeAxes = Axes.Y, - RowDimensions = new[] { new Dimension(GridSizeMode.AutoSize) }, ColumnDimensions = new[] { - new Dimension(GridSizeMode.Absolute, 215), - new Dimension(GridSizeMode.AutoSize), + new Dimension(GridSizeMode.Absolute, 200), + new Dimension(GridSizeMode.Absolute, 15), new Dimension(), }, Content = new[] { new[] { - Drawable.Empty(), - new OsuSpriteText + new GridContainer { - Text = time.ToLocalTime().ToString("dd MMMM yyyy").ToUpper(), - Font = OsuFont.Torus.With(size: 15, weight: FontWeight.SemiBold), - Colour = colourProvider.Content1, - Margin = new MarginPadding { Right = 10 }, + RelativeSizeAxes = Axes.Both, + ColumnDimensions = new[] + { + new Dimension(), + new Dimension(GridSizeMode.Absolute, 15), + new Dimension(GridSizeMode.AutoSize), + }, + Content = new[] + { + new[] + { + new Circle + { + Anchor = Anchor.CentreRight, + Origin = Anchor.CentreRight, + Colour = colourProvider.Background5, + RelativeSizeAxes = Axes.X, + Height = 2, + }, + Drawable.Empty(), + new OsuSpriteText + { + Anchor = Anchor.CentreRight, + Origin = Anchor.CentreRight, + Text = time.ToLocalTime().ToString("dd MMMM yyyy").ToUpper(), + Font = OsuFont.Torus.With(size: 15, weight: FontWeight.SemiBold), + Colour = colourProvider.Content1, + }, + }, + }, }, - new Box + Drawable.Empty(), + new Circle { Anchor = Anchor.CentreLeft, Origin = Anchor.CentreLeft, From c221058f0f6cb269ed1a9746a6f999a1027c6740 Mon Sep 17 00:00:00 2001 From: Jai Sharma Date: Mon, 9 May 2022 00:26:00 +0100 Subject: [PATCH 08/16] Simplify fetching `DrawableChannel` in `ChatOverlayV2` test --- osu.Game.Tests/Visual/Online/TestSceneChatOverlayV2.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/osu.Game.Tests/Visual/Online/TestSceneChatOverlayV2.cs b/osu.Game.Tests/Visual/Online/TestSceneChatOverlayV2.cs index 9d894314f8..259f5540b7 100644 --- a/osu.Game.Tests/Visual/Online/TestSceneChatOverlayV2.cs +++ b/osu.Game.Tests/Visual/Online/TestSceneChatOverlayV2.cs @@ -365,7 +365,7 @@ namespace osu.Game.Tests.Visual.Online AddAssert("TextBox is focused", () => InputManager.FocusedDrawable == chatOverlayTextBox); AddStep("Click listing", () => clickDrawable(chatOverlay.ChildrenOfType().Single())); AddAssert("TextBox is focused", () => InputManager.FocusedDrawable == chatOverlayTextBox); - AddStep("Click drawable channel", () => clickDrawable(chatOverlay.ChildrenOfType().Single())); + AddStep("Click drawable channel", () => clickDrawable(currentDrawableChannel)); AddAssert("TextBox is focused", () => InputManager.FocusedDrawable == chatOverlayTextBox); AddStep("Click channel list", () => clickDrawable(chatOverlay.ChildrenOfType().Single())); AddAssert("TextBox is focused", () => InputManager.FocusedDrawable == chatOverlayTextBox); @@ -381,8 +381,8 @@ namespace osu.Game.Tests.Visual.Online private Visibility loadingVisibility => chatOverlay.ChildrenOfType().Single().State.Value; - private ChatOverlayDrawableChannel currentDrawableChannel => - chatOverlay.ChildrenOfType>().Single().Child; + private DrawableChannel currentDrawableChannel => + chatOverlay.ChildrenOfType().Single(); private ChannelListItem getChannelListItem(Channel channel) => chatOverlay.ChildrenOfType().Single(item => item.Channel == channel); From aeb29849897521108bfc8d94a416272ec2bd69fa Mon Sep 17 00:00:00 2001 From: Jai Sharma Date: Mon, 9 May 2022 00:29:40 +0100 Subject: [PATCH 09/16] Move `ChatOverlayDrawableChannel` to it's own file --- .../Chat/ChatOverlayDrawableChannel.cs | 109 ++++++++++++++++++ osu.Game/Overlays/ChatOverlayV2.cs | 96 --------------- 2 files changed, 109 insertions(+), 96 deletions(-) create mode 100644 osu.Game/Overlays/Chat/ChatOverlayDrawableChannel.cs diff --git a/osu.Game/Overlays/Chat/ChatOverlayDrawableChannel.cs b/osu.Game/Overlays/Chat/ChatOverlayDrawableChannel.cs new file mode 100644 index 0000000000..793d81fe26 --- /dev/null +++ b/osu.Game/Overlays/Chat/ChatOverlayDrawableChannel.cs @@ -0,0 +1,109 @@ +// 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.Graphics; +using osu.Framework.Graphics.Containers; +using osu.Framework.Graphics.Shapes; +using osu.Game.Graphics; +using osu.Game.Graphics.Sprites; +using osu.Game.Online.Chat; + +namespace osu.Game.Overlays.Chat +{ + public class ChatOverlayDrawableChannel : DrawableChannel + { + public ChatOverlayDrawableChannel(Channel channel) + : base(channel) + { + } + + [BackgroundDependencyLoader] + private void load() + { + ChatLineFlow.Padding = new MarginPadding(0); + } + + protected override Drawable CreateDaySeparator(DateTimeOffset time) => new ChatOverlayDaySeparator(time); + + private class ChatOverlayDaySeparator : Container + { + private readonly DateTimeOffset time; + + public ChatOverlayDaySeparator(DateTimeOffset time) + { + this.time = time; + } + + [BackgroundDependencyLoader] + private void load(OverlayColourProvider colourProvider) + { + RelativeSizeAxes = Axes.X; + AutoSizeAxes = Axes.Y; + Padding = new MarginPadding(15); + Child = new GridContainer + { + RelativeSizeAxes = Axes.X, + AutoSizeAxes = Axes.Y, + ColumnDimensions = new[] + { + new Dimension(GridSizeMode.Absolute, 200), + new Dimension(GridSizeMode.Absolute, 15), + new Dimension(), + }, + Content = new[] + { + new[] + { + new GridContainer + { + RelativeSizeAxes = Axes.Both, + ColumnDimensions = new[] + { + new Dimension(), + new Dimension(GridSizeMode.Absolute, 15), + new Dimension(GridSizeMode.AutoSize), + }, + Content = new[] + { + new[] + { + new Circle + { + Anchor = Anchor.CentreRight, + Origin = Anchor.CentreRight, + Colour = colourProvider.Background5, + RelativeSizeAxes = Axes.X, + Height = 2, + }, + Drawable.Empty(), + new OsuSpriteText + { + Anchor = Anchor.CentreRight, + Origin = Anchor.CentreRight, + Text = time.ToLocalTime().ToString("dd MMMM yyyy").ToUpper(), + Font = OsuFont.Torus.With(size: 15, weight: FontWeight.SemiBold), + Colour = colourProvider.Content1, + }, + }, + }, + }, + Drawable.Empty(), + new Circle + { + Anchor = Anchor.CentreLeft, + Origin = Anchor.CentreLeft, + Colour = colourProvider.Background5, + RelativeSizeAxes = Axes.X, + Height = 2, + }, + }, + }, + }; + } + } + } +} diff --git a/osu.Game/Overlays/ChatOverlayV2.cs b/osu.Game/Overlays/ChatOverlayV2.cs index 8c832baa38..071f64ce29 100644 --- a/osu.Game/Overlays/ChatOverlayV2.cs +++ b/osu.Game/Overlays/ChatOverlayV2.cs @@ -3,7 +3,6 @@ #nullable enable -using System; using System.Collections; using System.Collections.Generic; using System.Collections.Specialized; @@ -17,9 +16,7 @@ using osu.Framework.Graphics.Shapes; using osu.Framework.Input.Events; using osu.Framework.Localisation; using osu.Game.Configuration; -using osu.Game.Graphics; using osu.Game.Graphics.Containers; -using osu.Game.Graphics.Sprites; using osu.Game.Graphics.UserInterface; using osu.Game.Localisation; using osu.Game.Online.Chat; @@ -314,97 +311,4 @@ namespace osu.Game.Overlays channelManager.PostMessage(message); } } - - public class ChatOverlayDrawableChannel : DrawableChannel - { - public ChatOverlayDrawableChannel(Channel channel) - : base(channel) - { - } - - [BackgroundDependencyLoader] - private void load() - { - ChatLineFlow.Padding = new MarginPadding(0); - } - - protected override Drawable CreateDaySeparator(DateTimeOffset time) => new ChatOverlayDaySeparator(time); - - private class ChatOverlayDaySeparator : Container - { - private readonly DateTimeOffset time; - - public ChatOverlayDaySeparator(DateTimeOffset time) - { - this.time = time; - } - - [BackgroundDependencyLoader] - private void load(OverlayColourProvider colourProvider) - { - RelativeSizeAxes = Axes.X; - AutoSizeAxes = Axes.Y; - Padding = new MarginPadding(15); - Child = new GridContainer - { - RelativeSizeAxes = Axes.X, - AutoSizeAxes = Axes.Y, - ColumnDimensions = new[] - { - new Dimension(GridSizeMode.Absolute, 200), - new Dimension(GridSizeMode.Absolute, 15), - new Dimension(), - }, - Content = new[] - { - new[] - { - new GridContainer - { - RelativeSizeAxes = Axes.Both, - ColumnDimensions = new[] - { - new Dimension(), - new Dimension(GridSizeMode.Absolute, 15), - new Dimension(GridSizeMode.AutoSize), - }, - Content = new[] - { - new[] - { - new Circle - { - Anchor = Anchor.CentreRight, - Origin = Anchor.CentreRight, - Colour = colourProvider.Background5, - RelativeSizeAxes = Axes.X, - Height = 2, - }, - Drawable.Empty(), - new OsuSpriteText - { - Anchor = Anchor.CentreRight, - Origin = Anchor.CentreRight, - Text = time.ToLocalTime().ToString("dd MMMM yyyy").ToUpper(), - Font = OsuFont.Torus.With(size: 15, weight: FontWeight.SemiBold), - Colour = colourProvider.Content1, - }, - }, - }, - }, - Drawable.Empty(), - new Circle - { - Anchor = Anchor.CentreLeft, - Origin = Anchor.CentreLeft, - Colour = colourProvider.Background5, - RelativeSizeAxes = Axes.X, - Height = 2, - }, - }, - }, - }; - } - } - } } From 623e2c94ae69cf5049c1c6001863319ca6029ef2 Mon Sep 17 00:00:00 2001 From: Jai Sharma Date: Mon, 9 May 2022 00:32:22 +0100 Subject: [PATCH 10/16] Adjust padding --- osu.Game/Overlays/Chat/ChatOverlayDrawableChannel.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Overlays/Chat/ChatOverlayDrawableChannel.cs b/osu.Game/Overlays/Chat/ChatOverlayDrawableChannel.cs index 793d81fe26..3b47adc4b7 100644 --- a/osu.Game/Overlays/Chat/ChatOverlayDrawableChannel.cs +++ b/osu.Game/Overlays/Chat/ChatOverlayDrawableChannel.cs @@ -43,7 +43,7 @@ namespace osu.Game.Overlays.Chat { RelativeSizeAxes = Axes.X; AutoSizeAxes = Axes.Y; - Padding = new MarginPadding(15); + Padding = new MarginPadding { Horizontal = 15, Vertical = 20 }; Child = new GridContainer { RelativeSizeAxes = Axes.X, From a35c57860cb309ff73ac62d41be0b39b5257c3b8 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 12 May 2022 23:54:43 +0900 Subject: [PATCH 11/16] Resolve colour inline --- osu.Game/Online/Chat/StandAloneChatDisplay.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/osu.Game/Online/Chat/StandAloneChatDisplay.cs b/osu.Game/Online/Chat/StandAloneChatDisplay.cs index 79c4ed6068..b7e1bc999b 100644 --- a/osu.Game/Online/Chat/StandAloneChatDisplay.cs +++ b/osu.Game/Online/Chat/StandAloneChatDisplay.cs @@ -155,7 +155,8 @@ namespace osu.Game.Online.Chat { public Func CreateChatLineAction; - private Colour4 daySepColour; + [Resolved] + private OsuColour colours { get; set; } public StandAloneDrawableChannel(Channel channel) : base(channel) @@ -163,10 +164,9 @@ namespace osu.Game.Online.Chat } [BackgroundDependencyLoader] - private void load(OsuColour colours) + private void load() { ChatLineFlow.Padding = new MarginPadding { Horizontal = 0 }; - daySepColour = colours.Yellow; } protected override ChatLine CreateChatLine(Message m) => CreateChatLineAction(m); @@ -174,7 +174,7 @@ namespace osu.Game.Online.Chat protected override Drawable CreateDaySeparator(DateTimeOffset time) => new DaySeparator(time) { TextSize = 14, - Colour = daySepColour, + Colour = colours.Yellow, LineHeight = 1, Padding = new MarginPadding { Horizontal = 10 }, Margin = new MarginPadding { Vertical = 5 }, From ff13ef6bb05e0633d8c59e4a40273e084645336b Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 13 May 2022 19:46:21 +0900 Subject: [PATCH 12/16] Fix a couple of markdown inspections --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index dba0b2670d..9daa9635a9 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@

- + osu! logo

# osu! @@ -31,7 +31,7 @@ If you are looking to install or test osu! without setting up a development envi **Latest build:** -| [Windows 8.1+ (x64)](https://github.com/ppy/osu/releases/latest/download/install.exe) | macOS 10.15+ ([Intel](https://github.com/ppy/osu/releases/latest/download/osu.app.Intel.zip), [Apple Silicon](https://github.com/ppy/osu/releases/latest/download/osu.app.Apple.Silicon.zip)) | [Linux (x64)](https://github.com/ppy/osu/releases/latest/download/osu.AppImage) | [iOS 10+](https://osu.ppy.sh/home/testflight) | [Android 5+](https://github.com/ppy/osu/releases/latest/download/sh.ppy.osulazer.apk) +| [Windows 8.1+ (x64)](https://github.com/ppy/osu/releases/latest/download/install.exe) | macOS 10.15+ ([Intel](https://github.com/ppy/osu/releases/latest/download/osu.app.Intel.zip), [Apple Silicon](https://github.com/ppy/osu/releases/latest/download/osu.app.Apple.Silicon.zip)) | [Linux (x64)](https://github.com/ppy/osu/releases/latest/download/osu.AppImage) | [iOS 10+](https://osu.ppy.sh/home/testflight) | [Android 5+](https://github.com/ppy/osu/releases/latest/download/sh.ppy.osulazer.apk) | | ------------- | ------------- | ------------- | ------------- | ------------- | - The iOS testflight link may fill up (Apple has a hard limit of 10,000 users). We reset it occasionally when this happens. Please do not ask about this. Check back regularly for link resets or follow [peppy](https://twitter.com/ppy) on twitter for announcements of link resets. From 4b4f3ec06432bebadf6f020653c938c8c5bb8d27 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 13 May 2022 19:46:28 +0900 Subject: [PATCH 13/16] Add crowdin information to README --- README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/README.md b/README.md index 9daa9635a9..75d61dad4d 100644 --- a/README.md +++ b/README.md @@ -8,6 +8,7 @@ [![GitHub release](https://img.shields.io/github/release/ppy/osu.svg)](https://github.com/ppy/osu/releases/latest) [![CodeFactor](https://www.codefactor.io/repository/github/ppy/osu/badge)](https://www.codefactor.io/repository/github/ppy/osu) [![dev chat](https://discordapp.com/api/guilds/188630481301012481/widget.png?style=shield)](https://discord.gg/ppy) +[![Crowdin](https://d322cqt584bo4o.cloudfront.net/osu-web/localized.svg)](https://crowdin.com/project/osu-web) A free-to-win rhythm game. Rhythm is just a *click* away! @@ -104,6 +105,8 @@ When it comes to contributing to the project, the two main things you can do to Note that while we already have certain standards in place, nothing is set in stone. If you have an issue with the way code is structured, with any libraries we are using, or with any processes involved with contributing, *please* bring it up. We welcome all feedback so we can make contributing to this project as painless as possible. +If you wish to help with localisation efforts, head over to [crowdin](https://crowdin.com/project/osu-web). + For those interested, we love to reward quality contributions via [bounties](https://docs.google.com/spreadsheets/d/1jNXfj_S3Pb5PErA-czDdC9DUu4IgUbe1Lt8E7CYUJuE/view?&rm=minimal#gid=523803337), paid out via PayPal or osu!supporter tags. Don't hesitate to [request a bounty](https://docs.google.com/forms/d/e/1FAIpQLSet_8iFAgPMG526pBZ2Kic6HSh7XPM3fE8xPcnWNkMzINDdYg/viewform) for your work on this project. ## Licence From dec298cccbdfd34108c2c34f771ed82d81ce643c Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 13 May 2022 21:47:22 +0900 Subject: [PATCH 14/16] Update resources --- osu.Android.props | 2 +- osu.Game/osu.Game.csproj | 2 +- osu.iOS.props | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/osu.Android.props b/osu.Android.props index 98dc28d915..b984f528fe 100644 --- a/osu.Android.props +++ b/osu.Android.props @@ -51,7 +51,7 @@ - + diff --git a/osu.Game/osu.Game.csproj b/osu.Game/osu.Game.csproj index 772a78c8fe..7f149b4e35 100644 --- a/osu.Game/osu.Game.csproj +++ b/osu.Game/osu.Game.csproj @@ -36,7 +36,7 @@ - + diff --git a/osu.iOS.props b/osu.iOS.props index af8f9b617c..932421a705 100644 --- a/osu.iOS.props +++ b/osu.iOS.props @@ -62,7 +62,7 @@ - + From c4871ebcf4eaf35b3fe804d74a86b95474410e3a Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Sat, 14 May 2022 02:50:51 +0900 Subject: [PATCH 15/16] Add editor track traversal keys (`Z`-`V`) --- osu.Game/Screens/Edit/Editor.cs | 39 +++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/osu.Game/Screens/Edit/Editor.cs b/osu.Game/Screens/Edit/Editor.cs index 947c184009..0fa9d4ef01 100644 --- a/osu.Game/Screens/Edit/Editor.cs +++ b/osu.Game/Screens/Edit/Editor.cs @@ -33,6 +33,7 @@ using osu.Game.Overlays.Notifications; using osu.Game.Resources.Localisation.Web; using osu.Game.Rulesets; using osu.Game.Rulesets.Edit; +using osu.Game.Rulesets.Objects; using osu.Game.Screens.Edit.Components; using osu.Game.Screens.Edit.Components.Menus; using osu.Game.Screens.Edit.Components.Timelines.Summary; @@ -475,6 +476,44 @@ namespace osu.Game.Screens.Edit case Key.Right: seek(e, 1); return true; + + // Track traversal keys. + // Matching osu-stable implementations. + case Key.Z: + // Seek to first object time, or track start if already there. + double? firstObjectTime = editorBeatmap.HitObjects.FirstOrDefault()?.StartTime; + + if (firstObjectTime == null || clock.CurrentTime == firstObjectTime) + clock.Seek(0); + else + clock.Seek(firstObjectTime.Value); + return true; + + case Key.X: + // Restart playback from beginning of track. + clock.Seek(0); + clock.Start(); + return true; + + case Key.C: + // Pause or resume. + if (clock.IsRunning) + clock.Stop(); + else + clock.Start(); + return true; + + case Key.V: + // Seek to last object time, or track end if already there. + // Note that in osu-stable subsequent presses when at track end won't return to last object. + // This has intentionally been changed to make it more useful. + double? lastObjectTime = editorBeatmap.HitObjects.LastOrDefault()?.GetEndTime(); + + if (lastObjectTime == null || clock.CurrentTime == lastObjectTime) + clock.Seek(clock.TrackLength); + else + clock.Seek(lastObjectTime.Value); + return true; } return base.OnKeyDown(e); From a346456daf26a32b528e7024cc302370c6944206 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Sat, 14 May 2022 03:01:42 +0900 Subject: [PATCH 16/16] Add test coverage of new traversal keys --- .../Visual/Editing/TestSceneEditorSeeking.cs | 45 +++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/osu.Game.Tests/Visual/Editing/TestSceneEditorSeeking.cs b/osu.Game.Tests/Visual/Editing/TestSceneEditorSeeking.cs index ff741a8ed5..da28387c4d 100644 --- a/osu.Game.Tests/Visual/Editing/TestSceneEditorSeeking.cs +++ b/osu.Game.Tests/Visual/Editing/TestSceneEditorSeeking.cs @@ -28,6 +28,51 @@ namespace osu.Game.Tests.Visual.Editing return beatmap; } + [Test] + public void TestSeekToFirst() + { + pressAndCheckTime(Key.Z, 2170); + pressAndCheckTime(Key.Z, 0); + pressAndCheckTime(Key.Z, 2170); + + AddAssert("track not running", () => !EditorClock.IsRunning); + } + + [Test] + public void TestRestart() + { + pressAndCheckTime(Key.V, 227170); + + AddAssert("track not running", () => !EditorClock.IsRunning); + + AddStep("press X", () => InputManager.Key(Key.X)); + + AddAssert("track running", () => EditorClock.IsRunning); + AddAssert("time restarted", () => EditorClock.CurrentTime < 100000); + } + + [Test] + public void TestPauseResume() + { + AddAssert("track not running", () => !EditorClock.IsRunning); + + AddStep("press C", () => InputManager.Key(Key.C)); + AddAssert("track running", () => EditorClock.IsRunning); + + AddStep("press C", () => InputManager.Key(Key.C)); + AddAssert("track not running", () => !EditorClock.IsRunning); + } + + [Test] + public void TestSeekToLast() + { + pressAndCheckTime(Key.V, 227170); + pressAndCheckTime(Key.V, 229170); + pressAndCheckTime(Key.V, 227170); + + AddAssert("track not running", () => !EditorClock.IsRunning); + } + [Test] public void TestSnappedSeeking() {