WIP: feat(modapi): game.fadeOut, fadeIn and fadeState: the game's own screen fade #3215
No reviewers
Labels
No labels
area/accessibility
area/audio
area/input
area/install
area/menu
area/mods
area/renderer
area/saves
area/tooling
area/upscaling
beanstalk: approved
beanstalk: failed
beanstalk: needs approval
beanstalk: running
beanstalk: tested
ci: approved
good first issue
gpu/amd
gpu/igpu
gpu/intel
gpu/nvidia
help wanted
kind
bug
kind
chore
kind
docs
kind
feature
kind
performance
kind
question
needs measurements
platform/linux
platform/macos
platform/steam-deck
platform/windows
preview
priority
critical
priority
high
priority
low
regression
risk
high
risk
low
risk
medium
status
blocked
status
confirmed
status
duplicate
status
invalid
status
needs-info
status
wontfix
ci: approved
No milestone
No project
No assignees
3 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
MagicBeanDev/Longshot!3215
Loadingβ¦
Reference in a new issue
No description provided.
Delete branch "ChloeNow/Longshot:feat/modapi-screen-fade"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
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
EventEventFadeOutand 274EventEventFadeInsteps).longshot/gamegets:fadeOut(options?): the screen goes to black (or white) with the game's own fade, the one its cutscenes, doorsand warps play; it stays until
fadeIn.options:color"black"/"white",speedthe 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/fadeInanswer false outside play (title, loads, events, the pause menu), as the writes do, and needcamera.write(withgame.pause(): what the player sees);fadeStateneedsstate.read.How it works (
game_core::call::fade;docs/dev/reference/camera.md#the-screen-fadehas the table):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).call leaves a request the layout's next update takes, as the in-game run shows.
fake_layout), taking each fade at once.docs/modding/camera.md("The game's screen fade"), the API guide's table, the dev reference, thegenerated reference.
Read first:
game/crates/game-core/src/call/fade.rs.Testing
Tested: Windows 11, NVIDIA GeForce RTX 4060 Laptop GPU.
game-corecall::fade::tests(new, 2): the set's arguments (the speed held to the presets), open and close withtheir modes, the state read; no layout is no fade and no call.
modtooltesting_game::tests::the_screen_fade_in_play_only(new): out and in in play withfadeState, a speedout of range is an ArgumentError, false on the title screen.
dev.py game-tests, kokiri-start, a temporary driver on the main thread): out with speed1 went clear β opening β shown in about 64 frames; in at once went clear the next frame; no fault, the game played on.
dev.py game-tests, a playtest mod on kokiri-start; passed): after each event's endthe mod snapped the screen black and faded it back in,
fadeStategoingoutβfadingInβclear.flags.evaluate, black otherwise): talking to the Kokiri shopkeeper (Npc_Kokiri_001_Shop_Adult, 44 steps, 3 of 3checks 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; akey held to close the screen and let go to open it (
fadeOut/fadeIn), many times over.Still to test:
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 intakes a mod's fade back (documented).
Checklist
Ready for review
main; the title is a Conventional Commit.mise run testpasses (any failure that also fails onmainis named).main, or Measurements says why there is nothing to measure.third_party/untouched; nothing GPL-incompatible.When it applies
Assisted-by:/Co-Authored-By:trailers.Ready to merge
π€ Generated with Claude Code
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.
@rebase
I rebased this pull request onto
main(3131b1ddca): the new head is70b3e83513.Conflicts resolved
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.
c9c2cceb5f70b3e83513Recommendation: 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.
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.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)
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.@fixcan do L1 and L2.Questions (2) (not confirmed from the code; they don't hold the recommendation)
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:
70b3e83513against3131b1ddca: 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:
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.
@ -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,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,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() {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.
Great work!
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.