Refactor **Actor tags into hierarchical reusable Tags** system for better gameplay scripting

This commit is contained in:
Wojtek Figat
2022-12-20 21:09:51 +01:00
parent 1cf6c5233e
commit a570d6d178
18 changed files with 991 additions and 239 deletions

View File

@@ -949,14 +949,15 @@ namespace FlaxEditor.Utilities
/// </summary>
/// <param name="searchBox">The search box.</param>
/// <param name="tree">The tree control.</param>
/// <param name="headerHeight">Amount of additional space above the search box to put custom UI.</param>
/// <returns>The created menu to setup and show.</returns>
public static ContextMenuBase CreateSearchPopup(out TextBox searchBox, out Tree tree)
public static ContextMenuBase CreateSearchPopup(out TextBox searchBox, out Tree tree, float headerHeight = 0)
{
var menu = new ContextMenuBase
{
Size = new Float2(320, 220),
Size = new Float2(320, 220 + headerHeight),
};
searchBox = new TextBox(false, 1, 1)
searchBox = new TextBox(false, 1, headerHeight + 1)
{
Width = menu.Width - 3,
WatermarkText = "Search...",
@@ -980,6 +981,33 @@ namespace FlaxEditor.Utilities
return menu;
}
/// <summary>
/// Updates (recursivly) search popup tree structures based on the filter text.
/// </summary>
public static void UpdateSearchPopupFilter(TreeNode node, string filterText)
{
// Update children
bool isAnyChildVisible = false;
for (int i = 0; i < node.Children.Count; i++)
{
if (node.Children[i] is TreeNode child)
{
UpdateSearchPopupFilter(child, filterText);
isAnyChildVisible |= child.Visible;
}
}
// Update itself
bool noFilter = string.IsNullOrWhiteSpace(filterText);
bool isThisVisible = noFilter || QueryFilterHelper.Match(filterText, node.Text);
bool isExpanded = isAnyChildVisible;
if (isExpanded)
node.Expand(true);
else
node.Collapse(true);
node.Visible = isThisVisible | isAnyChildVisible;
}
/// <summary>
/// Gets the asset name relative to the project root folder (without asset file extension)
/// </summary>