The prototype (the confirmation)
packages/web/src/system/template.ts: reads templates, makes them safe, merges parts, builds parts and attaches behaviours to attributes, finds outdated parts.
packages/screens/src/confirm.ts: the built-in confirmation template.
packages/web/src/system/confirm.ts: builds the confirmation from the template (replacing the earlier confirmDialog in ui.ts).
ask in default.ts: the plugin’s screens.confirm if present, otherwise the template.
- Tests:
test/e2e/confirm-template.test.ts (today’s behaviour; replacing with a game’s template; editing during development; screens.confirm first), test/e2e/screen-template-binder.test.ts (lists, replacing one part, states, outdated parts, safety, the attributes and list rebuilding added in stage f1), test/screen-templates.test.ts (class names and versions, the ui.templates check), test/e2e/screen-templates-author.test.ts (replacing the four screens of stage f1 with a game’s templates), test/e2e/screen-templates-author-saves.test.ts (the three screens of stage f2: a save row, one backlog page, the title’s items), test/e2e/screen-templates-author-config.test.ts (the settings screen of stage f3: tabs and item order, unusable items, a switch, a game’s own setting, one key binding row).
- The fix to the confirmation in stage f1: an invisible heading (
confirm.heading) became the name (aria-labelledby), and the question became the description (aria-describedby) (version 2). With a game template without the heading, the question becomes the name.
Parts and attributes of four screens (stage f1)
The built-in templates are packages/screens/src/<screen>.ts. The building code is menu-panel.ts, help.ts, ending.ts and choice-view.ts (all in packages/web/src/system/).
The DOM shape (class names, order, type, role, aria-pressed, data-action, data-kind) was kept as before the rewrite, confirmed by the fixed tests (test/e2e/screens-behavior-*.test.ts) passing unchanged.
| Part | Contents |
|---|
screen | .lm-menu-panel inside .lm-screen.lm-menu (heading .lm-screen-title, items .lm-menu-list, “Return to game” .lm-menu-resume) |
screen-button | A row opening a game screen (menu of defineScreen) |
- What pressing does: items have a system action name in
data-role (SYSTEM_ACTIONS: save, backlog, title and so on). Pressing closes the menu and then does that action. close closes it (Esc, right click, pad START and B too). open of screen-button opens the game screen.
- Order, shown and hidden: as written in the template. Even written actions that can’t be used now (quitting in the browser version, replaying a voice on a page without one, saving and loading during a replay, unused flowchart and items, reading-forward actions over a screen waiting for the player;
menuAllows in menu.ts) are removed. Actions not in the built-in order (fullscreen, rollback, rollforward) work if written.
- Game screen rows go where
<template data-list="screens" data-item="screen-button"> is (before “Title” in the built-in template).
- Values:
auto, skip ("true" or "false"; the built-in writes them with data-attr-aria-pressed), and label of screen-button.
- What the engine writes:
data-action on items (the action name, for older CSS and tests). Items with empty contents get the action’s built-in wording (menu.save and so on, as replaced by WebPlugin.texts) (the built-in template’s items are empty, for export size). Written text is shown as is. Pressing the outermost element itself (the dark area outside the frame) closes.
- Initial focus:
data-autofocus (“Return to game” in the built-in).
Controls help (help)
| Part | Contents |
|---|
screen | A heading bar (heading, tabs .lm-tabs, close button) and the body .lm-help-body inside .lm-screen.lm-help |
tab | One tab (.lm-tab) |
controls | The table of controls (.lm-help-table). Rows are the rows list |
row | One row of the controls table |
page | A page the game added (ui.help.pages; image and text in .lm-help-page) |
- What pressing does:
close (close), page of tab (show that tab).
- Values:
screen has tabs (whether the game has pages; data-if), tab has label and current ("true" or "false"), row has label, keyboard, touch, pad (”—” for missing controls), and page has title, image (image URL) and text.
- States:
data-lm-current on the current tab row.
- Pressing a tab rebuilds the tabs (
tabs) and the body (body: controls for the first tab, page for others) with view.list. Focus stays on the pressed tab.
- Initial focus: the screen’s outer frame (as before).
Ending name (ending)
| Part | Contents |
|---|
screen | A screen-covering proceed button .lm-ending-go inside .lm-screen.lm-ending (kind .lm-ending-kind, name .lm-ending-name, rule .lm-ending-rule, the end mark .lm-ending-mark) |
- What pressing does:
proceed and close (go on to the title; Enter, Space and pad A press the selected button; Esc, right click and pad B also go on). The built-in proceed button plays no sound as before (data-sound="none").
- Values:
name, kind (the kind name, written into data-kind with data-attr-data-kind, so the older .lm-ending[data-kind="bad"] works), kind-label (the kind wording, only with title=), mark, proceed, spoken (the name read aloud).
- How the end mark is placed (
lm-ending-mark-above, lm-ending-mark-none) is a class on the stage, so it isn’t in the template.
- Initial focus:
data-autofocus (the proceed button in the built-in).
Choices (choice)
| Part | Contents |
|---|
screen | The frame they’re laid out in. The outermost element stands for the choice layer (.choices) itself. The built-in has the time bar (.choice-timer) and the list of choices |
option | A text choice |
option-image | An image choice (the script’s image=; .choice-image) |
option-area | An invisible pressable area (only width= and height=; .choice-area) |
- The choice layer is an element always on the stage (used by its placement
ui.choice.position, the chat screen’s layout, and a game’s screens.choice), so the screen element doesn’t replace the layer. While choices are shown, the class and attributes of screen’s outermost element are put on the layer and its contents moved into the layer, and removed when choosing is done.
- Each choice is laid out as a child of the layer with
<template data-list="options"> (so the older .choices > button CSS and placement calculation keep working). The engine picks a part per row (image, area, text).
- What pressing does:
choose of a choice (choose; the sound is choice).
- Values:
screen has timer (the time limit in ms; empty without one, so the data-if="timer" bar isn’t shown; --choice-time, read by the bar, is written on the layer by the engine), and each choice has text, image (image URL) and index (position from the top, from 1).
- States:
data-lm-read on choices whose destination was read, and data-lm-disabled on choices that can’t be pressed (locked=, or other than the one chosen before during rollback) (disabled too on a <button>). For older CSS, the same choices also get the classes is-read and is-locked (.is-read was added to the classes in screen-catalog.ts).
- The look from the script (
hover= image swaps, x=, y=, width=, height=, cursor=, tip=) is written on the pressable element by the engine.
- Keys (arrows, Enter, pad d-pad and A), number keys (counting pressable ones from the top), notifying recordings and text-to-speech stay with the engine as before (the pressable element is
data-role="choose"; it doesn’t have to be a <button>).
- Initial focus: the first pressable choice (decided in code).
Parts and attributes of three screens (stage f2)
The built-in templates are packages/screens/src/<screen>.ts. The building code is saveload.ts, backlog-view.ts and title-view.ts (all in packages/web/src/system/).
The DOM shape (class names, order, type, aria-pressed, aria-label, title) was kept mostly as before the rewrite, confirmed by the fixed tests (test/e2e/screens-behavior-*.test.ts) passing unchanged (only where a backlog search bug was fixed was the test rewritten to the fixed behaviour).
The differences: the copy notice (.lm-slot-banner) isn’t placed (rather than hidden with hidden) while no destination is being picked. The slot number text (.lm-slot-name) goes into an inner span. Backlog search removes non-matching pages from the list instead of hiding them.
Save and load (saveload)
| Part | Contents |
|---|
screen | A heading bar (heading, page tabs .lm-tabs, close button), the copy notice (the banner list) and the slot grid .lm-slots inside .lm-screen.lm-saveload |
page | One page tab (.lm-tab) |
banner | The notice while picking a destination for copy and move (.lm-slot-banner; text and “Cancel”) |
slot | One slot row (inside .lm-slot-wrap, the pressable .lm-slot (thumbnail, number, protected mark, date, chapter name and play time, start of the text, memo) and the tools .lm-slot-tools) |
memo | The memo input (.lm-slot-memo-input; shown in place of the tools when the memo button is pressed) |
- Save and load share one template. The engine adds the class
lm-save or lm-load to the outermost element (the screen names are save and load).
- What pressing does:
close (close), page of page (show that page), cancel of banner (stop picking a destination; the sound is select as before), pick of slot (save, load, or pick as the destination), memo, protect (protect and unprotect), copy, move, delete. Slots without numbers (autosave and quick save) remove memo, protect, copy and move.
- Not pressable: empty slots when loading; while picking a destination,
pick of the source, protected slots and unnumbered slots; delete of protected slots (data-lm-disabled and disabled).
- Values:
screen has heading; page has label, current ("true" or "false"; aria-pressed) and spoken (the spoken name of the autosave page); banner has message; slot has name, date, chapter, time, text, memo, thumb (thumbnail URL), protect (the protect button’s wording) and the show flags sub, locked and tools; memo has memo, placeholder and label.
- States:
data-lm-current on tabs, and data-lm-empty, data-lm-protected and data-lm-source (the copy source) on rows. For older CSS, the pressable element (pick) also gets the classes lm-empty, is-locked and is-source.
- Changing pages, saving, protecting, copying and deleting rebuild the tabs, notice and slot list with
view.list. If focus is in the list, it stays on the pressable element of the row with the same index.
- The page to open (for save, the slot last written; for load, the newest save) is decided in code. Initial focus is the screen’s outer frame (as before).
Backlog (backlog)
| Part | Contents |
|---|
screen | A heading bar (heading, search field .lm-log-find, close button) and the list .lm-log inside .lm-screen.lm-backlog |
entry | One page (inside .lm-log-entry, voice replay and speaker .lm-log-speaker, text .lm-log-text, and “Jump here” .lm-log-jump) |
empty | The text placed in the list when nothing has been read yet (.lm-log-empty) |
- What pressing does:
close (close; scrolling the wheel down at the bottom also closes), voice of entry (replay the voice; removed on pages without one) and jump (read again from that page, after confirming; removed on the current page and pages that can’t be returned to).
- Values:
screen has search-label (the search field’s name and placeholder) and count (the number of matches; empty when not searching); entry has name (the speaker; empty for narration, “Choice” for a chosen choice), text, voice-label and jump-title.
- The engine puts the text with ruby, bold, color, line breaks and images, and each character’s dialogue text style (
text in cast.json), into the data-field="text" element. The data-field="name" element gets the speaker’s color.
- The search field is an
<input> with data-input="search". Typing rebuilds the list (entries) with only pages whose speaker or text matches, and writes the count with view.update. Esc while typing only clears the text.
- States:
data-lm-choice (a chosen choice), data-lm-narration (narration) and data-lm-hit (matched the search) on rows. For older CSS, also the classes lm-log-choice, lm-narration and is-hit.
- The list element (
data-list="entries") shows the bottom when opened. Initial focus is data-autofocus (the list in the built-in).
Title (title)
| Part | Contents |
|---|
screen | The title (.lm-title-name) or logo (.lm-title-logo) and the item list .lm-title-menu inside .lm-title |
- What pressing does:
start (new game), load (continue; with ui.title.resume, resumes from the newest save), extra, flowchart, config, help (controls help) and exit. Pressing plays the voice of that action in ui.systemVoice.actions.
- Order, shown and hidden: as written in the template. Even written items that can’t be used now (extras in a game without them, a hidden flowchart, controls help without
ui.help.title, quitting in the browser version) are removed. load without saves can’t be pressed (data-lm-disabled and disabled).
- Values:
name (the game’s title, translated to the language being played), logo (the image URL of ui.title.logo), heading (whether to show the title as text; not with a logo or when ui.title.showName is false).
- The background (
ui.title.background and ui.backgroundFocus) and music (ui.title.bgm) are put on the outermost element and the stage by the engine as before. So is a title changed by ui.title.variants.
- The title isn’t pushed onto the screen stack (
pushScreen). On opening nothing is selected, and arrows and the pad’s d-pad select items (as before). Screen JS’s dispose is called when the title is removed (including when rebuilding).
- A plugin’s
WebPlugin.title (including a theme’s title) comes first if present (as today).
Parts and attributes of the settings screen (stage f3)
The built-in template is packages/screens/src/config.ts. The building code is packages/web/src/system/config.ts.
The DOM shape (class names, order, type, aria-pressed, aria-label, hidden) was kept as before the rewrite, confirmed by the fixed test (test/e2e/screens-behavior-config.test.ts) and the per-item tests (settings-extra, settings-display, volume, controls, config-window, desktop-shell and others) passing unchanged.
The difference: the “Change” button of key and pad bindings plays the press sound like other buttons and has aria-pressed="false" from the start.
| Part | Contents |
|---|
screen | A heading bar (heading, tabs .lm-tabs, close button), item lists per tab .lm-config-rows (text, screen, sound, controls), the preview .lm-preview and the bottom bar .lm-config-footer inside .lm-screen.lm-config |
option | One choice whose number varies (.lm-toggle): language (list languages), window size (sizes), system voice (voices) |
speaker | One row of per-speaker voice volume (name, slider and value inside .lm-config-row). List speakers |
binding | One row of a key or pad binding (name, the current key or button .lm-config-keys, “Change”). Lists keys (keyboard) and buttons (gamepad) |
- Item rows use
data-setting (“Tying to settings” above). Names the built-in template writes: the text tab has textSpeed, autoWait, skipUnread, skipSpeed, autoAfterChoice, skipAfterChoice, choiceTimer and language. The screen tab has windowOpacity, textScale, font, reduceShake, reduceFlash, readColor, lineSpacing, textEdge, selfVoicing, highContrast, contentFilter, fullscreen, colorVision, captions, confirm, hideCursor, analytics and windowScale. The sound tab has master, mute, bgm, se, voice, per-speaker voice volume, voiceStopOnPage, duckBgm, systemVoice, whenHidden and whenUnfocused. The controls tab has padStyle.
- Items chosen in a shape different from the setting value:
readColor is on and off (if the player hasn’t decided, it follows whether the game sets ui.text.readColor), and analytics isn’t a setting value but whether to send play statistics, remembered separately on this device. Choosing windowScale leaves fullscreen. The choices of language, windowScale and systemVoice are rows of their lists.
- Items the engine removes with their row:
language (one language), fullscreen (where fullscreen isn’t available), windowScale (not the desktop version, or only one size to choose), analytics (the game doesn’t write build.analytics), contentFilter (the game doesn’t use it, or a variant decides it), systemVoice (the game doesn’t use it), and whenHidden and whenUnfocused (not the desktop version).
- Groups (tabs): pressing a button with
data-role="page" and data-page="name" shows only the elements whose data-page includes that name (others get hidden), and puts aria-pressed and data-lm-current on the button. data-page can list names separated by spaces (the built-in preview has text screen). Without tab buttons, everything is shown. On reopening, the tab open last time (or the first) is shown. Games may choose the names (merging tabs into two, adding more, and so on).
- What pressing does:
close (close; Esc, right click and pad B too), page (tabs), reset (reset to defaults; a game’s own settings are reset only if they are in the game’s defaults), export and import (exporting and importing save data; removed when unavailable), reset-controls (reset key and pad bindings), and change of binding (bind the next key or button pressed; pressing the waiting row again stops).
- Values:
screen has the value text of sliders (textSpeed, autoWait, windowOpacity, textScale, master, bgm, se, voice; shown in elements with that name in data-field), filter-label (the name of the content filter item; the game’s ui.contentFilter.label), preview (the preview text; the engine puts in the contents) and controls (whether to show key and pad bindings; data-if). option has label and lang (language only), speaker has label (also the slider’s spoken name) and volume, and binding has label, keys and waiting ("true" while waiting for a press; the built-in writes it into aria-pressed).
- The engine gives sliders the setting’s built-in name as their spoken name (
aria-label) (one written on the <input> wins).
- States:
data-lm-current on tabs, data-lm-on on switches, aria-pressed on choices.
- Starting to wait for a binding, binding, and stopping rebuild the
keys and buttons lists with view.list. Focus stays on “Change” in the row with the same index.
- Settings changed outside the screen (muting with the M key and so on) are reflected in the controls of the open screen.
- Initial focus: the screen’s outer frame (as before).