WIP: feat(modapi): game.fadeOut, fadeIn and fadeState: the game's own screen fade #3215

Draft
ChloeNow wants to merge 1 commit from ChloeNow/Longshot:feat/modapi-screen-fade into main
Member

Summary

Part of #2783 (Ocarina Forge, from glinesbdev): a mod does what an event step does, starting with the most used one,
the screen fade (the game's flows have 384 EventEventFadeOut and 274 EventEventFadeIn steps). longshot/game gets:

  • fadeOut(options?): the screen goes to black (or white) with the game's own fade, the one its cutscenes, doors
    and warps play; it stays until fadeIn. options: color "black" / "white", speed the game's preset 0 to 4
    (1, the default, about a second), instant.
  • fadeIn(options?): the screen comes back.
  • fadeState(): "clear", "fadingOut", "out", "fadingIn", or null before the game's UI is made.

fadeOut / fadeIn answer false outside play (title, loads, events, the pause menu), as the writes do, and need
camera.write (with game.pause(): what the player sees); fadeState needs state.read.

How it works (game_core::call::fade; docs/dev/reference/camera.md#the-screen-fade has the table):

  • The fade is a UI layout: the UI manager's lookup by hash finds it; f_833fb780(layout, color, speed, 0, 0) sets its
    "Color" animation frame and speed preset (field writes only); then its vtable's open (+0x28: 1 played, 3 at once) or
    close (+0x30: -1, -4), the calls each of the game's fade nodes makes (ExecuteEventFadeIn,
    ExecuteEventFadeIn/OutForTimeline, SeqExecuteEventFadeOut).
  • Called on the main thread at the mod's call. The game's flows call the same functions on their worker threads; the
    call leaves a request the layout's next update takes, as the in-game run shows.
  • The fake game has a fade of its own (fake_layout), taking each fade at once.
  • Docs: docs/modding/camera.md ("The game's screen fade"), the API guide's table, the dev reference, the
    generated reference.

Read first: game/crates/game-core/src/call/fade.rs.

Testing

Tested: Windows 11, NVIDIA GeForce RTX 4060 Laptop GPU.

  • game-core call::fade::tests (new, 2): the set's arguments (the speed held to the presets), open and close with
    their modes, the state read; no layout is no fade and no call.
  • modtool testing_game::tests::the_screen_fade_in_play_only (new): out and in in play with fadeState, a speed
    out of range is an ArgumentError, false on the title screen.
  • In game, the calls alone (dev.py game-tests, kokiri-start, a temporary driver on the main thread): out with speed
    1 went clear β†’ opening β†’ shown in about 64 frames; in at once went clear the next frame; no fault, the game played on.
  • In game, with #3203 and #3204 (dev.py game-tests, a playtest mod on kokiri-start; passed): after each event's end
    the mod snapped the screen black and faded it back in, fadeState going out β†’ fadingIn β†’ clear.
  • Played, with #3203 and #3204 (a playtest mod that fades white when every check the game asks in a scene matches
    flags.evaluate, black otherwise): talking to the Kokiri shopkeeper (Npc_Kokiri_001_Shop_Adult, 44 steps, 3 of 3
    checks matched) flashed white; a warp and other talks with no checks dipped black; each fade came back in. From the
    playtest's lab: black and white at speeds 0 to 4, instant, and held for a while before fadeIn, each as chosen; a
    key held to close the screen and let go to open it (fadeOut / fadeIn), many times over.

Still to test:

  • Linux: mise run test (CI).

Measurements

Nothing to measure: a fade is one lookup and three calls when a mod asks for one; nothing runs per frame.

Risks

The layout's open and close are virtual calls on the object the game's lookup returns; a build where the lookup or the
set is missing has has("game.fadeOut") false. A mod's fade and the game's events share one fade: an event fading in
takes a mod's fade back (documented).

Checklist

Ready for review

  • One topic, on current main; the title is a Conventional Commit.
  • Tested on my own PC, in the game for a change the game runs, as Testing says.
  • mise run test passes (any failure that also fails on main is named).
  • Measured against main, or Measurements says why there is nothing to measure.
  • No game files, build output or hand-edited generated files; third_party/ untouched; nothing GPL-incompatible.

When it applies

  • Docs updated.
  • AI assistance recorded with Assisted-by: / Co-Authored-By: trailers.

Ready to merge

  • Everything in Still to test has run, its results in Tested.
  • Approved in review, every comment answered.
  • CI passes on the head.

πŸ€– Generated with Claude Code

## Summary Part of #2783 (Ocarina Forge, from glinesbdev): a mod does what an event step does, starting with the most used one, the screen fade (the game's flows have 384 `EventEventFadeOut` and 274 `EventEventFadeIn` steps). `longshot/game` gets: - **`fadeOut(options?)`**: the screen goes to black (or white) with the game's own fade, the one its cutscenes, doors and warps play; it stays until `fadeIn`. `options`: `color` `"black"` / `"white"`, `speed` the game's preset 0 to 4 (1, the default, about a second), `instant`. - **`fadeIn(options?)`**: the screen comes back. - **`fadeState()`**: `"clear"`, `"fadingOut"`, `"out"`, `"fadingIn"`, or null before the game's UI is made. `fadeOut` / `fadeIn` answer false outside play (title, loads, events, the pause menu), as the writes do, and need `camera.write` (with `game.pause()`: what the player sees); `fadeState` needs `state.read`. How it works (`game_core::call::fade`; `docs/dev/reference/camera.md#the-screen-fade` has the table): - The fade is a UI layout: the UI manager's lookup by hash finds it; `f_833fb780(layout, color, speed, 0, 0)` sets its "Color" animation frame and speed preset (field writes only); then its vtable's open (+0x28: 1 played, 3 at once) or close (+0x30: -1, -4), the calls each of the game's fade nodes makes (`ExecuteEventFadeIn`, `ExecuteEventFadeIn/OutForTimeline`, `SeqExecuteEventFadeOut`). - Called on the main thread at the mod's call. The game's flows call the same functions on their worker threads; the call leaves a request the layout's next update takes, as the in-game run shows. - **The fake game** has a fade of its own (`fake_layout`), taking each fade at once. - **Docs**: `docs/modding/camera.md` ("The game's screen fade"), the API guide's table, the dev reference, the generated reference. Read first: `game/crates/game-core/src/call/fade.rs`. ## Testing **Tested:** Windows 11, NVIDIA GeForce RTX 4060 Laptop GPU. - `game-core` `call::fade::tests` (new, 2): the set's arguments (the speed held to the presets), open and close with their modes, the state read; no layout is no fade and no call. - `modtool` `testing_game::tests::the_screen_fade_in_play_only` (new): out and in in play with `fadeState`, a speed out of range is an ArgumentError, false on the title screen. - In game, the calls alone (`dev.py game-tests`, kokiri-start, a temporary driver on the main thread): out with speed 1 went clear β†’ opening β†’ shown in about 64 frames; in at once went clear the next frame; no fault, the game played on. - In game, with #3203 and #3204 (`dev.py game-tests`, a playtest mod on kokiri-start; passed): after each event's end the mod snapped the screen black and faded it back in, `fadeState` going `out` β†’ `fadingIn` β†’ `clear`. - Played, with #3203 and #3204 (a playtest mod that fades white when every check the game asks in a scene matches `flags.evaluate`, black otherwise): talking to the Kokiri shopkeeper (`Npc_Kokiri_001_Shop_Adult`, 44 steps, 3 of 3 checks matched) flashed white; a warp and other talks with no checks dipped black; each fade came back in. From the playtest's lab: black and white at speeds 0 to 4, instant, and held for a while before `fadeIn`, each as chosen; a key held to close the screen and let go to open it (`fadeOut` / `fadeIn`), many times over. **Still to test:** - Linux: `mise run test` (CI). ## Measurements Nothing to measure: a fade is one lookup and three calls when a mod asks for one; nothing runs per frame. ## Risks The layout's open and close are virtual calls on the object the game's lookup returns; a build where the lookup or the set is missing has `has("game.fadeOut")` false. A mod's fade and the game's events share one fade: an event fading in takes a mod's fade back (documented). ## Checklist ### Ready for review - [x] One topic, on current `main`; the title is a Conventional Commit. - [x] Tested on my own PC, in the game for a change the game runs, as Testing says. - [ ] `mise run test` passes (any failure that also fails on `main` is named). <!-- the new tests run; the whole suite not yet --> - [x] Measured against `main`, or Measurements says why there is nothing to measure. - [x] No game files, build output or hand-edited generated files; `third_party/` untouched; nothing GPL-incompatible. ### When it applies - [x] Docs updated. - [x] AI assistance recorded with `Assisted-by:` / `Co-Authored-By:` trailers. ### Ready to merge - [ ] Everything in Still to test has run, its results in Tested. - [ ] Approved in review, every comment answered. - [ ] CI passes on the head. πŸ€– Generated with [Claude Code](https://claude.com/claude-code)
feat(modapi): game.fadeOut, fadeIn and fadeState: the game's own screen fade
Some checks failed
PR description / Title and description (pull_request_target) Successful in 7s
CI / What the change needs (pull_request) Has been cancelled
CI / Lint (pre-commit, ShellCheck, actionlint) (pull_request) Has been cancelled
CI / Third-party parts and guide screenshots (pull_request) Has been cancelled
CI / Rust (rustfmt, clippy, cargo test, end to end) (pull_request) Has been cancelled
CI / Host C for Windows (llvm-mingw, compile only) (pull_request) Has been cancelled
CI / Renderer build check (Windows, compile --only renderer, without and with FSR 4) (pull_request) Has been cancelled
CI / Renderer build check (Linux, compile --only renderer, without and with FSR 4) (pull_request) Has been cancelled
CI / Game-free checks (run_all.py, part 1/2) (pull_request) Has been cancelled
CI / Game-free checks (run_all.py, part 2/2) (pull_request) Has been cancelled
CI / Website build and checks (pull_request) Has been cancelled
c9c2cceb5f
Part of #2783: a mod does what an event step does, starting with the
screen fade (384 EventEventFadeOut and 274 EventEventFadeIn steps in the
game's flows). fadeOut / fadeIn take a colour (black, white), the game's
speed preset 0 to 4 and instant; they answer false outside play.
fadeState reads clear, fadingOut, out or fadingIn.

game_core::call::fade finds the fade layout with the UI manager's lookup,
sets its colour and speed (f_833fb780), and opens or closes it through
its vtable, as the game's fade nodes do. The fake game has a fade of its
own (fake_layout).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Author
Member

Tested in game: Windows 11, NVIDIA GeForce RTX 4060 Laptop GPU, the play build with #3203 and #3204: Kokiri Forest, Hyrule Field, a minigame. A playtest mod's fades after each scene (white flash, black hold, black dip), black and white at speeds 0 to 4, instant, held then faded back in, and a held key fading out and back in: each as chosen, fadeState going out, fadingIn, clear; refused (false) outside play.

Tested in game: Windows 11, NVIDIA GeForce RTX 4060 Laptop GPU, the play build with #3203 and #3204: Kokiri Forest, Hyrule Field, a minigame. A playtest mod's fades after each scene (white flash, black hold, black dip), black and white at speeds 0 to 4, instant, held then faded back in, and a held key fading out and back in: each as chosen, fadeState going out, fadingIn, clear; refused (false) outside play.
Owner
@rebase
Member

I rebased this pull request onto main (3131b1ddca): the new head is 70b3e83513.

Conflicts resolved

  • docs/modding/reference.md: Kept the fade and pause menu reference entries and updated the combined schema hash.
  • docs/modding/permissions.md: Kept both sets of permissions and updated the combined schema hash.
  • docs/modding/scripting.md: Kept both sets of generated exports and features and updated the combined schema hash.

Nothing was built or run: read the resolution before merging.


Automated rebase by BeanBot (gpt-6.1-terra), asked for by HumanBean. Nothing was run; a maintainer decides.

I rebased this pull request onto `main` (3131b1ddcad3): the new head is 70b3e83513b7. **Conflicts resolved** - docs/modding/reference.md: Kept the fade and pause menu reference entries and updated the combined schema hash. - docs/modding/permissions.md: Kept both sets of permissions and updated the combined schema hash. - docs/modding/scripting.md: Kept both sets of generated exports and features and updated the combined schema hash. Nothing was built or run: read the resolution before merging. --- <sub>Automated rebase by BeanBot (gpt-6.1-terra), asked for by HumanBean. Nothing was run; a maintainer decides.</sub>
BeanBot force-pushed feat/modapi-screen-fade from c9c2cceb5f
Some checks failed
PR description / Title and description (pull_request_target) Successful in 7s
CI / What the change needs (pull_request) Has been cancelled
CI / Lint (pre-commit, ShellCheck, actionlint) (pull_request) Has been cancelled
CI / Third-party parts and guide screenshots (pull_request) Has been cancelled
CI / Rust (rustfmt, clippy, cargo test, end to end) (pull_request) Has been cancelled
CI / Host C for Windows (llvm-mingw, compile only) (pull_request) Has been cancelled
CI / Renderer build check (Windows, compile --only renderer, without and with FSR 4) (pull_request) Has been cancelled
CI / Renderer build check (Linux, compile --only renderer, without and with FSR 4) (pull_request) Has been cancelled
CI / Game-free checks (run_all.py, part 1/2) (pull_request) Has been cancelled
CI / Game-free checks (run_all.py, part 2/2) (pull_request) Has been cancelled
CI / Website build and checks (pull_request) Has been cancelled
to 70b3e83513
Some checks are pending
PR description / Title and description (pull_request_target) Successful in 6s
CI / What the change needs (pull_request) Successful in 7s
CI / Lint (pre-commit, ShellCheck, actionlint) (pull_request) Waiting to run
CI / Rust (rustfmt, clippy, cargo test, end to end) (pull_request) Waiting to run
CI / Host C for Windows (llvm-mingw, compile only) (pull_request) Waiting to run
CI / Renderer build check (Windows, compile --only renderer, without and with FSR 4) (pull_request) Waiting to run
CI / Renderer build check (Linux, compile --only renderer, without and with FSR 4) (pull_request) Waiting to run
CI / Game-free checks (run_all.py, part 1/2) (pull_request) Waiting to run
CI / Game-free checks (run_all.py, part 2/2) (pull_request) Waiting to run
CI / Website build and checks (pull_request) Waiting to run
CI / Third-party parts and guide screenshots (pull_request) Successful in 12s
2026-12-05 17:31:57 +00:00
Compare
BeanBot left a comment

Recommendation: Request changes. A stopped mod can leave the screen covered, and a default fade-in changes a white fade to black before revealing the game.

The change gives mods access to the game’s screen fade and its state. The Windows playtest shows the ordinary fade works, but the shared layout needs safer lifecycle handling and a consistent fade-in default.

Blocking (2): must change before merging.

  1. L1 game/crates/api/src/services/game.rs:459: A fade-out is not tracked as a live effect, so stopping its mod does not restore the screen. (more on the line) Do: Track ownership of mod-requested fades and release a stopped mod’s outstanding fade without undoing a newer game or mod request.
  2. L2 game/crates/api/src/services/game.rs:454: fadeIn defaults its color to black even when the existing fade is white. (more on the line) Do: When fadeIn omits color, preserve the layout’s current color; retain an explicit color override if it is intended to be supported, and test the white-out/default-in sequence.

Testing before merging (1) (runs on the systems it can change; it doesn't hold the recommendation)

  • L3 game/crates/game-core/src/call/fade.rs:140: The new platform-facing game calls have only a reported Windows game run. (more on the line) Do: Run a Linux game test covering played and instant fades, state transitions and a game event that uses the fade.

@fix can do L1 and L2.

Questions (2) (not confirmed from the code; they don't hold the recommendation)

  • What synchronization or frame ordering prevents a game worker’s fade request from overlapping the main-thread setter, open or close calls?
  • docs/modding/camera.md:245: When open and close are requested before the layout updates, does the close replace the pending open so that no fade-out is shown?

Checks: Still running: 11 checks.

More: does it help, other systems, switches, what was read

Does it help: Yes: the author reports successful black and white fades, speeds 0–4, instant fades and state transitions in a Windows 11 game run. This is a feature, not a performance change; no comparative performance numbers were supplied.

Other systems: The fade is shared with game events and other mods. The game’s flows call the same layout functions from worker threads, while this API calls them on the main thread; the supplied playtest does not establish how overlapping calls are synchronized. Linux and other Tier 1 systems have no reported game run.

Switches: None.

Reviewed: 70b3e83513 against 3131b1ddca: Read AGENTS.md, CONTRIBUTING.md, the pull request template, relevant standards, the diff and commit message, the new fade implementation and its call infrastructure, the changed service paths, schema additions, test changes and relevant camera documentation. Skimmed generated reference and permission tables and surrounding large test and schema files. docs/review-checklist.md and ../Tooling/AGENTS.md were absent; full large changed files and generated documentation were not read in their entirety.; nothing run (a code review).

Checked and fine:

  • The speed is checked before conversion to u32, and the core call also bounds its preset.
  • The commit records AI assistance in a trailer.
  • No switch, renderer API version change, third-party change or game-derived output appears in the diff.
  • The reported Windows playtest covers both colors, all five speed presets, instant fades and repeated use.

Testing: Read-only review; no code or tests were run. CI checks are still running.

Overlaps and merge order: Not established from the supplied information.


Automated code review by BeanBot (gpt-6.1-terra), asked for by BeanBot, after its rebase. Nothing was run; a maintainer decides.

**Recommendation: Request changes.** A stopped mod can leave the screen covered, and a default fade-in changes a white fade to black before revealing the game. The change gives mods access to the game’s screen fade and its state. The Windows playtest shows the ordinary fade works, but the shared layout needs safer lifecycle handling and a consistent fade-in default. **Blocking (2)**: must change before merging. 1. **L1** `game/crates/api/src/services/game.rs:459`: A fade-out is not tracked as a live effect, so stopping its mod does not restore the screen. (more on the line) **Do:** Track ownership of mod-requested fades and release a stopped mod’s outstanding fade without undoing a newer game or mod request. 2. **L2** `game/crates/api/src/services/game.rs:454`: fadeIn defaults its color to black even when the existing fade is white. (more on the line) **Do:** When fadeIn omits color, preserve the layout’s current color; retain an explicit color override if it is intended to be supported, and test the white-out/default-in sequence. **Testing before merging (1)** (runs on the systems it can change; it doesn't hold the recommendation) - **L3** `game/crates/game-core/src/call/fade.rs:140`: The new platform-facing game calls have only a reported Windows game run. (more on the line) **Do:** Run a Linux game test covering played and instant fades, state transitions and a game event that uses the fade. `@fix` can do L1 and L2. **Questions (2)** (not confirmed from the code; they don't hold the recommendation) - What synchronization or frame ordering prevents a game worker’s fade request from overlapping the main-thread setter, open or close calls? - `docs/modding/camera.md:245`: When open and close are requested before the layout updates, does the close replace the pending open so that no fade-out is shown? **Checks:** Still running: 11 checks. <details> <summary>More: does it help, other systems, switches, what was read</summary> **Does it help:** Yes: the author reports successful black and white fades, speeds 0–4, instant fades and state transitions in a Windows 11 game run. This is a feature, not a performance change; no comparative performance numbers were supplied. **Other systems:** The fade is shared with game events and other mods. The game’s flows call the same layout functions from worker threads, while this API calls them on the main thread; the supplied playtest does not establish how overlapping calls are synchronized. Linux and other Tier 1 systems have no reported game run. **Switches:** None. **Reviewed:** 70b3e83513b7 against 3131b1ddcad3: Read AGENTS.md, CONTRIBUTING.md, the pull request template, relevant standards, the diff and commit message, the new fade implementation and its call infrastructure, the changed service paths, schema additions, test changes and relevant camera documentation. Skimmed generated reference and permission tables and surrounding large test and schema files. docs/review-checklist.md and ../Tooling/AGENTS.md were absent; full large changed files and generated documentation were not read in their entirety.; nothing run (a code review). **Checked and fine:** - The speed is checked before conversion to u32, and the core call also bounds its preset. - The commit records AI assistance in a trailer. - No switch, renderer API version change, third-party change or game-derived output appears in the diff. - The reported Windows playtest covers both colors, all five speed presets, instant fades and repeated use. **Testing:** Read-only review; no code or tests were run. CI checks are still running. **Overlaps and merge order:** Not established from the supplied information. </details> --- <sub>Automated code review by BeanBot (gpt-6.1-terra), asked for by BeanBot, after its rebase. Nothing was run; a maintainer decides.</sub>
@ -419,0 +451,4 @@
return Err(ApiError::argument(format!("speed {speed}: the game's speeds are 0 to {}", speeds - 1)));
}
let fade = game_core::call::fade::Fade {
out,
Member

L2 (blocking): fadeIn defaults its color to black even when the existing fade is white.

When: After fadeOut({ color: "white" }) reaches white, fadeIn() calls the game’s color setter with black before closing the layout. The screen changes to black instead of fading back from white.

Do: When fadeIn omits color, preserve the layout’s current color; retain an explicit color override if it is intended to be supported, and test the white-out/default-in sequence.

**L2** (blocking): fadeIn defaults its color to black even when the existing fade is white. *When:* After fadeOut({ color: "white" }) reaches white, fadeIn() calls the game’s color setter with black before closing the layout. The screen changes to black instead of fading back from white. **Do:** When fadeIn omits color, preserve the layout’s current color; retain an explicit color override if it is intended to be supported, and test the white-out/default-in sequence.
@ -419,0 +456,4 @@
FadeColor::Black => 0,
FadeColor::White => 1,
},
speed: speed as u32,
Member

L1 (blocking): A fade-out is not tracked as a live effect, so stopping its mod does not restore the screen.

When: A mod fades out and is then disabled, reloaded or stopped for faults before it calls fadeIn. The layout remains covered while gameplay continues, and the normal mod-stop cleanup has no fade effect to undo.

Do: Track ownership of mod-requested fades and release a stopped mod’s outstanding fade without undoing a newer game or mod request.

**L1** (blocking): A fade-out is not tracked as a live effect, so stopping its mod does not restore the screen. *When:* A mod fades out and is then disabled, reloaded or stopped for faults before it calls fadeIn. The layout remains covered while gameplay continues, and the normal mod-stop cleanup has no fade effect to undo. **Do:** Track ownership of mod-requested fades and release a stopped mod’s outstanding fade without undoing a newer game or mod request.
@ -0,0 +137,4 @@
/// it at once (played or not).
pub fn fade(caller: &mut impl Caller, f: Fade) -> Result<bool, GameCallError> {
#[cfg(feature = "fake")]
if FAKE_STATE.get().is_some() {
Member

L3 (should fix): The new platform-facing game calls have only a reported Windows game run.

When: A Linux player using a mod that fades the screen exercises the guest calls and shared layout without a reported Linux game test.

Do: Run a Linux game test covering played and instant fades, state transitions and a game event that uses the fade.

**L3** (should fix): The new platform-facing game calls have only a reported Windows game run. *When:* A Linux player using a mod that fades the screen exercises the guest calls and shared layout without a reported Linux game test. **Do:** Run a Linux game test covering played and instant fades, state transitions and a game event that uses the fade.
Owner

Great work!

Great work!
Some checks are pending
PR description / Title and description (pull_request_target) Successful in 6s
CI / What the change needs (pull_request) Successful in 7s
CI / Lint (pre-commit, ShellCheck, actionlint) (pull_request) Waiting to run
CI / Rust (rustfmt, clippy, cargo test, end to end) (pull_request) Waiting to run
CI / Host C for Windows (llvm-mingw, compile only) (pull_request) Waiting to run
CI / Renderer build check (Windows, compile --only renderer, without and with FSR 4) (pull_request) Waiting to run
CI / Renderer build check (Linux, compile --only renderer, without and with FSR 4) (pull_request) Waiting to run
CI / Game-free checks (run_all.py, part 1/2) (pull_request) Waiting to run
CI / Game-free checks (run_all.py, part 2/2) (pull_request) Waiting to run
CI / Website build and checks (pull_request) Waiting to run
CI / Third-party parts and guide screenshots (pull_request) Successful in 12s
This pull request has changes conflicting with the target branch.
  • docs/modding/permissions.md
  • docs/modding/reference.md
  • docs/modding/scripting.md
  • game/crates/modtool/src/testing_game/tests.rs
View command line instructions

Manual merge helper

Use this merge commit message when completing the merge manually.

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u 'feat/modapi-screen-fade:ChloeNow-feat/modapi-screen-fade'
git switch 'ChloeNow-feat/modapi-screen-fade'
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
3 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
MagicBeanDev/Longshot!3215
No description provided.