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

View File

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

View File

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