TextComponent
Classpublic class TextComponent : MenuComponentBase, IMenuComponentA line of text that can be scrolled to but never does anything when activated.
The text may be fixed or produced per player through TextProvider, which is evaluated on every frame. Text wider than MaxWidth is truncated or scrolled according to Overflow, independently for every player looking at it.
View sourceConstructors
Properties
The colour applied when the component is disabled, or null to keep Style.
public string? DisabledColor { get; set; }Whether the selection can land on this component.
public override bool IsFocusable { get; }A label can hold the selection like any other body entry, so a menu scrolls past it rather than skipping over it, but it never overrides MenuActionContext) so activating it is always a no-op.
The width the text is fitted into.
public float MaxWidth { get; set; }Measured with String), so it is a weighted width rather than a character count. Values below one turn fitting off.
What happens to text wider than MaxWidth.
public MenuTextOverflow Overflow { get; set; }How long a scrolling animation rests at the end of a cycle, in milliseconds. Never below 15.
public int PauseIntervalMs { get; set; }Presentation hints applied to the text.
public MenuTextStyle Style { get; set; }The text shown when TextProvider is null or returns null.
public string Text { get; set; }Produces the text per player. Returning null falls back to Text.
public Func<IMenuSession, string?>? TextProvider { get; set; }How often a scrolling animation advances, in milliseconds. Never below 15.
public int UpdateIntervalMs { get; set; }Methods
Whether this component needs a new frame even though nothing invalidated the session.
public override bool NeedsRedraw(IMenuSession session, DateTime now)- sessionIMenuSessionThe session asking.
- nowDateTimeThe current time.
Asked once per tick for every visible component of an otherwise clean session, so keep the check cheap. Animated text and live values are what this exists for.
Resolves the text to display for a session without fitting it.
protected string RawText(IMenuSession session)- sessionIMenuSessionThe session to resolve for.
Produces this component's renderer-agnostic output.
public override MenuNode Render(IMenuComponentRenderContext context)- contextIMenuComponentRenderContextThe player and focus state to draw for.
Produces the placeholder shown while an activation is still running.
protected MenuNode? RenderWaiting(IMenuComponentRenderContext context)- contextIMenuComponentRenderContextThe context being drawn.
Components that build their own node tree should return this first when it is not null, so a slow callback is visible to the player rather than looking like a dead key.
Resolves the style to draw with, accounting for the disabled state.
protected virtual MenuTextStyle ResolveStyle(IMenuComponentRenderContext context)- contextIMenuComponentRenderContextThe context being drawn.
Resolves the text to display for a session, fitted to MaxWidth.
protected string ResolveText(IMenuSession session)- sessionIMenuSessionThe session to resolve for.