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

PagedCollectionComponent`1

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

Constructors

PagedCollectionComponent(Func<Task<IReadOnlyList<TItem>>>, string?)

Creates a collection.

public PagedCollectionComponent(Func<Task<IReadOnlyList<TItem>>> loader, string? id = null)
Parameters
  • loaderFunc<Task<IReadOnlyList<TItem>>>Produces the items. Runs on the collection loader thread.
  • idstring?optionalA stable id, or null to generate one.

Properties

EmptyColor

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

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

EmptyText

The text shown when the loader returns no items.

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

FailedColor

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

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

FailedText

The text shown when the loader throws.

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

Formatter

Turns an item into the text shown for it.

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

ItemHint

The hint shown while an item row holds the selection, or null for none.

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

ItemStyle

The style of an item row.

public MenuTextStyle ItemStyle { get; set; }
Property Value

LoadingColor

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

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

LoadingText

The text shown while the loader is running.

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

NodeFormatter

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

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

OnItemSelected

Runs when a player activates an item row.

public Action<MenuCollectionItemContext<TItem>>? OnItemSelected { get; set; }
Property Value
Action<MenuCollectionItemContext<TItem>>?

RowRenderer

Draws an item 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<MenuCollectionRowContext<TItem>, MenuNode>? RowRenderer { get; set; }
Property Value
Func<MenuCollectionRowContext<TItem>, MenuNode>?

ShowFailureMessage

Whether the exception message is appended to FailedText.

public bool ShowFailureMessage { get; set; }
Property Value

Methods

GetRows(IMenuSession, MenuRowContext)

The body entries this component stands for right now.

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

Reload()

Runs the loader again. Open menus update when it finishes. Does nothing before the first layout.

public void Reload()

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.

RowsChanged

Raised when MenuRowContext) would return something different.

public event Action? RowsChanged
Value