Skip to content

Commit 00127b3

Browse files
committed
Add search box to user tag control
1 parent 3d4dd85 commit 00127b3

File tree

1 file changed

+42
-14
lines changed

1 file changed

+42
-14
lines changed

osu.Game/Screens/Ranking/UserTagControl.cs

+42-14
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
using osu.Framework.Graphics.Shapes;
1818
using osu.Framework.Graphics.Sprites;
1919
using osu.Framework.Graphics.UserInterface;
20+
using osu.Framework.Localisation;
2021
using osu.Game.Beatmaps;
2122
using osu.Game.Configuration;
2223
using osu.Game.Extensions;
@@ -447,6 +448,9 @@ protected override void LoadComplete()
447448

448449
private partial class ExtraTagsPopover : OsuPopover
449450
{
451+
private SearchTextBox searchBox = null!;
452+
private SearchContainer searchContainer = null!;
453+
450454
public BindableList<UserTag> ExtraTags { get; } = new BindableList<UserTag>();
451455

452456
public Action<UserTag>? OnSelected { get; set; }
@@ -457,28 +461,43 @@ private void load()
457461
Child = new OsuScrollContainer
458462
{
459463
Width = 250,
460-
Height = 200,
464+
Height = 250,
461465
ScrollbarOverlapsContent = false,
462-
Child = new FillFlowContainer
466+
Children = new Drawable[]
463467
{
464-
RelativeSizeAxes = Axes.X,
465-
AutoSizeAxes = Axes.Y,
466-
Padding = new MarginPadding { Right = 5 },
467-
Spacing = new Vector2(10),
468-
ChildrenEnumerable = ExtraTags.Select(tag => new DrawableExtraTag(tag)
468+
searchBox = new SearchTextBox
469+
{
470+
RelativeSizeAxes = Axes.X,
471+
},
472+
searchContainer = new SearchContainer
469473
{
470-
Action = () =>
474+
RelativeSizeAxes = Axes.X,
475+
AutoSizeAxes = Axes.Y,
476+
Direction = FillDirection.Vertical,
477+
Padding = new MarginPadding { Right = 5, Top = 50, },
478+
Spacing = new Vector2(10),
479+
ChildrenEnumerable = ExtraTags.Select(tag => new DrawableExtraTag(tag)
471480
{
472-
OnSelected?.Invoke(tag);
473-
this.HidePopover();
474-
}
475-
})
476-
}
481+
Action = () =>
482+
{
483+
OnSelected?.Invoke(tag);
484+
this.HidePopover();
485+
}
486+
})
487+
}
488+
},
477489
};
478490
}
491+
492+
protected override void LoadComplete()
493+
{
494+
base.LoadComplete();
495+
496+
searchBox.Current.BindValueChanged(_ => searchContainer.SearchTerm = searchBox.Current.Value, true);
497+
}
479498
}
480499

481-
private partial class DrawableExtraTag : OsuAnimatedButton
500+
private partial class DrawableExtraTag : OsuAnimatedButton, IFilterable
482501
{
483502
private readonly UserTag tag;
484503

@@ -527,6 +546,15 @@ private void load(OsuColour colours)
527546
}
528547
});
529548
}
549+
550+
public IEnumerable<LocalisableString> FilterTerms => [tag.Name, tag.Description];
551+
552+
public bool MatchingFilter
553+
{
554+
set => Alpha = value ? 1 : 0;
555+
}
556+
557+
public bool FilteringActive { set { } }
530558
}
531559
}
532560

0 commit comments

Comments
 (0)