From d0427ec85f93ab7276a7593153d0f8fd77ce2b7e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Dach?= Date: Sat, 27 Nov 2021 17:53:57 +0100 Subject: [PATCH] Add support card size tab control to beatmap listing --- .../BeatmapListingFilterControl.cs | 22 ++++++++++++++++--- osu.Game/Overlays/BeatmapListingOverlay.cs | 14 ++++++------ 2 files changed, 26 insertions(+), 10 deletions(-) diff --git a/osu.Game/Overlays/BeatmapListing/BeatmapListingFilterControl.cs b/osu.Game/Overlays/BeatmapListing/BeatmapListingFilterControl.cs index f5b4785264..157753c09f 100644 --- a/osu.Game/Overlays/BeatmapListing/BeatmapListingFilterControl.cs +++ b/osu.Game/Overlays/BeatmapListing/BeatmapListingFilterControl.cs @@ -5,6 +5,7 @@ using System.Collections.Generic; using System.Linq; using osu.Framework.Allocation; +using osu.Framework.Bindables; using osu.Framework.Extensions.Color4Extensions; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; @@ -12,6 +13,7 @@ using osu.Framework.Graphics.Shapes; using osu.Framework.Localisation; using osu.Framework.Threading; +using osu.Game.Beatmaps.Drawables.Cards; using osu.Game.Online.API; using osu.Game.Online.API.Requests; using osu.Game.Online.API.Requests.Responses; @@ -48,6 +50,11 @@ public class BeatmapListingFilterControl : CompositeDrawable /// public int CurrentPage { get; private set; } + /// + /// The currently selected . + /// + public IBindable CardSize { get; } = new Bindable(); + private readonly BeatmapListingSearchControl searchControl; private readonly BeatmapListingSortTabControl sortControl; private readonly Box sortControlBackground; @@ -105,6 +112,13 @@ public BeatmapListingFilterControl() Anchor = Anchor.CentreLeft, Origin = Anchor.CentreLeft, Margin = new MarginPadding { Left = 20 } + }, + new BeatmapListingCardSizeTabControl + { + Anchor = Anchor.CentreRight, + Origin = Anchor.CentreRight, + Margin = new MarginPadding { Right = 20 }, + Current = { BindTarget = CardSize } } } } @@ -227,12 +241,14 @@ private void performRequest() if (filters.Any()) { - SearchFinished?.Invoke(SearchResult.SupporterOnlyFilters(filters)); + var supporterOnlyFilters = SearchResult.SupporterOnlyFilters(filters); + SearchFinished?.Invoke(supporterOnlyFilters); return; } } - SearchFinished?.Invoke(SearchResult.ResultsReturned(sets)); + var resultsReturned = SearchResult.ResultsReturned(sets); + SearchFinished?.Invoke(resultsReturned); }; api.Queue(getSetsRequest); @@ -296,7 +312,7 @@ public struct SearchResult public static SearchResult ResultsReturned(List results) => new SearchResult { Type = SearchResultType.ResultsReturned, - Results = results + Results = results, }; public static SearchResult SupporterOnlyFilters(List filters) => new SearchResult diff --git a/osu.Game/Overlays/BeatmapListingOverlay.cs b/osu.Game/Overlays/BeatmapListingOverlay.cs index d07f7c8f8f..dd726ed010 100644 --- a/osu.Game/Overlays/BeatmapListingOverlay.cs +++ b/osu.Game/Overlays/BeatmapListingOverlay.cs @@ -33,7 +33,7 @@ public class BeatmapListingOverlay : OnlineOverlay private Drawable currentContent; private Container panelTarget; - private FillFlowContainer foundContent; + private FillFlowContainer foundContent; private NotFoundDrawable notFoundContent; private SupporterRequiredDrawable supporterRequiredContent; private BeatmapListingFilterControl filterControl; @@ -78,7 +78,7 @@ private void load() Padding = new MarginPadding { Horizontal = 20 }, Children = new Drawable[] { - foundContent = new FillFlowContainer(), + foundContent = new FillFlowContainer(), notFoundContent = new NotFoundDrawable(), supporterRequiredContent = new SupporterRequiredDrawable(), } @@ -135,11 +135,11 @@ private void onSearchFinished(BeatmapListingFilterControl.SearchResult searchRes return; } - var newPanels = searchResult.Results.Select(b => new BeatmapCardNormal(b) + var newPanels = searchResult.Results.Select(b => BeatmapCard.Create(b, filterControl.CardSize.Value).With(card => { - Anchor = Anchor.TopCentre, - Origin = Anchor.TopCentre, - }); + card.Anchor = Anchor.TopCentre; + card.Origin = Anchor.TopCentre; + })); if (filterControl.CurrentPage == 0) { @@ -152,7 +152,7 @@ private void onSearchFinished(BeatmapListingFilterControl.SearchResult searchRes // spawn new children with the contained so we only clear old content at the last moment. // reverse ID flow is required for correct Z-ordering of the cards' expandable content (last card should be front-most). - var content = new ReverseChildIDFillFlowContainer + var content = new ReverseChildIDFillFlowContainer { RelativeSizeAxes = Axes.X, AutoSizeAxes = Axes.Y,