@drincs/pixi-vn 0.6.5 → 0.6.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +49 -3
- package/dist/classes/CharacterBaseModel.js +57 -57
- package/dist/classes/CharacterBaseModel.js.map +1 -1
- package/dist/classes/CharacterBaseModel.mjs +57 -57
- package/dist/classes/CharacterBaseModel.mjs.map +1 -1
- package/dist/classes/ChoiceMenuOption.d.mts +5 -2
- package/dist/classes/ChoiceMenuOption.d.ts +5 -2
- package/dist/classes/ChoiceMenuOption.js +42 -25
- package/dist/classes/ChoiceMenuOption.js.map +1 -1
- package/dist/classes/ChoiceMenuOption.mjs +42 -25
- package/dist/classes/ChoiceMenuOption.mjs.map +1 -1
- package/dist/classes/CloseLabel.d.mts +3 -1
- package/dist/classes/CloseLabel.d.ts +3 -1
- package/dist/classes/CloseLabel.js +25 -16
- package/dist/classes/CloseLabel.js.map +1 -1
- package/dist/classes/CloseLabel.mjs +25 -16
- package/dist/classes/CloseLabel.mjs.map +1 -1
- package/dist/classes/Label.d.mts +45 -4
- package/dist/classes/Label.d.ts +45 -4
- package/dist/classes/Label.js +25 -16
- package/dist/classes/Label.js.map +1 -1
- package/dist/classes/Label.mjs +25 -16
- package/dist/classes/Label.mjs.map +1 -1
- package/dist/classes/LabelAbstract.d.mts +50 -0
- package/dist/classes/LabelAbstract.d.ts +50 -0
- package/dist/classes/LabelAbstract.js +100 -0
- package/dist/classes/LabelAbstract.js.map +1 -0
- package/dist/classes/LabelAbstract.mjs +98 -0
- package/dist/classes/LabelAbstract.mjs.map +1 -0
- package/dist/classes/LabelJson.d.mts +30 -0
- package/dist/classes/LabelJson.d.ts +30 -0
- package/dist/classes/LabelJson.js +2766 -0
- package/dist/classes/LabelJson.js.map +1 -0
- package/dist/classes/LabelJson.mjs +2760 -0
- package/dist/classes/LabelJson.mjs.map +1 -0
- package/dist/classes/StoredClassModel.js.map +1 -1
- package/dist/classes/StoredClassModel.mjs.map +1 -1
- package/dist/classes/index.d.mts +6 -1
- package/dist/classes/index.d.ts +6 -1
- package/dist/classes/index.js +827 -26
- package/dist/classes/index.js.map +1 -1
- package/dist/classes/index.mjs +827 -27
- package/dist/classes/index.mjs.map +1 -1
- package/dist/classes/ticker/FadeAlphaTicker.js.map +1 -1
- package/dist/classes/ticker/FadeAlphaTicker.mjs.map +1 -1
- package/dist/classes/ticker/MoveTicker.js.map +1 -1
- package/dist/classes/ticker/MoveTicker.mjs.map +1 -1
- package/dist/classes/ticker/RotateTicker.js.map +1 -1
- package/dist/classes/ticker/RotateTicker.mjs.map +1 -1
- package/dist/classes/ticker/ZoomTicker.js.map +1 -1
- package/dist/classes/ticker/ZoomTicker.mjs.map +1 -1
- package/dist/classes/ticker/index.js.map +1 -1
- package/dist/classes/ticker/index.mjs.map +1 -1
- package/dist/constants.d.mts +1 -1
- package/dist/constants.d.ts +1 -1
- package/dist/constants.js +1 -1
- package/dist/constants.js.map +1 -1
- package/dist/constants.mjs +1 -1
- package/dist/constants.mjs.map +1 -1
- package/dist/decorators/LabelDecorator.d.mts +19 -5
- package/dist/decorators/LabelDecorator.d.ts +19 -5
- package/dist/decorators/LabelDecorator.js +29 -16
- package/dist/decorators/LabelDecorator.js.map +1 -1
- package/dist/decorators/LabelDecorator.mjs +29 -17
- package/dist/decorators/LabelDecorator.mjs.map +1 -1
- package/dist/decorators/index.d.mts +10 -2
- package/dist/decorators/index.d.ts +10 -2
- package/dist/decorators/index.js +25 -16
- package/dist/decorators/index.js.map +1 -1
- package/dist/decorators/index.mjs +25 -16
- package/dist/decorators/index.mjs.map +1 -1
- package/dist/functions/DialogueUtility.d.mts +3 -1
- package/dist/functions/DialogueUtility.d.ts +3 -1
- package/dist/functions/DialogueUtility.js +85 -26
- package/dist/functions/DialogueUtility.js.map +1 -1
- package/dist/functions/DialogueUtility.mjs +85 -26
- package/dist/functions/DialogueUtility.mjs.map +1 -1
- package/dist/functions/FlagsUtility.js.map +1 -1
- package/dist/functions/FlagsUtility.mjs.map +1 -1
- package/dist/functions/GameUtility.js.map +1 -1
- package/dist/functions/GameUtility.mjs.map +1 -1
- package/dist/functions/ImageUtility.js.map +1 -1
- package/dist/functions/ImageUtility.mjs.map +1 -1
- package/dist/functions/Importer.d.mts +24 -0
- package/dist/functions/Importer.d.ts +24 -0
- package/dist/functions/Importer.js +2804 -0
- package/dist/functions/Importer.js.map +1 -0
- package/dist/functions/Importer.mjs +2798 -0
- package/dist/functions/Importer.mjs.map +1 -0
- package/dist/functions/SavesUtility.d.mts +3 -1
- package/dist/functions/SavesUtility.d.ts +3 -1
- package/dist/functions/SavesUtility.js +139 -36
- package/dist/functions/SavesUtility.js.map +1 -1
- package/dist/functions/SavesUtility.mjs +139 -36
- package/dist/functions/SavesUtility.mjs.map +1 -1
- package/dist/functions/index.d.mts +6 -1
- package/dist/functions/index.d.ts +6 -1
- package/dist/functions/index.js +169 -27
- package/dist/functions/index.js.map +1 -1
- package/dist/functions/index.mjs +169 -28
- package/dist/functions/index.mjs.map +1 -1
- package/dist/index.d.mts +7 -1
- package/dist/index.d.ts +7 -1
- package/dist/index.js +131 -36
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +130 -37
- package/dist/index.mjs.map +1 -1
- package/dist/interface/IHistoryStep.d.mts +3 -1
- package/dist/interface/IHistoryStep.d.ts +3 -1
- package/dist/interface/ISaveData.d.mts +3 -1
- package/dist/interface/ISaveData.d.ts +3 -1
- package/dist/interface/LabelProps.d.mts +38 -5
- package/dist/interface/LabelProps.d.ts +38 -5
- package/dist/interface/export/ExportedStep.d.mts +3 -1
- package/dist/interface/export/ExportedStep.d.ts +3 -1
- package/dist/interface/export/index.d.mts +3 -1
- package/dist/interface/export/index.d.ts +3 -1
- package/dist/interface/index.d.mts +6 -4
- package/dist/interface/index.d.ts +6 -4
- package/dist/labels/BaseCanvasElementTestLabel.d.mts +3 -1
- package/dist/labels/BaseCanvasElementTestLabel.d.ts +3 -1
- package/dist/labels/BaseCanvasElementTestLabel.js +129 -26
- package/dist/labels/BaseCanvasElementTestLabel.js.map +1 -1
- package/dist/labels/BaseCanvasElementTestLabel.mjs +130 -27
- package/dist/labels/BaseCanvasElementTestLabel.mjs.map +1 -1
- package/dist/labels/CanvasEventsTestLabel.d.mts +3 -1
- package/dist/labels/CanvasEventsTestLabel.d.ts +3 -1
- package/dist/labels/CanvasEventsTestLabel.js +129 -26
- package/dist/labels/CanvasEventsTestLabel.js.map +1 -1
- package/dist/labels/CanvasEventsTestLabel.mjs +129 -26
- package/dist/labels/CanvasEventsTestLabel.mjs.map +1 -1
- package/dist/labels/CustomTickerCanvasElementTestLabel.d.mts +3 -1
- package/dist/labels/CustomTickerCanvasElementTestLabel.d.ts +3 -1
- package/dist/labels/CustomTickerCanvasElementTestLabel.js +129 -26
- package/dist/labels/CustomTickerCanvasElementTestLabel.js.map +1 -1
- package/dist/labels/CustomTickerCanvasElementTestLabel.mjs +130 -27
- package/dist/labels/CustomTickerCanvasElementTestLabel.mjs.map +1 -1
- package/dist/labels/ImagesAnimationsTestLabel.d.mts +3 -1
- package/dist/labels/ImagesAnimationsTestLabel.d.ts +3 -1
- package/dist/labels/ImagesAnimationsTestLabel.js +46 -35
- package/dist/labels/ImagesAnimationsTestLabel.js.map +1 -1
- package/dist/labels/ImagesAnimationsTestLabel.mjs +47 -36
- package/dist/labels/ImagesAnimationsTestLabel.mjs.map +1 -1
- package/dist/labels/MarkdownTest.d.mts +3 -1
- package/dist/labels/MarkdownTest.d.ts +3 -1
- package/dist/labels/MarkdownTest.js +129 -26
- package/dist/labels/MarkdownTest.js.map +1 -1
- package/dist/labels/MarkdownTest.mjs +129 -26
- package/dist/labels/MarkdownTest.mjs.map +1 -1
- package/dist/labels/StartLabel.d.mts +3 -1
- package/dist/labels/StartLabel.d.ts +3 -1
- package/dist/labels/StartLabel.js +47 -36
- package/dist/labels/StartLabel.js.map +1 -1
- package/dist/labels/StartLabel.mjs +47 -36
- package/dist/labels/StartLabel.mjs.map +1 -1
- package/dist/labels/StepLabelTest.d.mts +3 -1
- package/dist/labels/StepLabelTest.d.ts +3 -1
- package/dist/labels/StepLabelTest.js +129 -26
- package/dist/labels/StepLabelTest.js.map +1 -1
- package/dist/labels/StepLabelTest.mjs +129 -26
- package/dist/labels/StepLabelTest.mjs.map +1 -1
- package/dist/labels/TestConstant.js.map +1 -1
- package/dist/labels/TestConstant.mjs.map +1 -1
- package/dist/labels/index.d.mts +3 -1
- package/dist/labels/index.d.ts +3 -1
- package/dist/labels/index.js +47 -36
- package/dist/labels/index.js.map +1 -1
- package/dist/labels/index.mjs +47 -36
- package/dist/labels/index.mjs.map +1 -1
- package/dist/managers/StepManager.d.mts +5 -3
- package/dist/managers/StepManager.d.ts +5 -3
- package/dist/managers/StepManager.js +138 -35
- package/dist/managers/StepManager.js.map +1 -1
- package/dist/managers/StepManager.mjs +138 -35
- package/dist/managers/StepManager.mjs.map +1 -1
- package/dist/managers/WindowManager.js.map +1 -1
- package/dist/managers/WindowManager.mjs.map +1 -1
- package/dist/managers/index.d.mts +7 -5
- package/dist/managers/index.d.ts +7 -5
- package/dist/managers/index.js +138 -35
- package/dist/managers/index.js.map +1 -1
- package/dist/managers/index.mjs +138 -35
- package/dist/managers/index.mjs.map +1 -1
- package/dist/types/ChoiceMenuOptionsType.d.mts +3 -1
- package/dist/types/ChoiceMenuOptionsType.d.ts +3 -1
- package/dist/types/LabelJsonType.d.mts +22 -0
- package/dist/types/LabelJsonType.d.ts +22 -0
- package/dist/types/LabelJsonType.js +4 -0
- package/dist/types/LabelJsonType.js.map +1 -0
- package/dist/types/LabelJsonType.mjs +3 -0
- package/dist/types/LabelJsonType.mjs.map +1 -0
- package/dist/types/StepLabelJsonType.d.mts +30 -0
- package/dist/types/StepLabelJsonType.d.ts +30 -0
- package/dist/types/StepLabelJsonType.js +4 -0
- package/dist/types/StepLabelJsonType.js.map +1 -0
- package/dist/types/StepLabelJsonType.mjs +3 -0
- package/dist/types/StepLabelJsonType.mjs.map +1 -0
- package/dist/types/index.d.mts +5 -1
- package/dist/types/index.d.ts +5 -1
- package/package.json +3 -2
- package/dist/LabelProps-CFV-zRjG.d.ts +0 -113
- package/dist/LabelProps-CmRpvUJm.d.mts +0 -113
|
@@ -1,8 +1,10 @@
|
|
|
1
|
-
import
|
|
1
|
+
import Label from './Label.mjs';
|
|
2
2
|
import '../types/LabelIdType.mjs';
|
|
3
3
|
import '../types/StepLabelType.mjs';
|
|
4
4
|
import '@drincs/pixi-vn/dist/override';
|
|
5
|
+
import './LabelAbstract.mjs';
|
|
5
6
|
import '../types/StepHistoryDataType.mjs';
|
|
7
|
+
import '../interface/LabelProps.mjs';
|
|
6
8
|
|
|
7
9
|
declare const CLOSE_LABEL_ID = "__close-label-id__";
|
|
8
10
|
/**
|
|
@@ -1,8 +1,10 @@
|
|
|
1
|
-
import
|
|
1
|
+
import Label from './Label.js';
|
|
2
2
|
import '../types/LabelIdType.js';
|
|
3
3
|
import '../types/StepLabelType.js';
|
|
4
4
|
import '@drincs/pixi-vn/dist/override';
|
|
5
|
+
import './LabelAbstract.js';
|
|
5
6
|
import '../types/StepHistoryDataType.js';
|
|
7
|
+
import '../interface/LabelProps.js';
|
|
6
8
|
|
|
7
9
|
declare const CLOSE_LABEL_ID = "__close-label-id__";
|
|
8
10
|
/**
|
|
@@ -28,16 +28,14 @@ function checkIfStepsIsEqual(step1, step2) {
|
|
|
28
28
|
return step1 === step2;
|
|
29
29
|
}
|
|
30
30
|
|
|
31
|
-
// src/classes/
|
|
32
|
-
var
|
|
31
|
+
// src/classes/LabelAbstract.ts
|
|
32
|
+
var LabelAbstract = class {
|
|
33
33
|
/**
|
|
34
34
|
* @param id is the id of the label
|
|
35
|
-
* @param steps is the list of steps that the label will perform
|
|
36
35
|
* @param props is the properties of the label
|
|
37
36
|
*/
|
|
38
|
-
constructor(id,
|
|
37
|
+
constructor(id, props) {
|
|
39
38
|
this._id = id;
|
|
40
|
-
this._steps = steps;
|
|
41
39
|
this._onStepStart = props == null ? void 0 : props.onStepStart;
|
|
42
40
|
this._onLoadStep = props == null ? void 0 : props.onLoadStep;
|
|
43
41
|
this._onStepEnd = props == null ? void 0 : props.onStepEnd;
|
|
@@ -49,17 +47,6 @@ var Label = class {
|
|
|
49
47
|
get id() {
|
|
50
48
|
return this._id;
|
|
51
49
|
}
|
|
52
|
-
/**
|
|
53
|
-
* Get the steps of the label.
|
|
54
|
-
* This class should be extended and the steps method should be overridden.
|
|
55
|
-
* Every time you update this list will also be updated when the other game versions load.
|
|
56
|
-
*/
|
|
57
|
-
get steps() {
|
|
58
|
-
if (typeof this._steps === "function") {
|
|
59
|
-
return this._steps();
|
|
60
|
-
}
|
|
61
|
-
return this._steps;
|
|
62
|
-
}
|
|
63
50
|
/**
|
|
64
51
|
* Get the corresponding steps number
|
|
65
52
|
* @param externalSteps
|
|
@@ -110,6 +97,28 @@ var Label = class {
|
|
|
110
97
|
}
|
|
111
98
|
};
|
|
112
99
|
|
|
100
|
+
// src/classes/Label.ts
|
|
101
|
+
var Label = class extends LabelAbstract {
|
|
102
|
+
/**
|
|
103
|
+
* @param id is the id of the label
|
|
104
|
+
* @param steps is the list of steps that the label will perform
|
|
105
|
+
* @param props is the properties of the label
|
|
106
|
+
*/
|
|
107
|
+
constructor(id, steps, props) {
|
|
108
|
+
super(id, props);
|
|
109
|
+
this._steps = steps;
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* Get the steps of the label.
|
|
113
|
+
*/
|
|
114
|
+
get steps() {
|
|
115
|
+
if (typeof this._steps === "function") {
|
|
116
|
+
return this._steps();
|
|
117
|
+
}
|
|
118
|
+
return this._steps;
|
|
119
|
+
}
|
|
120
|
+
};
|
|
121
|
+
|
|
113
122
|
// src/classes/CloseLabel.ts
|
|
114
123
|
var CLOSE_LABEL_ID = "__close-label-id__";
|
|
115
124
|
function newCloseLabel(choiseIndex) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/functions/StepLabelUtility.ts","../../src/classes/Label.ts","../../src/classes/CloseLabel.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAmBO,SAAS,mBAAA,CAAoB,OAAiD,KAA0D,EAAA;AAC3I,EAAA,OAAO,KAAU,KAAA,KAAA,CAAA;AACrB,CAAA;;;
|
|
1
|
+
{"version":3,"sources":["../../src/functions/StepLabelUtility.ts","../../src/classes/LabelAbstract.ts","../../src/classes/Label.ts","../../src/classes/CloseLabel.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAmBO,SAAS,mBAAA,CAAoB,OAAiD,KAA0D,EAAA;AAC3I,EAAA,OAAO,KAAU,KAAA,KAAA,CAAA;AACrB,CAAA;;;ACdA,IAA8B,gBAA9B,MAA4E;AAAA;AAAA;AAAA;AAAA;AAAA,EAKxE,WAAA,CAAY,IAAiB,KAA4B,EAAA;AACrD,IAAA,IAAA,CAAK,GAAM,GAAA,EAAA,CAAA;AACX,IAAA,IAAA,CAAK,eAAe,KAAO,IAAA,IAAA,GAAA,KAAA,CAAA,GAAA,KAAA,CAAA,WAAA,CAAA;AAC3B,IAAA,IAAA,CAAK,cAAc,KAAO,IAAA,IAAA,GAAA,KAAA,CAAA,GAAA,KAAA,CAAA,UAAA,CAAA;AAC1B,IAAA,IAAA,CAAK,aAAa,KAAO,IAAA,IAAA,GAAA,KAAA,CAAA,GAAA,KAAA,CAAA,SAAA,CAAA;AACzB,IAAA,IAAA,CAAK,eAAe,KAAO,IAAA,IAAA,GAAA,KAAA,CAAA,GAAA,KAAA,CAAA,WAAA,CAAA;AAAA,GAC/B;AAAA;AAAA;AAAA;AAAA,EAMA,IAAW,EAAkB,GAAA;AACzB,IAAA,OAAO,IAAK,CAAA,GAAA,CAAA;AAAA,GAChB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAYU,4BAA4B,aAAgE,EAAA;AAClG,IAAI,IAAA,aAAA,CAAc,WAAW,CAAG,EAAA;AAC5B,MAAO,OAAA,CAAA,CAAA;AAAA,K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AAI,KAAK,CAAA,CAAA;AACf,IAAA,IAAA,CAAK,MAAS,GAAA,KAAA,CAAA;AAAA,GAClB;AAAA;AAAA;AAAA;AAAA,EAMA,IAAW,KAA4B,GAAA;AACnC,IAAI,IAAA,OAAO,IAAK,CAAA,MAAA,KAAW,UAAY,EAAA;AACnC,MAAA,OAAO,KAAK,MAAO,EAAA,CAAA;AAAA,KACvB;AACA,IAAA,OAAO,IAAK,CAAA,MAAA,CAAA;AAAA,GAChB;AACJ,CAAA,CAAA;;;AChDO,IAAM,cAAiB,GAAA,qBAAA;AAKf,SAAR,cAAkD,WAAsB,EAAA;AAC3E,EAAA,OAAO,IAAI,KAAA,CAAS,cAAgB,EAAA,EAAI,EAAA;AAAA,IACpC,WAAA;AAAA,GACH,CAAA,CAAA;AACL","file":"CloseLabel.js","sourcesContent":["import sha1 from 'crypto-js/sha1';\nimport { StepHistoryDataType } from \"../types/StepHistoryDataType\";\nimport { StepLabelType } from \"../types/StepLabelType\";\n\n/**\n * Convert StepLabel to StepHistoryData\n * @param step\n * @returns\n */\nexport function getStepSha1(step: StepLabelType): StepHistoryDataType {\n let sha1String = sha1(step.toString().toLocaleLowerCase())\n return sha1String.toString()\n}\n/**\n * Check if two steps are equal\n * @param step1\n * @param step2\n * @returns\n */\nexport function checkIfStepsIsEqual(step1: StepHistoryDataType | StepLabelType<any>, step2: StepHistoryDataType | StepLabelType<any>): boolean {\n return step1 === step2\n}\n","import { getLabelById } from \"../decorators\"\nimport { checkIfStepsIsEqual } from \"../functions/StepLabelUtility\"\nimport { LabelProps } from \"../interface\"\nimport { LabelIdType } from \"../types/LabelIdType\"\nimport { StepHistoryDataType } from \"../types/StepHistoryDataType\"\nimport { StepLabelType } from \"../types/StepLabelType\"\n\nexport default abstract class LabelAbstract<TLabel, TProps extends {} = {}> {\n /**\n * @param id is the id of the label\n * @param props is the properties of the label\n */\n constructor(id: LabelIdType, props?: LabelProps<TLabel>) {\n this._id = id\n this._onStepStart = props?.onStepStart\n this._onLoadStep = props?.onLoadStep\n this._onStepEnd = props?.onStepEnd\n this._choiseIndex = props?.choiseIndex\n }\n\n private _id: LabelIdType\n /**\n * Get the id of the label. This variable is used in the system to get the label by id, {@link getLabelById}\n */\n public get id(): LabelIdType {\n return this._id\n }\n\n /**\n * Get the steps of the label.\n */\n public abstract get steps(): StepLabelType<TProps>[]\n\n /**\n * Get the corresponding steps number\n * @param externalSteps\n * @returns Numer of corresponding steps, for example, if externalSteps is [ABC, DEF, GHI] and the steps of the label is [ABC, GHT], the result will be 1\n */\n protected getCorrespondingStepsNumber(externalSteps: StepHistoryDataType[] | StepLabelType[]): number {\n if (externalSteps.length === 0) {\n return 0\n }\n let res: number = 0\n externalSteps.forEach((step, index) => {\n if (checkIfStepsIsEqual(step, this.steps[index])) {\n res = index\n }\n })\n return res\n }\n\n private _onStepStart: ((stepIndex: number, label: TLabel) => void | Promise<void>) | undefined\n /**\n * Is a function that will be executed in {@link Label#onStepStart} and when the user goes back to it or when the user laods a save file.\n * @returns Promise<void> or void\n */\n public get onStepStart(): ((stepIndex: number, label: TLabel) => void | Promise<void>) | undefined {\n return async (stepIndex: number, label: TLabel) => {\n if (this._onLoadStep) {\n await this._onLoadStep(stepIndex, label)\n }\n if (this._onStepStart) {\n return await this._onStepStart(stepIndex, label)\n }\n }\n }\n\n private _onLoadStep: ((stepIndex: number, label: TLabel) => void | Promise<void>) | undefined\n /**\n * Get the function that will be executed a old step is reloaded. A step is reloaded when the user goes back to it or when the user laods a save file.\n * @returns Promise<void> or void\n */\n public get onLoadStep(): ((stepIndex: number, label: TLabel) => void | Promise<void>) | undefined {\n return this._onLoadStep\n }\n\n private _onStepEnd: ((stepIndex: number, label: TLabel) => void | Promise<void>) | undefined\n /**\n * Is a function that will be executed when the step ends.\n * @returns Promise<void> or void\n */\n public get onStepEnd(): ((stepIndex: number, label: TLabel) => void | Promise<void>) | undefined {\n return this._onStepEnd\n }\n\n private _choiseIndex: number | undefined\n public get choiseIndex(): number | undefined {\n return this._choiseIndex\n }\n}\n","import { LabelProps } from \"../interface\"\nimport { LabelIdType } from \"../types/LabelIdType\"\nimport { StepLabelType } from \"../types/StepLabelType\"\nimport LabelAbstract from \"./LabelAbstract\"\n\n/**\n * Label is a class that contains a list of steps, which will be performed as the game continues.\n * For Ren'py this is the equivalent of a label.\n * @example\n * ```typescript\n * const START_LABEL_ID = \"StartLabel\"\n * \n * export const startLabel = newLabel(START_LABEL_ID,\n * [\n * (props) => {\n * GameWindowManager.clear()\n * setDialogue({ character: liam, text: \"Which test do you want to perform?\" })\n * setChoiceMenuOptions([\n * new ChoiceMenuOption(\"Events Test\", eventsTestLabel),\n * new ChoiceMenuOption(\"Show Image Test\", showImageTest),\n * ])\n * },\n * (props) => GameStepManager.jumpLabel(START_LABEL_ID, props),\n * ]\n * )\n * \n * GameStepManager.callLabel(StartLabel)\n * ```\n */\nexport default class Label<T extends {} = {}> extends LabelAbstract<Label<T>, T> {\n /**\n * @param id is the id of the label\n * @param steps is the list of steps that the label will perform\n * @param props is the properties of the label\n */\n constructor(id: LabelIdType, steps: StepLabelType<T>[] | (() => StepLabelType<T>[]), props?: LabelProps<Label<T>>) {\n super(id, props)\n this._steps = steps\n }\n\n private _steps: StepLabelType<T>[] | (() => StepLabelType<T>[])\n /**\n * Get the steps of the label.\n */\n public get steps(): StepLabelType<T>[] {\n if (typeof this._steps === \"function\") {\n return this._steps()\n }\n return this._steps\n }\n}\n","import Label from \"./Label\"\n\nexport const CLOSE_LABEL_ID = \"__close-label-id__\"\n\n/**\n * CloseLabel is a label used for closing the menu.\n */\nexport default function newCloseLabel<T extends {} = {}>(choiseIndex?: number) {\n return new Label<T>(CLOSE_LABEL_ID, [], {\n choiseIndex: choiseIndex,\n })\n}\n"]}
|
|
@@ -24,16 +24,14 @@ function checkIfStepsIsEqual(step1, step2) {
|
|
|
24
24
|
return step1 === step2;
|
|
25
25
|
}
|
|
26
26
|
|
|
27
|
-
// src/classes/
|
|
28
|
-
var
|
|
27
|
+
// src/classes/LabelAbstract.ts
|
|
28
|
+
var LabelAbstract = class {
|
|
29
29
|
/**
|
|
30
30
|
* @param id is the id of the label
|
|
31
|
-
* @param steps is the list of steps that the label will perform
|
|
32
31
|
* @param props is the properties of the label
|
|
33
32
|
*/
|
|
34
|
-
constructor(id,
|
|
33
|
+
constructor(id, props) {
|
|
35
34
|
this._id = id;
|
|
36
|
-
this._steps = steps;
|
|
37
35
|
this._onStepStart = props == null ? void 0 : props.onStepStart;
|
|
38
36
|
this._onLoadStep = props == null ? void 0 : props.onLoadStep;
|
|
39
37
|
this._onStepEnd = props == null ? void 0 : props.onStepEnd;
|
|
@@ -45,17 +43,6 @@ var Label = class {
|
|
|
45
43
|
get id() {
|
|
46
44
|
return this._id;
|
|
47
45
|
}
|
|
48
|
-
/**
|
|
49
|
-
* Get the steps of the label.
|
|
50
|
-
* This class should be extended and the steps method should be overridden.
|
|
51
|
-
* Every time you update this list will also be updated when the other game versions load.
|
|
52
|
-
*/
|
|
53
|
-
get steps() {
|
|
54
|
-
if (typeof this._steps === "function") {
|
|
55
|
-
return this._steps();
|
|
56
|
-
}
|
|
57
|
-
return this._steps;
|
|
58
|
-
}
|
|
59
46
|
/**
|
|
60
47
|
* Get the corresponding steps number
|
|
61
48
|
* @param externalSteps
|
|
@@ -106,6 +93,28 @@ var Label = class {
|
|
|
106
93
|
}
|
|
107
94
|
};
|
|
108
95
|
|
|
96
|
+
// src/classes/Label.ts
|
|
97
|
+
var Label = class extends LabelAbstract {
|
|
98
|
+
/**
|
|
99
|
+
* @param id is the id of the label
|
|
100
|
+
* @param steps is the list of steps that the label will perform
|
|
101
|
+
* @param props is the properties of the label
|
|
102
|
+
*/
|
|
103
|
+
constructor(id, steps, props) {
|
|
104
|
+
super(id, props);
|
|
105
|
+
this._steps = steps;
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Get the steps of the label.
|
|
109
|
+
*/
|
|
110
|
+
get steps() {
|
|
111
|
+
if (typeof this._steps === "function") {
|
|
112
|
+
return this._steps();
|
|
113
|
+
}
|
|
114
|
+
return this._steps;
|
|
115
|
+
}
|
|
116
|
+
};
|
|
117
|
+
|
|
109
118
|
// src/classes/CloseLabel.ts
|
|
110
119
|
var CLOSE_LABEL_ID = "__close-label-id__";
|
|
111
120
|
function newCloseLabel(choiseIndex) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/functions/StepLabelUtility.ts","../../src/classes/Label.ts","../../src/classes/CloseLabel.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAmBO,SAAS,mBAAA,CAAoB,OAAiD,KAA0D,EAAA;AAC3I,EAAA,OAAO,KAAU,KAAA,KAAA,CAAA;AACrB,CAAA;;;
|
|
1
|
+
{"version":3,"sources":["../../src/functions/StepLabelUtility.ts","../../src/classes/LabelAbstract.ts","../../src/classes/Label.ts","../../src/classes/CloseLabel.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAmBO,SAAS,mBAAA,CAAoB,OAAiD,KAA0D,EAAA;AAC3I,EAAA,OAAO,KAAU,KAAA,KAAA,CAAA;AACrB,CAAA;;;ACdA,IAA8B,gBAA9B,MAA4E;AAAA;AAAA;AAAA;AAAA;AAAA,EAKxE,WAAA,CAAY,IAAiB,KAA4B,EAAA;AACrD,IAAA,IAAA,CAAK,GAAM,GAAA,EAAA,CAAA;AACX,IAAA,IAAA,CAAK,eAAe,KAAO,IAAA,IAAA,GAAA,KAAA,CAAA,GAAA,KAAA,CAAA,WAAA,CAAA;AAC3B,IAAA,IAAA,CAAK,cAAc,KAAO,IAAA,IAAA,GAAA,KAAA,CAAA,GAAA,KAAA,CAAA,UAAA,CAAA;AAC1B,IAAA,IAAA,CAAK,aAAa,KAAO,IAAA,IAAA,GAAA,KAAA,CAAA,GAAA,KAAA,CAAA,SAAA,CAAA;AACzB,IAAA,IAAA,CAAK,eAAe,KAAO,IAAA,IAAA,GAAA,KAAA,CAAA,GAAA,KAAA,CAAA,WAAA,CAA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,EAGA,IAAW,WAAkC,GAAA;AACzC,IAAA,OAAO,IAAK,CAAA,YAAA,CAAA;AAAA,GAChB;AACJ,CAAA,CAAA;;;AC5DA,IAAqB,KAAA,GAArB,cAAsD,aAA2B,CAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAM7E,WAAA,CAAY,EAAiB,EAAA,KAAA,EAAwD,KAA8B,EAAA;AAC/G,IAAA,KAAA,CAAM,IAAI,KAAK,CAAA,CAAA;AACf,IAAA,IAAA,CAAK,MAAS,GAAA,KAAA,CAAA;AAAA,GAClB;AAAA;AAAA;AAAA;AAAA,EAMA,IAAW,KAA4B,GAAA;AACnC,IAAI,IAAA,OAAO,IAAK,CAAA,MAAA,KAAW,UAAY,EAAA;AACnC,MAAA,OAAO,KAAK,MAAO,EAAA,CAAA;AAAA,KACvB;AACA,IAAA,OAAO,IAAK,CAAA,MAAA,CAAA;AAAA,GAChB;AACJ,CAAA,CAAA;;;AChDO,IAAM,cAAiB,GAAA,qBAAA;AAKf,SAAR,cAAkD,WAAsB,EAAA;AAC3E,EAAA,OAAO,IAAI,KAAA,CAAS,cAAgB,EAAA,EAAI,EAAA;AAAA,IACpC,WAAA;AAAA,GACH,CAAA,CAAA;AACL","file":"CloseLabel.mjs","sourcesContent":["import sha1 from 'crypto-js/sha1';\nimport { StepHistoryDataType } from \"../types/StepHistoryDataType\";\nimport { StepLabelType } from \"../types/StepLabelType\";\n\n/**\n * Convert StepLabel to StepHistoryData\n * @param step\n * @returns\n */\nexport function getStepSha1(step: StepLabelType): StepHistoryDataType {\n let sha1String = sha1(step.toString().toLocaleLowerCase())\n return sha1String.toString()\n}\n/**\n * Check if two steps are equal\n * @param step1\n * @param step2\n * @returns\n */\nexport function checkIfStepsIsEqual(step1: StepHistoryDataType | StepLabelType<any>, step2: StepHistoryDataType | StepLabelType<any>): boolean {\n return step1 === step2\n}\n","import { getLabelById } from \"../decorators\"\nimport { checkIfStepsIsEqual } from \"../functions/StepLabelUtility\"\nimport { LabelProps } from \"../interface\"\nimport { LabelIdType } from \"../types/LabelIdType\"\nimport { StepHistoryDataType } from \"../types/StepHistoryDataType\"\nimport { StepLabelType } from \"../types/StepLabelType\"\n\nexport default abstract class LabelAbstract<TLabel, TProps extends {} = {}> {\n /**\n * @param id is the id of the label\n * @param props is the properties of the label\n */\n constructor(id: LabelIdType, props?: LabelProps<TLabel>) {\n this._id = id\n this._onStepStart = props?.onStepStart\n this._onLoadStep = props?.onLoadStep\n this._onStepEnd = props?.onStepEnd\n this._choiseIndex = props?.choiseIndex\n }\n\n private _id: LabelIdType\n /**\n * Get the id of the label. This variable is used in the system to get the label by id, {@link getLabelById}\n */\n public get id(): LabelIdType {\n return this._id\n }\n\n /**\n * Get the steps of the label.\n */\n public abstract get steps(): StepLabelType<TProps>[]\n\n /**\n * Get the corresponding steps number\n * @param externalSteps\n * @returns Numer of corresponding steps, for example, if externalSteps is [ABC, DEF, GHI] and the steps of the label is [ABC, GHT], the result will be 1\n */\n protected getCorrespondingStepsNumber(externalSteps: StepHistoryDataType[] | StepLabelType[]): number {\n if (externalSteps.length === 0) {\n return 0\n }\n let res: number = 0\n externalSteps.forEach((step, index) => {\n if (checkIfStepsIsEqual(step, this.steps[index])) {\n res = index\n }\n })\n return res\n }\n\n private _onStepStart: ((stepIndex: number, label: TLabel) => void | Promise<void>) | undefined\n /**\n * Is a function that will be executed in {@link Label#onStepStart} and when the user goes back to it or when the user laods a save file.\n * @returns Promise<void> or void\n */\n public get onStepStart(): ((stepIndex: number, label: TLabel) => void | Promise<void>) | undefined {\n return async (stepIndex: number, label: TLabel) => {\n if (this._onLoadStep) {\n await this._onLoadStep(stepIndex, label)\n }\n if (this._onStepStart) {\n return await this._onStepStart(stepIndex, label)\n }\n }\n }\n\n private _onLoadStep: ((stepIndex: number, label: TLabel) => void | Promise<void>) | undefined\n /**\n * Get the function that will be executed a old step is reloaded. A step is reloaded when the user goes back to it or when the user laods a save file.\n * @returns Promise<void> or void\n */\n public get onLoadStep(): ((stepIndex: number, label: TLabel) => void | Promise<void>) | undefined {\n return this._onLoadStep\n }\n\n private _onStepEnd: ((stepIndex: number, label: TLabel) => void | Promise<void>) | undefined\n /**\n * Is a function that will be executed when the step ends.\n * @returns Promise<void> or void\n */\n public get onStepEnd(): ((stepIndex: number, label: TLabel) => void | Promise<void>) | undefined {\n return this._onStepEnd\n }\n\n private _choiseIndex: number | undefined\n public get choiseIndex(): number | undefined {\n return this._choiseIndex\n }\n}\n","import { LabelProps } from \"../interface\"\nimport { LabelIdType } from \"../types/LabelIdType\"\nimport { StepLabelType } from \"../types/StepLabelType\"\nimport LabelAbstract from \"./LabelAbstract\"\n\n/**\n * Label is a class that contains a list of steps, which will be performed as the game continues.\n * For Ren'py this is the equivalent of a label.\n * @example\n * ```typescript\n * const START_LABEL_ID = \"StartLabel\"\n * \n * export const startLabel = newLabel(START_LABEL_ID,\n * [\n * (props) => {\n * GameWindowManager.clear()\n * setDialogue({ character: liam, text: \"Which test do you want to perform?\" })\n * setChoiceMenuOptions([\n * new ChoiceMenuOption(\"Events Test\", eventsTestLabel),\n * new ChoiceMenuOption(\"Show Image Test\", showImageTest),\n * ])\n * },\n * (props) => GameStepManager.jumpLabel(START_LABEL_ID, props),\n * ]\n * )\n * \n * GameStepManager.callLabel(StartLabel)\n * ```\n */\nexport default class Label<T extends {} = {}> extends LabelAbstract<Label<T>, T> {\n /**\n * @param id is the id of the label\n * @param steps is the list of steps that the label will perform\n * @param props is the properties of the label\n */\n constructor(id: LabelIdType, steps: StepLabelType<T>[] | (() => StepLabelType<T>[]), props?: LabelProps<Label<T>>) {\n super(id, props)\n this._steps = steps\n }\n\n private _steps: StepLabelType<T>[] | (() => StepLabelType<T>[])\n /**\n * Get the steps of the label.\n */\n public get steps(): StepLabelType<T>[] {\n if (typeof this._steps === \"function\") {\n return this._steps()\n }\n return this._steps\n }\n}\n","import Label from \"./Label\"\n\nexport const CLOSE_LABEL_ID = \"__close-label-id__\"\n\n/**\n * CloseLabel is a label used for closing the menu.\n */\nexport default function newCloseLabel<T extends {} = {}>(choiseIndex?: number) {\n return new Label<T>(CLOSE_LABEL_ID, [], {\n choiseIndex: choiseIndex,\n })\n}\n"]}
|
package/dist/classes/Label.d.mts
CHANGED
|
@@ -1,5 +1,46 @@
|
|
|
1
|
-
import '../types/LabelIdType.mjs';
|
|
2
|
-
|
|
3
|
-
import '
|
|
4
|
-
import '../
|
|
1
|
+
import { LabelIdType } from '../types/LabelIdType.mjs';
|
|
2
|
+
import { StepLabelType } from '../types/StepLabelType.mjs';
|
|
3
|
+
import LabelAbstract from './LabelAbstract.mjs';
|
|
4
|
+
import LabelProps from '../interface/LabelProps.mjs';
|
|
5
5
|
import '@drincs/pixi-vn/dist/override';
|
|
6
|
+
import '../types/StepHistoryDataType.mjs';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Label is a class that contains a list of steps, which will be performed as the game continues.
|
|
10
|
+
* For Ren'py this is the equivalent of a label.
|
|
11
|
+
* @example
|
|
12
|
+
* ```typescript
|
|
13
|
+
* const START_LABEL_ID = "StartLabel"
|
|
14
|
+
*
|
|
15
|
+
* export const startLabel = newLabel(START_LABEL_ID,
|
|
16
|
+
* [
|
|
17
|
+
* (props) => {
|
|
18
|
+
* GameWindowManager.clear()
|
|
19
|
+
* setDialogue({ character: liam, text: "Which test do you want to perform?" })
|
|
20
|
+
* setChoiceMenuOptions([
|
|
21
|
+
* new ChoiceMenuOption("Events Test", eventsTestLabel),
|
|
22
|
+
* new ChoiceMenuOption("Show Image Test", showImageTest),
|
|
23
|
+
* ])
|
|
24
|
+
* },
|
|
25
|
+
* (props) => GameStepManager.jumpLabel(START_LABEL_ID, props),
|
|
26
|
+
* ]
|
|
27
|
+
* )
|
|
28
|
+
*
|
|
29
|
+
* GameStepManager.callLabel(StartLabel)
|
|
30
|
+
* ```
|
|
31
|
+
*/
|
|
32
|
+
declare class Label<T extends {} = {}> extends LabelAbstract<Label<T>, T> {
|
|
33
|
+
/**
|
|
34
|
+
* @param id is the id of the label
|
|
35
|
+
* @param steps is the list of steps that the label will perform
|
|
36
|
+
* @param props is the properties of the label
|
|
37
|
+
*/
|
|
38
|
+
constructor(id: LabelIdType, steps: StepLabelType<T>[] | (() => StepLabelType<T>[]), props?: LabelProps<Label<T>>);
|
|
39
|
+
private _steps;
|
|
40
|
+
/**
|
|
41
|
+
* Get the steps of the label.
|
|
42
|
+
*/
|
|
43
|
+
get steps(): StepLabelType<T>[];
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export { Label as default };
|
package/dist/classes/Label.d.ts
CHANGED
|
@@ -1,5 +1,46 @@
|
|
|
1
|
-
import '../types/LabelIdType.js';
|
|
2
|
-
|
|
3
|
-
import '
|
|
4
|
-
import '../
|
|
1
|
+
import { LabelIdType } from '../types/LabelIdType.js';
|
|
2
|
+
import { StepLabelType } from '../types/StepLabelType.js';
|
|
3
|
+
import LabelAbstract from './LabelAbstract.js';
|
|
4
|
+
import LabelProps from '../interface/LabelProps.js';
|
|
5
5
|
import '@drincs/pixi-vn/dist/override';
|
|
6
|
+
import '../types/StepHistoryDataType.js';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Label is a class that contains a list of steps, which will be performed as the game continues.
|
|
10
|
+
* For Ren'py this is the equivalent of a label.
|
|
11
|
+
* @example
|
|
12
|
+
* ```typescript
|
|
13
|
+
* const START_LABEL_ID = "StartLabel"
|
|
14
|
+
*
|
|
15
|
+
* export const startLabel = newLabel(START_LABEL_ID,
|
|
16
|
+
* [
|
|
17
|
+
* (props) => {
|
|
18
|
+
* GameWindowManager.clear()
|
|
19
|
+
* setDialogue({ character: liam, text: "Which test do you want to perform?" })
|
|
20
|
+
* setChoiceMenuOptions([
|
|
21
|
+
* new ChoiceMenuOption("Events Test", eventsTestLabel),
|
|
22
|
+
* new ChoiceMenuOption("Show Image Test", showImageTest),
|
|
23
|
+
* ])
|
|
24
|
+
* },
|
|
25
|
+
* (props) => GameStepManager.jumpLabel(START_LABEL_ID, props),
|
|
26
|
+
* ]
|
|
27
|
+
* )
|
|
28
|
+
*
|
|
29
|
+
* GameStepManager.callLabel(StartLabel)
|
|
30
|
+
* ```
|
|
31
|
+
*/
|
|
32
|
+
declare class Label<T extends {} = {}> extends LabelAbstract<Label<T>, T> {
|
|
33
|
+
/**
|
|
34
|
+
* @param id is the id of the label
|
|
35
|
+
* @param steps is the list of steps that the label will perform
|
|
36
|
+
* @param props is the properties of the label
|
|
37
|
+
*/
|
|
38
|
+
constructor(id: LabelIdType, steps: StepLabelType<T>[] | (() => StepLabelType<T>[]), props?: LabelProps<Label<T>>);
|
|
39
|
+
private _steps;
|
|
40
|
+
/**
|
|
41
|
+
* Get the steps of the label.
|
|
42
|
+
*/
|
|
43
|
+
get steps(): StepLabelType<T>[];
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export { Label as default };
|
package/dist/classes/Label.js
CHANGED
|
@@ -26,16 +26,14 @@ function checkIfStepsIsEqual(step1, step2) {
|
|
|
26
26
|
return step1 === step2;
|
|
27
27
|
}
|
|
28
28
|
|
|
29
|
-
// src/classes/
|
|
30
|
-
var
|
|
29
|
+
// src/classes/LabelAbstract.ts
|
|
30
|
+
var LabelAbstract = class {
|
|
31
31
|
/**
|
|
32
32
|
* @param id is the id of the label
|
|
33
|
-
* @param steps is the list of steps that the label will perform
|
|
34
33
|
* @param props is the properties of the label
|
|
35
34
|
*/
|
|
36
|
-
constructor(id,
|
|
35
|
+
constructor(id, props) {
|
|
37
36
|
this._id = id;
|
|
38
|
-
this._steps = steps;
|
|
39
37
|
this._onStepStart = props == null ? void 0 : props.onStepStart;
|
|
40
38
|
this._onLoadStep = props == null ? void 0 : props.onLoadStep;
|
|
41
39
|
this._onStepEnd = props == null ? void 0 : props.onStepEnd;
|
|
@@ -47,17 +45,6 @@ var Label = class {
|
|
|
47
45
|
get id() {
|
|
48
46
|
return this._id;
|
|
49
47
|
}
|
|
50
|
-
/**
|
|
51
|
-
* Get the steps of the label.
|
|
52
|
-
* This class should be extended and the steps method should be overridden.
|
|
53
|
-
* Every time you update this list will also be updated when the other game versions load.
|
|
54
|
-
*/
|
|
55
|
-
get steps() {
|
|
56
|
-
if (typeof this._steps === "function") {
|
|
57
|
-
return this._steps();
|
|
58
|
-
}
|
|
59
|
-
return this._steps;
|
|
60
|
-
}
|
|
61
48
|
/**
|
|
62
49
|
* Get the corresponding steps number
|
|
63
50
|
* @param externalSteps
|
|
@@ -108,6 +95,28 @@ var Label = class {
|
|
|
108
95
|
}
|
|
109
96
|
};
|
|
110
97
|
|
|
98
|
+
// src/classes/Label.ts
|
|
99
|
+
var Label = class extends LabelAbstract {
|
|
100
|
+
/**
|
|
101
|
+
* @param id is the id of the label
|
|
102
|
+
* @param steps is the list of steps that the label will perform
|
|
103
|
+
* @param props is the properties of the label
|
|
104
|
+
*/
|
|
105
|
+
constructor(id, steps, props) {
|
|
106
|
+
super(id, props);
|
|
107
|
+
this._steps = steps;
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Get the steps of the label.
|
|
111
|
+
*/
|
|
112
|
+
get steps() {
|
|
113
|
+
if (typeof this._steps === "function") {
|
|
114
|
+
return this._steps();
|
|
115
|
+
}
|
|
116
|
+
return this._steps;
|
|
117
|
+
}
|
|
118
|
+
};
|
|
119
|
+
|
|
111
120
|
module.exports = Label;
|
|
112
121
|
//# sourceMappingURL=Label.js.map
|
|
113
122
|
//# sourceMappingURL=Label.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/functions/StepLabelUtility.ts","../../src/classes/Label.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAmBO,SAAS,mBAAA,CAAoB,OAAiD,KAA0D,EAAA;AAC3I,EAAA,OAAO,KAAU,KAAA,KAAA,CAAA;AACrB,CAAA;;;
|
|
1
|
+
{"version":3,"sources":["../../src/functions/StepLabelUtility.ts","../../src/classes/LabelAbstract.ts","../../src/classes/Label.ts"],"names":[],"mappings":";;;;;;;;;;;;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js","sourcesContent":["import sha1 from 'crypto-js/sha1';\nimport { StepHistoryDataType } from \"../types/StepHistoryDataType\";\nimport { StepLabelType } from \"../types/StepLabelType\";\n\n/**\n * Convert StepLabel to StepHistoryData\n * @param step\n * @returns\n */\nexport function getStepSha1(step: StepLabelType): StepHistoryDataType {\n let sha1String = sha1(step.toString().toLocaleLowerCase())\n return sha1String.toString()\n}\n/**\n * Check if two steps are equal\n * @param step1\n * @param step2\n * @returns\n */\nexport function checkIfStepsIsEqual(step1: StepHistoryDataType | StepLabelType<any>, step2: StepHistoryDataType | StepLabelType<any>): boolean {\n return step1 === step2\n}\n","import { getLabelById } from \"../decorators\"\nimport { checkIfStepsIsEqual } from \"../functions/StepLabelUtility\"\nimport { LabelProps } from \"../interface\"\nimport { LabelIdType } from \"../types/LabelIdType\"\nimport { StepHistoryDataType } from \"../types/StepHistoryDataType\"\nimport { StepLabelType } from \"../types/StepLabelType\"\n\nexport default abstract class LabelAbstract<TLabel, TProps extends {} = {}> {\n /**\n * @param id is the id of the label\n * @param props is the properties of the label\n */\n constructor(id: LabelIdType, props?: LabelProps<TLabel>) {\n this._id = id\n this._onStepStart = props?.onStepStart\n this._onLoadStep = props?.onLoadStep\n this._onStepEnd = props?.onStepEnd\n this._choiseIndex = props?.choiseIndex\n }\n\n private _id: LabelIdType\n /**\n * Get the id of the label. This variable is used in the system to get the label by id, {@link getLabelById}\n */\n public get id(): LabelIdType {\n return this._id\n }\n\n /**\n * Get the steps of the label.\n */\n public abstract get steps(): StepLabelType<TProps>[]\n\n /**\n * Get the corresponding steps number\n * @param externalSteps\n * @returns Numer of corresponding steps, for example, if externalSteps is [ABC, DEF, GHI] and the steps of the label is [ABC, GHT], the result will be 1\n */\n protected getCorrespondingStepsNumber(externalSteps: StepHistoryDataType[] | StepLabelType[]): number {\n if (externalSteps.length === 0) {\n return 0\n }\n let res: number = 0\n externalSteps.forEach((step, index) => {\n if (checkIfStepsIsEqual(step, this.steps[index])) {\n res = index\n }\n })\n return res\n }\n\n private _onStepStart: ((stepIndex: number, label: TLabel) => void | Promise<void>) | undefined\n /**\n * Is a function that will be executed in {@link Label#onStepStart} and when the user goes back to it or when the user laods a save file.\n * @returns Promise<void> or void\n */\n public get onStepStart(): ((stepIndex: number, label: TLabel) => void | Promise<void>) | undefined {\n return async (stepIndex: number, label: TLabel) => {\n if (this._onLoadStep) {\n await this._onLoadStep(stepIndex, label)\n }\n if (this._onStepStart) {\n return await this._onStepStart(stepIndex, label)\n }\n }\n }\n\n private _onLoadStep: ((stepIndex: number, label: TLabel) => void | Promise<void>) | undefined\n /**\n * Get the function that will be executed a old step is reloaded. A step is reloaded when the user goes back to it or when the user laods a save file.\n * @returns Promise<void> or void\n */\n public get onLoadStep(): ((stepIndex: number, label: TLabel) => void | Promise<void>) | undefined {\n return this._onLoadStep\n }\n\n private _onStepEnd: ((stepIndex: number, label: TLabel) => void | Promise<void>) | undefined\n /**\n * Is a function that will be executed when the step ends.\n * @returns Promise<void> or void\n */\n public get onStepEnd(): ((stepIndex: number, label: TLabel) => void | Promise<void>) | undefined {\n return this._onStepEnd\n }\n\n private _choiseIndex: number | undefined\n public get choiseIndex(): number | undefined {\n return this._choiseIndex\n }\n}\n","import { LabelProps } from \"../interface\"\nimport { LabelIdType } from \"../types/LabelIdType\"\nimport { StepLabelType } from \"../types/StepLabelType\"\nimport LabelAbstract from \"./LabelAbstract\"\n\n/**\n * Label is a class that contains a list of steps, which will be performed as the game continues.\n * For Ren'py this is the equivalent of a label.\n * @example\n * ```typescript\n * const START_LABEL_ID = \"StartLabel\"\n * \n * export const startLabel = newLabel(START_LABEL_ID,\n * [\n * (props) => {\n * GameWindowManager.clear()\n * setDialogue({ character: liam, text: \"Which test do you want to perform?\" })\n * setChoiceMenuOptions([\n * new ChoiceMenuOption(\"Events Test\", eventsTestLabel),\n * new ChoiceMenuOption(\"Show Image Test\", showImageTest),\n * ])\n * },\n * (props) => GameStepManager.jumpLabel(START_LABEL_ID, props),\n * ]\n * )\n * \n * GameStepManager.callLabel(StartLabel)\n * ```\n */\nexport default class Label<T extends {} = {}> extends LabelAbstract<Label<T>, T> {\n /**\n * @param id is the id of the label\n * @param steps is the list of steps that the label will perform\n * @param props is the properties of the label\n */\n constructor(id: LabelIdType, steps: StepLabelType<T>[] | (() => StepLabelType<T>[]), props?: LabelProps<Label<T>>) {\n super(id, props)\n this._steps = steps\n }\n\n private _steps: StepLabelType<T>[] | (() => StepLabelType<T>[])\n /**\n * Get the steps of the label.\n */\n public get steps(): StepLabelType<T>[] {\n if (typeof this._steps === \"function\") {\n return this._steps()\n }\n return this._steps\n }\n}\n"]}
|
package/dist/classes/Label.mjs
CHANGED
|
@@ -24,16 +24,14 @@ function checkIfStepsIsEqual(step1, step2) {
|
|
|
24
24
|
return step1 === step2;
|
|
25
25
|
}
|
|
26
26
|
|
|
27
|
-
// src/classes/
|
|
28
|
-
var
|
|
27
|
+
// src/classes/LabelAbstract.ts
|
|
28
|
+
var LabelAbstract = class {
|
|
29
29
|
/**
|
|
30
30
|
* @param id is the id of the label
|
|
31
|
-
* @param steps is the list of steps that the label will perform
|
|
32
31
|
* @param props is the properties of the label
|
|
33
32
|
*/
|
|
34
|
-
constructor(id,
|
|
33
|
+
constructor(id, props) {
|
|
35
34
|
this._id = id;
|
|
36
|
-
this._steps = steps;
|
|
37
35
|
this._onStepStart = props == null ? void 0 : props.onStepStart;
|
|
38
36
|
this._onLoadStep = props == null ? void 0 : props.onLoadStep;
|
|
39
37
|
this._onStepEnd = props == null ? void 0 : props.onStepEnd;
|
|
@@ -45,17 +43,6 @@ var Label = class {
|
|
|
45
43
|
get id() {
|
|
46
44
|
return this._id;
|
|
47
45
|
}
|
|
48
|
-
/**
|
|
49
|
-
* Get the steps of the label.
|
|
50
|
-
* This class should be extended and the steps method should be overridden.
|
|
51
|
-
* Every time you update this list will also be updated when the other game versions load.
|
|
52
|
-
*/
|
|
53
|
-
get steps() {
|
|
54
|
-
if (typeof this._steps === "function") {
|
|
55
|
-
return this._steps();
|
|
56
|
-
}
|
|
57
|
-
return this._steps;
|
|
58
|
-
}
|
|
59
46
|
/**
|
|
60
47
|
* Get the corresponding steps number
|
|
61
48
|
* @param externalSteps
|
|
@@ -106,6 +93,28 @@ var Label = class {
|
|
|
106
93
|
}
|
|
107
94
|
};
|
|
108
95
|
|
|
96
|
+
// src/classes/Label.ts
|
|
97
|
+
var Label = class extends LabelAbstract {
|
|
98
|
+
/**
|
|
99
|
+
* @param id is the id of the label
|
|
100
|
+
* @param steps is the list of steps that the label will perform
|
|
101
|
+
* @param props is the properties of the label
|
|
102
|
+
*/
|
|
103
|
+
constructor(id, steps, props) {
|
|
104
|
+
super(id, props);
|
|
105
|
+
this._steps = steps;
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Get the steps of the label.
|
|
109
|
+
*/
|
|
110
|
+
get steps() {
|
|
111
|
+
if (typeof this._steps === "function") {
|
|
112
|
+
return this._steps();
|
|
113
|
+
}
|
|
114
|
+
return this._steps;
|
|
115
|
+
}
|
|
116
|
+
};
|
|
117
|
+
|
|
109
118
|
export { Label as default };
|
|
110
119
|
//# sourceMappingURL=Label.mjs.map
|
|
111
120
|
//# sourceMappingURL=Label.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/functions/StepLabelUtility.ts","../../src/classes/Label.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAmBO,SAAS,mBAAA,CAAoB,OAAiD,KAA0D,EAAA;AAC3I,EAAA,OAAO,KAAU,KAAA,KAAA,CAAA;AACrB,CAAA;;;
|
|
1
|
+
{"version":3,"sources":["../../src/functions/StepLabelUtility.ts","../../src/classes/LabelAbstract.ts","../../src/classes/Label.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAmBO,SAAS,mBAAA,CAAoB,OAAiD,KAA0D,EAAA;AAC3I,EAAA,OAAO,KAAU,KAAA,KAAA,CAAA;AACrB,CAAA;;;ACdA,IAA8B,gBAA9B,M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C/C,MAAA,IAAI,KAAK,WAAa,EAAA;AAClB,QAAM,MAAA,IAAA,CAAK,WAAY,CAAA,SAAA,EAAW,KAAK,CAAA,CAAA;AAAA,OAC3C;AACA,MAAA,IAAI,KAAK,YAAc,EAAA;AACnB,QAAA,OAAO,MAAM,IAAA,CAAK,YAAa,CAAA,SAAA,EAAW,KAAK,CAAA,CAAA;AAAA,OACnD;AAAA,KACJ,CAAA,CAAA;AAAA,GACJ;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,IAAW,UAAuF,GAAA;AAC9F,IAAA,OAAO,IAAK,CAAA,WAAA,CAAA;AAAA,GAChB;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,IAAW,SAAsF,GAAA;AAC7F,IAAA,OAAO,IAAK,CAAA,UAAA,CAAA;AAAA,GAChB;AAAA,EAGA,IAAW,WAAkC,GAAA;AACzC,IAAA,OAAO,IAAK,CAAA,YAAA,CAAA;AAAA,GAChB;AACJ,CAAA,CAAA;;;AC5DqB,IAAA,KAAA,GAArB,cAAsD,aAA2B,CAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAM7E,WAAA,CAAY,EAAiB,EAAA,KAAA,EAAwD,KAA8B,EAAA;AAC/G,IAAA,KAAA,CAAM,IAAI,KAAK,CAAA,CAAA;AACf,IAAA,IAAA,CAAK,MAAS,GAAA,KAAA,CAAA;AAAA,GAClB;AAAA;AAAA;AAAA;AAAA,EAMA,IAAW,KAA4B,GAAA;AACnC,IAAI,IAAA,OAAO,IAAK,CAAA,MAAA,KAAW,UAAY,EAAA;AACnC,MAAA,OAAO,KAAK,MAAO,EAAA,CAAA;AAAA,KACvB;AACA,IAAA,OAAO,IAAK,CAAA,MAAA,CAAA;AAAA,GAChB;AACJ","file":"Label.mjs","sourcesContent":["import sha1 from 'crypto-js/sha1';\nimport { StepHistoryDataType } from \"../types/StepHistoryDataType\";\nimport { StepLabelType } from \"../types/StepLabelType\";\n\n/**\n * Convert StepLabel to StepHistoryData\n * @param step\n * @returns\n */\nexport function getStepSha1(step: StepLabelType): StepHistoryDataType {\n let sha1String = sha1(step.toString().toLocaleLowerCase())\n return sha1String.toString()\n}\n/**\n * Check if two steps are equal\n * @param step1\n * @param step2\n * @returns\n */\nexport function checkIfStepsIsEqual(step1: StepHistoryDataType | StepLabelType<any>, step2: StepHistoryDataType | StepLabelType<any>): boolean {\n return step1 === step2\n}\n","import { getLabelById } from \"../decorators\"\nimport { checkIfStepsIsEqual } from \"../functions/StepLabelUtility\"\nimport { LabelProps } from \"../interface\"\nimport { LabelIdType } from \"../types/LabelIdType\"\nimport { StepHistoryDataType } from \"../types/StepHistoryDataType\"\nimport { StepLabelType } from \"../types/StepLabelType\"\n\nexport default abstract class LabelAbstract<TLabel, TProps extends {} = {}> {\n /**\n * @param id is the id of the label\n * @param props is the properties of the label\n */\n constructor(id: LabelIdType, props?: LabelProps<TLabel>) {\n this._id = id\n this._onStepStart = props?.onStepStart\n this._onLoadStep = props?.onLoadStep\n this._onStepEnd = props?.onStepEnd\n this._choiseIndex = props?.choiseIndex\n }\n\n private _id: LabelIdType\n /**\n * Get the id of the label. This variable is used in the system to get the label by id, {@link getLabelById}\n */\n public get id(): LabelIdType {\n return this._id\n }\n\n /**\n * Get the steps of the label.\n */\n public abstract get steps(): StepLabelType<TProps>[]\n\n /**\n * Get the corresponding steps number\n * @param externalSteps\n * @returns Numer of corresponding steps, for example, if externalSteps is [ABC, DEF, GHI] and the steps of the label is [ABC, GHT], the result will be 1\n */\n protected getCorrespondingStepsNumber(externalSteps: StepHistoryDataType[] | StepLabelType[]): number {\n if (externalSteps.length === 0) {\n return 0\n }\n let res: number = 0\n externalSteps.forEach((step, index) => {\n if (checkIfStepsIsEqual(step, this.steps[index])) {\n res = index\n }\n })\n return res\n }\n\n private _onStepStart: ((stepIndex: number, label: TLabel) => void | Promise<void>) | undefined\n /**\n * Is a function that will be executed in {@link Label#onStepStart} and when the user goes back to it or when the user laods a save file.\n * @returns Promise<void> or void\n */\n public get onStepStart(): ((stepIndex: number, label: TLabel) => void | Promise<void>) | undefined {\n return async (stepIndex: number, label: TLabel) => {\n if (this._onLoadStep) {\n await this._onLoadStep(stepIndex, label)\n }\n if (this._onStepStart) {\n return await this._onStepStart(stepIndex, label)\n }\n }\n }\n\n private _onLoadStep: ((stepIndex: number, label: TLabel) => void | Promise<void>) | undefined\n /**\n * Get the function that will be executed a old step is reloaded. A step is reloaded when the user goes back to it or when the user laods a save file.\n * @returns Promise<void> or void\n */\n public get onLoadStep(): ((stepIndex: number, label: TLabel) => void | Promise<void>) | undefined {\n return this._onLoadStep\n }\n\n private _onStepEnd: ((stepIndex: number, label: TLabel) => void | Promise<void>) | undefined\n /**\n * Is a function that will be executed when the step ends.\n * @returns Promise<void> or void\n */\n public get onStepEnd(): ((stepIndex: number, label: TLabel) => void | Promise<void>) | undefined {\n return this._onStepEnd\n }\n\n private _choiseIndex: number | undefined\n public get choiseIndex(): number | undefined {\n return this._choiseIndex\n }\n}\n","import { LabelProps } from \"../interface\"\nimport { LabelIdType } from \"../types/LabelIdType\"\nimport { StepLabelType } from \"../types/StepLabelType\"\nimport LabelAbstract from \"./LabelAbstract\"\n\n/**\n * Label is a class that contains a list of steps, which will be performed as the game continues.\n * For Ren'py this is the equivalent of a label.\n * @example\n * ```typescript\n * const START_LABEL_ID = \"StartLabel\"\n * \n * export const startLabel = newLabel(START_LABEL_ID,\n * [\n * (props) => {\n * GameWindowManager.clear()\n * setDialogue({ character: liam, text: \"Which test do you want to perform?\" })\n * setChoiceMenuOptions([\n * new ChoiceMenuOption(\"Events Test\", eventsTestLabel),\n * new ChoiceMenuOption(\"Show Image Test\", showImageTest),\n * ])\n * },\n * (props) => GameStepManager.jumpLabel(START_LABEL_ID, props),\n * ]\n * )\n * \n * GameStepManager.callLabel(StartLabel)\n * ```\n */\nexport default class Label<T extends {} = {}> extends LabelAbstract<Label<T>, T> {\n /**\n * @param id is the id of the label\n * @param steps is the list of steps that the label will perform\n * @param props is the properties of the label\n */\n constructor(id: LabelIdType, steps: StepLabelType<T>[] | (() => StepLabelType<T>[]), props?: LabelProps<Label<T>>) {\n super(id, props)\n this._steps = steps\n }\n\n private _steps: StepLabelType<T>[] | (() => StepLabelType<T>[])\n /**\n * Get the steps of the label.\n */\n public get steps(): StepLabelType<T>[] {\n if (typeof this._steps === \"function\") {\n return this._steps()\n }\n return this._steps\n }\n}\n"]}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { LabelIdType } from '../types/LabelIdType.mjs';
|
|
2
|
+
import { StepLabelType } from '../types/StepLabelType.mjs';
|
|
3
|
+
import { StepHistoryDataType } from '../types/StepHistoryDataType.mjs';
|
|
4
|
+
import LabelProps from '../interface/LabelProps.mjs';
|
|
5
|
+
import '@drincs/pixi-vn/dist/override';
|
|
6
|
+
|
|
7
|
+
declare abstract class LabelAbstract<TLabel, TProps extends {} = {}> {
|
|
8
|
+
/**
|
|
9
|
+
* @param id is the id of the label
|
|
10
|
+
* @param props is the properties of the label
|
|
11
|
+
*/
|
|
12
|
+
constructor(id: LabelIdType, props?: LabelProps<TLabel>);
|
|
13
|
+
private _id;
|
|
14
|
+
/**
|
|
15
|
+
* Get the id of the label. This variable is used in the system to get the label by id, {@link getLabelById}
|
|
16
|
+
*/
|
|
17
|
+
get id(): LabelIdType;
|
|
18
|
+
/**
|
|
19
|
+
* Get the steps of the label.
|
|
20
|
+
*/
|
|
21
|
+
abstract get steps(): StepLabelType<TProps>[];
|
|
22
|
+
/**
|
|
23
|
+
* Get the corresponding steps number
|
|
24
|
+
* @param externalSteps
|
|
25
|
+
* @returns Numer of corresponding steps, for example, if externalSteps is [ABC, DEF, GHI] and the steps of the label is [ABC, GHT], the result will be 1
|
|
26
|
+
*/
|
|
27
|
+
protected getCorrespondingStepsNumber(externalSteps: StepHistoryDataType[] | StepLabelType[]): number;
|
|
28
|
+
private _onStepStart;
|
|
29
|
+
/**
|
|
30
|
+
* Is a function that will be executed in {@link Label#onStepStart} and when the user goes back to it or when the user laods a save file.
|
|
31
|
+
* @returns Promise<void> or void
|
|
32
|
+
*/
|
|
33
|
+
get onStepStart(): ((stepIndex: number, label: TLabel) => void | Promise<void>) | undefined;
|
|
34
|
+
private _onLoadStep;
|
|
35
|
+
/**
|
|
36
|
+
* Get the function that will be executed a old step is reloaded. A step is reloaded when the user goes back to it or when the user laods a save file.
|
|
37
|
+
* @returns Promise<void> or void
|
|
38
|
+
*/
|
|
39
|
+
get onLoadStep(): ((stepIndex: number, label: TLabel) => void | Promise<void>) | undefined;
|
|
40
|
+
private _onStepEnd;
|
|
41
|
+
/**
|
|
42
|
+
* Is a function that will be executed when the step ends.
|
|
43
|
+
* @returns Promise<void> or void
|
|
44
|
+
*/
|
|
45
|
+
get onStepEnd(): ((stepIndex: number, label: TLabel) => void | Promise<void>) | undefined;
|
|
46
|
+
private _choiseIndex;
|
|
47
|
+
get choiseIndex(): number | undefined;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export { LabelAbstract as default };
|