Filtering reagents (#18211)

* Making it work

* Refactoring

* Autoformat revert

* Implementing suggestions

* Changed to file scoped namespaces.
This commit is contained in:
Hebi
2023-07-26 10:05:09 +02:00
committed by GitHub
parent 158af403e8
commit 756699ffcc
9 changed files with 171 additions and 10 deletions

View File

@@ -3,6 +3,7 @@ using System.Linq;
using Content.Client.Chemistry.EntitySystems;
using Content.Client.Guidebook.Richtext;
using Content.Client.Message;
using Content.Client.UserInterface.ControlExtensions;
using Content.Shared.Chemistry.Reaction;
using Content.Shared.Chemistry.Reagent;
using JetBrains.Annotations;
@@ -20,7 +21,7 @@ namespace Content.Client.Guidebook.Controls;
/// Control for embedding a reagent into a guidebook.
/// </summary>
[UsedImplicitly, GenerateTypedNameReferences]
public sealed partial class GuideReagentEmbed : BoxContainer, IDocumentTag
public sealed partial class GuideReagentEmbed : BoxContainer, IDocumentTag, ISearchableControl
{
[Dependency] private readonly IEntitySystemManager _systemManager = default!;
[Dependency] private readonly IPrototypeManager _prototype = default!;
@@ -45,6 +46,16 @@ public sealed partial class GuideReagentEmbed : BoxContainer, IDocumentTag
GenerateControl(reagent);
}
public bool CheckMatchesSearch(string query)
{
return this.ChildrenContainText(query);
}
public void SetHiddenState(bool state, string query)
{
this.Visible = CheckMatchesSearch(query) ? state : !state;
}
public bool TryParseTag(Dictionary<string, string> args, [NotNullWhen(true)] out Control? control)
{
control = null;