narraleaf-react
Version:
A React visual novel player framework
73 lines (72 loc) • 2.56 kB
TypeScript
import { Pausing } from "../../../nlcore/elements/character/pause";
import { Word } from "../../../nlcore/elements/character/word";
import { GameState } from "../../../../game/nlcore/common/game";
import { EventDispatcher, EventToken } from "../../../../util/data";
import React from "react";
import { DialogAction, DialogStateType, SayElementProps } from "./type";
type DialogEvents = {
"event:dialog.requestComplete": [];
"event:dialog.complete": [force: boolean];
"event:dialog.forceSkip": [];
"event:dialog.onFlush": [];
"event:dialog.simulateClick": [];
};
type DialogStateConfig = {
useTypeEffect: boolean;
action: DialogAction;
evaluatedWords: Word<Pausing | string>[];
gameState: GameState;
};
export declare class DialogState {
static Events: {
requestComplete: "event:dialog.requestComplete";
complete: "event:dialog.complete";
forceSkip: "event:dialog.forceSkip";
onFlush: "event:dialog.onFlush";
simulateClick: "event:dialog.simulateClick";
};
readonly config: Readonly<DialogStateConfig>;
readonly events: EventDispatcher<DialogEvents>;
private _state;
private _count;
private _forceSkipped;
private _idle;
private autoForwardScheduler;
constructor(config: DialogStateConfig);
get state(): DialogStateType;
get deps(): React.DependencyList;
isIdle(): boolean;
setIdle(idle: boolean): void;
/**
* Only for dialog component to call
*
* Calling this method will request the sentence to be completed
* If the sentence is already completed, it will exit the dialog
*/
requestComplete(): void;
/**
* Only for dialog state to call
*
* Force the sentence to cancel/skip all the tasks
*/
forceSkip(): void;
/**
* Only for sentence component to call
*
* Only call this method when the sentence is completed
* Calling this method will schedule the exit of the dialog
*/
dispatchComplete(): this | undefined;
emitComplete(): this;
isEnded(): boolean;
setPause(pause: boolean): void;
isForceSkipped(): boolean;
tryScheduleAutoForward(): void;
cancelAutoForward(): void;
emitFlush(): this;
onFlush(listener: () => void): EventToken;
safeEmit(event: keyof DialogEvents, ...args: DialogEvents[keyof DialogEvents]): this;
private scheduleAutoForward;
}
export default function PlayerDialog({ action, onFinished, useTypeEffect, gameState, }: Readonly<SayElementProps>): React.JSX.Element;
export {};