mirror of
https://github.com/ppy/osu.git
synced 2025-02-20 00:52:56 +08:00
Allow specifying custom search action to metadata sections
This commit is contained in:
parent
cd085cbd97
commit
eafa11555a
@ -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:
|
||||||
|
if (searchAction != null)
|
||||||
|
loaded.AddLink(text, () => searchAction(text));
|
||||||
|
else
|
||||||
loaded.AddLink(text, LinkAction.SearchBeatmapSet, text);
|
loaded.AddLink(text, LinkAction.SearchBeatmapSet, text);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
Loading…
Reference in New Issue
Block a user