import { Constructable } from "../action/constructable"; import { Color, ImageSrc } from "../types"; import { LogicAction } from "../action/logicAction"; import { Sound, VoiceIdMap, VoiceSrcGenerator } from "../elements/sound"; import { Image } from "../elements/displayable/image"; import { ActionStatements, Persistent } from "../common/core"; import { Chained, Proxied } from "../action/chain"; import { ImageTransition } from "../elements/transition/transitions/image/imageTransition"; import { Layer } from "../elements/layer"; import { NVLToken } from "./nvl"; import type { TransformDefinitions } from "../elements/transform/type"; export interface ISceneUserConfig { /** * Background music */ backgroundMusic: Sound | null; /** * Background music fade duration, in milliseconds */ backgroundMusicFade: number; /** * Voice map or a function that returns the voice URL */ voices?: VoiceIdMap | VoiceSrcGenerator; /** * Background src, can be a {@link Color} or an {@link Image} */ background: ImageSrc | Color; /** * An array of {@link Layer}s */ layers: Layer[]; } export type JumpConfig = { transition: ImageTransition; }; type ChainableAction = Proxied> | LogicAction.Actions; type ChainedScene = Proxied>; export declare class Scene extends Constructable { get local(): Persistent; get background(): Image; get backgroundLayer(): Layer; get displayableLayer(): Layer; constructor(name: string, config?: Partial); /** * Update the scene background immediately or via transition. * @param background - Color or image source to render. * @param transition - Optional animation applied while swapping backgrounds. * @chainable * @example * ```ts * scene.action([ * scene.setBackground("#000", new FadeIn(1000)) * ]); * ``` */ setBackground(background: Color | ImageSrc, transition?: ImageTransition): ChainedScene; /** * Jump to another scene and discard the current one. * * After the jump the calling scene is unloaded and any actions that follow are ignored. * @param scene - The destination scene instance. * @param config - Optional transition config (or transition object). * @chainable * @example * ```ts * scene.action([ * scene.jumpTo(nextScene, new FadeIn(800)) * ]); * ``` */ jumpTo(scene: Scene, config?: Partial | JumpConfig["transition"]): ChainableAction; /** * Set the scene background music, optionally fading the previous track. * @param sound - The BGM or `null` to stop the music. * @param fade - Duration of the cross-fade, in milliseconds. * @chainable * @example * ```ts * scene.setBackgroundMusic(Sound.bgm("theme.mp3"), 500); * ``` */ setBackgroundMusic(sound: Sound | null, fade?: number): ChainedScene; /** * Create an NVL (Novel) mode block for displaying accumulated dialog. * In NVL mode, dialogs are stacked on screen rather than replacing each other. * @param actions - Actions to execute within NVL mode, or a callback receiving an NVLToken * @chainable * @example * ```ts * scene.nvl([ * character.say("First line"), * character.say("Second line"), * character.say("Third line"), * ]); * ``` * @example * ```ts * scene.nvl(nvl => [ * nvl.show({ duration: 500 }), * character.say("Line 1"), * character.say("Line 2"), * nvl.hide({ duration: 500 }), * ]); * ``` */ nvl(actions: ActionStatements | ((nvl: NVLToken) => ActionStatements)): ChainableAction; nvl(options: Partial, actions: ActionStatements | ((nvl: NVLToken) => ActionStatements)): ChainableAction; /** * Register the list of actions (or an action-generating callback) that this scene will execute. * @param actions - Either a list of actions or a factory that receives the scene and returns actions. * @returns The scene instance, allowing chaining. * @example * ```ts * story.entry( * new Scene("scene-1").action(scene => [ * scene.setBackground("#000"), * Control.sleep(1000) * ]) * ); * ``` */ action(actions: ActionStatements): this; action(actions: ((scene: Scene) => ActionStatements) | (() => ActionStatements)): this; /** * Manually register image URLs so the story knows to preload them. * @param src - One or more image URLs to cache ahead of time. * @returns The scene so calls can be chained. * @example * ```ts * scene.preloadImage(["bg-night.png", "bg-day.png"]); * ``` */ preloadImage(src: string | string[]): this; } export {};