UNPKG

@drincs/pixi-vn

Version:

Pixi'VN is a npm package that provides various features for creating visual novels.

260 lines (257 loc) 8.39 kB
import { LabelIdType } from '../types/LabelIdType.cjs'; import { StorageObjectType } from '../types/StorageElementType.cjs'; import Label from './Label.cjs'; import { CloseType } from '../types/CloseType.cjs'; import LabelRunModeType from '../types/LabelRunModeType.cjs'; import './LabelAbstract.cjs'; import '../types/StepLabelType.cjs'; import '@drincs/pixi-vn'; import '../interface/LabelProps.cjs'; type ChoiceMenuOptionOptions = { /** * Type of the label to be opened. @default "call" */ type?: LabelRunModeType; /** * If this is true, the choice can only be made once. @default false */ oneTime?: boolean; /** * If this is true, the choice can see only if there are no other choices. For example, all choices are one-time choices and they are already selected. * @default false */ onlyHaveNoChoice?: boolean; /** * If this is true and if is the only choice, it will be automatically selected, and call/jump to the label. * @default false */ autoSelect?: boolean; }; type ChoiceMenuOptionCloseOptions = { /** * If true, the current label will be closed. @default false */ closeCurrentLabel?: boolean; /** * If this is true, the choice can only be made once. @default false */ oneTime?: boolean; /** * If this is true, the choice can see only if there are no other choices. For example, all choices are one-time choices and they are already selected. * @default false */ onlyHaveNoChoice?: boolean; /** * If this is true and if is the only choice, it will be automatically selected, and call/jump to the label. * @default false */ autoSelect?: boolean; }; /** * ChoiceMenuOption is a class that contains a Label and a text that will be displayed in the menu. * @example * ```typescript * new ChoiceMenuOption("Hello", HelloLabel, {}) * ``` */ declare class ChoiceMenuOption<T extends StorageObjectType> { /** * Text to be displayed in the menu */ text: string; private _label; /** * Label to be opened when the option is selected */ get label(): Label<T>; /** * Type of the label to be opened */ type: LabelRunModeType; /** * If this is true, the choice can only be made once. */ oneTime: boolean; /** * If this is true, the choice can see only if there are no other choices. For example, all choices are one-time choices and they are already selected. */ onlyHaveNoChoice: boolean; /** * If this is true and if is the only choice, it will be automatically selected, and call/jump to the label. */ autoSelect: boolean; /** * Properties to be passed to the label and olther parameters that you can use when get all the choice menu options. * @example * ```tsx * narration.choiceMenuOptions = [ * new ChoiceMenuOption("Hello", helloLabel, { disabled: true }), * ] * return <List> * {narration.choiceMenuOptions?.map((item, index) => { * return ( * <ChoiceButton * disabled={item.props.disabled} * onClick={() => { * afterSelectChoice(item) * }} * > * {item.text} * </ChoiceButton> * ) * })} * </List> * ``` */ props: StorageObjectType; /** * @param text Text to be displayed in the menu * @param label Label to be opened when the option is selected or the id of the label * @param props Properties to be passed to the label and olther parameters that you can use when get all the choice menu options. It be converted to a JSON string, so it cannot contain functions or classes. * @param options Options */ constructor(text: string, label: Label<T> | LabelIdType, props: T, options?: ChoiceMenuOptionOptions); } /** * ChoiceMenuOptionClose is a class that contains a text that will be displayed in the menu. * It is used to close the menu. * @example * ```typescript * new ChoiceMenuOptionClose("Return") * ``` */ declare class ChoiceMenuOptionClose<T extends {} = {}> { /** * Label to be opened when the option is selected */ label: Label<T>; /** * Text to be displayed in the menu */ text: string; /** * If true, the current label will be closed */ closeCurrentLabel: boolean; /** * Type of the label to be opened */ type: CloseType; /** * If this is true, the choice can only be made once. */ oneTime: boolean; /** * If this is true, the choice can see only if there are no other choices. For example, all choices are one-time choices and they are already selected. */ onlyHaveNoChoice: boolean; /** * If this is true and if is the only choice, it will be automatically selected, and call/jump to the label. */ autoSelect: boolean; /** * Properties to be passed to the label and olther parameters that you can use when get all the choice menu options. * @example * ```tsx * narration.choiceMenuOptions = [ * new ChoiceMenuOption("Hello", helloLabel, { disabled: true }), * ] * return <List> * {narration.choiceMenuOptions?.map((item, index) => { * return ( * <ChoiceButton * disabled={item.props.disabled} * onClick={() => { * afterSelectChoice(item) * }} * > * {item.text} * </ChoiceButton> * ) * })} * </List> * ``` */ props: StorageObjectType; /** * @param text Text to be displayed in the menu * @param closeCurrentLabel If true, the current label will be closed. @default false */ constructor(text: string, options?: ChoiceMenuOptionCloseOptions); } type IStoratedChoiceMenuOption = { /** * Text to be displayed in the menu */ text: string; /** * Label Id to be opened when the option is selected */ label: LabelIdType; /** * Type of the label to be opened */ type: LabelRunModeType; /** * If this is true, the choice can only be made once. */ oneTime: boolean; /** * If this is true, the choice can see only if there are no other choices. For example, all choices are one-time choices and they are already selected. */ onlyHaveNoChoice: boolean; /** * If this is true and if is the only choice, it will be automatically selected, and call/jump to the label. */ autoSelect: boolean; /** * Properties to be passed to the label and olther parameters that you can use when get all the choice menu options. * @example * ```tsx * narration.choiceMenuOptions = [ * new ChoiceMenuOption("Hello", helloLabel, { disabled: true }), * ] * return <List> * {narration.choiceMenuOptions?.map((item, index) => { * return ( * <ChoiceButton * disabled={item.props.disabled} * onClick={() => { * afterSelectChoice(item) * }} * > * {item.text} * </ChoiceButton> * ) * })} * </List> * ``` */ props: StorageObjectType; } | { /** * Text to be displayed in the menu */ text: string; /** * Type of the label to be opened */ type: CloseType; /** * If this is true, the choice can only be made once. */ oneTime: boolean; /** * If this is true, the choice can see only if there are no other choices. For example, all choices are one-time choices and they are already selected. */ onlyHaveNoChoice: boolean; /** * If this is true and if is the only choice, it will be automatically selected, and call/jump to the label. */ autoSelect: boolean; /** * If true, the current label will be closed */ closeCurrentLabel: boolean; }; export { ChoiceMenuOptionClose, type IStoratedChoiceMenuOption, ChoiceMenuOption as default };