UI/SpawnMenu/Props/SpawnPageLocal.razor

A Razor UI panel for the spawn menu that shows local props. It renders a search box, toolbar and a grid of prop icons filtered by category and search text, and rebuilds the displayed list when parameters or language change.

File Access
@using Sandbox;
@using Sandbox.UI;

@inherits Panel
@namespace Sandbox

<SpawnMenuContent>

    <Header>
        <SpawnMenuToolbar>
            <Left>
                <TextEntry Placeholder="#spawnmenu.common.search" class="filter menu-input" Value:bind=@Filter />
            </Left>
        </SpawnMenuToolbar>
    </Header>

    <Body>
        @if ( Entries.Count == 0 )
        {
            <SpawnMenuEmptyState Icon="search_off" Subtitle="#spawnmenu.empty.try_another_category" />
        }
        else
        {
            <VirtualGrid Items=@Entries ItemSize=@(new Vector2( 123, 123 ))>
                <Item Context="item">
                    @if ( item is LocalProps.Entry entry )
                    {
                        <SpawnMenuIcon Ident=@($"prop:{entry.Path}") Title=@(entry.Title ?? entry.DisplayName) />
                    }
                </Item>
            </VirtualGrid>
        }
    </Body>

</SpawnMenuContent>

@code
{
    public string Category { get; set; } = "";

    private string Filter
    {
        get;
        set { field = value; Rebuild(); }
    }

    private List<LocalProps.Entry> Entries = new();

    protected override void OnParametersSet()
    {
        Rebuild();
    }

    /// <summary>
    /// Reapplies the active search to the translated prop names.
    /// </summary>
    public override void LanguageChanged()
    {
        base.LanguageChanged();
        Rebuild();
    }

    void Rebuild()
    {
        var source = string.IsNullOrEmpty( Category )
            ? LocalProps.All
            : LocalProps.All.Where( x => x.Category == Category ).ToList();

        if ( !string.IsNullOrWhiteSpace( Filter ) )
            source = source.Where( x => x.DisplayName.Contains( Filter, StringComparison.CurrentCultureIgnoreCase )
                                     || x.Path.Contains( Filter, StringComparison.OrdinalIgnoreCase ) ).ToList();

        Entries = source;
        StateHasChanged();
    }
}