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

Merge pull request #19124 from frenzibyte/song-select-metadata-search

Change clicking source/tags on song select to filter instead of searching online
This commit is contained in:
Dean Herbert 2022-07-15 19:16:31 +09:00 committed by GitHub
commit cf38b15332
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 37 additions and 14 deletions

View File

@ -3,6 +3,7 @@
#nullable disable
using System;
using osu.Framework.Extensions;
using osu.Framework.Extensions.Color4Extensions;
using osu.Framework.Graphics;
@ -22,11 +23,14 @@ namespace osu.Game.Overlays.BeatmapSet
private readonly MetadataType type;
private TextFlowContainer textFlow;
private readonly Action<string> searchAction;
private const float transition_duration = 250;
public MetadataSection(MetadataType type)
public MetadataSection(MetadataType type, Action<string> searchAction = null)
{
this.type = type;
this.searchAction = searchAction;
Alpha = 0;
@ -91,7 +95,12 @@ namespace osu.Game.Overlays.BeatmapSet
for (int i = 0; i <= tags.Length - 1; i++)
{
loaded.AddLink(tags[i], LinkAction.SearchBeatmapSet, tags[i]);
string tag = tags[i];
if (searchAction != null)
loaded.AddLink(tag, () => searchAction(tag));
else
loaded.AddLink(tag, LinkAction.SearchBeatmapSet, tag);
if (i != tags.Length - 1)
loaded.AddText(" ");
@ -100,7 +109,11 @@ namespace osu.Game.Overlays.BeatmapSet
break;
case MetadataType.Source:
loaded.AddLink(text, LinkAction.SearchBeatmapSet, text);
if (searchAction != null)
loaded.AddLink(text, () => searchAction(text));
else
loaded.AddLink(text, LinkAction.SearchBeatmapSet, text);
break;
default:

View File

@ -1,8 +1,6 @@
// 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.
#nullable disable
using System.Linq;
using osu.Framework.Allocation;
using osu.Framework.Extensions.Color4Extensions;
@ -38,15 +36,18 @@ namespace osu.Game.Screens.Select
private readonly LoadingLayer loading;
[Resolved]
private IAPIProvider api { get; set; }
private IAPIProvider api { get; set; } = null!;
private IBeatmapInfo beatmapInfo;
[Resolved]
private SongSelect? songSelect { get; set; }
private APIFailTimes failTimes;
private IBeatmapInfo? beatmapInfo;
private int[] ratings;
private APIFailTimes? failTimes;
public IBeatmapInfo BeatmapInfo
private int[]? ratings;
public IBeatmapInfo? BeatmapInfo
{
get => beatmapInfo;
set
@ -56,7 +57,7 @@ namespace osu.Game.Screens.Select
beatmapInfo = value;
var onlineInfo = beatmapInfo as IBeatmapOnlineInfo;
var onlineSetInfo = beatmapInfo.BeatmapSet as IBeatmapSetOnlineInfo;
var onlineSetInfo = beatmapInfo?.BeatmapSet as IBeatmapSetOnlineInfo;
failTimes = onlineInfo?.FailTimes;
ratings = onlineSetInfo?.Ratings;
@ -140,9 +141,9 @@ namespace osu.Game.Screens.Select
LayoutEasing = Easing.OutQuad,
Children = new[]
{
description = new MetadataSection(MetadataType.Description),
source = new MetadataSection(MetadataType.Source),
tags = new MetadataSection(MetadataType.Tags),
description = new MetadataSection(MetadataType.Description, searchOnSongSelect),
source = new MetadataSection(MetadataType.Source, searchOnSongSelect),
tags = new MetadataSection(MetadataType.Tags, searchOnSongSelect),
},
},
},
@ -175,6 +176,12 @@ namespace osu.Game.Screens.Select
},
loading = new LoadingLayer(true)
};
void searchOnSongSelect(string text)
{
if (songSelect != null)
songSelect.FilterControl.CurrentTextSearch.Value = text;
}
}
private void updateStatistics()

View File

@ -31,6 +31,8 @@ namespace osu.Game.Screens.Select
public Action<FilterCriteria> FilterChanged;
public Bindable<string> CurrentTextSearch => searchTextBox.Current;
private OsuTabControl<SortMode> sortTabs;
private Bindable<SortMode> sortMode;
@ -63,6 +65,7 @@ namespace osu.Game.Screens.Select
}
private SeekLimitedSearchTextBox searchTextBox;
private CollectionFilterDropdown collectionDropdown;
public override bool ReceivePositionalInputAt(Vector2 screenSpacePos) =>