From 3a24cc1aa976e746e57509a5b0ddb4f71eed4340 Mon Sep 17 00:00:00 2001 From: Andrei Zavatski Date: Mon, 7 Sep 2020 22:13:29 +0300 Subject: [PATCH 01/16] Implement PaginatedContainerHeader component --- .../TestScenePaginatedContainerHeader.cs | 77 +++++++++++ .../Overlays/Profile/Sections/CounterPill.cs | 14 +- .../Sections/PaginatedContainerHeader.cs | 129 ++++++++++++++++++ 3 files changed, 208 insertions(+), 12 deletions(-) create mode 100644 osu.Game.Tests/Visual/UserInterface/TestScenePaginatedContainerHeader.cs create mode 100644 osu.Game/Overlays/Profile/Sections/PaginatedContainerHeader.cs diff --git a/osu.Game.Tests/Visual/UserInterface/TestScenePaginatedContainerHeader.cs b/osu.Game.Tests/Visual/UserInterface/TestScenePaginatedContainerHeader.cs new file mode 100644 index 0000000000..114a3af1d9 --- /dev/null +++ b/osu.Game.Tests/Visual/UserInterface/TestScenePaginatedContainerHeader.cs @@ -0,0 +1,77 @@ +using NUnit.Framework; +using osu.Game.Overlays.Profile.Sections; +using osu.Framework.Testing; +using System.Linq; +using osu.Framework.Graphics; +using osu.Game.Overlays; +using osu.Framework.Allocation; + +namespace osu.Game.Tests.Visual.UserInterface +{ + public class TestScenePaginatedContainerHeader : OsuTestScene + { + [Cached] + private readonly OverlayColourProvider colourProvider = new OverlayColourProvider(OverlayColourScheme.Pink); + + private PaginatedContainerHeader header; + + [Test] + public void TestHiddenCounter() + { + AddStep("Create header", () => createHeader("Header with hidden counter", CounterVisibilityState.AlwaysHidden)); + AddAssert("Value is 0", () => header.Current.Value == 0); + AddAssert("Counter is hidden", () => header.ChildrenOfType().First().Alpha == 0); + AddStep("Set count 10", () => header.Current.Value = 10); + AddAssert("Value is 10", () => header.Current.Value == 10); + AddAssert("Counter is hidden", () => header.ChildrenOfType().First().Alpha == 0); + } + + [Test] + public void TestVisibleCounter() + { + AddStep("Create header", () => createHeader("Header with visible counter", CounterVisibilityState.AlwaysVisible)); + AddAssert("Value is 0", () => header.Current.Value == 0); + AddAssert("Counter is visible", () => header.ChildrenOfType().First().Alpha == 1); + AddStep("Set count 10", () => header.Current.Value = 10); + AddAssert("Value is 10", () => header.Current.Value == 10); + AddAssert("Counter is visible", () => header.ChildrenOfType().First().Alpha == 1); + } + + [Test] + public void TestVisibleWhenZeroCounter() + { + AddStep("Create header", () => createHeader("Header with visible when zero counter", CounterVisibilityState.VisibleWhenNonZero)); + AddAssert("Value is 0", () => header.Current.Value == 0); + AddAssert("Counter is visible", () => header.ChildrenOfType().First().Alpha == 1); + AddStep("Set count 10", () => header.Current.Value = 10); + AddAssert("Value is 10", () => header.Current.Value == 10); + AddAssert("Counter is hidden", () => header.ChildrenOfType().First().Alpha == 0); + AddStep("Set count 0", () => header.Current.Value = 0); + AddAssert("Value is 0", () => header.Current.Value == 0); + AddAssert("Counter is visible", () => header.ChildrenOfType().First().Alpha == 1); + } + + [Test] + public void TestInitialVisibility() + { + AddStep("Create header with 0 value", () => createHeader("Header with visible when zero counter", CounterVisibilityState.VisibleWhenNonZero, 0)); + AddAssert("Value is 0", () => header.Current.Value == 0); + AddAssert("Counter is visible", () => header.ChildrenOfType().First().Alpha == 1); + + AddStep("Create header with 1 value", () => createHeader("Header with visible when zero counter", CounterVisibilityState.VisibleWhenNonZero, 1)); + AddAssert("Value is 1", () => header.Current.Value == 1); + AddAssert("Counter is hidden", () => header.ChildrenOfType().First().Alpha == 0); + } + + private void createHeader(string text, CounterVisibilityState state, int initialValue = 0) + { + Clear(); + Add(header = new PaginatedContainerHeader(text, state) + { + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + Current = { Value = initialValue } + }); + } + } +} diff --git a/osu.Game/Overlays/Profile/Sections/CounterPill.cs b/osu.Game/Overlays/Profile/Sections/CounterPill.cs index 52adefa4ad..131df105ad 100644 --- a/osu.Game/Overlays/Profile/Sections/CounterPill.cs +++ b/osu.Game/Overlays/Profile/Sections/CounterPill.cs @@ -13,8 +13,6 @@ namespace osu.Game.Overlays.Profile.Sections { public class CounterPill : CircularContainer { - private const int duration = 200; - public readonly BindableInt Current = new BindableInt(); private OsuSpriteText counter; @@ -23,7 +21,6 @@ namespace osu.Game.Overlays.Profile.Sections private void load(OverlayColourProvider colourProvider) { AutoSizeAxes = Axes.Both; - Alpha = 0; Masking = true; Children = new Drawable[] { @@ -36,8 +33,8 @@ namespace osu.Game.Overlays.Profile.Sections { Anchor = Anchor.Centre, Origin = Anchor.Centre, - Margin = new MarginPadding { Horizontal = 10, Vertical = 5 }, - Font = OsuFont.GetFont(weight: FontWeight.Bold), + Margin = new MarginPadding { Horizontal = 10, Bottom = 1 }, + Font = OsuFont.GetFont(size: 14 * 0.8f, weight: FontWeight.Bold), Colour = colourProvider.Foreground1 } }; @@ -51,14 +48,7 @@ namespace osu.Game.Overlays.Profile.Sections private void onCurrentChanged(ValueChangedEvent value) { - if (value.NewValue == 0) - { - this.FadeOut(duration, Easing.OutQuint); - return; - } - counter.Text = value.NewValue.ToString("N0"); - this.FadeIn(duration, Easing.OutQuint); } } } diff --git a/osu.Game/Overlays/Profile/Sections/PaginatedContainerHeader.cs b/osu.Game/Overlays/Profile/Sections/PaginatedContainerHeader.cs new file mode 100644 index 0000000000..e965b83682 --- /dev/null +++ b/osu.Game/Overlays/Profile/Sections/PaginatedContainerHeader.cs @@ -0,0 +1,129 @@ +using osu.Framework.Allocation; +using osu.Framework.Graphics.Containers; +using osu.Framework.Graphics; +using osu.Framework.Graphics.UserInterface; +using osu.Framework.Bindables; +using System; +using osu.Framework.Graphics.Shapes; +using osuTK; +using osu.Game.Graphics.Sprites; +using osu.Game.Graphics; + +namespace osu.Game.Overlays.Profile.Sections +{ + public class PaginatedContainerHeader : CompositeDrawable, IHasCurrentValue + { + public Bindable Current + { + get => current; + set + { + if (value == null) + throw new ArgumentNullException(nameof(value)); + + current.UnbindBindings(); + current.BindTo(value); + } + } + + private readonly Bindable current = new Bindable(); + + private readonly string text; + private readonly CounterVisibilityState counterState; + + private CounterPill counterPill; + + public PaginatedContainerHeader(string text, CounterVisibilityState counterState) + { + this.text = text; + this.counterState = counterState; + } + + [BackgroundDependencyLoader] + private void load(OverlayColourProvider colourProvider) + { + AutoSizeAxes = Axes.Both; + Padding = new MarginPadding { Vertical = 10 }; + InternalChildren = new Drawable[] + { + new CircularContainer + { + RelativeSizeAxes = Axes.Y, + Height = 0.65f, + Width = 3, + Masking = true, + Anchor = Anchor.CentreLeft, + Origin = Anchor.CentreRight, + Margin = new MarginPadding { Right = 10 }, + Child = new Box + { + RelativeSizeAxes = Axes.Both, + Colour = colourProvider.Highlight1 + } + }, + new FillFlowContainer + { + AutoSizeAxes = Axes.Both, + Direction = FillDirection.Horizontal, + Spacing = new Vector2(10, 0), + Children = new Drawable[] + { + new OsuSpriteText + { + Anchor = Anchor.CentreLeft, + Origin = Anchor.CentreLeft, + Text = text, + Font = OsuFont.GetFont(size: 14, weight: FontWeight.Bold), + }, + counterPill = new CounterPill + { + Anchor = Anchor.CentreLeft, + Origin = Anchor.CentreLeft, + Alpha = getInitialCounterAlpha(), + Current = { BindTarget = current } + } + } + } + }; + } + + protected override void LoadComplete() + { + base.LoadComplete(); + current.BindValueChanged(onCurrentChanged); + } + + private float getInitialCounterAlpha() + { + switch (counterState) + { + case CounterVisibilityState.AlwaysHidden: + return 0; + + case CounterVisibilityState.AlwaysVisible: + return 1; + + case CounterVisibilityState.VisibleWhenNonZero: + return current.Value == 0 ? 1 : 0; + + default: + throw new NotImplementedException($"{counterState} has an incorrect value."); + } + } + + private void onCurrentChanged(ValueChangedEvent countValue) + { + if (counterState == CounterVisibilityState.VisibleWhenNonZero) + { + counterPill.Alpha = countValue.NewValue == 0 ? 1 : 0; + } + } + } + + public enum CounterVisibilityState + { + AlwaysHidden, + AlwaysVisible, + VisibleWhenNonZero + } +} From 33f14fe7b7b7f4c10b629b582dfd6e9c6219e8f7 Mon Sep 17 00:00:00 2001 From: Andrei Zavatski Date: Mon, 7 Sep 2020 22:19:19 +0300 Subject: [PATCH 02/16] Remove no longer needed test --- .../Online/TestSceneProfileCounterPill.cs | 40 ------------------- 1 file changed, 40 deletions(-) delete mode 100644 osu.Game.Tests/Visual/Online/TestSceneProfileCounterPill.cs diff --git a/osu.Game.Tests/Visual/Online/TestSceneProfileCounterPill.cs b/osu.Game.Tests/Visual/Online/TestSceneProfileCounterPill.cs deleted file mode 100644 index eaa989f0de..0000000000 --- a/osu.Game.Tests/Visual/Online/TestSceneProfileCounterPill.cs +++ /dev/null @@ -1,40 +0,0 @@ -// 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 osu.Framework.Allocation; -using osu.Framework.Bindables; -using osu.Framework.Graphics; -using osu.Game.Overlays; -using osu.Game.Overlays.Profile.Sections; - -namespace osu.Game.Tests.Visual.Online -{ - public class TestSceneProfileCounterPill : OsuTestScene - { - [Cached] - private readonly OverlayColourProvider colourProvider = new OverlayColourProvider(OverlayColourScheme.Red); - - private readonly CounterPill pill; - private readonly BindableInt value = new BindableInt(); - - public TestSceneProfileCounterPill() - { - Child = pill = new CounterPill - { - Anchor = Anchor.Centre, - Origin = Anchor.Centre, - Current = { BindTarget = value } - }; - } - - [Test] - public void TestVisibility() - { - AddStep("Set value to 0", () => value.Value = 0); - AddAssert("Check hidden", () => !pill.IsPresent); - AddStep("Set value to 10", () => value.Value = 10); - AddAssert("Check visible", () => pill.IsPresent); - } - } -} From 1c55039994e80d827d5739610d2e6b4710c9b04f Mon Sep 17 00:00:00 2001 From: Andrei Zavatski Date: Mon, 7 Sep 2020 22:24:10 +0300 Subject: [PATCH 03/16] Remove old header from PaginatedContainer --- .../Beatmaps/PaginatedBeatmapContainer.cs | 14 ++------- .../Profile/Sections/BeatmapsSection.cs | 10 +++---- .../PaginatedMostPlayedBeatmapContainer.cs | 3 +- .../Profile/Sections/HistoricalSection.cs | 2 +- .../Kudosu/PaginatedKudosuHistoryContainer.cs | 4 +-- .../Profile/Sections/KudosuSection.cs | 2 +- .../Profile/Sections/PaginatedContainer.cs | 29 +------------------ .../Sections/Ranks/PaginatedScoreContainer.cs | 11 ++----- .../Overlays/Profile/Sections/RanksSection.cs | 4 +-- .../PaginatedRecentActivityContainer.cs | 4 +-- .../Profile/Sections/RecentSection.cs | 2 +- 11 files changed, 20 insertions(+), 65 deletions(-) diff --git a/osu.Game/Overlays/Profile/Sections/Beatmaps/PaginatedBeatmapContainer.cs b/osu.Game/Overlays/Profile/Sections/Beatmaps/PaginatedBeatmapContainer.cs index 191f3c908a..1936cb6188 100644 --- a/osu.Game/Overlays/Profile/Sections/Beatmaps/PaginatedBeatmapContainer.cs +++ b/osu.Game/Overlays/Profile/Sections/Beatmaps/PaginatedBeatmapContainer.cs @@ -18,8 +18,8 @@ namespace osu.Game.Overlays.Profile.Sections.Beatmaps private const float panel_padding = 10f; private readonly BeatmapSetType type; - public PaginatedBeatmapContainer(BeatmapSetType type, Bindable user, string header, string missing = "None... yet.") - : base(user, header, missing) + public PaginatedBeatmapContainer(BeatmapSetType type, Bindable user) + : base(user, "None... yet.") { this.type = type; @@ -38,15 +38,5 @@ namespace osu.Game.Overlays.Profile.Sections.Beatmaps Anchor = Anchor.TopCentre, Origin = Anchor.TopCentre, }; - - protected override int GetCount(User user) => type switch - { - BeatmapSetType.Favourite => user.FavouriteBeatmapsetCount, - BeatmapSetType.Graveyard => user.GraveyardBeatmapsetCount, - BeatmapSetType.Loved => user.LovedBeatmapsetCount, - BeatmapSetType.RankedAndApproved => user.RankedAndApprovedBeatmapsetCount, - BeatmapSetType.Unranked => user.UnrankedBeatmapsetCount, - _ => 0 - }; } } diff --git a/osu.Game/Overlays/Profile/Sections/BeatmapsSection.cs b/osu.Game/Overlays/Profile/Sections/BeatmapsSection.cs index 37f017277f..156696da16 100644 --- a/osu.Game/Overlays/Profile/Sections/BeatmapsSection.cs +++ b/osu.Game/Overlays/Profile/Sections/BeatmapsSection.cs @@ -16,11 +16,11 @@ namespace osu.Game.Overlays.Profile.Sections { Children = new[] { - new PaginatedBeatmapContainer(BeatmapSetType.Favourite, User, "Favourite Beatmaps"), - new PaginatedBeatmapContainer(BeatmapSetType.RankedAndApproved, User, "Ranked & Approved Beatmaps"), - new PaginatedBeatmapContainer(BeatmapSetType.Loved, User, "Loved Beatmaps"), - new PaginatedBeatmapContainer(BeatmapSetType.Unranked, User, "Pending Beatmaps"), - new PaginatedBeatmapContainer(BeatmapSetType.Graveyard, User, "Graveyarded Beatmaps"), + new PaginatedBeatmapContainer(BeatmapSetType.Favourite, User), + new PaginatedBeatmapContainer(BeatmapSetType.RankedAndApproved, User), + new PaginatedBeatmapContainer(BeatmapSetType.Loved, User), + new PaginatedBeatmapContainer(BeatmapSetType.Unranked, User), + new PaginatedBeatmapContainer(BeatmapSetType.Graveyard, User) }; } } diff --git a/osu.Game/Overlays/Profile/Sections/Historical/PaginatedMostPlayedBeatmapContainer.cs b/osu.Game/Overlays/Profile/Sections/Historical/PaginatedMostPlayedBeatmapContainer.cs index 6e6d6272c7..f16842f4ab 100644 --- a/osu.Game/Overlays/Profile/Sections/Historical/PaginatedMostPlayedBeatmapContainer.cs +++ b/osu.Game/Overlays/Profile/Sections/Historical/PaginatedMostPlayedBeatmapContainer.cs @@ -15,10 +15,9 @@ namespace osu.Game.Overlays.Profile.Sections.Historical public class PaginatedMostPlayedBeatmapContainer : PaginatedContainer { public PaginatedMostPlayedBeatmapContainer(Bindable user) - : base(user, "Most Played Beatmaps", "No records. :(") + : base(user, "No records. :(") { ItemsPerPage = 5; - ItemsContainer.Direction = FillDirection.Vertical; } diff --git a/osu.Game/Overlays/Profile/Sections/HistoricalSection.cs b/osu.Game/Overlays/Profile/Sections/HistoricalSection.cs index 4bdd25ee66..3d1a1efe6e 100644 --- a/osu.Game/Overlays/Profile/Sections/HistoricalSection.cs +++ b/osu.Game/Overlays/Profile/Sections/HistoricalSection.cs @@ -19,7 +19,7 @@ namespace osu.Game.Overlays.Profile.Sections Children = new Drawable[] { new PaginatedMostPlayedBeatmapContainer(User), - new PaginatedScoreContainer(ScoreType.Recent, User, "Recent Plays (24h)", "No performance records. :("), + new PaginatedScoreContainer(ScoreType.Recent, User, "No performance records. :("), }; } } diff --git a/osu.Game/Overlays/Profile/Sections/Kudosu/PaginatedKudosuHistoryContainer.cs b/osu.Game/Overlays/Profile/Sections/Kudosu/PaginatedKudosuHistoryContainer.cs index 0e7cfc37c0..923316d8c5 100644 --- a/osu.Game/Overlays/Profile/Sections/Kudosu/PaginatedKudosuHistoryContainer.cs +++ b/osu.Game/Overlays/Profile/Sections/Kudosu/PaginatedKudosuHistoryContainer.cs @@ -13,8 +13,8 @@ namespace osu.Game.Overlays.Profile.Sections.Kudosu { public class PaginatedKudosuHistoryContainer : PaginatedContainer { - public PaginatedKudosuHistoryContainer(Bindable user, string header, string missing) - : base(user, header, missing) + public PaginatedKudosuHistoryContainer(Bindable user, string missing) + : base(user, missing) { ItemsPerPage = 5; } diff --git a/osu.Game/Overlays/Profile/Sections/KudosuSection.cs b/osu.Game/Overlays/Profile/Sections/KudosuSection.cs index 9ccce7d837..7e75e7e3e4 100644 --- a/osu.Game/Overlays/Profile/Sections/KudosuSection.cs +++ b/osu.Game/Overlays/Profile/Sections/KudosuSection.cs @@ -17,7 +17,7 @@ namespace osu.Game.Overlays.Profile.Sections Children = new Drawable[] { new KudosuInfo(User), - new PaginatedKudosuHistoryContainer(User, null, @"This user hasn't received any kudosu!"), + new PaginatedKudosuHistoryContainer(User, "This user hasn't received any kudosu!"), }; } } diff --git a/osu.Game/Overlays/Profile/Sections/PaginatedContainer.cs b/osu.Game/Overlays/Profile/Sections/PaginatedContainer.cs index 9720469548..87472e77ea 100644 --- a/osu.Game/Overlays/Profile/Sections/PaginatedContainer.cs +++ b/osu.Game/Overlays/Profile/Sections/PaginatedContainer.cs @@ -24,7 +24,6 @@ namespace osu.Game.Overlays.Profile.Sections private readonly OsuSpriteText missingText; private APIRequest> retrievalRequest; private CancellationTokenSource loadCancellation; - private readonly BindableInt count = new BindableInt(); [Resolved] private IAPIProvider api { get; set; } @@ -36,7 +35,7 @@ namespace osu.Game.Overlays.Profile.Sections protected readonly FillFlowContainer ItemsContainer; protected RulesetStore Rulesets; - protected PaginatedContainer(Bindable user, string header, string missing) + protected PaginatedContainer(Bindable user, string missing) { User.BindTo(user); @@ -46,29 +45,6 @@ namespace osu.Game.Overlays.Profile.Sections Children = new Drawable[] { - new FillFlowContainer - { - AutoSizeAxes = Axes.Both, - Direction = FillDirection.Horizontal, - Spacing = new Vector2(5, 0), - Margin = new MarginPadding { Top = 10, Bottom = 10 }, - Children = new Drawable[] - { - new OsuSpriteText - { - Anchor = Anchor.CentreLeft, - Origin = Anchor.CentreLeft, - Text = header, - Font = OsuFont.GetFont(size: 20, weight: FontWeight.Bold), - }, - new CounterPill - { - Anchor = Anchor.CentreLeft, - Origin = Anchor.CentreLeft, - Current = { BindTarget = count } - } - } - }, ItemsContainer = new FillFlowContainer { AutoSizeAxes = Axes.Y, @@ -112,7 +88,6 @@ namespace osu.Game.Overlays.Profile.Sections if (e.NewValue != null) { showMore(); - count.Value = GetCount(e.NewValue); } } @@ -146,8 +121,6 @@ namespace osu.Game.Overlays.Profile.Sections }, loadCancellation.Token); }); - protected virtual int GetCount(User user) => 0; - protected abstract APIRequest> CreateRequest(); protected abstract Drawable CreateDrawableItem(TModel model); diff --git a/osu.Game/Overlays/Profile/Sections/Ranks/PaginatedScoreContainer.cs b/osu.Game/Overlays/Profile/Sections/Ranks/PaginatedScoreContainer.cs index 64494f9814..2cefe45e4a 100644 --- a/osu.Game/Overlays/Profile/Sections/Ranks/PaginatedScoreContainer.cs +++ b/osu.Game/Overlays/Profile/Sections/Ranks/PaginatedScoreContainer.cs @@ -17,25 +17,18 @@ namespace osu.Game.Overlays.Profile.Sections.Ranks { private readonly ScoreType type; - public PaginatedScoreContainer(ScoreType type, Bindable user, string header, string missing) - : base(user, header, missing) + public PaginatedScoreContainer(ScoreType type, Bindable user, string missing) + : base(user, missing) { this.type = type; ItemsPerPage = 5; - ItemsContainer.Direction = FillDirection.Vertical; } protected override APIRequest> CreateRequest() => new GetUserScoresRequest(User.Value.Id, type, VisiblePages++, ItemsPerPage); - protected override int GetCount(User user) => type switch - { - ScoreType.Firsts => user.ScoresFirstCount, - _ => 0 - }; - protected override Drawable CreateDrawableItem(APILegacyScoreInfo model) { switch (type) diff --git a/osu.Game/Overlays/Profile/Sections/RanksSection.cs b/osu.Game/Overlays/Profile/Sections/RanksSection.cs index dbdff3a273..40bd050955 100644 --- a/osu.Game/Overlays/Profile/Sections/RanksSection.cs +++ b/osu.Game/Overlays/Profile/Sections/RanksSection.cs @@ -16,8 +16,8 @@ namespace osu.Game.Overlays.Profile.Sections { Children = new[] { - new PaginatedScoreContainer(ScoreType.Best, User, "Best Performance", "No performance records. :("), - new PaginatedScoreContainer(ScoreType.Firsts, User, "First Place Ranks", "No awesome performance records yet. :("), + new PaginatedScoreContainer(ScoreType.Best, User, "No performance records. :("), + new PaginatedScoreContainer(ScoreType.Firsts, User, "No awesome performance records yet. :("), }; } } diff --git a/osu.Game/Overlays/Profile/Sections/Recent/PaginatedRecentActivityContainer.cs b/osu.Game/Overlays/Profile/Sections/Recent/PaginatedRecentActivityContainer.cs index a37f398272..4c828ef0c1 100644 --- a/osu.Game/Overlays/Profile/Sections/Recent/PaginatedRecentActivityContainer.cs +++ b/osu.Game/Overlays/Profile/Sections/Recent/PaginatedRecentActivityContainer.cs @@ -14,8 +14,8 @@ namespace osu.Game.Overlays.Profile.Sections.Recent { public class PaginatedRecentActivityContainer : PaginatedContainer { - public PaginatedRecentActivityContainer(Bindable user, string header, string missing) - : base(user, header, missing) + public PaginatedRecentActivityContainer(Bindable user, string missing) + : base(user, missing) { ItemsPerPage = 10; ItemsContainer.Spacing = new Vector2(0, 8); diff --git a/osu.Game/Overlays/Profile/Sections/RecentSection.cs b/osu.Game/Overlays/Profile/Sections/RecentSection.cs index 8fcc5cc7c0..0c118b80b5 100644 --- a/osu.Game/Overlays/Profile/Sections/RecentSection.cs +++ b/osu.Game/Overlays/Profile/Sections/RecentSection.cs @@ -15,7 +15,7 @@ namespace osu.Game.Overlays.Profile.Sections { Children = new[] { - new PaginatedRecentActivityContainer(User, null, @"This user hasn't done anything notable recently!"), + new PaginatedRecentActivityContainer(User, "This user hasn't done anything notable recently!"), }; } } From b7bd084296a90a50672b7355b41842a405ad79d1 Mon Sep 17 00:00:00 2001 From: Andrei Zavatski Date: Mon, 7 Sep 2020 22:30:43 +0300 Subject: [PATCH 04/16] Remove missing text where not needed --- .../Profile/Sections/Beatmaps/PaginatedBeatmapContainer.cs | 2 +- osu.Game/Overlays/Profile/Sections/HistoricalSection.cs | 2 +- .../Sections/Kudosu/PaginatedKudosuHistoryContainer.cs | 4 ++-- osu.Game/Overlays/Profile/Sections/KudosuSection.cs | 2 +- osu.Game/Overlays/Profile/Sections/PaginatedContainer.cs | 7 +++++-- .../Profile/Sections/Ranks/PaginatedScoreContainer.cs | 4 ++-- osu.Game/Overlays/Profile/Sections/RanksSection.cs | 4 ++-- .../Sections/Recent/PaginatedRecentActivityContainer.cs | 4 ++-- osu.Game/Overlays/Profile/Sections/RecentSection.cs | 2 +- 9 files changed, 17 insertions(+), 14 deletions(-) diff --git a/osu.Game/Overlays/Profile/Sections/Beatmaps/PaginatedBeatmapContainer.cs b/osu.Game/Overlays/Profile/Sections/Beatmaps/PaginatedBeatmapContainer.cs index 1936cb6188..1f99b75909 100644 --- a/osu.Game/Overlays/Profile/Sections/Beatmaps/PaginatedBeatmapContainer.cs +++ b/osu.Game/Overlays/Profile/Sections/Beatmaps/PaginatedBeatmapContainer.cs @@ -19,7 +19,7 @@ namespace osu.Game.Overlays.Profile.Sections.Beatmaps private readonly BeatmapSetType type; public PaginatedBeatmapContainer(BeatmapSetType type, Bindable user) - : base(user, "None... yet.") + : base(user) { this.type = type; diff --git a/osu.Game/Overlays/Profile/Sections/HistoricalSection.cs b/osu.Game/Overlays/Profile/Sections/HistoricalSection.cs index 3d1a1efe6e..e021f16e5e 100644 --- a/osu.Game/Overlays/Profile/Sections/HistoricalSection.cs +++ b/osu.Game/Overlays/Profile/Sections/HistoricalSection.cs @@ -19,7 +19,7 @@ namespace osu.Game.Overlays.Profile.Sections Children = new Drawable[] { new PaginatedMostPlayedBeatmapContainer(User), - new PaginatedScoreContainer(ScoreType.Recent, User, "No performance records. :("), + new PaginatedScoreContainer(ScoreType.Recent, User), }; } } diff --git a/osu.Game/Overlays/Profile/Sections/Kudosu/PaginatedKudosuHistoryContainer.cs b/osu.Game/Overlays/Profile/Sections/Kudosu/PaginatedKudosuHistoryContainer.cs index 923316d8c5..c823053c4b 100644 --- a/osu.Game/Overlays/Profile/Sections/Kudosu/PaginatedKudosuHistoryContainer.cs +++ b/osu.Game/Overlays/Profile/Sections/Kudosu/PaginatedKudosuHistoryContainer.cs @@ -13,8 +13,8 @@ namespace osu.Game.Overlays.Profile.Sections.Kudosu { public class PaginatedKudosuHistoryContainer : PaginatedContainer { - public PaginatedKudosuHistoryContainer(Bindable user, string missing) - : base(user, missing) + public PaginatedKudosuHistoryContainer(Bindable user) + : base(user, "This user hasn't received any kudosu!") { ItemsPerPage = 5; } diff --git a/osu.Game/Overlays/Profile/Sections/KudosuSection.cs b/osu.Game/Overlays/Profile/Sections/KudosuSection.cs index 7e75e7e3e4..a9e9952257 100644 --- a/osu.Game/Overlays/Profile/Sections/KudosuSection.cs +++ b/osu.Game/Overlays/Profile/Sections/KudosuSection.cs @@ -17,7 +17,7 @@ namespace osu.Game.Overlays.Profile.Sections Children = new Drawable[] { new KudosuInfo(User), - new PaginatedKudosuHistoryContainer(User, "This user hasn't received any kudosu!"), + new PaginatedKudosuHistoryContainer(User), }; } } diff --git a/osu.Game/Overlays/Profile/Sections/PaginatedContainer.cs b/osu.Game/Overlays/Profile/Sections/PaginatedContainer.cs index 87472e77ea..9ddca48298 100644 --- a/osu.Game/Overlays/Profile/Sections/PaginatedContainer.cs +++ b/osu.Game/Overlays/Profile/Sections/PaginatedContainer.cs @@ -35,7 +35,7 @@ namespace osu.Game.Overlays.Profile.Sections protected readonly FillFlowContainer ItemsContainer; protected RulesetStore Rulesets; - protected PaginatedContainer(Bindable user, string missing) + protected PaginatedContainer(Bindable user, string missing = "") { User.BindTo(user); @@ -107,7 +107,10 @@ namespace osu.Game.Overlays.Profile.Sections { moreButton.Hide(); moreButton.IsLoading = false; - missingText.Show(); + + if (!string.IsNullOrEmpty(missingText.Text)) + missingText.Show(); + return; } diff --git a/osu.Game/Overlays/Profile/Sections/Ranks/PaginatedScoreContainer.cs b/osu.Game/Overlays/Profile/Sections/Ranks/PaginatedScoreContainer.cs index 2cefe45e4a..fbf92fd2e6 100644 --- a/osu.Game/Overlays/Profile/Sections/Ranks/PaginatedScoreContainer.cs +++ b/osu.Game/Overlays/Profile/Sections/Ranks/PaginatedScoreContainer.cs @@ -17,8 +17,8 @@ namespace osu.Game.Overlays.Profile.Sections.Ranks { private readonly ScoreType type; - public PaginatedScoreContainer(ScoreType type, Bindable user, string missing) - : base(user, missing) + public PaginatedScoreContainer(ScoreType type, Bindable user) + : base(user) { this.type = type; diff --git a/osu.Game/Overlays/Profile/Sections/RanksSection.cs b/osu.Game/Overlays/Profile/Sections/RanksSection.cs index 40bd050955..18bf4f31d8 100644 --- a/osu.Game/Overlays/Profile/Sections/RanksSection.cs +++ b/osu.Game/Overlays/Profile/Sections/RanksSection.cs @@ -16,8 +16,8 @@ namespace osu.Game.Overlays.Profile.Sections { Children = new[] { - new PaginatedScoreContainer(ScoreType.Best, User, "No performance records. :("), - new PaginatedScoreContainer(ScoreType.Firsts, User, "No awesome performance records yet. :("), + new PaginatedScoreContainer(ScoreType.Best, User), + new PaginatedScoreContainer(ScoreType.Firsts, User), }; } } diff --git a/osu.Game/Overlays/Profile/Sections/Recent/PaginatedRecentActivityContainer.cs b/osu.Game/Overlays/Profile/Sections/Recent/PaginatedRecentActivityContainer.cs index 4c828ef0c1..a2f844503f 100644 --- a/osu.Game/Overlays/Profile/Sections/Recent/PaginatedRecentActivityContainer.cs +++ b/osu.Game/Overlays/Profile/Sections/Recent/PaginatedRecentActivityContainer.cs @@ -14,8 +14,8 @@ namespace osu.Game.Overlays.Profile.Sections.Recent { public class PaginatedRecentActivityContainer : PaginatedContainer { - public PaginatedRecentActivityContainer(Bindable user, string missing) - : base(user, missing) + public PaginatedRecentActivityContainer(Bindable user) + : base(user) { ItemsPerPage = 10; ItemsContainer.Spacing = new Vector2(0, 8); diff --git a/osu.Game/Overlays/Profile/Sections/RecentSection.cs b/osu.Game/Overlays/Profile/Sections/RecentSection.cs index 0c118b80b5..1e6cfcc9fd 100644 --- a/osu.Game/Overlays/Profile/Sections/RecentSection.cs +++ b/osu.Game/Overlays/Profile/Sections/RecentSection.cs @@ -15,7 +15,7 @@ namespace osu.Game.Overlays.Profile.Sections { Children = new[] { - new PaginatedRecentActivityContainer(User, "This user hasn't done anything notable recently!"), + new PaginatedRecentActivityContainer(User), }; } } From e39609d3ca6bf4b55009def24f13997c5ea7efc4 Mon Sep 17 00:00:00 2001 From: Andrei Zavatski Date: Mon, 7 Sep 2020 23:08:50 +0300 Subject: [PATCH 05/16] Implement PaginatedContainerWithHeader component --- .../TestScenePaginatedContainerHeader.cs | 11 ++++-- .../Beatmaps/PaginatedBeatmapContainer.cs | 37 +++++++++++++++++-- .../Profile/Sections/BeatmapsSection.cs | 10 ++--- .../PaginatedMostPlayedBeatmapContainer.cs | 10 ++++- .../Profile/Sections/HistoricalSection.cs | 2 +- .../Profile/Sections/PaginatedContainer.cs | 33 +++++++++++------ .../Sections/PaginatedContainerHeader.cs | 11 ++++-- .../Sections/PaginatedContainerWithHeader.cs | 34 +++++++++++++++++ .../Sections/Ranks/PaginatedScoreContainer.cs | 24 ++++++++++-- .../Overlays/Profile/Sections/RanksSection.cs | 4 +- .../PaginatedRecentActivityContainer.cs | 8 +++- 11 files changed, 147 insertions(+), 37 deletions(-) create mode 100644 osu.Game/Overlays/Profile/Sections/PaginatedContainerWithHeader.cs diff --git a/osu.Game.Tests/Visual/UserInterface/TestScenePaginatedContainerHeader.cs b/osu.Game.Tests/Visual/UserInterface/TestScenePaginatedContainerHeader.cs index 114a3af1d9..2e9f919cfd 100644 --- a/osu.Game.Tests/Visual/UserInterface/TestScenePaginatedContainerHeader.cs +++ b/osu.Game.Tests/Visual/UserInterface/TestScenePaginatedContainerHeader.cs @@ -1,4 +1,7 @@ -using NUnit.Framework; +// 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 osu.Game.Overlays.Profile.Sections; using osu.Framework.Testing; using System.Linq; @@ -40,7 +43,7 @@ namespace osu.Game.Tests.Visual.UserInterface [Test] public void TestVisibleWhenZeroCounter() { - AddStep("Create header", () => createHeader("Header with visible when zero counter", CounterVisibilityState.VisibleWhenNonZero)); + AddStep("Create header", () => createHeader("Header with visible when zero counter", CounterVisibilityState.VisibleWhenZero)); AddAssert("Value is 0", () => header.Current.Value == 0); AddAssert("Counter is visible", () => header.ChildrenOfType().First().Alpha == 1); AddStep("Set count 10", () => header.Current.Value = 10); @@ -54,11 +57,11 @@ namespace osu.Game.Tests.Visual.UserInterface [Test] public void TestInitialVisibility() { - AddStep("Create header with 0 value", () => createHeader("Header with visible when zero counter", CounterVisibilityState.VisibleWhenNonZero, 0)); + AddStep("Create header with 0 value", () => createHeader("Header with visible when zero counter", CounterVisibilityState.VisibleWhenZero, 0)); AddAssert("Value is 0", () => header.Current.Value == 0); AddAssert("Counter is visible", () => header.ChildrenOfType().First().Alpha == 1); - AddStep("Create header with 1 value", () => createHeader("Header with visible when zero counter", CounterVisibilityState.VisibleWhenNonZero, 1)); + AddStep("Create header with 1 value", () => createHeader("Header with visible when zero counter", CounterVisibilityState.VisibleWhenZero, 1)); AddAssert("Value is 1", () => header.Current.Value == 1); AddAssert("Counter is hidden", () => header.ChildrenOfType().First().Alpha == 0); } diff --git a/osu.Game/Overlays/Profile/Sections/Beatmaps/PaginatedBeatmapContainer.cs b/osu.Game/Overlays/Profile/Sections/Beatmaps/PaginatedBeatmapContainer.cs index 1f99b75909..ea700a812f 100644 --- a/osu.Game/Overlays/Profile/Sections/Beatmaps/PaginatedBeatmapContainer.cs +++ b/osu.Game/Overlays/Profile/Sections/Beatmaps/PaginatedBeatmapContainer.cs @@ -2,6 +2,7 @@ // See the LICENCE file in the repository root for full licence text. using System.Collections.Generic; +using osu.Framework.Allocation; using osu.Framework.Bindables; using osu.Framework.Graphics; using osu.Game.Online.API; @@ -13,21 +14,49 @@ using osuTK; namespace osu.Game.Overlays.Profile.Sections.Beatmaps { - public class PaginatedBeatmapContainer : PaginatedContainer + public class PaginatedBeatmapContainer : PaginatedContainerWithHeader { private const float panel_padding = 10f; private readonly BeatmapSetType type; - public PaginatedBeatmapContainer(BeatmapSetType type, Bindable user) - : base(user) + public PaginatedBeatmapContainer(BeatmapSetType type, Bindable user, string headerText) + : base(user, headerText, CounterVisibilityState.AlwaysVisible) { this.type = type; - ItemsPerPage = 6; + } + [BackgroundDependencyLoader] + private void load() + { ItemsContainer.Spacing = new Vector2(panel_padding); } + protected override int GetCount(User user) + { + switch (type) + { + case BeatmapSetType.Favourite: + return user.FavouriteBeatmapsetCount; + + case BeatmapSetType.Graveyard: + return user.GraveyardBeatmapsetCount; + + case BeatmapSetType.Loved: + return user.LovedBeatmapsetCount; + + case BeatmapSetType.RankedAndApproved: + return user.RankedAndApprovedBeatmapsetCount; + + case BeatmapSetType.Unranked: + return user.UnrankedBeatmapsetCount; + + default: + return 0; + } + } + + protected override APIRequest> CreateRequest() => new GetUserBeatmapsRequest(User.Value.Id, type, VisiblePages++, ItemsPerPage); diff --git a/osu.Game/Overlays/Profile/Sections/BeatmapsSection.cs b/osu.Game/Overlays/Profile/Sections/BeatmapsSection.cs index 156696da16..c283de42f3 100644 --- a/osu.Game/Overlays/Profile/Sections/BeatmapsSection.cs +++ b/osu.Game/Overlays/Profile/Sections/BeatmapsSection.cs @@ -16,11 +16,11 @@ namespace osu.Game.Overlays.Profile.Sections { Children = new[] { - new PaginatedBeatmapContainer(BeatmapSetType.Favourite, User), - new PaginatedBeatmapContainer(BeatmapSetType.RankedAndApproved, User), - new PaginatedBeatmapContainer(BeatmapSetType.Loved, User), - new PaginatedBeatmapContainer(BeatmapSetType.Unranked, User), - new PaginatedBeatmapContainer(BeatmapSetType.Graveyard, User) + new PaginatedBeatmapContainer(BeatmapSetType.Favourite, User, "Favourite Beatmaps"), + new PaginatedBeatmapContainer(BeatmapSetType.RankedAndApproved, User, "Ranked & Approved Beatmaps"), + new PaginatedBeatmapContainer(BeatmapSetType.Loved, User, "Loved Beatmaps"), + new PaginatedBeatmapContainer(BeatmapSetType.Unranked, User, "Pending Beatmaps"), + new PaginatedBeatmapContainer(BeatmapSetType.Graveyard, User, "Graveyarded Beatmaps") }; } } diff --git a/osu.Game/Overlays/Profile/Sections/Historical/PaginatedMostPlayedBeatmapContainer.cs b/osu.Game/Overlays/Profile/Sections/Historical/PaginatedMostPlayedBeatmapContainer.cs index f16842f4ab..ad35ea1460 100644 --- a/osu.Game/Overlays/Profile/Sections/Historical/PaginatedMostPlayedBeatmapContainer.cs +++ b/osu.Game/Overlays/Profile/Sections/Historical/PaginatedMostPlayedBeatmapContainer.cs @@ -2,6 +2,7 @@ // See the LICENCE file in the repository root for full licence text. using System.Collections.Generic; +using osu.Framework.Allocation; using osu.Framework.Bindables; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; @@ -12,12 +13,17 @@ using osu.Game.Users; namespace osu.Game.Overlays.Profile.Sections.Historical { - public class PaginatedMostPlayedBeatmapContainer : PaginatedContainer + public class PaginatedMostPlayedBeatmapContainer : PaginatedContainerWithHeader { public PaginatedMostPlayedBeatmapContainer(Bindable user) - : base(user, "No records. :(") + : base(user, "Most Played Beatmaps", CounterVisibilityState.AlwaysHidden, "No records. :(") { ItemsPerPage = 5; + } + + [BackgroundDependencyLoader] + private void load() + { ItemsContainer.Direction = FillDirection.Vertical; } diff --git a/osu.Game/Overlays/Profile/Sections/HistoricalSection.cs b/osu.Game/Overlays/Profile/Sections/HistoricalSection.cs index e021f16e5e..bfc47bd88c 100644 --- a/osu.Game/Overlays/Profile/Sections/HistoricalSection.cs +++ b/osu.Game/Overlays/Profile/Sections/HistoricalSection.cs @@ -19,7 +19,7 @@ namespace osu.Game.Overlays.Profile.Sections Children = new Drawable[] { new PaginatedMostPlayedBeatmapContainer(User), - new PaginatedScoreContainer(ScoreType.Recent, User), + new PaginatedScoreContainer(ScoreType.Recent, User, "Recent Plays (24h)", CounterVisibilityState.VisibleWhenZero), }; } } diff --git a/osu.Game/Overlays/Profile/Sections/PaginatedContainer.cs b/osu.Game/Overlays/Profile/Sections/PaginatedContainer.cs index 9ddca48298..1bc8ffe671 100644 --- a/osu.Game/Overlays/Profile/Sections/PaginatedContainer.cs +++ b/osu.Game/Overlays/Profile/Sections/PaginatedContainer.cs @@ -20,11 +20,6 @@ namespace osu.Game.Overlays.Profile.Sections { public abstract class PaginatedContainer : FillFlowContainer { - private readonly ShowMoreButton moreButton; - private readonly OsuSpriteText missingText; - private APIRequest> retrievalRequest; - private CancellationTokenSource loadCancellation; - [Resolved] private IAPIProvider api { get; set; } @@ -32,19 +27,32 @@ namespace osu.Game.Overlays.Profile.Sections protected int ItemsPerPage; protected readonly Bindable User = new Bindable(); - protected readonly FillFlowContainer ItemsContainer; + protected FillFlowContainer ItemsContainer; protected RulesetStore Rulesets; + private APIRequest> retrievalRequest; + private CancellationTokenSource loadCancellation; + + private readonly string missing; + private ShowMoreButton moreButton; + private OsuSpriteText missingText; + protected PaginatedContainer(Bindable user, string missing = "") { + this.missing = missing; User.BindTo(user); + } + [BackgroundDependencyLoader] + private void load(RulesetStore rulesets) + { RelativeSizeAxes = Axes.X; AutoSizeAxes = Axes.Y; Direction = FillDirection.Vertical; Children = new Drawable[] { + CreateHeaderContent, ItemsContainer = new FillFlowContainer { AutoSizeAxes = Axes.Y, @@ -66,11 +74,7 @@ namespace osu.Game.Overlays.Profile.Sections Alpha = 0, }, }; - } - [BackgroundDependencyLoader] - private void load(RulesetStore rulesets) - { Rulesets = rulesets; User.ValueChanged += onUserChanged; @@ -87,7 +91,7 @@ namespace osu.Game.Overlays.Profile.Sections if (e.NewValue != null) { - showMore(); + OnUserChanged(e.NewValue); } } @@ -124,6 +128,13 @@ namespace osu.Game.Overlays.Profile.Sections }, loadCancellation.Token); }); + protected virtual void OnUserChanged(User user) + { + showMore(); + } + + protected virtual Drawable CreateHeaderContent => Empty(); + protected abstract APIRequest> CreateRequest(); protected abstract Drawable CreateDrawableItem(TModel model); diff --git a/osu.Game/Overlays/Profile/Sections/PaginatedContainerHeader.cs b/osu.Game/Overlays/Profile/Sections/PaginatedContainerHeader.cs index e965b83682..4779b44eb0 100644 --- a/osu.Game/Overlays/Profile/Sections/PaginatedContainerHeader.cs +++ b/osu.Game/Overlays/Profile/Sections/PaginatedContainerHeader.cs @@ -1,4 +1,7 @@ -using osu.Framework.Allocation; +// 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.Containers; using osu.Framework.Graphics; using osu.Framework.Graphics.UserInterface; @@ -103,7 +106,7 @@ namespace osu.Game.Overlays.Profile.Sections case CounterVisibilityState.AlwaysVisible: return 1; - case CounterVisibilityState.VisibleWhenNonZero: + case CounterVisibilityState.VisibleWhenZero: return current.Value == 0 ? 1 : 0; default: @@ -113,7 +116,7 @@ namespace osu.Game.Overlays.Profile.Sections private void onCurrentChanged(ValueChangedEvent countValue) { - if (counterState == CounterVisibilityState.VisibleWhenNonZero) + if (counterState == CounterVisibilityState.VisibleWhenZero) { counterPill.Alpha = countValue.NewValue == 0 ? 1 : 0; } @@ -124,6 +127,6 @@ namespace osu.Game.Overlays.Profile.Sections { AlwaysHidden, AlwaysVisible, - VisibleWhenNonZero + VisibleWhenZero } } diff --git a/osu.Game/Overlays/Profile/Sections/PaginatedContainerWithHeader.cs b/osu.Game/Overlays/Profile/Sections/PaginatedContainerWithHeader.cs new file mode 100644 index 0000000000..cf88b290ae --- /dev/null +++ b/osu.Game/Overlays/Profile/Sections/PaginatedContainerWithHeader.cs @@ -0,0 +1,34 @@ +// 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.Bindables; +using osu.Framework.Graphics; +using osu.Game.Users; + +namespace osu.Game.Overlays.Profile.Sections +{ + public abstract class PaginatedContainerWithHeader : PaginatedContainer + { + private readonly string headerText; + private readonly CounterVisibilityState counterVisibilityState; + + private PaginatedContainerHeader header; + + public PaginatedContainerWithHeader(Bindable user, string headerText, CounterVisibilityState counterVisibilityState, string missing = "") + : base(user, missing) + { + this.headerText = headerText; + this.counterVisibilityState = counterVisibilityState; + } + + protected override Drawable CreateHeaderContent => header = new PaginatedContainerHeader(headerText, counterVisibilityState); + + protected override void OnUserChanged(User user) + { + base.OnUserChanged(user); + header.Current.Value = GetCount(user); + } + + protected virtual int GetCount(User user) => 0; + } +} diff --git a/osu.Game/Overlays/Profile/Sections/Ranks/PaginatedScoreContainer.cs b/osu.Game/Overlays/Profile/Sections/Ranks/PaginatedScoreContainer.cs index fbf92fd2e6..f1cf3e632c 100644 --- a/osu.Game/Overlays/Profile/Sections/Ranks/PaginatedScoreContainer.cs +++ b/osu.Game/Overlays/Profile/Sections/Ranks/PaginatedScoreContainer.cs @@ -10,22 +10,40 @@ using osu.Framework.Graphics; using osu.Game.Online.API.Requests.Responses; using System.Collections.Generic; using osu.Game.Online.API; +using osu.Framework.Allocation; namespace osu.Game.Overlays.Profile.Sections.Ranks { - public class PaginatedScoreContainer : PaginatedContainer + public class PaginatedScoreContainer : PaginatedContainerWithHeader { private readonly ScoreType type; - public PaginatedScoreContainer(ScoreType type, Bindable user) - : base(user) + public PaginatedScoreContainer(ScoreType type, Bindable user, string headerText, CounterVisibilityState counterVisibilityState, string missingText = "") + : base(user, headerText, counterVisibilityState, missingText) { this.type = type; ItemsPerPage = 5; + } + + [BackgroundDependencyLoader] + private void load() + { ItemsContainer.Direction = FillDirection.Vertical; } + protected override int GetCount(User user) + { + switch (type) + { + case ScoreType.Firsts: + return user.ScoresFirstCount; + + default: + return 0; + } + } + protected override APIRequest> CreateRequest() => new GetUserScoresRequest(User.Value.Id, type, VisiblePages++, ItemsPerPage); diff --git a/osu.Game/Overlays/Profile/Sections/RanksSection.cs b/osu.Game/Overlays/Profile/Sections/RanksSection.cs index 18bf4f31d8..e41e414893 100644 --- a/osu.Game/Overlays/Profile/Sections/RanksSection.cs +++ b/osu.Game/Overlays/Profile/Sections/RanksSection.cs @@ -16,8 +16,8 @@ namespace osu.Game.Overlays.Profile.Sections { Children = new[] { - new PaginatedScoreContainer(ScoreType.Best, User), - new PaginatedScoreContainer(ScoreType.Firsts, User), + new PaginatedScoreContainer(ScoreType.Best, User, "Best Performance", CounterVisibilityState.AlwaysHidden, "No performance records. :("), + new PaginatedScoreContainer(ScoreType.Firsts, User, "First Place Ranks", CounterVisibilityState.AlwaysVisible) }; } } diff --git a/osu.Game/Overlays/Profile/Sections/Recent/PaginatedRecentActivityContainer.cs b/osu.Game/Overlays/Profile/Sections/Recent/PaginatedRecentActivityContainer.cs index a2f844503f..adfe31109b 100644 --- a/osu.Game/Overlays/Profile/Sections/Recent/PaginatedRecentActivityContainer.cs +++ b/osu.Game/Overlays/Profile/Sections/Recent/PaginatedRecentActivityContainer.cs @@ -9,15 +9,21 @@ using osu.Game.Online.API.Requests.Responses; using osu.Game.Online.API; using System.Collections.Generic; using osuTK; +using osu.Framework.Allocation; namespace osu.Game.Overlays.Profile.Sections.Recent { public class PaginatedRecentActivityContainer : PaginatedContainer { public PaginatedRecentActivityContainer(Bindable user) - : base(user) + : base(user, "This user hasn't done anything notable recently!") { ItemsPerPage = 10; + } + + [BackgroundDependencyLoader] + private void load() + { ItemsContainer.Spacing = new Vector2(0, 8); } From c72a192cb5f59c5e85ac7b1ec381f16ab760a0f9 Mon Sep 17 00:00:00 2001 From: Andrei Zavatski Date: Mon, 7 Sep 2020 23:33:04 +0300 Subject: [PATCH 06/16] Fix recent plays counter is always zero --- .../Overlays/Profile/Sections/PaginatedContainer.cs | 6 ++++++ .../Profile/Sections/PaginatedContainerWithHeader.cs | 12 ++++++++++++ 2 files changed, 18 insertions(+) diff --git a/osu.Game/Overlays/Profile/Sections/PaginatedContainer.cs b/osu.Game/Overlays/Profile/Sections/PaginatedContainer.cs index 1bc8ffe671..9693c8b5f3 100644 --- a/osu.Game/Overlays/Profile/Sections/PaginatedContainer.cs +++ b/osu.Game/Overlays/Profile/Sections/PaginatedContainer.cs @@ -107,6 +107,8 @@ namespace osu.Game.Overlays.Profile.Sections protected virtual void UpdateItems(List items) => Schedule(() => { + OnItemsReceived(items); + if (!items.Any() && VisiblePages == 1) { moreButton.Hide(); @@ -133,6 +135,10 @@ namespace osu.Game.Overlays.Profile.Sections showMore(); } + protected virtual void OnItemsReceived(List items) + { + } + protected virtual Drawable CreateHeaderContent => Empty(); protected abstract APIRequest> CreateRequest(); diff --git a/osu.Game/Overlays/Profile/Sections/PaginatedContainerWithHeader.cs b/osu.Game/Overlays/Profile/Sections/PaginatedContainerWithHeader.cs index cf88b290ae..f27ea7a626 100644 --- a/osu.Game/Overlays/Profile/Sections/PaginatedContainerWithHeader.cs +++ b/osu.Game/Overlays/Profile/Sections/PaginatedContainerWithHeader.cs @@ -1,6 +1,7 @@ // Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. +using System.Collections.Generic; using osu.Framework.Bindables; using osu.Framework.Graphics; using osu.Game.Users; @@ -29,6 +30,17 @@ namespace osu.Game.Overlays.Profile.Sections header.Current.Value = GetCount(user); } + protected override void OnItemsReceived(List items) + { + base.OnItemsReceived(items); + + if (counterVisibilityState == CounterVisibilityState.VisibleWhenZero) + { + header.Current.Value = items.Count; + header.Current.TriggerChange(); + } + } + protected virtual int GetCount(User user) => 0; } } From f88b2509f862062383e32bd1a78c585fcaa8fc09 Mon Sep 17 00:00:00 2001 From: Andrei Zavatski Date: Mon, 7 Sep 2020 23:43:26 +0300 Subject: [PATCH 07/16] Fix ProfileSection header margin is too small --- osu.Game/Overlays/Profile/ProfileSection.cs | 2 +- .../Profile/Sections/Beatmaps/PaginatedBeatmapContainer.cs | 1 - osu.Game/Overlays/Profile/Sections/PaginatedContainer.cs | 2 +- .../Overlays/Profile/Sections/PaginatedContainerWithHeader.cs | 2 +- 4 files changed, 3 insertions(+), 4 deletions(-) diff --git a/osu.Game/Overlays/Profile/ProfileSection.cs b/osu.Game/Overlays/Profile/ProfileSection.cs index 2e19ae4b64..21f7921da6 100644 --- a/osu.Game/Overlays/Profile/ProfileSection.cs +++ b/osu.Game/Overlays/Profile/ProfileSection.cs @@ -59,7 +59,7 @@ namespace osu.Game.Overlays.Profile { Horizontal = UserProfileOverlay.CONTENT_X_MARGIN, Top = 15, - Bottom = 10, + Bottom = 20, }, Children = new Drawable[] { diff --git a/osu.Game/Overlays/Profile/Sections/Beatmaps/PaginatedBeatmapContainer.cs b/osu.Game/Overlays/Profile/Sections/Beatmaps/PaginatedBeatmapContainer.cs index ea700a812f..d7c72131ea 100644 --- a/osu.Game/Overlays/Profile/Sections/Beatmaps/PaginatedBeatmapContainer.cs +++ b/osu.Game/Overlays/Profile/Sections/Beatmaps/PaginatedBeatmapContainer.cs @@ -56,7 +56,6 @@ namespace osu.Game.Overlays.Profile.Sections.Beatmaps } } - protected override APIRequest> CreateRequest() => new GetUserBeatmapsRequest(User.Value.Id, type, VisiblePages++, ItemsPerPage); diff --git a/osu.Game/Overlays/Profile/Sections/PaginatedContainer.cs b/osu.Game/Overlays/Profile/Sections/PaginatedContainer.cs index 9693c8b5f3..c22e5660e6 100644 --- a/osu.Game/Overlays/Profile/Sections/PaginatedContainer.cs +++ b/osu.Game/Overlays/Profile/Sections/PaginatedContainer.cs @@ -50,7 +50,7 @@ namespace osu.Game.Overlays.Profile.Sections AutoSizeAxes = Axes.Y; Direction = FillDirection.Vertical; - Children = new Drawable[] + Children = new[] { CreateHeaderContent, ItemsContainer = new FillFlowContainer diff --git a/osu.Game/Overlays/Profile/Sections/PaginatedContainerWithHeader.cs b/osu.Game/Overlays/Profile/Sections/PaginatedContainerWithHeader.cs index f27ea7a626..9d8ed89053 100644 --- a/osu.Game/Overlays/Profile/Sections/PaginatedContainerWithHeader.cs +++ b/osu.Game/Overlays/Profile/Sections/PaginatedContainerWithHeader.cs @@ -15,7 +15,7 @@ namespace osu.Game.Overlays.Profile.Sections private PaginatedContainerHeader header; - public PaginatedContainerWithHeader(Bindable user, string headerText, CounterVisibilityState counterVisibilityState, string missing = "") + protected PaginatedContainerWithHeader(Bindable user, string headerText, CounterVisibilityState counterVisibilityState, string missing = "") : base(user, missing) { this.headerText = headerText; From 1bc41bcfd7d61fb44e3a6fed3a1171664a1f658b Mon Sep 17 00:00:00 2001 From: Andrei Zavatski Date: Tue, 8 Sep 2020 00:04:14 +0300 Subject: [PATCH 08/16] Move scores counter logic to a better place --- .../Sections/PaginatedContainerWithHeader.cs | 18 +++--------------- .../Sections/Ranks/PaginatedScoreContainer.cs | 13 +++++++++++++ 2 files changed, 16 insertions(+), 15 deletions(-) diff --git a/osu.Game/Overlays/Profile/Sections/PaginatedContainerWithHeader.cs b/osu.Game/Overlays/Profile/Sections/PaginatedContainerWithHeader.cs index 9d8ed89053..32c589e342 100644 --- a/osu.Game/Overlays/Profile/Sections/PaginatedContainerWithHeader.cs +++ b/osu.Game/Overlays/Profile/Sections/PaginatedContainerWithHeader.cs @@ -1,7 +1,6 @@ // Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. -using System.Collections.Generic; using osu.Framework.Bindables; using osu.Framework.Graphics; using osu.Game.Users; @@ -13,7 +12,7 @@ namespace osu.Game.Overlays.Profile.Sections private readonly string headerText; private readonly CounterVisibilityState counterVisibilityState; - private PaginatedContainerHeader header; + protected PaginatedContainerHeader Header; protected PaginatedContainerWithHeader(Bindable user, string headerText, CounterVisibilityState counterVisibilityState, string missing = "") : base(user, missing) @@ -22,23 +21,12 @@ namespace osu.Game.Overlays.Profile.Sections this.counterVisibilityState = counterVisibilityState; } - protected override Drawable CreateHeaderContent => header = new PaginatedContainerHeader(headerText, counterVisibilityState); + protected override Drawable CreateHeaderContent => Header = new PaginatedContainerHeader(headerText, counterVisibilityState); protected override void OnUserChanged(User user) { base.OnUserChanged(user); - header.Current.Value = GetCount(user); - } - - protected override void OnItemsReceived(List items) - { - base.OnItemsReceived(items); - - if (counterVisibilityState == CounterVisibilityState.VisibleWhenZero) - { - header.Current.Value = items.Count; - header.Current.TriggerChange(); - } + Header.Current.Value = GetCount(user); } protected virtual int GetCount(User user) => 0; diff --git a/osu.Game/Overlays/Profile/Sections/Ranks/PaginatedScoreContainer.cs b/osu.Game/Overlays/Profile/Sections/Ranks/PaginatedScoreContainer.cs index f1cf3e632c..0b2bddabbc 100644 --- a/osu.Game/Overlays/Profile/Sections/Ranks/PaginatedScoreContainer.cs +++ b/osu.Game/Overlays/Profile/Sections/Ranks/PaginatedScoreContainer.cs @@ -44,6 +44,19 @@ namespace osu.Game.Overlays.Profile.Sections.Ranks } } + protected override void OnItemsReceived(List items) + { + base.OnItemsReceived(items); + + if (type == ScoreType.Recent) + { + var count = items.Count; + + Header.Current.Value = count == 0 ? 0 : -1; + Header.Current.TriggerChange(); + } + } + protected override APIRequest> CreateRequest() => new GetUserScoresRequest(User.Value.Id, type, VisiblePages++, ItemsPerPage); From 95eeebd93fd8aba3d3d2b837273944ad21328fdb Mon Sep 17 00:00:00 2001 From: Andrei Zavatski Date: Tue, 8 Sep 2020 15:31:00 +0300 Subject: [PATCH 09/16] Fix setting count for recent scores is overcomplicated --- .../Profile/Sections/Ranks/PaginatedScoreContainer.cs | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/osu.Game/Overlays/Profile/Sections/Ranks/PaginatedScoreContainer.cs b/osu.Game/Overlays/Profile/Sections/Ranks/PaginatedScoreContainer.cs index 0b2bddabbc..7dbdf47cad 100644 --- a/osu.Game/Overlays/Profile/Sections/Ranks/PaginatedScoreContainer.cs +++ b/osu.Game/Overlays/Profile/Sections/Ranks/PaginatedScoreContainer.cs @@ -49,12 +49,7 @@ namespace osu.Game.Overlays.Profile.Sections.Ranks base.OnItemsReceived(items); if (type == ScoreType.Recent) - { - var count = items.Count; - - Header.Current.Value = count == 0 ? 0 : -1; - Header.Current.TriggerChange(); - } + Header.Current.Value = items.Count; } protected override APIRequest> CreateRequest() => From 9b504272e41e9e6fadcb315eb732c05c9a458c0b Mon Sep 17 00:00:00 2001 From: Andrei Zavatski Date: Thu, 10 Sep 2020 20:24:43 +0300 Subject: [PATCH 10/16] Make Header a property --- .../Overlays/Profile/Sections/PaginatedContainerWithHeader.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Overlays/Profile/Sections/PaginatedContainerWithHeader.cs b/osu.Game/Overlays/Profile/Sections/PaginatedContainerWithHeader.cs index 32c589e342..5e175a2203 100644 --- a/osu.Game/Overlays/Profile/Sections/PaginatedContainerWithHeader.cs +++ b/osu.Game/Overlays/Profile/Sections/PaginatedContainerWithHeader.cs @@ -12,7 +12,7 @@ namespace osu.Game.Overlays.Profile.Sections private readonly string headerText; private readonly CounterVisibilityState counterVisibilityState; - protected PaginatedContainerHeader Header; + protected PaginatedContainerHeader Header { get; private set; } protected PaginatedContainerWithHeader(Bindable user, string headerText, CounterVisibilityState counterVisibilityState, string missing = "") : base(user, missing) From 931e567c7e809401526f3dda607ace733c07212c Mon Sep 17 00:00:00 2001 From: Andrei Zavatski Date: Thu, 10 Sep 2020 20:25:35 +0300 Subject: [PATCH 11/16] Replace counter font size with an actual value --- osu.Game/Overlays/Profile/Sections/CounterPill.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Overlays/Profile/Sections/CounterPill.cs b/osu.Game/Overlays/Profile/Sections/CounterPill.cs index 131df105ad..ca8abcfe5a 100644 --- a/osu.Game/Overlays/Profile/Sections/CounterPill.cs +++ b/osu.Game/Overlays/Profile/Sections/CounterPill.cs @@ -34,7 +34,7 @@ namespace osu.Game.Overlays.Profile.Sections Anchor = Anchor.Centre, Origin = Anchor.Centre, Margin = new MarginPadding { Horizontal = 10, Bottom = 1 }, - Font = OsuFont.GetFont(size: 14 * 0.8f, weight: FontWeight.Bold), + Font = OsuFont.GetFont(size: 11.2f, weight: FontWeight.Bold), Colour = colourProvider.Foreground1 } }; From e5f70d8eae57ae2892130730cb86ec2fdb990087 Mon Sep 17 00:00:00 2001 From: Andrei Zavatski Date: Thu, 10 Sep 2020 20:31:00 +0300 Subject: [PATCH 12/16] Simplify counter visibility changes in PaginatedContainerHeader --- .../Sections/PaginatedContainerHeader.cs | 57 ++++++++----------- 1 file changed, 24 insertions(+), 33 deletions(-) diff --git a/osu.Game/Overlays/Profile/Sections/PaginatedContainerHeader.cs b/osu.Game/Overlays/Profile/Sections/PaginatedContainerHeader.cs index 4779b44eb0..8c617e5fbd 100644 --- a/osu.Game/Overlays/Profile/Sections/PaginatedContainerHeader.cs +++ b/osu.Game/Overlays/Profile/Sections/PaginatedContainerHeader.cs @@ -16,21 +16,14 @@ namespace osu.Game.Overlays.Profile.Sections { public class PaginatedContainerHeader : CompositeDrawable, IHasCurrentValue { + private readonly BindableWithCurrent current = new BindableWithCurrent(); + public Bindable Current { - get => current; - set - { - if (value == null) - throw new ArgumentNullException(nameof(value)); - - current.UnbindBindings(); - current.BindTo(value); - } + get => current.Current; + set => current.Current = value; } - private readonly Bindable current = new Bindable(); - private readonly string text; private readonly CounterVisibilityState counterState; @@ -82,7 +75,6 @@ namespace osu.Game.Overlays.Profile.Sections { Anchor = Anchor.CentreLeft, Origin = Anchor.CentreLeft, - Alpha = getInitialCounterAlpha(), Current = { BindTarget = current } } } @@ -93,33 +85,32 @@ namespace osu.Game.Overlays.Profile.Sections protected override void LoadComplete() { base.LoadComplete(); - current.BindValueChanged(onCurrentChanged); - } - - private float getInitialCounterAlpha() - { - switch (counterState) - { - case CounterVisibilityState.AlwaysHidden: - return 0; - - case CounterVisibilityState.AlwaysVisible: - return 1; - - case CounterVisibilityState.VisibleWhenZero: - return current.Value == 0 ? 1 : 0; - - default: - throw new NotImplementedException($"{counterState} has an incorrect value."); - } + current.BindValueChanged(onCurrentChanged, true); } private void onCurrentChanged(ValueChangedEvent countValue) { - if (counterState == CounterVisibilityState.VisibleWhenZero) + float alpha; + + switch (counterState) { - counterPill.Alpha = countValue.NewValue == 0 ? 1 : 0; + case CounterVisibilityState.AlwaysHidden: + alpha = 0; + break; + + case CounterVisibilityState.AlwaysVisible: + alpha = 1; + break; + + case CounterVisibilityState.VisibleWhenZero: + alpha = current.Value == 0 ? 1 : 0; + break; + + default: + throw new NotImplementedException($"{counterState} has an incorrect value."); } + + counterPill.Alpha = alpha; } } From 913e3faf606130e9c1f4eb6308a403357e6b5ff1 Mon Sep 17 00:00:00 2001 From: Andrei Zavatski Date: Thu, 10 Sep 2020 20:48:06 +0300 Subject: [PATCH 13/16] Move PaginatedContainerWithHeader logic to a base class --- .../Beatmaps/PaginatedBeatmapContainer.cs | 4 +-- .../PaginatedMostPlayedBeatmapContainer.cs | 4 +-- .../Profile/Sections/PaginatedContainer.cs | 27 +++++++++------ .../Sections/PaginatedContainerWithHeader.cs | 34 ------------------- .../Sections/Ranks/PaginatedScoreContainer.cs | 6 ++-- 5 files changed, 24 insertions(+), 51 deletions(-) delete mode 100644 osu.Game/Overlays/Profile/Sections/PaginatedContainerWithHeader.cs diff --git a/osu.Game/Overlays/Profile/Sections/Beatmaps/PaginatedBeatmapContainer.cs b/osu.Game/Overlays/Profile/Sections/Beatmaps/PaginatedBeatmapContainer.cs index d7c72131ea..265972bb86 100644 --- a/osu.Game/Overlays/Profile/Sections/Beatmaps/PaginatedBeatmapContainer.cs +++ b/osu.Game/Overlays/Profile/Sections/Beatmaps/PaginatedBeatmapContainer.cs @@ -14,13 +14,13 @@ using osuTK; namespace osu.Game.Overlays.Profile.Sections.Beatmaps { - public class PaginatedBeatmapContainer : PaginatedContainerWithHeader + public class PaginatedBeatmapContainer : PaginatedContainer { private const float panel_padding = 10f; private readonly BeatmapSetType type; public PaginatedBeatmapContainer(BeatmapSetType type, Bindable user, string headerText) - : base(user, headerText, CounterVisibilityState.AlwaysVisible) + : base(user, "", headerText, CounterVisibilityState.AlwaysVisible) { this.type = type; ItemsPerPage = 6; diff --git a/osu.Game/Overlays/Profile/Sections/Historical/PaginatedMostPlayedBeatmapContainer.cs b/osu.Game/Overlays/Profile/Sections/Historical/PaginatedMostPlayedBeatmapContainer.cs index ad35ea1460..8f1d894379 100644 --- a/osu.Game/Overlays/Profile/Sections/Historical/PaginatedMostPlayedBeatmapContainer.cs +++ b/osu.Game/Overlays/Profile/Sections/Historical/PaginatedMostPlayedBeatmapContainer.cs @@ -13,10 +13,10 @@ using osu.Game.Users; namespace osu.Game.Overlays.Profile.Sections.Historical { - public class PaginatedMostPlayedBeatmapContainer : PaginatedContainerWithHeader + public class PaginatedMostPlayedBeatmapContainer : PaginatedContainer { public PaginatedMostPlayedBeatmapContainer(Bindable user) - : base(user, "Most Played Beatmaps", CounterVisibilityState.AlwaysHidden, "No records. :(") + : base(user, "No records. :(") { ItemsPerPage = 5; } diff --git a/osu.Game/Overlays/Profile/Sections/PaginatedContainer.cs b/osu.Game/Overlays/Profile/Sections/PaginatedContainer.cs index c22e5660e6..f0b11dc147 100644 --- a/osu.Game/Overlays/Profile/Sections/PaginatedContainer.cs +++ b/osu.Game/Overlays/Profile/Sections/PaginatedContainer.cs @@ -36,10 +36,16 @@ namespace osu.Game.Overlays.Profile.Sections private readonly string missing; private ShowMoreButton moreButton; private OsuSpriteText missingText; + private PaginatedContainerHeader header; - protected PaginatedContainer(Bindable user, string missing = "") + private readonly string headerText; + private readonly CounterVisibilityState counterVisibilityState; + + protected PaginatedContainer(Bindable user, string missing = "", string headerText = "", CounterVisibilityState counterVisibilityState = CounterVisibilityState.AlwaysHidden) { + this.headerText = headerText; this.missing = missing; + this.counterVisibilityState = counterVisibilityState; User.BindTo(user); } @@ -50,9 +56,12 @@ namespace osu.Game.Overlays.Profile.Sections AutoSizeAxes = Axes.Y; Direction = FillDirection.Vertical; - Children = new[] + Children = new Drawable[] { - CreateHeaderContent, + header = new PaginatedContainerHeader(headerText, counterVisibilityState) + { + Alpha = string.IsNullOrEmpty(headerText) ? 0 : 1 + }, ItemsContainer = new FillFlowContainer { AutoSizeAxes = Axes.Y, @@ -91,7 +100,8 @@ namespace osu.Game.Overlays.Profile.Sections if (e.NewValue != null) { - OnUserChanged(e.NewValue); + showMore(); + SetCount(GetCount(e.NewValue)); } } @@ -130,17 +140,14 @@ namespace osu.Game.Overlays.Profile.Sections }, loadCancellation.Token); }); - protected virtual void OnUserChanged(User user) - { - showMore(); - } + protected virtual int GetCount(User user) => 0; + + protected void SetCount(int value) => header.Current.Value = value; protected virtual void OnItemsReceived(List items) { } - protected virtual Drawable CreateHeaderContent => Empty(); - protected abstract APIRequest> CreateRequest(); protected abstract Drawable CreateDrawableItem(TModel model); diff --git a/osu.Game/Overlays/Profile/Sections/PaginatedContainerWithHeader.cs b/osu.Game/Overlays/Profile/Sections/PaginatedContainerWithHeader.cs deleted file mode 100644 index 5e175a2203..0000000000 --- a/osu.Game/Overlays/Profile/Sections/PaginatedContainerWithHeader.cs +++ /dev/null @@ -1,34 +0,0 @@ -// 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.Bindables; -using osu.Framework.Graphics; -using osu.Game.Users; - -namespace osu.Game.Overlays.Profile.Sections -{ - public abstract class PaginatedContainerWithHeader : PaginatedContainer - { - private readonly string headerText; - private readonly CounterVisibilityState counterVisibilityState; - - protected PaginatedContainerHeader Header { get; private set; } - - protected PaginatedContainerWithHeader(Bindable user, string headerText, CounterVisibilityState counterVisibilityState, string missing = "") - : base(user, missing) - { - this.headerText = headerText; - this.counterVisibilityState = counterVisibilityState; - } - - protected override Drawable CreateHeaderContent => Header = new PaginatedContainerHeader(headerText, counterVisibilityState); - - protected override void OnUserChanged(User user) - { - base.OnUserChanged(user); - Header.Current.Value = GetCount(user); - } - - protected virtual int GetCount(User user) => 0; - } -} diff --git a/osu.Game/Overlays/Profile/Sections/Ranks/PaginatedScoreContainer.cs b/osu.Game/Overlays/Profile/Sections/Ranks/PaginatedScoreContainer.cs index 7dbdf47cad..71ee89d526 100644 --- a/osu.Game/Overlays/Profile/Sections/Ranks/PaginatedScoreContainer.cs +++ b/osu.Game/Overlays/Profile/Sections/Ranks/PaginatedScoreContainer.cs @@ -14,12 +14,12 @@ using osu.Framework.Allocation; namespace osu.Game.Overlays.Profile.Sections.Ranks { - public class PaginatedScoreContainer : PaginatedContainerWithHeader + public class PaginatedScoreContainer : PaginatedContainer { private readonly ScoreType type; public PaginatedScoreContainer(ScoreType type, Bindable user, string headerText, CounterVisibilityState counterVisibilityState, string missingText = "") - : base(user, headerText, counterVisibilityState, missingText) + : base(user, missingText, headerText, counterVisibilityState) { this.type = type; @@ -49,7 +49,7 @@ namespace osu.Game.Overlays.Profile.Sections.Ranks base.OnItemsReceived(items); if (type == ScoreType.Recent) - Header.Current.Value = items.Count; + SetCount(items.Count); } protected override APIRequest> CreateRequest() => From cfc6e2175d2fc9ae36b60402ed4a210d55ff33df Mon Sep 17 00:00:00 2001 From: Andrei Zavatski Date: Thu, 10 Sep 2020 20:58:37 +0300 Subject: [PATCH 14/16] Add missing header to MostPlayedBeatmapsContainer --- .../Sections/Historical/PaginatedMostPlayedBeatmapContainer.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Overlays/Profile/Sections/Historical/PaginatedMostPlayedBeatmapContainer.cs b/osu.Game/Overlays/Profile/Sections/Historical/PaginatedMostPlayedBeatmapContainer.cs index 8f1d894379..30284818a6 100644 --- a/osu.Game/Overlays/Profile/Sections/Historical/PaginatedMostPlayedBeatmapContainer.cs +++ b/osu.Game/Overlays/Profile/Sections/Historical/PaginatedMostPlayedBeatmapContainer.cs @@ -16,7 +16,7 @@ namespace osu.Game.Overlays.Profile.Sections.Historical public class PaginatedMostPlayedBeatmapContainer : PaginatedContainer { public PaginatedMostPlayedBeatmapContainer(Bindable user) - : base(user, "No records. :(") + : base(user, "No records. :(", "Most Played Beatmaps") { ItemsPerPage = 5; } From be5d143b5a6b28030a2f39c7e5c03c3ec803318e Mon Sep 17 00:00:00 2001 From: smoogipoo Date: Fri, 11 Sep 2020 12:17:12 +0900 Subject: [PATCH 15/16] Reorder params --- .../Profile/Sections/Beatmaps/PaginatedBeatmapContainer.cs | 2 +- .../Sections/Historical/PaginatedMostPlayedBeatmapContainer.cs | 2 +- .../Profile/Sections/Kudosu/PaginatedKudosuHistoryContainer.cs | 2 +- osu.Game/Overlays/Profile/Sections/PaginatedContainer.cs | 2 +- .../Overlays/Profile/Sections/Ranks/PaginatedScoreContainer.cs | 2 +- .../Profile/Sections/Recent/PaginatedRecentActivityContainer.cs | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/osu.Game/Overlays/Profile/Sections/Beatmaps/PaginatedBeatmapContainer.cs b/osu.Game/Overlays/Profile/Sections/Beatmaps/PaginatedBeatmapContainer.cs index 265972bb86..4b7de8de90 100644 --- a/osu.Game/Overlays/Profile/Sections/Beatmaps/PaginatedBeatmapContainer.cs +++ b/osu.Game/Overlays/Profile/Sections/Beatmaps/PaginatedBeatmapContainer.cs @@ -20,7 +20,7 @@ namespace osu.Game.Overlays.Profile.Sections.Beatmaps private readonly BeatmapSetType type; public PaginatedBeatmapContainer(BeatmapSetType type, Bindable user, string headerText) - : base(user, "", headerText, CounterVisibilityState.AlwaysVisible) + : base(user, headerText, "", CounterVisibilityState.AlwaysVisible) { this.type = type; ItemsPerPage = 6; diff --git a/osu.Game/Overlays/Profile/Sections/Historical/PaginatedMostPlayedBeatmapContainer.cs b/osu.Game/Overlays/Profile/Sections/Historical/PaginatedMostPlayedBeatmapContainer.cs index 30284818a6..8f19cd900c 100644 --- a/osu.Game/Overlays/Profile/Sections/Historical/PaginatedMostPlayedBeatmapContainer.cs +++ b/osu.Game/Overlays/Profile/Sections/Historical/PaginatedMostPlayedBeatmapContainer.cs @@ -16,7 +16,7 @@ namespace osu.Game.Overlays.Profile.Sections.Historical public class PaginatedMostPlayedBeatmapContainer : PaginatedContainer { public PaginatedMostPlayedBeatmapContainer(Bindable user) - : base(user, "No records. :(", "Most Played Beatmaps") + : base(user, "Most Played Beatmaps", "No records. :(") { ItemsPerPage = 5; } diff --git a/osu.Game/Overlays/Profile/Sections/Kudosu/PaginatedKudosuHistoryContainer.cs b/osu.Game/Overlays/Profile/Sections/Kudosu/PaginatedKudosuHistoryContainer.cs index c823053c4b..b968edcb5a 100644 --- a/osu.Game/Overlays/Profile/Sections/Kudosu/PaginatedKudosuHistoryContainer.cs +++ b/osu.Game/Overlays/Profile/Sections/Kudosu/PaginatedKudosuHistoryContainer.cs @@ -14,7 +14,7 @@ namespace osu.Game.Overlays.Profile.Sections.Kudosu public class PaginatedKudosuHistoryContainer : PaginatedContainer { public PaginatedKudosuHistoryContainer(Bindable user) - : base(user, "This user hasn't received any kudosu!") + : base(user, missing: "This user hasn't received any kudosu!") { ItemsPerPage = 5; } diff --git a/osu.Game/Overlays/Profile/Sections/PaginatedContainer.cs b/osu.Game/Overlays/Profile/Sections/PaginatedContainer.cs index f0b11dc147..6e681a779f 100644 --- a/osu.Game/Overlays/Profile/Sections/PaginatedContainer.cs +++ b/osu.Game/Overlays/Profile/Sections/PaginatedContainer.cs @@ -41,7 +41,7 @@ namespace osu.Game.Overlays.Profile.Sections private readonly string headerText; private readonly CounterVisibilityState counterVisibilityState; - protected PaginatedContainer(Bindable user, string missing = "", string headerText = "", CounterVisibilityState counterVisibilityState = CounterVisibilityState.AlwaysHidden) + protected PaginatedContainer(Bindable user, string headerText = "", string missing = "", CounterVisibilityState counterVisibilityState = CounterVisibilityState.AlwaysHidden) { this.headerText = headerText; this.missing = missing; diff --git a/osu.Game/Overlays/Profile/Sections/Ranks/PaginatedScoreContainer.cs b/osu.Game/Overlays/Profile/Sections/Ranks/PaginatedScoreContainer.cs index 71ee89d526..3c540d6fbb 100644 --- a/osu.Game/Overlays/Profile/Sections/Ranks/PaginatedScoreContainer.cs +++ b/osu.Game/Overlays/Profile/Sections/Ranks/PaginatedScoreContainer.cs @@ -19,7 +19,7 @@ namespace osu.Game.Overlays.Profile.Sections.Ranks private readonly ScoreType type; public PaginatedScoreContainer(ScoreType type, Bindable user, string headerText, CounterVisibilityState counterVisibilityState, string missingText = "") - : base(user, missingText, headerText, counterVisibilityState) + : base(user, headerText, missingText, counterVisibilityState) { this.type = type; diff --git a/osu.Game/Overlays/Profile/Sections/Recent/PaginatedRecentActivityContainer.cs b/osu.Game/Overlays/Profile/Sections/Recent/PaginatedRecentActivityContainer.cs index adfe31109b..4901789963 100644 --- a/osu.Game/Overlays/Profile/Sections/Recent/PaginatedRecentActivityContainer.cs +++ b/osu.Game/Overlays/Profile/Sections/Recent/PaginatedRecentActivityContainer.cs @@ -16,7 +16,7 @@ namespace osu.Game.Overlays.Profile.Sections.Recent public class PaginatedRecentActivityContainer : PaginatedContainer { public PaginatedRecentActivityContainer(Bindable user) - : base(user, "This user hasn't done anything notable recently!") + : base(user, missing: "This user hasn't done anything notable recently!") { ItemsPerPage = 10; } From 22c5e9f64f03e5cdca648028442e46e3c33439a8 Mon Sep 17 00:00:00 2001 From: smoogipoo Date: Fri, 11 Sep 2020 12:19:26 +0900 Subject: [PATCH 16/16] Rename missing parameter --- .../Kudosu/PaginatedKudosuHistoryContainer.cs | 2 +- .../Profile/Sections/PaginatedContainer.cs | 18 +++++++++--------- .../Recent/PaginatedRecentActivityContainer.cs | 2 +- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/osu.Game/Overlays/Profile/Sections/Kudosu/PaginatedKudosuHistoryContainer.cs b/osu.Game/Overlays/Profile/Sections/Kudosu/PaginatedKudosuHistoryContainer.cs index b968edcb5a..1b8bd23eb4 100644 --- a/osu.Game/Overlays/Profile/Sections/Kudosu/PaginatedKudosuHistoryContainer.cs +++ b/osu.Game/Overlays/Profile/Sections/Kudosu/PaginatedKudosuHistoryContainer.cs @@ -14,7 +14,7 @@ namespace osu.Game.Overlays.Profile.Sections.Kudosu public class PaginatedKudosuHistoryContainer : PaginatedContainer { public PaginatedKudosuHistoryContainer(Bindable user) - : base(user, missing: "This user hasn't received any kudosu!") + : base(user, missingText: "This user hasn't received any kudosu!") { ItemsPerPage = 5; } diff --git a/osu.Game/Overlays/Profile/Sections/PaginatedContainer.cs b/osu.Game/Overlays/Profile/Sections/PaginatedContainer.cs index 6e681a779f..c1107ce907 100644 --- a/osu.Game/Overlays/Profile/Sections/PaginatedContainer.cs +++ b/osu.Game/Overlays/Profile/Sections/PaginatedContainer.cs @@ -33,18 +33,18 @@ namespace osu.Game.Overlays.Profile.Sections private APIRequest> retrievalRequest; private CancellationTokenSource loadCancellation; - private readonly string missing; + private readonly string missingText; private ShowMoreButton moreButton; - private OsuSpriteText missingText; + private OsuSpriteText missing; private PaginatedContainerHeader header; private readonly string headerText; private readonly CounterVisibilityState counterVisibilityState; - protected PaginatedContainer(Bindable user, string headerText = "", string missing = "", CounterVisibilityState counterVisibilityState = CounterVisibilityState.AlwaysHidden) + protected PaginatedContainer(Bindable user, string headerText = "", string missingText = "", CounterVisibilityState counterVisibilityState = CounterVisibilityState.AlwaysHidden) { this.headerText = headerText; - this.missing = missing; + this.missingText = missingText; this.counterVisibilityState = counterVisibilityState; User.BindTo(user); } @@ -76,10 +76,10 @@ namespace osu.Game.Overlays.Profile.Sections Margin = new MarginPadding { Top = 10 }, Action = showMore, }, - missingText = new OsuSpriteText + missing = new OsuSpriteText { Font = OsuFont.GetFont(size: 15), - Text = missing, + Text = missingText, Alpha = 0, }, }; @@ -124,15 +124,15 @@ namespace osu.Game.Overlays.Profile.Sections moreButton.Hide(); moreButton.IsLoading = false; - if (!string.IsNullOrEmpty(missingText.Text)) - missingText.Show(); + if (!string.IsNullOrEmpty(missing.Text)) + missing.Show(); return; } LoadComponentsAsync(items.Select(CreateDrawableItem).Where(d => d != null), drawables => { - missingText.Hide(); + missing.Hide(); moreButton.FadeTo(items.Count == ItemsPerPage ? 1 : 0); moreButton.IsLoading = false; diff --git a/osu.Game/Overlays/Profile/Sections/Recent/PaginatedRecentActivityContainer.cs b/osu.Game/Overlays/Profile/Sections/Recent/PaginatedRecentActivityContainer.cs index 4901789963..08f39c6272 100644 --- a/osu.Game/Overlays/Profile/Sections/Recent/PaginatedRecentActivityContainer.cs +++ b/osu.Game/Overlays/Profile/Sections/Recent/PaginatedRecentActivityContainer.cs @@ -16,7 +16,7 @@ namespace osu.Game.Overlays.Profile.Sections.Recent public class PaginatedRecentActivityContainer : PaginatedContainer { public PaginatedRecentActivityContainer(Bindable user) - : base(user, missing: "This user hasn't done anything notable recently!") + : base(user, missingText: "This user hasn't done anything notable recently!") { ItemsPerPage = 10; }