swiftlys2/docs/api/releases/features/ai/
API Reference › Menu.Components

PlayerListComponent

Class
Namespace: SwiftlyS2.Shared.Menu.Components · Assembly: SwiftlyS2.CS2.dll
public sealed class PlayerListComponent : MenuComponentBase, IMenuComponent, IMenuRowSource
View source

Constructors

PlayerListComponent(string?)

Creates a player list.

public PlayerListComponent(string? id = null)
Parameters
  • idstring?optionalA stable id, or null to generate one.

Properties

ClearButton

The button that clears the search. Only shown while a search is active.

public ButtonComponent ClearButton { get; }
Property Value

DefaultTarget

The target used when the search is empty.

public string DefaultTarget { get; set; }
Property Value

EmptyColor

The colour of EmptyText, or null for the default colour.

public string? EmptyColor { get; set; }
Property Value

EmptyText

The text shown when nobody matches, or null for the translated default.

public string? EmptyText { get; set; }
Property Value

Filter

An extra filter applied after the search, or null to keep every match. Receives the viewer and the candidate.

public Func<IPlayer, IPlayer, bool>? Filter { get; set; }
Property Value

Formatter

Turns a player into the text shown for them. An empty result shows the translated unknown-player text.

public Func<IPlayer, string> Formatter { get; set; }
Property Value

ItemHint

The hint shown while a player row holds the selection, or null for none.

public Func<IPlayer, string?>? ItemHint { get; set; }
Property Value

ItemStyle

The style of a player row.

public MenuTextStyle ItemStyle { get; set; }
Property Value

MaxResults

The most players listed, or null for no limit.

public int? MaxResults { get; set; }
Property Value

NameComparison

How player names are compared.

public StringComparison NameComparison { get; set; }
Property Value

NodeFormatter

Turns a player into a full node, for lines with several colours. Takes over from Formatter when set.

public Func<IPlayer, MenuNode>? NodeFormatter { get; set; }
Property Value

OnPlayerDeselected

Runs when the focus leaves a player row. Target is the player it left.

public Action<MenuPlayerContext>? OnPlayerDeselected { get; set; }
Property Value

OnPlayerSelected

Runs when a player activates a row.

public Action<MenuPlayerContext>? OnPlayerSelected { get; set; }
Property Value

RefreshInterval

How often the list is looked up again so joins and leaves show up.

public TimeSpan RefreshInterval { get; set; }
Property Value

RowRenderer

Draws a player row with full control over its layout, including its index and focus. Takes over from NodeFormatter and Formatter when set. The busy placeholder still shows while a row waits on an action.

public Func<MenuPlayerRowContext, MenuNode>? RowRenderer { get; set; }

SearchInput

The search line. Its empty text and hint come from the translation file on every rebuild, so set them there.

public InputComponent SearchInput { get; }
Property Value

SearchMode

The search mode passed to StringComparison).

public TargetSearchMode SearchMode { get; set; }
Property Value

ShowClearButton

Whether ClearButton is shown while a search is active.

public bool ShowClearButton { get; set; }
Property Value

ShowSearch

Whether the search line is shown. The filter can still be set with String).

public bool ShowSearch { get; set; }
Property Value

Sorter

Orders the matches, or null to keep the order the search returns.

public Func<IEnumerable<IPlayer>, IEnumerable<IPlayer>>? Sorter { get; set; }

Methods

GetFilter(IMenuSession)

Reads the search text of one session.

public string GetFilter(IMenuSession session)
Parameters
Returns

GetRows(IMenuSession, MenuRowContext)

The body entries this component stands for right now.

public IReadOnlyList<IMenuComponent> GetRows(IMenuSession session, MenuRowContext context)
Parameters

Refresh(IMenuSession)

Looks the list up again for one session on its next draw.

public void Refresh(IMenuSession session)
Parameters

Render(IMenuComponentRenderContext)

Produces this component's renderer-agnostic output.

public override MenuNode Render(IMenuComponentRenderContext context)
Parameters
Returns
The nodes describing this component.

Never drawn: the menu replaces this component with MenuRowContext) when it lays out the body.

SetFilter(IMenuSession, string)

Sets the search text of one session.

public void SetFilter(IMenuSession session, string text)
Parameters

RowsChanged

Raised when MenuRowContext) would return something different.

public event Action? RowsChanged
Value