From ed2737e0276efa75859ff1f205c9e58e3ef26d72 Mon Sep 17 00:00:00 2001 From: Andrei Zavatski Date: Mon, 27 Jan 2020 14:47:47 +0300 Subject: [PATCH 1/6] Recolour TotalCommentCounter --- .../Online/TestSceneTotalCommentsCounter.cs | 5 +++++ .../Overlays/Comments/TotalCommentsCounter.cs | 16 +++++++++------- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/osu.Game.Tests/Visual/Online/TestSceneTotalCommentsCounter.cs b/osu.Game.Tests/Visual/Online/TestSceneTotalCommentsCounter.cs index f14c75084f..8ecbf0891b 100644 --- a/osu.Game.Tests/Visual/Online/TestSceneTotalCommentsCounter.cs +++ b/osu.Game.Tests/Visual/Online/TestSceneTotalCommentsCounter.cs @@ -7,6 +7,8 @@ using osu.Framework.Graphics; using osu.Framework.Bindables; using osu.Game.Overlays.Comments; using osu.Framework.Utils; +using osu.Framework.Allocation; +using osu.Game.Overlays; namespace osu.Game.Tests.Visual.Online { @@ -17,6 +19,9 @@ namespace osu.Game.Tests.Visual.Online typeof(TotalCommentsCounter), }; + [Cached] + private readonly OverlayColourProvider colourProvider = new OverlayColourProvider(OverlayColourScheme.Blue); + public TestSceneTotalCommentsCounter() { var count = new BindableInt(); diff --git a/osu.Game/Overlays/Comments/TotalCommentsCounter.cs b/osu.Game/Overlays/Comments/TotalCommentsCounter.cs index 376853c1de..57f4986bce 100644 --- a/osu.Game/Overlays/Comments/TotalCommentsCounter.cs +++ b/osu.Game/Overlays/Comments/TotalCommentsCounter.cs @@ -5,7 +5,6 @@ using osu.Framework.Graphics.Containers; using osu.Framework.Graphics; using osu.Framework.Graphics.Shapes; using osu.Game.Graphics; -using osu.Framework.Graphics.Sprites; using osuTK; using osu.Framework.Allocation; using osu.Framework.Bindables; @@ -17,7 +16,9 @@ namespace osu.Game.Overlays.Comments { public readonly BindableInt Current = new BindableInt(); - private readonly SpriteText counter; + private readonly OsuSpriteText counter; + private readonly OsuSpriteText text; + private readonly Box pillBackground; public TotalCommentsCounter() { @@ -33,7 +34,7 @@ namespace osu.Game.Overlays.Comments Spacing = new Vector2(5, 0), Children = new Drawable[] { - new OsuSpriteText + text = new OsuSpriteText { Anchor = Anchor.CentreLeft, Origin = Anchor.CentreLeft, @@ -48,10 +49,9 @@ namespace osu.Game.Overlays.Comments Masking = true, Children = new Drawable[] { - new Box + pillBackground = new Box { RelativeSizeAxes = Axes.Both, - Colour = OsuColour.Gray(0.05f) }, counter = new OsuSpriteText { @@ -67,9 +67,11 @@ namespace osu.Game.Overlays.Comments } [BackgroundDependencyLoader] - private void load(OsuColour colours) + private void load(OverlayColourProvider colourProvider) { - counter.Colour = colours.BlueLighter; + text.Colour = colourProvider.Light1; + pillBackground.Colour = colourProvider.Background6; + counter.Colour = colourProvider.Foreground1; } protected override void LoadComplete() From 12ca28ea6d3f4a21f10ea44794acbd9899adc612 Mon Sep 17 00:00:00 2001 From: Andrei Zavatski Date: Mon, 27 Jan 2020 14:58:27 +0300 Subject: [PATCH 2/6] Recolour CommentsHeader --- osu.Game.Tests/Visual/Online/TestSceneCommentsHeader.cs | 5 +++++ osu.Game/Overlays/Comments/CommentsHeader.cs | 4 ++-- osu.Game/Overlays/Comments/HeaderButton.cs | 5 ++--- osu.Game/Overlays/Comments/SortTabControl.cs | 4 ++-- 4 files changed, 11 insertions(+), 7 deletions(-) diff --git a/osu.Game.Tests/Visual/Online/TestSceneCommentsHeader.cs b/osu.Game.Tests/Visual/Online/TestSceneCommentsHeader.cs index bc3e0eff1a..a60f220e4b 100644 --- a/osu.Game.Tests/Visual/Online/TestSceneCommentsHeader.cs +++ b/osu.Game.Tests/Visual/Online/TestSceneCommentsHeader.cs @@ -4,7 +4,9 @@ using System; using System.Collections.Generic; using NUnit.Framework; +using osu.Framework.Allocation; using osu.Framework.Bindables; +using osu.Game.Overlays; using osu.Game.Overlays.Comments; namespace osu.Game.Tests.Visual.Online @@ -19,6 +21,9 @@ namespace osu.Game.Tests.Visual.Online typeof(SortTabControl), }; + [Cached] + private readonly OverlayColourProvider colourProvider = new OverlayColourProvider(OverlayColourScheme.Blue); + private readonly Bindable sort = new Bindable(); private readonly BindableBool showDeleted = new BindableBool(); diff --git a/osu.Game/Overlays/Comments/CommentsHeader.cs b/osu.Game/Overlays/Comments/CommentsHeader.cs index 6a7a678cc7..ad80e67330 100644 --- a/osu.Game/Overlays/Comments/CommentsHeader.cs +++ b/osu.Game/Overlays/Comments/CommentsHeader.cs @@ -76,9 +76,9 @@ namespace osu.Game.Overlays.Comments } [BackgroundDependencyLoader] - private void load(OsuColour colours) + private void load(OverlayColourProvider colourProvider) { - background.Colour = colours.Gray3; + background.Colour = colourProvider.Background4; } private class ShowDeletedButton : HeaderButton diff --git a/osu.Game/Overlays/Comments/HeaderButton.cs b/osu.Game/Overlays/Comments/HeaderButton.cs index 8789cf5830..fdc8db35ab 100644 --- a/osu.Game/Overlays/Comments/HeaderButton.cs +++ b/osu.Game/Overlays/Comments/HeaderButton.cs @@ -5,7 +5,6 @@ using osu.Framework.Allocation; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics; using osu.Framework.Graphics.Shapes; -using osu.Game.Graphics; using osu.Framework.Input.Events; using osu.Game.Graphics.UserInterface; @@ -45,9 +44,9 @@ namespace osu.Game.Overlays.Comments } [BackgroundDependencyLoader] - private void load(OsuColour colours) + private void load(OverlayColourProvider colourProvider) { - background.Colour = colours.Gray4; + background.Colour = colourProvider.Background3; } protected override bool OnHover(HoverEvent e) diff --git a/osu.Game/Overlays/Comments/SortTabControl.cs b/osu.Game/Overlays/Comments/SortTabControl.cs index a114197b8d..700d63351f 100644 --- a/osu.Game/Overlays/Comments/SortTabControl.cs +++ b/osu.Game/Overlays/Comments/SortTabControl.cs @@ -56,7 +56,7 @@ namespace osu.Game.Overlays.Comments public readonly BindableBool Active = new BindableBool(); [Resolved] - private OsuColour colours { get; set; } + private OverlayColourProvider colourProvider { get; set; } private readonly SpriteText text; @@ -78,7 +78,7 @@ namespace osu.Game.Overlays.Comments updateBackgroundState(); text.Font = text.Font.With(weight: active.NewValue ? FontWeight.Bold : FontWeight.Medium); - text.Colour = active.NewValue ? colours.BlueLighter : Color4.White; + text.Colour = active.NewValue ? colourProvider.Light1 : Color4.White; }, true); } From 68503bf7711a8f5163cf36b084e4a876454f1d0f Mon Sep 17 00:00:00 2001 From: Andrei Zavatski Date: Mon, 27 Jan 2020 15:00:56 +0300 Subject: [PATCH 3/6] Recolour CommentsShowMoreButton --- osu.Game/Overlays/Comments/CommentsShowMoreButton.cs | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/osu.Game/Overlays/Comments/CommentsShowMoreButton.cs b/osu.Game/Overlays/Comments/CommentsShowMoreButton.cs index b0174e7b1a..ab65c9c63a 100644 --- a/osu.Game/Overlays/Comments/CommentsShowMoreButton.cs +++ b/osu.Game/Overlays/Comments/CommentsShowMoreButton.cs @@ -1,8 +1,8 @@ // 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.Bindables; -using osu.Game.Graphics; using osu.Game.Graphics.UserInterface; namespace osu.Game.Overlays.Comments @@ -11,11 +11,12 @@ namespace osu.Game.Overlays.Comments { public readonly BindableInt Current = new BindableInt(); - public CommentsShowMoreButton() + [BackgroundDependencyLoader] + private void load(OverlayColourProvider colourProvider) { - IdleColour = OsuColour.Gray(0.3f); - HoverColour = OsuColour.Gray(0.4f); - ChevronIconColour = OsuColour.Gray(0.5f); + IdleColour = colourProvider.Background2; + HoverColour = colourProvider.Background1; + ChevronIconColour = colourProvider.Foreground1; } protected override void LoadComplete() From 100532845b2d5ba27828ffc9b4f5c6a2836584f8 Mon Sep 17 00:00:00 2001 From: Andrei Zavatski Date: Mon, 27 Jan 2020 15:07:24 +0300 Subject: [PATCH 4/6] Recolour CommentsContainer --- .../Visual/Online/TestSceneCommentsContainer.cs | 5 +++++ osu.Game/Overlays/Comments/CommentsContainer.cs | 13 +++++-------- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/osu.Game.Tests/Visual/Online/TestSceneCommentsContainer.cs b/osu.Game.Tests/Visual/Online/TestSceneCommentsContainer.cs index 8134c10750..3d63e2b07e 100644 --- a/osu.Game.Tests/Visual/Online/TestSceneCommentsContainer.cs +++ b/osu.Game.Tests/Visual/Online/TestSceneCommentsContainer.cs @@ -8,6 +8,8 @@ using osu.Game.Online.API.Requests; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics; using osu.Game.Overlays.Comments; +using osu.Game.Overlays; +using osu.Framework.Allocation; namespace osu.Game.Tests.Visual.Online { @@ -28,6 +30,9 @@ namespace osu.Game.Tests.Visual.Online protected override bool UseOnlineAPI => true; + [Cached] + private readonly OverlayColourProvider colourProvider = new OverlayColourProvider(OverlayColourScheme.Purple); + public TestSceneCommentsContainer() { BasicScrollContainer scroll; diff --git a/osu.Game/Overlays/Comments/CommentsContainer.cs b/osu.Game/Overlays/Comments/CommentsContainer.cs index d252083411..36b165c97d 100644 --- a/osu.Game/Overlays/Comments/CommentsContainer.cs +++ b/osu.Game/Overlays/Comments/CommentsContainer.cs @@ -8,7 +8,6 @@ using osu.Game.Online.API.Requests; using osu.Framework.Graphics; using osu.Framework.Bindables; using osu.Framework.Graphics.Shapes; -using osu.Game.Graphics; using osu.Game.Online.API.Requests.Responses; using System.Threading; using System.Linq; @@ -27,14 +26,12 @@ namespace osu.Game.Overlays.Comments [Resolved] private IAPIProvider api { get; set; } - [Resolved] - private OsuColour colours { get; set; } - private GetCommentsRequest request; private CancellationTokenSource loadCancellation; private int currentPage; private readonly Box background; + private readonly Box footerBackground; private readonly FillFlowContainer content; private readonly DeletedChildrenPlaceholder deletedChildrenPlaceholder; private readonly CommentsShowMoreButton moreButton; @@ -75,10 +72,9 @@ namespace osu.Game.Overlays.Comments AutoSizeAxes = Axes.Y, Children = new Drawable[] { - new Box + footerBackground = new Box { RelativeSizeAxes = Axes.Both, - Colour = OsuColour.Gray(0.2f) }, new FillFlowContainer { @@ -114,9 +110,10 @@ namespace osu.Game.Overlays.Comments } [BackgroundDependencyLoader] - private void load() + private void load(OverlayColourProvider colourProvider) { - background.Colour = colours.Gray2; + background.Colour = colourProvider.Background5; + footerBackground.Colour = colourProvider.Background4; } protected override void LoadComplete() From ce95b4a10623ad8533df7de211369fd4a9ef1a6c Mon Sep 17 00:00:00 2001 From: Andrei Zavatski Date: Tue, 28 Jan 2020 05:57:45 +0300 Subject: [PATCH 5/6] TotalCommentsCounter improvements --- .../Overlays/Comments/TotalCommentsCounter.cs | 24 +++++++------------ 1 file changed, 9 insertions(+), 15 deletions(-) diff --git a/osu.Game/Overlays/Comments/TotalCommentsCounter.cs b/osu.Game/Overlays/Comments/TotalCommentsCounter.cs index 57f4986bce..1bb9b52689 100644 --- a/osu.Game/Overlays/Comments/TotalCommentsCounter.cs +++ b/osu.Game/Overlays/Comments/TotalCommentsCounter.cs @@ -16,11 +16,10 @@ namespace osu.Game.Overlays.Comments { public readonly BindableInt Current = new BindableInt(); - private readonly OsuSpriteText counter; - private readonly OsuSpriteText text; - private readonly Box pillBackground; + private OsuSpriteText counter; - public TotalCommentsCounter() + [BackgroundDependencyLoader] + private void load(OverlayColourProvider colourProvider) { RelativeSizeAxes = Axes.X; Height = 50; @@ -34,11 +33,12 @@ namespace osu.Game.Overlays.Comments Spacing = new Vector2(5, 0), Children = new Drawable[] { - text = new OsuSpriteText + new OsuSpriteText { Anchor = Anchor.CentreLeft, Origin = Anchor.CentreLeft, Font = OsuFont.GetFont(size: 20, italics: true), + Colour = colourProvider.Light1, Text = @"Comments" }, new CircularContainer @@ -49,16 +49,18 @@ namespace osu.Game.Overlays.Comments Masking = true, Children = new Drawable[] { - pillBackground = new Box + new Box { RelativeSizeAxes = Axes.Both, + Colour = colourProvider.Background6 }, counter = new OsuSpriteText { Anchor = Anchor.Centre, Origin = Anchor.Centre, Margin = new MarginPadding { Horizontal = 10, Vertical = 5 }, - Font = OsuFont.GetFont(size: 14, weight: FontWeight.Bold) + Font = OsuFont.GetFont(size: 14, weight: FontWeight.Bold), + Colour = colourProvider.Foreground1 } }, } @@ -66,14 +68,6 @@ namespace osu.Game.Overlays.Comments }); } - [BackgroundDependencyLoader] - private void load(OverlayColourProvider colourProvider) - { - text.Colour = colourProvider.Light1; - pillBackground.Colour = colourProvider.Background6; - counter.Colour = colourProvider.Foreground1; - } - protected override void LoadComplete() { Current.BindValueChanged(value => counter.Text = value.NewValue.ToString("N0"), true); From 5a2fd18bdd46ea994d7605cf757daa4434b36fb1 Mon Sep 17 00:00:00 2001 From: Andrei Zavatski Date: Tue, 28 Jan 2020 10:21:27 +0300 Subject: [PATCH 6/6] Allow better async support for CommentsContainer --- .../Overlays/Comments/CommentsContainer.cs | 26 +++++++------------ 1 file changed, 10 insertions(+), 16 deletions(-) diff --git a/osu.Game/Overlays/Comments/CommentsContainer.cs b/osu.Game/Overlays/Comments/CommentsContainer.cs index 36b165c97d..78df73eb0d 100644 --- a/osu.Game/Overlays/Comments/CommentsContainer.cs +++ b/osu.Game/Overlays/Comments/CommentsContainer.cs @@ -30,22 +30,22 @@ namespace osu.Game.Overlays.Comments private CancellationTokenSource loadCancellation; private int currentPage; - private readonly Box background; - private readonly Box footerBackground; - private readonly FillFlowContainer content; - private readonly DeletedChildrenPlaceholder deletedChildrenPlaceholder; - private readonly CommentsShowMoreButton moreButton; - private readonly TotalCommentsCounter commentCounter; + private FillFlowContainer content; + private DeletedChildrenPlaceholder deletedChildrenPlaceholder; + private CommentsShowMoreButton moreButton; + private TotalCommentsCounter commentCounter; - public CommentsContainer() + [BackgroundDependencyLoader] + private void load(OverlayColourProvider colourProvider) { RelativeSizeAxes = Axes.X; AutoSizeAxes = Axes.Y; AddRangeInternal(new Drawable[] { - background = new Box + new Box { RelativeSizeAxes = Axes.Both, + Colour = colourProvider.Background5 }, new FillFlowContainer { @@ -72,9 +72,10 @@ namespace osu.Game.Overlays.Comments AutoSizeAxes = Axes.Y, Children = new Drawable[] { - footerBackground = new Box + new Box { RelativeSizeAxes = Axes.Both, + Colour = colourProvider.Background4 }, new FillFlowContainer { @@ -109,13 +110,6 @@ namespace osu.Game.Overlays.Comments }); } - [BackgroundDependencyLoader] - private void load(OverlayColourProvider colourProvider) - { - background.Colour = colourProvider.Background5; - footerBackground.Colour = colourProvider.Background4; - } - protected override void LoadComplete() { Sort.BindValueChanged(_ => refetchComments(), true);