# Liminalia Studio

## Flowchart

**Flowchart** is an overview of the branches, made from the script. Scenes (the top of each file, and each stretch from one label to the next) are cards (that scene's background and the images of its characters,
"#label" and the first line of text), and how scenes connect (continues, `@jump`, `@call`, choices, commands with a jump target; conditional if inside `@if`) are lines.
They are stacked from top to bottom in story order, file by file (built by `GET /map`, laid out by `model/map-layout.ts`). For projects where the stacked height exceeds 4,000px and
wrapping into columns in story order makes everything look at least 1.5 times larger when fitted (projects with many files), the files are wrapped into columns placed side by side
(`wrapColumns`; it tries a column height limit at each file boundary and picks the one that fits largest in a panel with a 1.6:1 width-to-height ratio). Lines to the very next file in the same column go down,
lines that skip ahead or go back within the same column go around the right of the column, and lines to other columns cross on curves. Turning off "Wrap" in the top bar goes back to a single column (it appears only for projects that can wrap; remembered in the browser).
The positions of scenes you moved are remembered in the coordinates of the single-column layout, and when wrapped, they are shifted along with their file's block (positions you moved before still work).
Lines from choices are labeled with the choice text,
and `@call` is a dotted line. Lines that go back to an earlier scene, such as investigating or choosing again, become loops around the right of the card. Each time it opens, the scene where the script cursor is
is highlighted and centered, and the scenes and lines of the route you chose are emphasized. If the all-routes test (Check) has been run, scenes that weren't reached are faded. Click a scene
to go to that scene's script. Drag the background to move the whole chart, and drag a card to move just that scene (moved positions are remembered in `.liminalia/shared.json`;
"Reset position" in the right-click menu puts it back where it is placed automatically). "Play from Here" in a card's right-click menu starts a test play from the beginning of that scene, and "Lines Leading Here" lists the lines that lead to it.
A card's right-click menu (and "…") also has the scene actions (rename, duplicate, move to another file, split the file from here, delete), and after a rewrite, the flowchart is redrawn without moving the view.
You can build on the flowchart (the text is rewritten in `model/map-edit.ts`; the open file receives editor changes, and ⌘Z and ⇧⌘Z on the Flowchart screen undo and redo; see "Undo on screens" below):

- Draw a line: hover over a card, and a handle appears in the middle of its bottom edge. Drag the handle and release it on another card to write a line that goes to that scene. A scene that ends with choices gets one more choice
  (its text is the target scene's name; edit it later), a scene that ends with `@jump` gets its jump target changed, a scene that ends with `@stop` has the `@stop` changed to `@jump`, and a scene that runs on into the next gets an `@jump` added at its end
  (before any trailing comments). Lines can't be drawn from scenes that end with `@return` or a command that ends the play (you are told so). The jump target is `#scene` in the same file, and `file#scene` otherwise
- Delete a line: hover over a line to thicken it, and right-click for "Open the line" and "Delete line." It deletes the `@jump` or `@call` line or the choice line (if it is the only choice, from `@choice` to `@end`),
  and for a line that continues to the next scene, it adds `@stop` at the end of the scene. Lines decided by commands can't be deleted
- Add a scene: right-click the background and choose "Add a scene to start.lim" or similar (the file is the nearest one above the clicked height in the clicked column). It asks for a name, adds `# name` at the end of that file, and places the card where you clicked
  (the position is remembered like a moved scene). If the last scene stopped at the end of the file, `@stop` is added so that it doesn't run on into the new scene. Zoom in and out with ⌘ / Ctrl + wheel or ＋ −, and search by label name or the start of the text with "Find a scene."
"Fit all" zooms so that everything (when filtered, the matching scenes) fits. It doesn't go below 10%, though; when things don't fit, it shows the start of the story (top left)
and shows where you are on the overview at the bottom right (＋ − and the wheel zoom out to 4%; below 35%, ＋ − step by 1.4 times).
Below 20%, cards become filled rectangles without images or text (and their image sources aren't fetched), lines keep their thickness, and file names stay at a readable size,
drawn over the top edge of that file's cards.
When not all cards are visible, an overview appears at the bottom right (dots for scenes, the current scene, scenes matching the search, scenes matching the filter, and the visible area); click or drag in it to center that spot.
Filter with the selections in the top bar: file (choosing a folder selects all the files under it), character (people who speak in that scene; `GET /map/cast`), tags and status (see "Edit tags and status" above; shown only when some scene has them), "Unreached" (scenes the all-routes test didn't reach; disabled if it hasn't been run) and "Endings" (scenes where the play ends).
The layout doesn't change; scenes and lines that don't match fade, the count is shown as "N / M scenes," and it zooms so that the matching scenes fit (not remembered).
The card images are built from the duration bars (`GET /sweep/stage`), fetched only for files whose cards come into view. For a scene that shows choices, the card shows the background and characters
at the point where the choices appear rather than at the start of the scene. A card image is the background at one point and the characters on screen at that time (characters who appear later in the scene aren't layered on).
Scenes where the play ends (the end of a file, `@stop`, a command that ends the play; `ends` on the command) get an "End" mark (or, if the command's `ending` parameter is given, its kind and
the name in `title`, such as `bad "Silence"`), and no line is drawn to the next scene.
"Endings" in the top bar opens a panel listing the scenes where the play ends (`endings-panel.ts`; built from the same `GET /map` data, with no separate calculation). It shows the kind and name of the ending (or "End" if there is none), the file and scene, and whether it is reached (the result of the all-routes test, with the number reached for each kind, if it has been run; if not, it says so).
Click one to center that scene and mark it. The Check screen also shows the number of endings and "See the list."
For plugin commands whose jump target is decided by data, arrows are drawn using what the command's `targets` reports it might jump to ([plugins.md](../plugins.md#命令commands)).

Switches within a screen (character settings and position, variable kinds, the project's basics, extras, translation and export, comment filters) are all placed to the right of the screen's heading row.
Asset kinds and plugin pages are many and keep growing, so they are listed in the left panel.
