@drincs/pixi-vn
Version:
Pixi'VN is a npm package that provides various features for creating visual novels.
107 lines (99 loc) • 3.08 kB
TypeScript
import { b as TickerHistory, d as TickersSequence } from './TickersSequence-Cf1Vcu22.js';
import { Container, ContainerOptions } from 'pixi.js';
/**
* This class is used to create a canvas element to add into a Pixi Application.
* You can use {@link canvas.add()} to add this element into the application.
* This class should be implemented and the memory method should be overridden.
* You must use the {@link canvasComponentDecorator} to register the canvas in the game.
* In Ren'Py is a displayable.
* @example
* ```typescript
* \@canvasComponentDecorator() // this is equivalent to canvasComponentDecorator("CanvasExample")
* export class CanvasExample extends Container implements CanvasBaseItem<ICanvasExampleMemory> {
* get memory(): ICanvasExampleMemory {
* return {
* pixivnId: "CanvasExample",
* // ... other properties
* }
* }
* set memory(value: ICanvasExampleMemory) {
* // ... set other properties
* }
* }
* ```
*/
declare class CanvasBaseItem<T2 extends CanvasBaseItemMemory> {
/**
* This method return the memory of the canvas element.
*/
get memory(): T2;
/**
* This method set the memory of the canvas element.
*/
set memory(_value: T2);
/**
* This method set the memory of the canvas element. Is equivalent to the {@link CanvasBaseItem.memory} method, but this method is async.
*/
setMemory(_value: T2): Promise<void> | void;
/**
* Get the id of the canvas element. This variable is used in the system to get the canvas element by id, {@link getCanvasElementInstanceById}
*/
pixivnId: string;
}
/**
* Interface for the canvas base memory
*/
interface CanvasBaseItemMemory {
pixivnId: string;
}
type PauseTickerType = {
/**
* Ticker ids excluded
*/
tickerIdsExcluded?: string[];
/**
* Ticker ids included
*/
tickerIdsIncluded?: string[];
};
/**
* Interface exported canvas
*/
interface CanvasGameState {
tickers: {
[id: string]: TickerHistory<any>;
};
tickersSteps: {
[alias: string]: {
[tickerId: string]: TickersSequence;
};
};
elements: {
[alias: string]: CanvasBaseItemMemory;
};
stage: Partial<ContainerMemory>;
elementAliasesOrder: string[];
/**
* @deprecated
*/
tickersOnPause: {
[alias: string]: PauseTickerType;
};
tickersToCompleteOnStepEnd: {
tikersIds: {
id: string;
}[];
stepAlias: {
id: string;
alias: string;
}[];
};
}
type ContainerChild = Container & CanvasBaseItem<any>;
/**
* Interface for the canvas container memory
*/
interface ContainerMemory<C extends ContainerChild = ContainerChild> extends ContainerOptions<C>, CanvasBaseItemMemory {
elements: CanvasBaseItemMemory[];
}
export { CanvasBaseItem as C, type PauseTickerType as P, type CanvasGameState as a, type CanvasBaseItemMemory as b, type ContainerMemory as c, type ContainerChild as d };