swiftlys2/docs/api/ai/
API Reference › Menu

MenuTextLayout

Class
Namespace: SwiftlyS2.Shared.Menu · Assembly: SwiftlyS2.CS2.dll
public static class MenuTextLayout
Inherits object

Fits text into a width budget, scrolling it when asked.

Widths are measured with String), which weighs wide scripts more than latin characters, so a budget is roughly "this many capital letters" rather than a plain character count.

View source

Methods

Apply(string, MenuTextOverflow, float, MenuTextScrollState, DateTime, int, int)

Fits text into a width budget, advancing the animation when one is running.

public static string Apply(string text, MenuTextOverflow overflow, float maxWidth, MenuTextScrollState state, DateTime now, int updateIntervalMs = 120, int pauseIntervalMs = 1000)
Parameters
  • textstringThe text to fit.
  • overflowMenuTextOverflowWhat to do when the text does not fit.
  • maxWidthfloatThe width budget. Values below one disable fitting.
  • stateMenuTextScrollStateThis player's scroll position. Ignored by the truncating modes.
  • nowDateTimeThe current time.
  • updateIntervalMsintoptionalHow often the animation advances.
  • pauseIntervalMsintoptionalHow long to rest at the end of a cycle.
Returns
The text to display.

IsScrolling(MenuTextOverflow)

Whether an overflow mode animates over time.

public static bool IsScrolling(MenuTextOverflow overflow)
Parameters
Returns
true for the scrolling modes.

NeedsRedraw(string, MenuTextOverflow, float, MenuTextScrollState, DateTime, int)

Whether the animation would advance if a frame were drawn now.

public static bool NeedsRedraw(string text, MenuTextOverflow overflow, float maxWidth, MenuTextScrollState state, DateTime now, int updateIntervalMs = 120)
Parameters
Returns
true when a redraw would show something different.

Fields

MinimumIntervalMs

The shortest interval an animation may advance at.

public const int MinimumIntervalMs = 15
Field Value