Mod Framework
UI components
The parts of the Mod Framework's UI layer, one page each, named <componentName>.md after the
name a modder writes in markup, such as text_field.md. Every page tells what the part is for,
shows short examples of its variants, and lists its params, events and keys. Those tables are
written from the framework's declarations, and so are the links at the head and foot of every
page, the picture grid of each section below and the list of the components in the repository's
README. They follow the entries written in the comment under each section's heading, one line
- [Name](page.md): what it is each; a grid shows each page's first picture.
Every example is markup inside a component's render:
module Camp_Notes
UI = Mod_Framework::UI
class NotesWindow < UI::Component
def render
window "Camp notes" do
text "The example goes here."
end
end
end
end
Open it with UI.open(Camp_Notes::NotesWindow). Component explains components,
params, state and events.
Pictures. Each example is marked with a comment such as <!-- example: button-variants -->,
followed by a picture line such as  (a .gif for a part that
moves). The in-game test suite runs every example as its page writes it, in the Monarch look, crops
it to the part and keeps the picture as a reference; once approved, it is copied into images.
Your mod
The calls beyond the parts, each on a page of its own:
- Component
UI::Component,UI.open,UI.show, params, state, events and when a component renders again - Mod
a mod's files in
Patch, its tag and load order, title mods, the restart, installing and updating, versions and logs - Options
Options.add,Options.keep,Options.value, the rows in Options > Mods and the Mod Configuration - Hotkeys
Hotkeys.define, the keys every window knows and the ones a mod cannot take - Settings
Settings.setting,store,forgetandreadable? - Hooks
Hooks.before,after,around,Run.on_start,on_resetandon_close
Stackstack
Containercontainer, its parts in the middle at a most width, with gutters
Gridgrid,grid_item, items side by side in twelve columns, each spanning its share
Paperpaper
Cardcard,card_header,card_media,card_content,actions, a framed card with a head, a picture, its text and buttons
Drop zonedrop_container,drop_zone, areas whose items the player drags from one to another
Asideaside
Dividerdivider
Slidesslides,slide
Drawerdrawer,drawer_header
Groupgroup, a titled section with a note beside its title
Expansion panelsexpansion_panels,expansion_panel, panels whose titles fold them open and shut
Tabstabs,tab,tabs_header
Menumenu, a button that opens a menu of items, andUI.menu
Breadcrumbsbreadcrumbs, the way to the place shown, as links the player follows back
Buttonbutton
Text fieldtext_field
Autocompleteautocomplete, a text field with the matches of what is typed under it
Numeric fieldnumeric_field, a number typed, or stepped within its bounds by its arrows, andUI.number
Checkboxcheckbox
Switchswitch
Sliderslider, a number slid between its bounds by Left and Right, a click or a drag
Ratingrating, stars the player fills from the left
Color pickercolor_picker, a color picked from swatches or set by sliders of its red, green and blue
Radio groupradio_group,radio, radios of which the player picks one
Toggle grouptoggle_group,toggle_item, joined buttons the player turns on
Formform, andrequired:andvalidate:on every input
Selectselect,select_item
Hotkey fieldhotkey_field
Options listoptions_list
Texttext
Fieldfield, a value after its caption
Imageimage
Iconicon, an icon on its own, such as a mark in a head
Avataravatar, a character's face or map sprite in a circle or a square
Badgebadge, a count, a short text or a dot over the corner of the parts it holds
Chip setchip_set,chip, chips that show facts, such as tags
Timelinetimeline,timeline_item, entries in the order things happened, such as story points
Alertalert
Progressprogress
Arrowarrow
Tooltiptooltip
Key helpkey_help
Help linehelp_line, what the part the player is on does
Headerheader, an icon, a title, marks after it and a line under it
Slot rowslot_row, a row of icon slots to pick, such as skills or gems
Stat gridstat_grid, name and value rows that color what rose or fell
Lineslines, lines that show as many as their room holds, alone or in groups
ConfirmUI.confirm, a yes or no question
MessageUI.message, a message with an OK button- Task
UI.task, a wait on work that ends later
Needed modsMods.ask_needed, the dialog that makes ready the mods a place needs
Replace windowUI.replace_window, a component of your own in the place of a game window
Replace sceneUI.replace_scene, a component of your own in the place of a game scene
PatchUI.patch, changes to another mod's window, a framework screen or a game window
ToastMod_Framework.toast,UI.toasts,UI.offers, the notice stack
DrawnUI::Drawn, a component that measures and draws itself, such as a bar drawn by hand
Listlist
Loglog, colored rows that wrap, the newest at the bottom, such as a chat
Tabletable,column, items in rows under the titles of their columns
Paginationpagination, numbered pages to pick one from
Page viewpage_view,page_head,page_pane, a head, items in groups that fold and a reading pane
Game parts
They read the game's own data. UI::Equip tells what a screen shows of a character's gear (UI::Equip.item(actor, slot),
UI::Equip.slot_rows(actor), UI::Equip.stats(item), UI::Equip.compare(worn, item), UI::Equip.socketed?(item), ...), and a render that reads it renders again once the gear changes;
Game data lists every call of UI::Equip and UI::Game. They only read: a mod
changes the gear through the game's own methods, as the Equipment Window does, which builds every
screen of its own from the general parts above and these readers.
Calls and content of a component of your own
A component class declares the calls of its handle with action :pulse: part(:gems).pulse([0])
in the render that holds it runs the component's public method pulse. Every part's handle also takes focus: part(:search).focus moves the
focus onto that part, such as back onto a bar after Enter in its search. param :note, content: :text takes markup or a text, which
children :note places; a text shows as one line of small text.
Moving the focus into a component
part(:id) finds the parts and components your own render wrote, not the parts inside another
component, which belong to it. To move the focus into a component, call focus on its handle: the
part inside it that held the focus last, else its first part that takes the keys, takes it, much
as FocusAsync on a MudBlazor input's reference. So the fields of a form need not focus
themselves:
class NoteForm < UI::Component
def render
window "Notes" do
note_field id: :note_card # a component of your own holding a text_field
button "Write a note", on_click: -> { part(:note_card).focus }
end
end
end
A component that wants another part to take the focus declares action :focus and a public
method focus that moves it there, such as part(:note_text).focus; its own call wins.
Live data
A component's own params take plain values, never a lambda. Give it what the value comes from and
read the value in its render, where the framework sees it change:
class MemberBar < UI::Component
param :actor
def render
stack row: true do
text "Lv #{UI::Game.level(actor)}" # renders again on a level up
progress value: -> { UI::Game.hp_rate(actor) }, max: 1 # a live param: only the bar redraws
end
end
end
Written member_bar actor: $game_party.leader. A value read through UI::Game renders the
component again once that part of the game changes; a lambda on a built-in's live param (marked
"yes" under Live in its table) is read while it shows, every few frames. For data the framework
cannot see, declare watch { MyMod.party_serial } in the class: the component renders again once
the answer changes. The params every part takes, such as visible: and tooltip:, take lambdas
on your component as on a built-in.
Shrink to fit
A part can name compact forms that it takes once its window runs short of room, instead of being
cut. compact: gives each form by the step it comes in at; the window tries step 1, then 2 and so
on, and at each step every part shows the form of the highest step it names up to it, until what
the window holds fits. A form is the part's own params with the form's merged over them:
header name, icon: icon, subtitle: "Equipped", compact: { 3 => { dense: true } }
slot_row gems, compact: { 2 => { visible: false } }
lines effects, grow: 1, compact: { 1 => { most_rows: 1 } }
In a short window the effect lines first ask for one row (they still show what their room
holds), then the gems leave, then the header takes one row. The window keeps the step it reached
while it keeps its size, so nothing comes back whole as the content gets smaller; at a new size it
starts over from the full forms. A form cannot change id:, which names the full form. The
Equipment Window's comparison is built this way.
A part whose content changes, such as a comparison that follows a list's cursor, would still step
on once the cursor reaches a taller item. compact_for: gives it copies that never show, each
the part's own params with an entry's merged over them; the window picks its step as for the
tallest of the part and its copies, so it opens at the step the tallest needs and keeps it as the
cursor moves:
compare actor: actor, slot: slot, picked: row, height: :fill,
compact_for: UI::Equip.room(rows, UI::Equip.item(actor, slot)).map { |item| { picked: item } }
Each copy is a whole part to render, so name only the few contents that likely need the most
room; UI::Equip.room picks those of a list of items, here for a comparison of your own named
Compare. A copy cannot change id: or key:. The Equipment Window's item dialog sizes its
comparison this way.
Room and borders
Every part takes margin:, padding:, border:, border_width: and background:, as MudBlazor's
spacing classes and borders do. From the outside in a part has its margin, its border, its padding,
then its fixed pieces, such as a title row or a scrollbar, and then what it holds. Its size
(width:, height:, min_size:, max_size:) counts its border and its padding, not its margin.
margin:andpadding:take units of 4 px, also half units such as 0.5: one number for every side,[vertical, horizontal]or[top, right, bottom, left]. A margin adds to thespacing:of the stack it lies in; nothing of the part draws there, and a click there reaches what lies around it. A padding replaces the part's own room, such as the 6 px inside a card's frame.padding_shrinks: truelets the padding give way, down to none on each side, before what the part holds narrows once the part reaches itsmax_size:or the room it gets: ahud max_size: [320, nil], padding: [0.5, 2], padding_shrinks: truekeeps 8 px of padding at each side of a short text, while a long text at 320 px takes that room as well.border:draws a line along the inside of the part's edge,border_width:pixels thick: a color,:shadefor a darker shade of the part's own color,:themefor the theme's frame, orfalsefor none, such as a card without its frame.background:fills the part under what it draws: a color, also see-through as[r, g, b, a],:themefor the look's own back,falsefor none, or{ color: ..., fade: [:right, 48] }, which thins it to nothing over its last 48 pixels toward the right.
stack row: true do
card padding: 1, margin: [0, 2] do
text "Less room inside"
end
card border: :primary, border_width: 1, background: [0, 0, 0, 170] do
text "Its own border and plate"
end
end

Params every part takes
A component of your own takes them too, besides its own params, and hands them to the part at the
top of its render.
| Param | Takes | Default | Live | About |
|---|---|---|---|---|
id: |
a Symbol or a text | its public name, which other mods' UI.patch selects; unique within the mod | ||
class: |
a Symbol or an Array of Symbols | names for selectors | ||
key: |
any value | who it is among siblings of its type, so a part made in a loop keeps its state | ||
visible: |
true, false | true |
yes | false takes no room |
disabled: |
true, false | false |
yes | greyed out and takes no input: a press buzzes and the keys skip it; its tooltip still shows |
tooltip: |
a text | yes | shows on hover and on key focus | |
help: |
a text | a line for the help line | ||
width: |
px, :fill, :content |
:content |
pixels; :fill takes the free room | |
height: |
px, :fill, :content |
:content |
pixels; :fill takes the free room | |
min_size: |
[width, height] | the least size | ||
max_size: |
[width, height] | the largest size | ||
grow: |
a whole number | 0 |
share of the free room in a stack | |
align_self: |
:start, :center, :end, :stretch |
where it sits across its stack | ||
autofocus: |
true, false | false |
the focus starts on it as its window opens, not on the first part that takes the keys, and lands on it as the keys go into a part around it, such as confirm into a page view's pane | |
context_menu: |
an Array of choices, each a text or { text:, on_click:, disabled:, tooltip: }, or a lambda without arguments answering them | the choices a right click, the Menu key or a gamepad's confirm held opens on it, each a text or { text:, on_click:, disabled:, tooltip: }, or a lambda answering them | ||
on_focus: |
a lambda, a method name or nil | runs as the keys or a click move the focus onto it, such as to change a key help or a help text by the part in use | ||
on_blur: |
a lambda, a method name or nil | runs as the focus leaves it | ||
compact: |
{ 1 => { dense: true } }: the params of each compact form by the step it comes in at, from 1 | its compact forms, tried in order as its window runs short of room: at each step every part takes the form of the highest step it names up to it, until what the window holds fits; the window keeps its step while it keeps its size | ||
compact_for: |
[{ picked: item }]: the params of each copy | copies of it that never show, each with these params over its own, such as [{ picked: tallest_item }]: its window picks the step of the compact forms as for the tallest of the part and its copies, so the step stays as what the part shows changes | ||
pulse: |
any value | yes | any value; each time it changes, the part pulses once, turning see-through and fading back, such as gold an event gave; not as it first shows, nor with Animations off | |
outline: |
a color name such as :primary or :rainbow, "#RRGGBB", [r, g, b] or a game text color such as 2 | yes | the outline of its texts and of everything inside it; black by default | |
contrast: |
true, false | false |
yes | true writes the texts of it and of everything inside it that lie on a fill, such as a filled button's, in text_dark or text_light, whichever reads better on the fill, a dark text with text_light round it; text_color: and outline: set by hand win |
theme: |
:game, or a preset's name such as "Legacy" | the look of it and everything inside it, whose color names resolve in that preset: :game for the look of the game's own windows, their skin, or the player's pick while Look on Game Windows is On, with its rows and its texts without typo: in the game's own font size; or a preset's name; the player's pick by default | ||
margin: |
units of 4 px, also half units such as 0.5, for every side, or as [vertical, horizontal] or [top, right, bottom, left] | room kept around it, outside its size, where nothing of it draws and it takes no clicks; it adds to the spacing: of what it lies in; on a window, a dialog or a hud the room from the screen's edge and the parts beside it | ||
padding: |
units of 4 px, also half units such as 0.5, for every side, or as [vertical, horizontal] or [top, right, bottom, left] | room between its border and what it holds, in place of the part's own room; a title row, a scrollbar and the room of a mark, an icon, a badge or an arrow stay; by default the part's own room | ||
padding_shrinks: |
true, false | false |
true lets its padding give way, down to none on each side, before what it holds narrows once it reaches its max_size: or the room it gets, such as a strip whose text takes the whole max width | |
border: |
:shade, :theme, false, a color name such as :primary or :rainbow, "#RRGGBB", [r, g, b] or a game text color such as 2 |
yes | a line along the inside of its edge, in that color: :shade a darker shade of its own color (its color:, the first of colors:), :theme the theme's frame, false none; by default the theme's frame on a paper, card, hud, popover and text field, the theme's edge on a progress bar, none elsewhere; while the focus or the pointer lights a part by its edge, the light shows instead | |
border_width: |
a whole number | how thick its border is, in pixels, inside its size; with :theme the theme's rim takes the outer pixel and its edge the rest; by default the part's own, 1 where it draws none | ||
background: |
a color name such as :primary, "#RRGGBB", [r, g, b] or see-through [r, g, b, a], or a game text color such as 2; :theme, false, or { color:, fade: [side, pixels] } |
yes | fills its size under everything it draws, inside its border: a color, :theme for the look's own back, false for none, or { color:, fade: [:right, 48] }, which thins it from its alpha to nothing over its last pixels toward that side; by default the theme's back on a paper, card, hud and popover, the field color on a text field, the well on a progress bar and an avatar, none elsewhere; on a window or a dialog with the game's frame it paints the frame's back, which takes no fade |






