Authoring RON UI files
The engine’s UI documents are hand-written RON deserialized into the real Rust
types in manifold-ui-protocol. Validate files with ui-validate; optional
editor support is described below.
Document format
Every document whose root is a widget tree (a window or workbench .ui.ron,
a HUD layer, a component, a plugin extension or overlay) is wrapped in a
versioned envelope:
UiDocument(
format_version: 1,
root: Window(
title: Localized(key: "mymod.shop.title"),
bui_key: "mymod:shop",
closeable: true,
draggable: true,
root: Label(text: Localized(key: "mymod.shop.empty")),
),
)
Themes and .override.ron files have their own shapes and no envelope.
The format was broken once, in Enki C’s P0 (Enki C §13), and is append-only
since. There is no reader for the old shape: a document without the
envelope, or with another format_version, is refused with an error that
names the file (engine.ui.document.legacy, …unsupported). To bring a
pre-P0 document forward: wrap its root as above; write Slider limits as
min: Literal(0.0) or Bind("…"); and write input actions as
action: Some(…).
Inputs say where an edit goes. TextEdit, Slider, Checkbox,
Dropdown and the look’s fields (NumberField, Vec3Field, Segmented,
ToolRail) take action: Option<ActionDef>. None is allowed only on a
Local.* binding, which is written in place; a Local.* binding with an
action is refused. In a mod document the action is Some(Ron("<node id>")):
the id names the node in the UiEvent the mod receives.
Local state. A LocalState node declares fields its subtree reads and
writes as Local.<name>, without the server or the mod:
LocalState(
fields: [
(name: "radius", kind: F32, default: F32(4.0)),
(name: "advanced", kind: Bool, default: Bool(false)),
],
child: NumberField(binding: "Local.radius", min: Some(Literal(1.0))),
)
Kinds are String, F32, U16, U32 and Bool. Values reset when the
window closes. persist: true is refused until persistence lands.
Workbench. A Workbench is a full-screen layer (Enki C §3.15) and must be
the document root. It takes module, bui_key, a header, a tool_rail,
an area (Fixed(panes: One(…) | Quad(…), right_dock, bottom_dock)) and a
status_bar. The host reads the panes’ rectangles for input routing
(look_render::workbench_panes). Key hints and status-bar hints draw the
action’s current binding.
Fields without a runtime yet are refused at load, naming the field and
what it waits for: WorkbenchArea::Docked, Workbench.menu_bar,
ToolRail.source, PaneHeader.menu, StatusBar.modifier_hints,
Dropdown.source, Dropdown.searchable and LocalField.persist. Focus
fields (focus, Window.back) parse, and ui-validate checks that a nav
target names a node of the document, but navigation waits for the input
system.
Mod documents
A mod ships its documents in its own asset tree and registers them by path:
UiBuilder::new("mymod", "mymod:shop")
.field("price", BindingValueKind::U32)
.tree_asset("ui/shop.ui.ron") // assets/ui/shop.ui.ron in the mod
.build()
The host reads the file from the mod’s archive when the mod loads; the root’s
bui_key (the string form "<mod-id>:<name>") must be the registration’s
key. A missing, legacy or mismatched document is refused naming
<mod-id>:<path>, and so is, on the client, a document using a message key
that its mod’s and the engine’s catalogs lack; on the server the mod’s UIs are then disabled, on the
client the mod’s client-ui.open reports the reason. .client_authority()
serves the UI from the mod’s client instance (see the
mod contract). ui-validate
checks a mod document against its mod’s catalogs (the nearest mod.toml).
1. Validate before you run — ui-validate
# validate a single file (or a directory of them):
cargo run -p manifold-ui-validate --bin ui-validate -- path/to/your.ui.ron
# validate the whole engine asset tree (default when no path is given):
cargo run -p manifold-ui-validate --bin ui-validate
It runs two passes:
- Parse (structural): wrong field names, unknown enum variants, type
mismatches, reported with
file:line:col. - Reference (strict): every binding, slot schema, and typed action is checked
against the live registries. A dangling binding is an error, even in a
Label, HUD predicate, or template, where the renderer would otherwise silently degrade the value (empty string /false/"??") and hide the mistake.
References intentionally written ahead of their gameplay backing live in
assets/ui/.validate-allow.ron and are reported as non-failing info lines.
Remove an entry there once its backing exists. A CI test fails if an allowlist
row no longer matches any asset (no stale rows), and another fails if a new
dangling reference appears without an allowlist entry.
The same checks run in CI: manifold-ui-runtime’s parse gate covers every
assets/ui/** file structurally, and manifold-ui-validate’s asset gate
resolves every reference.
It also checks text and direction (see text and localization):
- Hardcoded text (warning):
LiteralorTemplatetext with words, on a node withouttext_options: (untranslated: true). - Unknown message keys (error): a
Localizedkey that the engine’s or the owning mod’s catalogs (the nearestmod.toml) lack. - Mirroring (warning): a physical-side anchor (
TopLeft, …) or unequalleft/rightmargins withoutmirror: Never. - Catalog lints (warning): messages without a translator comment.
A developer-only document (a debug panel, an editor fixture) opts out of the
hardcoded-text warning with a // ui-validate: untranslated line.
Validate a translation pack against the mods it translates with
ui-validate --translation-pack PACK_DIR --source MOD_DIR....
2. Text players read
Write text as message keys resolved in the player’s language:
Label(text: Localized(key: "mymod.shop.title")),
Button(
label: Localized(key: "mymod.shop.buy", args: {"price": Bind("Shop.price")}),
action: Typed("Buy", ()),
),
The key mymod.shop.buy is the message shop-buy in
locales/<language>/*.ftl of the mod whose id is mymod. Numbers passed as
arguments are formatted for the player’s locale and drive plural selectors.
Literal(..) is for names and symbols. Template(..) is for
language-independent formatting like {0} / {1}.
text_options controls how a text node lays out:
dir: Some(Auto | Ltr | Rtl | Locale). The default isLocaleforLocalizedtext andAuto(first strong letter) otherwise.overflow_wrap: Normal | BreakWord | Anywhere.max_lines: Some(n)andellipsis: End.untranslated: true.
Place things logically. Anchors TopStart, CenterEnd, BottomStart, …
and Margin(start: Some(..), end: Some(..)) follow the reading direction. Rows, grids,
anchors and margins mirror in a right-to-left UI unless the node sets
mirror: Never. Icons flip only when icons.ron marks them mirror_in_rtl.
A Dropdown with append: Languages lists every installed language after its
authored options, each named in its own language.
3. Editor autocomplete — ron-lsp (optional)
For RON autocomplete, try the third-party
JasonMcGhee.ron-lsp extension, which derives completions / diagnostics / hover
from Rust types rather than a schema.
- Install RON (Rusty Object Notation) LSP and CLI (
JasonMcGhee.ron-lsp) in VS Code. - Annotate the document’s root Rust type so the LSP knows what to complete
against (see the extension’s docs for the annotation syntax, e.g. the root
Nodefor*.ui.ron,HudLayerDocumentforhud/*,Themefor*.theme.ron). - Open a
.ui.ronfile and confirm completions for theNodevariants/fields.
Workspace support is unverified. Test whether
ron-lspresolvesmanifold_ui_protocol’s cross-crate types in your editor, then record the result and any working root-type annotation here. Useui-validatefor validation regardless of editor support.