UNPKG

narraleaf-react

Version:

A React visual novel player framework

77 lines (76 loc) 2.86 kB
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"; 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; unloadScene: boolean; }; type ChainableAction = Proxied<LogicAction.GameElement, Chained<LogicAction.Actions>> | LogicAction.Actions; type ChainedScene = Proxied<Scene, Chained<LogicAction.Actions>>; export declare class Scene extends Constructable<LogicAction.Actions, Scene> { get local(): Persistent<any>; get background(): Image; get backgroundLayer(): Layer; get displayableLayer(): Layer; constructor(name: string, config?: Partial<ISceneUserConfig>); /** * Set background, if {@link transition} is provided, it'll be applied * @chainable */ setBackground(background: Color | ImageSrc, transition?: ImageTransition): ChainedScene; /** * Jump to the specified scene * * After calling the method, you **won't** be able to return to the context of the scene that called the jump, * so the scene will be unloaded * * Any operations after the jump operation won't be executed * @chainable */ jumpTo(scene: Scene, config?: Partial<JumpConfig> | JumpConfig["transition"]): ChainableAction; /** * Set background music * @param sound Target music * @param fade If set, the fade-out effect will be applied to the previous music, and the fade-in effect will be applied to the current music, with a duration of {@link fade} milliseconds * @chainable */ setBackgroundMusic(sound: Sound | null, fade?: number): ChainedScene; /** * Add actions to the scene */ action(actions: ActionStatements): this; action(actions: ((scene: Scene) => ActionStatements) | (() => ActionStatements)): this; /** * Manually register image sources */ preloadImage(src: string | string[]): this; } export {};