# metropolisUi
The interface of Painted Metropolis: an in-play HUD and eighteen screens with one identity, cut paper and wet
paint over a painted city. Tokens and classes in one theme, a designed icon set, prompts read from the input
system, layouts anchored to edges so they hold at other sizes. Screens are pure functions of their data; view
models (`modules.present`) turn the game's views (ids, numbers, catalog keys) into that data with the engine's
translator, so no screen and no rule holds a sentence.
**Status:** the pure parts (theme, view models, settings, map model, every screen's tree at several sizes) are
covered by case modules that run in the engine's Luau VM in edit mode. NOTHING has been drawn on screen from
this package in this build: `modules.app` (the only module that calls `ui.*`) and `MetropolisUi.component`
have not been run, and no capture exists. How the first eight screens look is shown by static HTML mock-ups in
`D:/AgentStorage/artifacts/painted-metropolis/ui/` (mock-ups, not captures); the screens added for the full
game (wheel, rule card, decision, the list pages, subtitles) have no mock-up.
## Identity
- **Surfaces**: warm paper with a torn edge (`W.paper`, clip-path + a soft lift) carries what you read in play;
indigo night (`W.night`, scrims) carries menus and the mission layer. Nothing is a glass panel.
- **Colour**: only the game's eight pigments. Each attention state owns one (`state-clear` verdigris,
`state-noticed` saffron, `state-reported` amber, `state-pursuit` madder, `state-search` cobalt,
`state-escaped` meadow green), used for the state disc, its meter and the compass ticks.
- **Type** (bundled engine fonts): **Anton** for anything shouted (state names, titles, numbers),
**Bricolage Grotesque** for anything read, **Gelasio italic** for anyone speaking (briefs, twists, the lines
under a district's name).
- **Icons**: sixty 24 x 24 stencil marks in `modules/icons` (SVG, two colours), and eight pattern marks so
pigments can be told apart without colour.
- **Motion**: decided once, in `Tokens.motion` (nine named specs: `enter`, `leave`, `meter`, `select`, `pulse`,
`flash`, `drain`, `wheel`, `stamp`, each a duration, an easing and what it is for). Screens ask
`Theme.motion(name)`. No idle animation in play except the pulse while watched or hunted. With "reduce motion"
on, every duration is 0 except the two that carry information (`meter`, `drain`).
- **Reading and seeing** (`modules.settings`, tab "access"): four text sizes (every `text-*` token scales), a
colour-blind safe palette for the pigments (Okabe-Ito hues, `Tokens.safe`) with pattern marks on tins,
subtitles with speaker names and a backing, reduced motion, and the greywash effect as a meter only.
- **Reading over any scene**: text never sits on the scene without paper under it, except the district banner
and context prompts, which use `text-on-scene` (paper-coloured text with a two-layer indigo shadow).
## Modules
| `require("metropolisUi.<path>")` | What it is | Engine calls |
|-|-|-|
| `modules.tokens` | the token table and style classes (data) | none |
| `modules.theme` | resolves `$token` references; `Theme.t`, `Theme.style`; `Theme.register()` | `ui.registerTheme`, `ui.defineStyles` |
| `modules.icons` | the icon set; `Icons.svg`, `Icons.node`, `Icons.pattern` | none |
| `modules.widgets` | paper, night, text, meter, pips, key, prompt, menu, footer, entrance, pulse | none |
| `modules.format` | counts, timers, tins, percentages, compass positions | none |
| `modules.layout` | `Layout.frame(size, safeArea)`: class, margins, columns, map size | none |
| `modules.prompts` | glyphs for controls: `glyph`, `keyName` (pure); `forControl`, `class` (engine) | `Zin.scheme.*`, `Zin.gamepad.*` |
| `modules.mapModel` | the city map as SVG: `fromPlan` (a cityGen plan record: district outlines, ways by class, the shore), `base`, `overlay` (markers, search area, road blocks ordered and standing, the forecast, a route, a marker), `labels`, `point` | none |
| `modules.present` | the view models: `hud`, `wheel`, `ruleCard`, `decision`, `board`, `crew`, `roster`, `garages`, `impound`, `shop`, `journal`, `bill`, `subtitle`, each `(data, t) -> screen data` | none |
| `modules.settings` | settings as data: tabs, defaults, `rows`, `set`, `rebind` (a key in use swaps), `apply` (onto the theme; returns what the host applies) | none |
| `modules.app` | owns the engine screens; `mount`, `setHud`, `show` / `update` / `hide`, `notify`, `banner`, `input`, `on`, `tick` | `ui.*` |
| `screens.*` | `build(data, env) -> tree` for hud, pause, map, mission, caught, escaped, title, settings, shop, wheel; `card` (`rules`, `decision`, `subtitle`); `pages` (`board`, `crew`, `roster`, `garages`, `impound`, `journal`) | none |
| `MetropolisUi.component` | the persistent owner: forwards `onCallback`, ticks the app (also while paused) | component hooks |
| `tests/cases/{core,game}` | case modules for everything marked "none" above (run in-process with `caseBench`; `tests/metropolisUi.testSuite` registers them for the engine's runner) | |
## Screens, data contracts and events
`env` for every screen is `{ frame, text(key, vars), glyph(control) }`; the app supplies it. `text` is the
engine's translator (`i18n.t`); keys are `pm_ui.*` and the game's other catalogs.
| Screen | Data it takes | Actions it emits (through `App.on`) |
|-|-|-|
| `hud` | `Present.hud(game:view(id), t)`: `arms { id, name, shotsText, pigment { hex, property }, cooling, refused? }?`, `colour { value, state, label, effect }?`, `target { name, icon, parts { name, value }[], out, outText? }?`, `vehicle { name, speed, status, tone, plate, stock? }?`, `paint { tool { id, name }, pigments { id, name, hex, pattern, tins, selected }[], total, capacity, refused? }`, `pursuit { state, stateName, hint?, level, levelName, heat, timer { left, duration }?, watchers { id, kind, value, stage, bearing }[], grab { by, progress }?, described[], strikes }`, `money { sous, renown, rankName, fraction }`, `objective { title, text, step, count, timer?, twist? }?`, `mural { name, coverage, accuracy, overspray, tier, tierName, signed }?`, `clock { text, phase, phaseName }`, `scrubs { name, state, startsIn }[]`, `player { yaw }`; plus `prompts { control, text, hold? }[]`, notifications and the banner from the app | none (the HUD has no widgets that take input) |
| `pause` | `title, items[], selected, summary { district?, sous, renown, rankName, clockText, phaseName, objective?, saved? }, labels` | `pause:resume`, `pause:map`, `pause:settings`, `pause:saveQuit`, `pause:back` |
| `map` | `title, size, base, overlay` (SVG from `mapModel`), `districts { id, name, rule, colour, vigilance, painted, signed, total, hue }[], focus, legend[], summary, labels` | `map:district:<id>`, `map:back` |
| `mission` | `mode` (start, done, failed), `kicker, title, body, about?, rewardsLabel?, rewards[], actions { id, control, label }[]` | `mission:accept`, `mission:later`, `mission:continue`, `mission:retry`, `mission:walk` |
| `caught` | `stage` (grabbed, restrained, itemised, transport, released), `progress, held { title, prompt, breakable, breakProgress, charges }, title, by, billTitle, lines { icon, text, amount?, tone? }[], keptTitle, kept[], note?, canSkip, skipLabel, released?, actions[]` | `caught:retry`, `caught:walk` |
| `escaped` | `title, sub, levelName, renownText, age, seconds` | none (it leaves by itself) |
| `title` | `title, city, line, items { id, label, note?, disabled? }[], selected, warn?` | `title:continue`, `title:new`, `title:settings`, `title:quit` |
| `settings` | `title, tabs[], tab, selected, rows { id, label, kind (slider, toggle, choice, key, action), value, min?, max?, options?, help?, glyph?, rebound? }[], rebinding?, labels` (rows from `Settings.rows`) | `settings:tab:<id>`, `settings:set:<row>` (`payload.value`), `settings:toggle:<row>`, `settings:choice:<row>:<option>`, `settings:nudge:<row>` (`payload.value` = -1 or 1, from keys or a pad), `settings:rebind:<action>`, `settings:action:<row>`, `settings:reset`, `settings:back` |
| `wheel` | `Present.wheel(view, t)` + `ring`, `hover`, `slots` | `wheel:arm:<id>`, `wheel:pigment:<id>` (hover and click) |
| `rules` | `Present.ruleCard(district, t)` + `close` | `rules:back` |
| `decision` | `Present.decision(view.objective, t)` + `selected`, `timer?` | `decision:<option>` |
| `subtitle` | `Present.subtitle(line, t, settings)` | none |
| `board`, `crew`, `roster`, `garage`, `impound`, `journal` | the matching `Present.*` + `selected`, `labels { back, confirm? }` | `<screen>:<rowId>`, `<screen>:back` |
The caught screen follows pursuitKit's `arrestStage` events one to one; the bill's lines are built by the game
from `Arrest.bill`'s `lines` (each `key` has copy under `caught.<key>`).
## Using it
```lua
local App = require("metropolisUi.modules.app")
local Present = require("metropolisUi.modules.present")
local Settings = require("metropolisUi.modules.settings")
local t = i18n.t
App.mount({ text = t, hosted = true }) -- with MetropolisUi.component on an entity in the scene
App.on(function(action, payload) ... end)
local host = Settings.apply(savedSettings, Theme) -- palette, text size, motion; returns volumes, look speed, bindings ...
-- the game's host interface `ui` (metropolisGame.interfaces) is this, per player:
ui.setHud = function(player, view) App.setHud(Present.hud(view, t, { wash = host.washEffect }), { prompts = promptsHere }) end
ui.show = function(player, screen, data) App.show(screen, data) end -- data already presented, e.g.
-- App.show("rules", Present.ruleCard(view.district, t))
-- App.show("board", Present.board(session.board:view(day, session:progress(), district), t, { district = district }))
-- App.show("caught", Present.bill(bill, t, view.clock.text))
ui.notify = function(player, note) App.notify({ icon = note.icon, tone = note.tone, text = t(note.key, note.values) }) end
ui.banner = function(player, d) App.banner(Present.ruleCard(d, t)) end
```
Menu controls come from the game's `menu.inputMap`: while `App.menuOpen()` the host keeps that map active and
calls `App.input("up" | "down" | "left" | "right" | "confirm" | "back" | "tabPrev" | "tabNext")` from its
handlers. Pointer and touch act on the widgets directly.
## Layout at other sizes
Everything is pinned with `left` / `top` / `right` / `bottom` from `Layout.frame`, which adds the safe area's
insets. Classes: `wide` (the 1280 point canvas at 620 points high or more), `short` (ultrawide: margins 20,
scale 0.9, a narrower compass and objective), `narrow` (under 1000 wide, a phone: margins 14, menus drop their
side panel, the map loses its district column). The cases build the HUD at 410 x 900, 1280 x 548, 1280 x 960,
1600 x 900 and 1024 x 640.
## The map
`MapModel.fromPlan(plan)` reads the baked cityGen record (`require("metropolis.verrane.cityPlan")`): district
outlines, the road graph's edges by class (`MapModel.WAYS`: highway to track, each a width, a least stroke, and
whether it shows on a sheet of the whole city), the shore, places. The frame is the engine's (+z south runs down
the sheet). A window (`MapModel.new(city, size, { view = ... })`) is the minimap or a zoomed sheet and draws
alleys, stairs and tram lines. The overlay takes what the game's view carries: `pursuit.search`, `pursuit.lkp`,
`pursuit.blocks`, and a forecast from `pursuitKit.roadblocks.plan` for the next heat level.