1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-11 12:57:36 +08:00

Add support card size tab control to beatmap listing

This commit is contained in:
Bartłomiej Dach 2021-11-27 17:53:57 +01:00
parent 1876617d8e
commit d0427ec85f
No known key found for this signature in database
GPG Key ID: BCECCD4FA41F6497
2 changed files with 26 additions and 10 deletions

View File

@ -5,6 +5,7 @@ using System;
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.Effects;
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 @@ namespace osu.Game.Overlays.BeatmapListing
/// </summary>
public int CurrentPage { get; private set; }
/// <summary>
/// The currently selected <see cref="BeatmapCardSize"/>.
/// </summary>
public IBindable<BeatmapCardSize> CardSize { get; } = new Bindable<BeatmapCardSize>();
private readonly BeatmapListingSearchControl searchControl;
private readonly BeatmapListingSortTabControl sortControl;
private readonly Box sortControlBackground;
@ -105,6 +112,13 @@ namespace osu.Game.Overlays.BeatmapListing
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 @@ namespace osu.Game.Overlays.BeatmapListing
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 @@ namespace osu.Game.Overlays.BeatmapListing
public static SearchResult ResultsReturned(List<APIBeatmapSet> results) => new SearchResult
{
Type = SearchResultType.ResultsReturned,
Results = results
Results = results,
};
public static SearchResult SupporterOnlyFilters(List<LocalisableString> filters) => new SearchResult

View File

@ -33,7 +33,7 @@ namespace osu.Game.Overlays
private Drawable currentContent;
private Container panelTarget;
private FillFlowContainer<BeatmapCardNormal> foundContent;
private FillFlowContainer<BeatmapCard> foundContent;
private NotFoundDrawable notFoundContent;
private SupporterRequiredDrawable supporterRequiredContent;
private BeatmapListingFilterControl filterControl;
@ -78,7 +78,7 @@ namespace osu.Game.Overlays
Padding = new MarginPadding { Horizontal = 20 },
Children = new Drawable[]
{
foundContent = new FillFlowContainer<BeatmapCardNormal>(),
foundContent = new FillFlowContainer<BeatmapCard>(),
notFoundContent = new NotFoundDrawable(),
supporterRequiredContent = new SupporterRequiredDrawable(),
}
@ -135,11 +135,11 @@ namespace osu.Game.Overlays
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 @@ namespace osu.Game.Overlays
// 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<BeatmapCardNormal>
var content = new ReverseChildIDFillFlowContainer<BeatmapCard>
{
RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y,