From 0476ec0e572f267ba16150588cb75d910d24afcc Mon Sep 17 00:00:00 2001 From: Black Ram <67595890+BlackRam-oss@users.noreply.github.com> Date: Sat, 18 May 2024 12:42:30 +0200 Subject: [PATCH] refactor: Update ChoiceMenuOptionsType to accept generic props parameter --- src/functions/DialogueUtility.ts | 7 ++++--- src/types/ChoiceMenuOptionsType.ts | 3 ++- src/types/StorageElementType.ts | 4 ++-- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/functions/DialogueUtility.ts b/src/functions/DialogueUtility.ts index 664e6401..0ecef8bd 100644 --- a/src/functions/DialogueUtility.ts +++ b/src/functions/DialogueUtility.ts @@ -4,6 +4,7 @@ import { DialogueData } from "../classes/DialogueBaseModel"; import { getLabelTypeByClassName } from "../decorators/LabelDecorator"; import { IDialogueHistory } from "../interface"; import { GameStepManager, GameStorageManager } from "../managers"; +import { StorageObjectType } from "../types"; import { ChoiceMenuOptionsType } from "../types/ChoiceMenuOptionsType"; /** @@ -94,17 +95,17 @@ export function setChoiceMenuOptions(options: ChoiceMenuOptionsType): void { * Get the options to be shown in the game * @returns Options to be shown in the game */ -export function getChoiceMenuOptions(): ChoiceMenuOptionsType | undefined { +export function getChoiceMenuOptions(): ChoiceMenuOptionsType | undefined { let d = GameStorageManager.getVariable(GameStorageManager.keysSystem.CURRENT_MENU_OPTIONS_MEMORY_KEY) if (d) { - let options: ChoiceMenuOptionsType = [] + let options: ChoiceMenuOptionsType = [] d.forEach((option) => { let label = getLabelTypeByClassName(option.label) if (label) { options.push({ ...option, label: label - }) + } as any) } }) return options diff --git a/src/types/ChoiceMenuOptionsType.ts b/src/types/ChoiceMenuOptionsType.ts index 23f1047f..4e30cf4e 100644 --- a/src/types/ChoiceMenuOptionsType.ts +++ b/src/types/ChoiceMenuOptionsType.ts @@ -1,7 +1,8 @@ import { ChoiceMenuOptionLabel } from "../classes"; +import { StorageObjectType } from "./StorageElementType"; /** * Munu is a type that contains a list of Label that a player can choose from. * For Ren'py this is the equivalent of a menu. */ -export type ChoiceMenuOptionsType = ChoiceMenuOptionLabel[] \ No newline at end of file +export type ChoiceMenuOptionsType = ChoiceMenuOptionLabel[] \ No newline at end of file diff --git a/src/types/StorageElementType.ts b/src/types/StorageElementType.ts index 8f08ffad..a385ed19 100644 --- a/src/types/StorageElementType.ts +++ b/src/types/StorageElementType.ts @@ -4,8 +4,8 @@ type StorageElementInternalType = StorageElementPrimaryType | Record | { [key: string | number | symbol]: StorageElementType } +export type StorageElementType = StorageElementInternalType | Record | { [key: string | number | symbol]: StorageElementType } | StorageObjectType[] /** * StorageObjectType are all the types that can be stored in the storage */ -export type StorageObjectType = Record \ No newline at end of file +export type StorageObjectType = Record