momentum-mod / lumper

BSP lump editor and review tool
MIT License
23 stars 14 forks source link

Pakfile Explorer Searching #57

Open tsa96 opened 2 months ago

tsa96 commented 2 months ago

Add a text box to the top bar of the pakfile explorer page to filter displayed items.

This is probably quite challenging. As far as I can tell, TreeDataGrid doesn't have a specific property for whether a node should be displayed or not; it just displays item in a list of a node's children (you provide an accessor function https://github.com/momentum-mod/lumper/blob/f68c05b02a0f3003f8ba0293c20a065a9f406844/src/Lumper.UI/ViewModels/Pages/PakfileExplorer/PakfileExplorerViewModel.cs#L56-L71).

So when the search changes, every node in the tree needs to determine which of it's children to display.

Probably the best way to do this is to change every directory node to hold a SourceList _source of all children, then track changes to a child node's reactive property IsVisible then do something like _source.Connect().AutoRefresh(x => x.IsVisible).Filter(x => x.IsVisible).BindTo(this, x => x.FilteredChildren); where FilteredChildren is an ObservableCollection, then determine if this node should be visible with FilteredChildren.CountChanged.Select(x => x > 0).Subscribe(x => IsVisible = x) (probably don't want ToPropertyEx here since IsVisible with be a regular reactive property not an ObservableAsProperty). Leaf nodes then listen to the search input children and change their IsVisible property accordingly, which should bubble up through the tree.

Hoooopefully that approach is okay. It sounds very expensive but not sure of alternatives due to how TreeDataGrid works.

This is mostly blocked until https://github.com/momentum-mod/lumper/pull/39 is merged. Someone could get started if they want, but pakfile explorer code on that branch may change.

tsa96 commented 2 months ago

Whilst doing this we should also do a checkbox to allow filtering out cubemaps and .vhv files.