Expand description
The optional ui section of a mod’s mod.json, the launcher-UI
schema the Mods page renders generically: buttons shown for the mod,
and the popups those buttons open. See
crate::mod_config::ModConfig::ui, which holds this as an
Option, a mod without a ui section (e.g. the existing
practice-as-race mod) stays fully valid and simply gets no buttons.
Wire shape (per the tournament design contract):
"ui": { "buttons": [ { "id": "create_room", "label": "Create",
"action": "tournament.create", "popup": "create_room" } ],
"popups": { "create_room": { "title": "Create Tournament Room",
"kind": "form", "fields": [ ... ] } } }Design notes:
- Parse liberally, validate strictly. Every field has a serde
default, so a partial
uisection (buttons without popups, a popup without fields, …) still parses; structural problems surface as per-mod validation errors fromModUi::validate, collected bycrate::mod_config::ModConfig::validateexactly like parameter and rule problems, a broken mod shows up in the launcher’s mod list as broken rather than failing to parse outright. - Forward compatible. Unknown extra keys are ignored by serde (and
reported as non-fatal warnings by
crate::mod_config::ModConfig::load_from_path_with_warnings). Unknown kind strings (e.g. a"kind": "datepicker"field written by a newer launcher) round-trip through theUiFieldKind::Unknown/UiPopupKind::Unknowncatch-all variants instead of failing to parse, and are then rejected byModUi::validatewith a clear message, same mechanism, at the right layer. button.labelis displayed verbatim;{placeholder}tokens inside it (e.g."Join ({room_count})") are filled in live by the launcher (from its currentroom_listresponse), never interpolated here.button.actionstrings in thetournament.*namespace are handled by launcher logic; other actions are free-form for future use. This crate stores them opaquely.
Structs§
- ModUi
- A mod’s authored launcher-UI schema: which buttons to show for the
mod, and which popups they open.
popupsis a map keyed by popup id so buttons can reference popups by name, and validation can catch a button pointing at a popup that doesn’t exist (seeModUi::validate). - UiButton
- One button rendered for a mod on the Mods page. Clicking it performs
action(launcher-handled, e.g.tournament.create), optionally opening the popup named bypopupfirst to collect input. - UiField
- One input field inside a
UiPopupKind::Formpopup. - UiPopup
- One popup a
UiButtoncan open: a titled window that is either an input form (UiPopupKind::Form) or a live room list (UiPopupKind::RoomList).
Enums§
- UiField
Kind - What kind of control a
UiFieldrenders. Unknown kind strings round-trip throughUiFieldKind::Unknownso they fail validation (with the raw string in the message) instead of failing to parse. - UiPopup
Kind - What kind of popup a
UiPopupis. Unknown kind strings from a newer launcher round-trip throughUiPopupKind::Unknownso they fail validation (with the raw string in the message) instead of failing to parse.