diff --git a/project/code/TMV/UI/TextureBrowser.cs b/project/code/TMV/UI/TextureBrowser.cs index 0b9d4cf..84088d1 100644 --- a/project/code/TMV/UI/TextureBrowser.cs +++ b/project/code/TMV/UI/TextureBrowser.cs @@ -1,3 +1,4 @@ +using System.Text.RegularExpressions; using Godot; namespace KeepersCompound.TMV.UI; @@ -28,6 +29,8 @@ public partial class TextureBrowser : Node _previewTexture = GetNode("%PreviewTexture"); _texturePath = GetNode("%PathBox"); + _searchBar.TextChanged += ApplySearchFilter; + BuildFolderTree(); BuildTextureList(); // TODO: This should be triggered on folder change } @@ -67,6 +70,7 @@ public partial class TextureBrowser : Node textureRect.SetAnchorsPreset(Control.LayoutPreset.FullRect); var slot = new Panel(); + slot.Name = name; slot.CustomMinimumSize = new Vector2(128, 128); slot.AddChild(textureRect); slot.GuiInput += (input) => @@ -88,4 +92,14 @@ public partial class TextureBrowser : Node _previewTexture.Texture = texture; _texturePath.Text = name; } + + private void ApplySearchFilter(string filter) + { + var regexString = "^.*" + Regex.Escape(filter).Replace("\\*", ".*") + ".*$"; + foreach (var node in _textureList.GetChildren()) + { + var panel = (Panel)node; + panel.Visible = Regex.IsMatch(panel.Name.ToString(), regexString); + } + } }