Class Ui
- Namespace
- Ofs
- Assembly
- Ofs.Api.dll
Immediate-mode widgets, drawn each frame inside OnRenderUi(Ui). Boolean-returning widgets report "changed this frame"; value widgets bind through ref.
Conventions: widget width is host-owned — there is no pixel-size parameter; a widget fills
the available width, and widgets inside Row(string, Action) split it evenly, so plugin UI is
automatically font-, DPI- and translation-safe (use Section(string, Action)/Row(string, Action) for
layout). Labels and titles are rendered verbatim — localizing them is the plugin's job.
maxBytes parameters count UTF-8 bytes, not characters (a CJK glyph is 3 bytes, an emoji 4),
so size text buffers generously for non-ASCII input.
public sealed class Ui
- Inheritance
-
objectUi
Methods
Button(string)
A clickable button. Returns true on the frame it is clicked.
public bool Button(string label)
Parameters
labelstring
Returns
Checkbox(string, ref bool)
A boolean checkbox bound to value. Returns true on the frame it changes.
public bool Checkbox(string label, ref bool value)
Parameters
Returns
ColorEdit(string, ref Vector4, bool)
Color editor; each channel is 0..1. Returns true the frame it is edited. When
alpha is false the alpha channel is hidden and color.W is left
unchanged (RGB-only editing).
public bool ColorEdit(string label, ref Vector4 color, bool alpha = true)
Parameters
Returns
Combo(string, ref int, IReadOnlyList<string>)
A dropdown over items, bound to the selected index.
Returns true on the frame the selection changes. For an enum-bound combo, prefer the
Combo<TEnum>(string, ref TEnum, Func<TEnum, string>) overload.
public bool Combo(string label, ref int index, IReadOnlyList<string> items)
Parameters
labelstringindexintitemsIReadOnlyList<string>
Returns
Combo<TEnum>(string, ref TEnum, Func<TEnum, string>)
Binds directly to an enum with a caller-supplied label per member — the localized,
order-safe way to drive an enum from a combo. labelOf maps each member to its
display string (typically a Str.* catalog entry), so the combo follows the active UI
language, and because the binding is by enum value (not list position) reordering or
inserting members can never mismap a label. This replaces the manual pattern of a parallel
ordering array plus index ↔ value bookkeeping around the
Combo(string, ref int, IReadOnlyList<string>) overload.
public bool Combo<TEnum>(string label, ref TEnum value, Func<TEnum, string> labelOf) where TEnum : struct, Enum
Parameters
Returns
Type Parameters
TEnum
Disabled(bool, Action)
Draws the widgets in body greyed and non-interactive when
disabled is true (a no-op wrapper when false). Balanced and depth-guarded by
the host — an exception thrown in body cannot leave the block open.
public void Disabled(bool disabled, Action body)
Parameters
Disabled(bool, string, Action)
Like Disabled(bool, Action), but while disabled, hovering any greyed
widget in body shows tooltipWhenDisabled explaining why —
a hover-on-demand replacement for an always-visible disclaimer line. The tooltip never appears
while enabled, so pass "" (or anything) for the enabled case.
public void Disabled(bool disabled, string tooltipWhenDisabled, Action body)
Parameters
DragFloat(string, ref float, float, float, float, int)
A draggable float. decimals (0..9) is the displayed
fractional-digit count.
public bool DragFloat(string label, ref float value, float speed = 1, float min = 0, float max = 0, int decimals = 3)
Parameters
Returns
DragInt(string, ref int, float, int, int)
A draggable integer. speed scales the drag; min
equal to max (the default) leaves the value unbounded.
public bool DragInt(string label, ref int value, float speed = 1, int min = 0, int max = 0)
Parameters
Returns
InputFloat(string, ref float, float, bool, int)
A float input box. The -/+ buttons appear only when stepButtons is
true and step > 0 (the amount each button applies); pass false to force
them off regardless of step. decimals (0..9) is the
displayed fractional-digit count.
public bool InputFloat(string label, ref float value, float step = 0, bool stepButtons = true, int decimals = 3)
Parameters
Returns
InputInt(string, ref int, int, bool)
An integer input box. step is the amount each -/+ button applies.
Set stepButtons to false to drop the -/+ buttons (e.g. when laying two inputs
side-by-side in a narrow panel, where the fixed-size buttons would overflow).
public bool InputInt(string label, ref int value, int step = 1, bool stepButtons = true)
Parameters
Returns
InputText(string, ref string, int, bool, bool)
Single-line text box. maxBytes caps the UTF-8 edit buffer
(including the trailing NUL); a longer initial value is truncated to fit. Set
password to mask the text, or readOnly to display it
without allowing edits.
public bool InputText(string label, ref string value, int maxBytes = 256, bool password = false, bool readOnly = false)
Parameters
Returns
InputTextMultiline(string, ref string, int, int, bool)
Multi-line text box. maxBytes caps the UTF-8 edit buffer (incl. the
trailing NUL); heightLines is the visible height in text lines (0 = default).
Set readOnly to display the text without allowing edits.
public bool InputTextMultiline(string label, ref string value, int maxBytes = 4096, int heightLines = 0, bool readOnly = false)
Parameters
Returns
Label(string)
A single line of unwrapped text. For wrapping paragraphs use LabelWrapped(string).
public void Label(string text)
Parameters
textstring
LabelWrapped(string)
Word-wrapped paragraph text. Unlike Label(string) (a single unwrapped line), this wraps to the available width — use it for sentences and disclaimers.
public void LabelWrapped(string text)
Parameters
textstring
Node()
A capture-safe handle to the node currently rendering its body UI. Grab one inside a
node's ui callback when a deferred/async write needs to update the node's state later (a
TState value can't be captured by ref across an await): capture the returned
Node() and call Update<TState>(StateMutator<TState>) when the work completes. Outside a
node UI pass the handle is inert (its Update is a no-op).
public Node Node()
Returns
ProgressBar(float, string?)
A progress bar; fraction is clamped to 0..1. Optional overlay text.
public void ProgressBar(float fraction, string? overlay = null)
Parameters
RadioButton(string, ref int, int)
A radio button bound to a shared int: selected when value equals
option; clicking sets value to option.
Returns true on the frame it is clicked.
public bool RadioButton(string label, ref int value, int option)
Parameters
Returns
Row(string, Action)
Lays the widgets drawn inside body out on a single horizontal
line, with an optional left-hand label. Width-bearing widgets (sliders,
inputs, drags, combos) share the row width evenly. Balanced and depth-guarded by the host —
an exception thrown in body cannot leave the row open.
public void Row(string label, Action body)
Parameters
Section(string, Action)
Groups the widgets drawn in body under a titled heading, laid out as a
2-column label/value form. Balanced and depth-guarded by the host — an exception in
body cannot leave the section open.
public void Section(string title, Action body)
Parameters
Separator()
A horizontal separator line.
public void Separator()
Slider(string, ref int, int, int)
An integer slider over the inclusive range min..max.
Returns true on the frame it changes.
public bool Slider(string label, ref int value, int min, int max)
Parameters
Returns
Slider(string, ref float, float, float, int)
A float slider. decimals (0..9) is the displayed fractional-digit
count.
public bool Slider(string label, ref float value, float min, float max, int decimals = 3)
Parameters
Returns
Tooltip(string)
Attaches a hover tooltip to the most recently drawn widget — call immediately after it. A no-op if no widget precedes it, and it does not appear on a disabled widget (use the Disabled(bool, string, Action) overload for that).
public void Tooltip(string text)
Parameters
textstring