diff --git a/Content.Client/UserInterface/Systems/Ghost/Controls/GhostTargetWindow.xaml b/Content.Client/UserInterface/Systems/Ghost/Controls/GhostTargetWindow.xaml index df42f22c47..86fd09b2c8 100644 --- a/Content.Client/UserInterface/Systems/Ghost/Controls/GhostTargetWindow.xaml +++ b/Content.Client/UserInterface/Systems/Ghost/Controls/GhostTargetWindow.xaml @@ -1,15 +1,10 @@ - - - - - - + + + + + + + + + diff --git a/Content.Client/UserInterface/Systems/Ghost/Controls/GhostTargetWindow.xaml.cs b/Content.Client/UserInterface/Systems/Ghost/Controls/GhostTargetWindow.xaml.cs index 3d86266df8..3c17697c25 100644 --- a/Content.Client/UserInterface/Systems/Ghost/Controls/GhostTargetWindow.xaml.cs +++ b/Content.Client/UserInterface/Systems/Ghost/Controls/GhostTargetWindow.xaml.cs @@ -12,12 +12,14 @@ namespace Content.Client.UserInterface.Systems.Ghost.Controls public sealed partial class GhostTargetWindow : DefaultWindow { private List<(string, NetEntity)> _warps = new(); + private string _searchText = string.Empty; public event Action? WarpClicked; public GhostTargetWindow() { RobustXamlLoader.Load(this); + SearchBar.OnTextChanged += OnSearchTextChanged; } public void UpdateWarps(IEnumerable warps) @@ -60,9 +62,31 @@ namespace Content.Client.UserInterface.Systems.Ghost.Controls }; currentButtonRef.OnPressed += _ => WarpClicked?.Invoke(warpTarget); + currentButtonRef.Visible = ButtonIsVisible(currentButtonRef); ButtonContainer.AddChild(currentButtonRef); } } + + private bool ButtonIsVisible(Button button) + { + return string.IsNullOrEmpty(_searchText) || button.Text == null || button.Text.Contains(_searchText, StringComparison.OrdinalIgnoreCase); + } + + private void UpdateVisibleButtons() + { + foreach (var child in ButtonContainer.Children) + { + if (child is Button button) + button.Visible = ButtonIsVisible(button); + } + } + + private void OnSearchTextChanged(LineEdit.LineEditEventArgs args) + { + _searchText = args.Text; + + UpdateVisibleButtons(); + } } }