# Default system screens

## Flow

"Click to start" ("Tap to start" on touch devices; not shown in the desktop version) → title → game. When the game ends, it returns to the title.

The title screen buttons are "New Game," "Continue" (when there is save data; an autosave alone is enough), "Extras" (once anything is unlocked), "Settings" and "Quit" (only in the desktop version and the Android app).

## Controls

| | Mouse and keyboard | Touch | Gamepad |
|---|---|---|---|
| Advance | Click, Enter, Space, wheel down | Tap | A |
| Back a page, forward a page | PageUp, PageDown (wheel down rolls forward from a page you went back to) | Swipe right, swipe left | LB, LT |
| Menu | Right-click, Esc | Long press, the menu button at the top right | START, B |
| Close a screen | Right-click, Esc | Close button | B |
| Log (backlog) | Wheel up, B | Swipe down | Y |
| Hide window | H, Delete, middle click, "Hide" in the quick menu | Swipe up | X |
| Skip | Hold Ctrl, Tab (each press toggles it) | — | Hold RB, L3 (each press toggles it) |
| Auto | A | From the menu | RT |
| Choose an option | 1 to 9 (the option with that number) | Tap | A |
| Settings | C, "Settings" in the quick menu | From the menu | SELECT |
| Quick save / load | S / L | From the menu | D-pad right, left (while playing; loading asks first) |
| Previous choice, next choice | From the menu (assign keys with `ui.keys`) | From the menu | — |
| Select a button | Arrow keys | — | D-pad, left stick |
| Scroll an open screen (Log, Save, Extras and so on) | Wheel | Swipe | Right stick |
| Fullscreen | Alt+Enter, F11 (desktop version), "Display" in Settings | "Display" in Settings | — |
| Mute | M (if that key is assigned to another action, that action comes first) | "Mute" in Settings | R3 |

- When the player (the "Controls" tab in Settings) or the project (`ui.keys`) assigns one of the default keys (B, H, Delete, A, Tab, C and so on) to another action,
  that action comes first (the key is removed from the default). To turn off a default key, write the action in `ui.keys` with an empty array (`"skip": []`).
  Turn off middle click with `ui.input.middleClick: "none"`, and choosing with the number keys with `ui.input.numberKeys: false`
- Gamepad buttons use the names of the standard layout (A is the bottom button, B the right one). The labels on the "Controls" screen and in the "Controls" tab of Settings change with "Button labels" in Settings
  ("Automatic," "Xbox," "PlayStation," "Switch"). "Automatic" decides from the name of the connected gamepad. RT was mute in earlier versions
  (you can swap it in the "Controls" tab of Settings). When a gamepad that the browser can't read as the standard layout (one whose `mapping` in the Gamepad API isn't `standard`) is connected,
  the buttons may not match, so the game tells the player once, at first, to swap them in the "Controls" tab of Settings
- **Text input** (`@text-input`): `mode=number` uses a numeric keyboard and accepts digits only (full-width digits become half-width), `mode=password` hides the typed characters,
  and with `pattern=` (a regular expression), the input can't be confirmed until the whole text matches it. On touch devices, the input frame moves up into the visible area above the on-screen keyboard.
  When a gamepad is connected, an on-screen keyboard (hiragana, katakana, alphanumeric; digits only for `mode=number`; alphanumeric only for English games) appears below the frame,
  and the player selects keys with the D-pad and enters them with A (in the desktop version, Steam's on-screen keyboard is used when it's available). While the frame is shown, the D-pad selects the frame's buttons and doesn't quick save and so on
- Advancing during auto or skip only stops it. Auto and skip also stop at choices (set "Auto after choices" and "Skip after choices" in Settings
  to "Keep going" to start them again after choosing). While the window is hidden, any input only brings the window back
- During auto and skip (including while Ctrl or RB is held), a small "Auto" or "Skip" appears at the top left (not while a screen is open or while the window is hidden).
  Set its position with `ui.indicator` (top-left, top-right, bottom-left, bottom-right, hidden). Its color is the same as the quick menu's (`ui.menuBar.color`, `shadow` and the theme).
  Style it with `.lm-indicator` in CSS (`data-state` is auto or skip); to make the project's own, use `screens.indicator` in a plugin (docs/plugins.md).
  When the project replaces the quick menu, it doesn't appear unless you write `ui.indicator` or replace it with `screens.indicator`
- Advancing while waiting for an effect (background change, fade to black, camera, `@wait` and so on) skips the running effect to the end (sound doesn't stop;
  [format.md](../design/format.md) chapter 5). `ui.input.skipEffects: false` turns this off
- The arrow keys and the D-pad select buttons on the open screen, the title and choices, nearest in that direction first (the selected button gets an outline).
  Sliders in Settings change value with left and right. While playing, up and down on the arrow keys and the D-pad select HUD buttons (`@hud-button`); Enter and A press them, and Esc and B stop selecting
- On touch devices, a menu button appears at the top right instead of the quick menu. When a landscape game is held upright, it asks the player to turn the device sideways.
  On touch devices and in portrait games, the text and buttons of the codex, investigations, map choices and stacked notices are made larger (text at least 12px on screen, buttons at least 44px; in portrait games, the map choice panel goes at the bottom).
  On devices where the game screen, fitted upright, would be narrower than 560px (CSS px) (phones), the notice covers the whole screen, and while it does, sound, videos, auto and the choice time limit
  are paused, the same as when going to the background. On devices where it's wide enough (tablets), only a notice appears at the top, and "Keep playing" closes it (it isn't shown again during that session)
- Swiping to the right goes back a page, and swiping to the left rolls forward from a page you went back to (you can go back even while choices are shown; swipes that start at the left or right edge of the screen
  are ignored so they don't clash with the browser's back gesture). `ui.input.swipeSide: "none"` turns this off (for example, when the project uses sideways swipes on the screen)
- Back (the back button and back gesture in the Android app, and back in mobile browsers) depends on the situation. An input frame (`@dialog`) is canceled (`@text-input` does nothing),
  an open screen is closed, a hidden window comes back, and during the game the menu opens. On the title, the Android app, which can close itself, asks whether to quit,
  and browsers go back to the previous page. Mobile browsers and PWAs added to the home screen push one history entry (when back is pressed) so that back doesn't leave the game.
  If the project replaces the system screens, handle it with `system.back()` (return true when it's handled)
- In the iOS app and in browsers, which can't close the game themselves, `@quit` says so and returns to the title screen (the Android app closes). "Quit" on the title and in the menu
  appears only in the desktop version and the Android app. The confirmation is a frame inside the game, in the language being played. In the mobile apps, `@open-url` opens in the device's browser
  (http, https and mailto only). Links in the project's HTML that lead outside the game also open in the device's browser
- During auto and while `@movie` plays, the screen doesn't turn off (it doesn't sleep; Screen Wake Lock in browsers, `FLAG_KEEP_SCREEN_ON` in the Android app,
  `isIdleTimerDisabled` in the iOS app). `@vibrate` vibrates the device in the Android app, uses haptics in the iOS app (on iPads and other devices without haptics it does nothing),
  and uses the Vibration API in browsers; it also vibrates a connected gamepad
- **Next choice**: Jumps to the next choice (without advancing the text; it rebuilds the state at the choice, the same way as loading. The skipped text goes into the backlog,
  and things that happen when skipping through, such as unlocking CGs and chapters, still happen. The text isn't marked as read. If there are no more choices ahead, it only says so).
  Unread text follows the skip setting in Settings; with "Read only," it jumps to the first unread page before the choice and stops there.
  With `ui.nextChoice.readOnly: true`, it jumps only when everything up to the next choice has been read (if there is unread text, it only says so).
  It first runs ahead without showing anything to check, and if there are no more choices ahead, it says so and doesn't jump
- **Rollback**: Goes back one page at a time (without asking). The text of the page you go back to appears all at once. If a choice was shown just before the current page, it goes back to that choice.
  From a page you went back to, you can roll forward (along the option you chose before), and if you read on and reach the same place, you can keep rolling forward. Choosing a different option discards the pages to roll forward to.
  You can go back up to 100 pages from the newest. Save data holds the return points of the newest 20 pages, as differences from the save, so you can go back that far after loading too
  (save data made by earlier versions doesn't have them, so you can't go back from the loaded page. If space runs short, this record is trimmed first).
  Read status, unlocked extras and settings aren't rolled back. The BGM becomes the one at the page you went back to.
  `ui.rollback.fixChoices: true` lets the player choose only the previous option after going back, and `ui.rollback.enabled: false` turns rollback off.
  `ui.input.wheelUp: "rollback"` makes wheel up go back a page instead of opening the backlog. Rollback goes in the quick menu only when you write it (`rollback`, `rollforward`)
- **Next unread**: Skips read pages and stops at an unread page (it stops even when the skip target in Settings is "All"; it also stops at choices).
  It first runs ahead without showing anything to check, and if everything to the end has been read, it says so and doesn't skip. The quick menu button and the key exist only when you write them (`next-unread`, `ui.keys.nextUnread`)
- **Read choices**: Options whose target's first page has been read (following up to three `@jump`s at the start of the target) are shown slightly faded
  (if you set a color with `ui.choice.readColor`, they're shown in that color instead). The targets are worked out from the script, so the project doesn't need to write anything
- **Screenshot** (in the menu; the quick menu button and the key exist only when you write them: `screenshot`, `ui.keys.screenshot`): The desktop version captures the window
  as it is and puts it in a "<title>" folder in the Pictures folder. The browser version saves the game screen (without the message window and system screens) as a PNG. The mobile app passes the same PNG to
  the share sheet (Save to Photos, Save to Files and so on; exporting save data works the same way)
- **Going to the background**: When the browser tab goes to the background (switching to another tab, minimizing the window, going back to the home screen on a phone), the game autosaves
  (see "Autosave" below) and then pauses playing sounds, playing videos, text-to-speech, auto and the choice time limit, and resumes them when the player comes back
  (auto counts its wait again from the start). If the project doesn't want them paused, use `ui.screen.pauseInBackground: false`.
  In the desktop version, the player can choose on the "Sound" tab of Settings what happens "When minimized" and "When inactive" (while another window is selected):
  "Pause," "Mute" (only the sound is silenced, and the game goes on) or "Keep playing" (by default, "When minimized" follows the project's setting (pause), and "When inactive" keeps playing.
  The settings are `whenHidden` and `whenUnfocused`). With "Mute" or "Keep playing," rendering and timers aren't throttled even when minimized (Electron's backgroundThrottling; throttling would stop the text from appearing and auto from advancing)
- **Screen sleep**: The desktop version keeps the display from sleeping during auto and while a video plays (`@movie`, except looping videos) (Electron's powerSaveBlocker)
- **Replay voice**: Plays the current page's voice again (the V key. It appears in the menu only when the current page has a voice.
  In the quick menu only when you write it: `replay-voice`. It can't be pressed on pages without a voice. The key is `ui.keys.replayVoice`)
- **Copy text**: Ctrl+C (⌘+C on Mac) copies the current page's text (with the speaker) when no text is selected (when text is selected, the browser copies as usual).
  Text in the backlog can be selected and copied. To use another key, set `ui.keys.copyText`
- **Search the log**: The field at the top of the Log screen searches speakers and text (only matching pages are listed; Esc while typing only clears the text)
- **Previous choice**: Choose again from an earlier choice (while choosing, the choice before this one; asks first, and progress after it is lost).
  You can go back to the newest 50 choices shown in this playthrough. Save data holds the newest 10, so you can go back from there after loading too
  (if save data runs short of space, the choice records are trimmed first)
- These go in the quick menu only when you write them (`prev-choice`, `next-choice` in `ui.menuBar.items`). From plugins, use `system.perform("prev-choice")` and so on

Even when the project replaces the system screens, it can use the same touch, gamepad and arrow-key controls with `bindPlayerInput` (docs/plugins.md).
