1
0
mirror of https://github.com/ppy/osu.git synced 2024-09-22 04:07:25 +08:00

Show count of visible beatmaps at song select

This commit is contained in:
Dean Herbert 2023-03-03 15:25:55 +09:00
parent 29be26b150
commit dc669835e2
4 changed files with 90 additions and 57 deletions

View File

@ -1,4 +1,4 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
using osu.Framework.Localisation;
@ -19,6 +19,11 @@ namespace osu.Game.Localisation
/// </summary>
public static LocalisableString LocallyModifiedTooltip => new TranslatableString(getKey(@"locally_modified_tooltip"), @"Has been locally modified");
/// <summary>
/// "{0} beatmaps displayed"
/// </summary>
public static LocalisableString BeatmapsDisplayed(int arg0) => new TranslatableString(getKey(@"beatmaps_displayed"), @"{0:#,0} beatmaps displayed", arg0);
private static string getKey(string key) => $@"{prefix}:{key}";
}
}

View File

@ -49,6 +49,11 @@ namespace osu.Game.Screens.Select
/// </summary>
public Action? BeatmapSetsChanged;
/// <summary>
/// Triggered after filter conditions have finished being applied to the model hierarchy.
/// </summary>
public Action? FilterApplied;
/// <summary>
/// The currently selected beatmap.
/// </summary>
@ -56,6 +61,11 @@ namespace osu.Game.Screens.Select
private CarouselBeatmap? selectedBeatmap => selectedBeatmapSet?.Beatmaps.FirstOrDefault(s => s.State.Value == CarouselItemState.Selected);
/// <summary>
/// The total count of non-filtered beatmaps displayed.
/// </summary>
public int CountDisplayed => beatmapSets.Where(s => !s.Filtered.Value).Sum(s => s.Beatmaps.Count(b => !b.Filtered.Value));
/// <summary>
/// The currently selected beatmap set.
/// </summary>
@ -639,6 +649,8 @@ namespace osu.Game.Screens.Select
if (alwaysResetScrollPosition || !Scroll.UserScrolling)
ScrollToSelected(true);
FilterApplied?.Invoke();
}
}

View File

@ -10,6 +10,7 @@ using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes;
using osu.Framework.Input.Events;
using osu.Framework.Localisation;
using osu.Game.Collections;
using osu.Game.Configuration;
using osu.Game.Graphics;
@ -27,13 +28,20 @@ namespace osu.Game.Screens.Select
{
public partial class FilterControl : Container
{
public const float HEIGHT = 2 * side_margin + 85;
private const float side_margin = 20;
public const float HEIGHT = 2 * side_margin + 120;
private const float side_margin = 10;
public Action<FilterCriteria> FilterChanged;
public Bindable<string> CurrentTextSearch => searchTextBox.Current;
public LocalisableString InformationalText
{
get => filterText.Text;
set => filterText.Text = value;
}
private OsuTabControl<SortMode> sortTabs;
private Bindable<SortMode> sortMode;
@ -44,6 +52,8 @@ namespace osu.Game.Screens.Select
private CollectionDropdown collectionDropdown;
private OsuSpriteText filterText;
public FilterCriteria CreateCriteria()
{
string query = searchTextBox.Text;
@ -99,27 +109,33 @@ namespace osu.Game.Screens.Select
{
RelativeSizeAxes = Axes.Both,
Spacing = new Vector2(0, 5),
Children = new[]
{
new Container
{
RelativeSizeAxes = Axes.X,
Height = 60,
Children = new Drawable[]
{
searchTextBox = new SeekLimitedSearchTextBox { RelativeSizeAxes = Axes.X },
new Container
{
RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y,
AutoSizeDuration = 200,
AutoSizeEasing = Easing.OutQuint,
Children = new Drawable[]
{
filterText = new OsuSpriteText
{
Anchor = Anchor.TopRight,
Origin = Anchor.TopRight,
Font = OsuFont.Default.With(size: 12),
},
}
},
new Box
{
RelativeSizeAxes = Axes.X,
Height = 1,
Colour = OsuColour.Gray(80),
Origin = Anchor.BottomLeft,
Anchor = Anchor.BottomLeft,
},
new GridContainer
{
Anchor = Anchor.BottomRight,
Origin = Anchor.BottomRight,
RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y,
ColumnDimensions = new[]
@ -165,8 +181,6 @@ namespace osu.Game.Screens.Select
}
}
},
}
},
new Container
{
RelativeSizeAxes = Axes.X,

View File

@ -40,6 +40,7 @@ using osu.Game.Skinning;
using osuTK;
using osuTK.Graphics;
using osuTK.Input;
using osu.Game.Localisation;
namespace osu.Game.Screens.Select
{
@ -162,6 +163,7 @@ namespace osu.Game.Screens.Select
BleedBottom = Footer.HEIGHT,
SelectionChanged = updateSelectedBeatmap,
BeatmapSetsChanged = carouselBeatmapsLoaded,
FilterApplied = () => FilterControl.InformationalText = SongSelectStrings.BeatmapsDisplayed(Carousel.CountDisplayed),
GetRecommendedBeatmap = s => recommender?.GetRecommendedBeatmap(s),
}, c => carouselContainer.Child = c);