@drincs/pixi-vn 0.6.4 → 0.6.6
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 +56 -7
- package/dist/classes/CharacterBaseModel.js +99 -90
- package/dist/classes/CharacterBaseModel.js.map +1 -1
- package/dist/classes/CharacterBaseModel.mjs +99 -90
- package/dist/classes/CharacterBaseModel.mjs.map +1 -1
- package/dist/classes/ChoiceMenuOption.d.mts +71 -8
- package/dist/classes/ChoiceMenuOption.d.ts +71 -8
- package/dist/classes/ChoiceMenuOption.js +160 -77
- package/dist/classes/ChoiceMenuOption.js.map +1 -1
- package/dist/classes/ChoiceMenuOption.mjs +160 -77
- 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 +77 -32
- package/dist/classes/CloseLabel.js.map +1 -1
- package/dist/classes/CloseLabel.mjs +77 -32
- package/dist/classes/CloseLabel.mjs.map +1 -1
- package/dist/classes/Label.d.mts +6 -33
- package/dist/classes/Label.d.ts +6 -33
- package/dist/classes/Label.js +74 -31
- package/dist/classes/Label.js.map +1 -1
- package/dist/classes/Label.mjs +74 -31
- 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 +42 -33
- package/dist/classes/StoredClassModel.js.map +1 -1
- package/dist/classes/StoredClassModel.mjs +42 -33
- package/dist/classes/StoredClassModel.mjs.map +1 -1
- package/dist/classes/canvas/CanvasContainer.js +2 -2
- package/dist/classes/canvas/CanvasContainer.js.map +1 -1
- package/dist/classes/canvas/CanvasContainer.mjs +2 -2
- package/dist/classes/canvas/CanvasContainer.mjs.map +1 -1
- package/dist/classes/canvas/CanvasImage.js +2 -2
- package/dist/classes/canvas/CanvasImage.js.map +1 -1
- package/dist/classes/canvas/CanvasImage.mjs +2 -2
- package/dist/classes/canvas/CanvasImage.mjs.map +1 -1
- package/dist/classes/canvas/CanvasSprite.js +2 -2
- package/dist/classes/canvas/CanvasSprite.js.map +1 -1
- package/dist/classes/canvas/CanvasSprite.mjs +2 -2
- package/dist/classes/canvas/CanvasSprite.mjs.map +1 -1
- package/dist/classes/canvas/CanvasText.js +2 -2
- package/dist/classes/canvas/CanvasText.js.map +1 -1
- package/dist/classes/canvas/CanvasText.mjs +2 -2
- package/dist/classes/canvas/CanvasText.mjs.map +1 -1
- package/dist/classes/canvas/index.js +2 -2
- package/dist/classes/canvas/index.js.map +1 -1
- package/dist/classes/canvas/index.mjs +2 -2
- package/dist/classes/canvas/index.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 +945 -78
- package/dist/classes/index.js.map +1 -1
- package/dist/classes/index.mjs +945 -79
- package/dist/classes/index.mjs.map +1 -1
- package/dist/classes/ticker/FadeAlphaTicker.js +42 -33
- package/dist/classes/ticker/FadeAlphaTicker.js.map +1 -1
- package/dist/classes/ticker/FadeAlphaTicker.mjs +42 -33
- package/dist/classes/ticker/FadeAlphaTicker.mjs.map +1 -1
- package/dist/classes/ticker/MoveTicker.d.mts +1 -0
- package/dist/classes/ticker/MoveTicker.d.ts +1 -0
- package/dist/classes/ticker/MoveTicker.js +42 -33
- package/dist/classes/ticker/MoveTicker.js.map +1 -1
- package/dist/classes/ticker/MoveTicker.mjs +42 -33
- package/dist/classes/ticker/MoveTicker.mjs.map +1 -1
- package/dist/classes/ticker/RotateTicker.d.mts +1 -0
- package/dist/classes/ticker/RotateTicker.d.ts +1 -0
- package/dist/classes/ticker/RotateTicker.js +42 -33
- package/dist/classes/ticker/RotateTicker.js.map +1 -1
- package/dist/classes/ticker/RotateTicker.mjs +42 -33
- package/dist/classes/ticker/RotateTicker.mjs.map +1 -1
- package/dist/classes/ticker/ZoomTicker.d.mts +1 -0
- package/dist/classes/ticker/ZoomTicker.d.ts +1 -0
- package/dist/classes/ticker/ZoomTicker.js +42 -33
- package/dist/classes/ticker/ZoomTicker.js.map +1 -1
- package/dist/classes/ticker/ZoomTicker.mjs +42 -33
- package/dist/classes/ticker/ZoomTicker.mjs.map +1 -1
- package/dist/classes/ticker/index.js +42 -33
- package/dist/classes/ticker/index.js.map +1 -1
- package/dist/classes/ticker/index.mjs +42 -33
- 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/CanvasElementDecorator.js +2 -2
- package/dist/decorators/CanvasElementDecorator.js.map +1 -1
- package/dist/decorators/CanvasElementDecorator.mjs +2 -2
- package/dist/decorators/CanvasElementDecorator.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 +102 -65
- package/dist/decorators/LabelDecorator.js.map +1 -1
- package/dist/decorators/LabelDecorator.mjs +102 -66
- 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 +98 -65
- package/dist/decorators/index.js.map +1 -1
- package/dist/decorators/index.mjs +98 -65
- package/dist/decorators/index.mjs.map +1 -1
- package/dist/functions/CanvasUtility.js +2 -2
- package/dist/functions/CanvasUtility.js.map +1 -1
- package/dist/functions/CanvasUtility.mjs +2 -2
- package/dist/functions/CanvasUtility.mjs.map +1 -1
- package/dist/functions/DialogueUtility.d.mts +10 -8
- package/dist/functions/DialogueUtility.d.ts +10 -8
- package/dist/functions/DialogueUtility.js +268 -131
- package/dist/functions/DialogueUtility.js.map +1 -1
- package/dist/functions/DialogueUtility.mjs +268 -131
- package/dist/functions/DialogueUtility.mjs.map +1 -1
- package/dist/functions/FlagsUtility.js +42 -33
- package/dist/functions/FlagsUtility.js.map +1 -1
- package/dist/functions/FlagsUtility.mjs +42 -33
- package/dist/functions/FlagsUtility.mjs.map +1 -1
- package/dist/functions/GameUtility.js +42 -33
- package/dist/functions/GameUtility.js.map +1 -1
- package/dist/functions/GameUtility.mjs +42 -33
- package/dist/functions/GameUtility.mjs.map +1 -1
- package/dist/functions/ImageUtility.js +45 -36
- package/dist/functions/ImageUtility.js.map +1 -1
- package/dist/functions/ImageUtility.mjs +45 -36
- 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 +5 -3
- package/dist/functions/SavesUtility.d.ts +5 -3
- package/dist/functions/SavesUtility.js +310 -145
- package/dist/functions/SavesUtility.js.map +1 -1
- package/dist/functions/SavesUtility.mjs +310 -145
- package/dist/functions/SavesUtility.mjs.map +1 -1
- package/dist/functions/TickerUtility.d.mts +2 -1
- package/dist/functions/TickerUtility.d.ts +2 -1
- package/dist/functions/TickerUtility.js +19 -15
- package/dist/functions/TickerUtility.js.map +1 -1
- package/dist/functions/TickerUtility.mjs +19 -15
- package/dist/functions/TickerUtility.mjs.map +1 -1
- package/dist/functions/index.d.mts +7 -2
- package/dist/functions/index.d.ts +7 -2
- package/dist/functions/index.js +364 -140
- package/dist/functions/index.js.map +1 -1
- package/dist/functions/index.mjs +364 -141
- package/dist/functions/index.mjs.map +1 -1
- package/dist/index.d.mts +6 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.js +453 -219
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +453 -221
- 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 -0
- package/dist/interface/LabelProps.d.ts +38 -0
- package/dist/interface/LabelProps.js +4 -0
- package/dist/interface/LabelProps.js.map +1 -0
- package/dist/interface/LabelProps.mjs +3 -0
- package/dist/interface/LabelProps.mjs.map +1 -0
- 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 +3 -1
- package/dist/interface/index.d.ts +3 -1
- package/dist/labels/BaseCanvasElementTestLabel.d.mts +3 -1
- package/dist/labels/BaseCanvasElementTestLabel.d.ts +3 -1
- package/dist/labels/BaseCanvasElementTestLabel.js +303 -136
- package/dist/labels/BaseCanvasElementTestLabel.js.map +1 -1
- package/dist/labels/BaseCanvasElementTestLabel.mjs +304 -137
- package/dist/labels/BaseCanvasElementTestLabel.mjs.map +1 -1
- package/dist/labels/CanvasEventsTestLabel.d.mts +4 -5
- package/dist/labels/CanvasEventsTestLabel.d.ts +4 -5
- package/dist/labels/CanvasEventsTestLabel.js +313 -148
- package/dist/labels/CanvasEventsTestLabel.js.map +1 -1
- package/dist/labels/CanvasEventsTestLabel.mjs +314 -149
- 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 +294 -133
- package/dist/labels/CustomTickerCanvasElementTestLabel.js.map +1 -1
- package/dist/labels/CustomTickerCanvasElementTestLabel.mjs +295 -134
- 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 +298 -181
- package/dist/labels/ImagesAnimationsTestLabel.js.map +1 -1
- package/dist/labels/ImagesAnimationsTestLabel.mjs +299 -182
- 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 +294 -133
- package/dist/labels/MarkdownTest.js.map +1 -1
- package/dist/labels/MarkdownTest.mjs +294 -133
- 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 +360 -213
- package/dist/labels/StartLabel.js.map +1 -1
- package/dist/labels/StartLabel.mjs +361 -214
- package/dist/labels/StartLabel.mjs.map +1 -1
- package/dist/labels/StepLabelTest.d.mts +11 -0
- package/dist/labels/StepLabelTest.d.ts +11 -0
- package/dist/labels/StepLabelTest.js +2861 -0
- package/dist/labels/StepLabelTest.js.map +1 -0
- package/dist/labels/StepLabelTest.mjs +2855 -0
- package/dist/labels/StepLabelTest.mjs.map +1 -0
- package/dist/labels/TestConstant.js +43 -34
- package/dist/labels/TestConstant.js.map +1 -1
- package/dist/labels/TestConstant.mjs +43 -34
- 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 +360 -213
- package/dist/labels/index.js.map +1 -1
- package/dist/labels/index.mjs +361 -214
- package/dist/labels/index.mjs.map +1 -1
- package/dist/managers/StepManager.d.mts +10 -7
- package/dist/managers/StepManager.d.ts +10 -7
- package/dist/managers/StepManager.js +300 -139
- package/dist/managers/StepManager.js.map +1 -1
- package/dist/managers/StepManager.mjs +300 -139
- package/dist/managers/StepManager.mjs.map +1 -1
- package/dist/managers/WindowManager.js +2 -2
- package/dist/managers/WindowManager.js.map +1 -1
- package/dist/managers/WindowManager.mjs +2 -2
- 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 +300 -139
- package/dist/managers/index.js.map +1 -1
- package/dist/managers/index.mjs +300 -139
- 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 +4 -0
- package/dist/types/index.d.ts +4 -0
- package/package.json +7 -6
package/dist/classes/Label.js
CHANGED
|
@@ -2,24 +2,42 @@
|
|
|
2
2
|
|
|
3
3
|
require('crypto-js/sha1');
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
var __async = (__this, __arguments, generator) => {
|
|
6
|
+
return new Promise((resolve, reject) => {
|
|
7
|
+
var fulfilled = (value) => {
|
|
8
|
+
try {
|
|
9
|
+
step(generator.next(value));
|
|
10
|
+
} catch (e) {
|
|
11
|
+
reject(e);
|
|
12
|
+
}
|
|
13
|
+
};
|
|
14
|
+
var rejected = (value) => {
|
|
15
|
+
try {
|
|
16
|
+
step(generator.throw(value));
|
|
17
|
+
} catch (e) {
|
|
18
|
+
reject(e);
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
22
|
+
step((generator = generator.apply(__this, __arguments)).next());
|
|
23
|
+
});
|
|
24
|
+
};
|
|
6
25
|
function checkIfStepsIsEqual(step1, step2) {
|
|
7
26
|
return step1 === step2;
|
|
8
27
|
}
|
|
9
28
|
|
|
10
|
-
// src/classes/
|
|
11
|
-
var
|
|
29
|
+
// src/classes/LabelAbstract.ts
|
|
30
|
+
var LabelAbstract = class {
|
|
12
31
|
/**
|
|
13
32
|
* @param id is the id of the label
|
|
14
|
-
* @param
|
|
15
|
-
* @param onStepRun is a function that will be executed before any step is executed, is useful for example to make sure all images used have been cached
|
|
16
|
-
* @param choiseIndex is the index of the choice that the label will perform
|
|
33
|
+
* @param props is the properties of the label
|
|
17
34
|
*/
|
|
18
|
-
constructor(id,
|
|
35
|
+
constructor(id, props) {
|
|
19
36
|
this._id = id;
|
|
20
|
-
this.
|
|
21
|
-
this.
|
|
22
|
-
this.
|
|
37
|
+
this._onStepStart = props == null ? void 0 : props.onStepStart;
|
|
38
|
+
this._onLoadStep = props == null ? void 0 : props.onLoadStep;
|
|
39
|
+
this._onStepEnd = props == null ? void 0 : props.onStepEnd;
|
|
40
|
+
this._choiseIndex = props == null ? void 0 : props.choiseIndex;
|
|
23
41
|
}
|
|
24
42
|
/**
|
|
25
43
|
* Get the id of the label. This variable is used in the system to get the label by id, {@link getLabelById}
|
|
@@ -27,17 +45,6 @@ var Label = class {
|
|
|
27
45
|
get id() {
|
|
28
46
|
return this._id;
|
|
29
47
|
}
|
|
30
|
-
/**
|
|
31
|
-
* Get the steps of the label.
|
|
32
|
-
* This class should be extended and the steps method should be overridden.
|
|
33
|
-
* Every time you update this list will also be updated when the other game versions load.
|
|
34
|
-
*/
|
|
35
|
-
get steps() {
|
|
36
|
-
if (typeof this._steps === "function") {
|
|
37
|
-
return this._steps();
|
|
38
|
-
}
|
|
39
|
-
return this._steps;
|
|
40
|
-
}
|
|
41
48
|
/**
|
|
42
49
|
* Get the corresponding steps number
|
|
43
50
|
* @param externalSteps
|
|
@@ -56,24 +63,60 @@ var Label = class {
|
|
|
56
63
|
return res;
|
|
57
64
|
}
|
|
58
65
|
/**
|
|
59
|
-
*
|
|
66
|
+
* 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.
|
|
67
|
+
* @returns Promise<void> or void
|
|
68
|
+
*/
|
|
69
|
+
get onStepStart() {
|
|
70
|
+
return (stepIndex, label) => __async(this, null, function* () {
|
|
71
|
+
if (this._onLoadStep) {
|
|
72
|
+
yield this._onLoadStep(stepIndex, label);
|
|
73
|
+
}
|
|
74
|
+
if (this._onStepStart) {
|
|
75
|
+
return yield this._onStepStart(stepIndex, label);
|
|
76
|
+
}
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* 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.
|
|
60
81
|
* @returns Promise<void> or void
|
|
61
|
-
* @example
|
|
62
|
-
* ```typescript
|
|
63
|
-
* newLabel("id", [], () => {
|
|
64
|
-
* Assets.load('path/to/image1.png')
|
|
65
|
-
* Assets.load('path/to/image2.png')
|
|
66
|
-
* })
|
|
67
|
-
* ```
|
|
68
82
|
*/
|
|
69
|
-
get
|
|
70
|
-
return this.
|
|
83
|
+
get onLoadStep() {
|
|
84
|
+
return this._onLoadStep;
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Is a function that will be executed when the step ends.
|
|
88
|
+
* @returns Promise<void> or void
|
|
89
|
+
*/
|
|
90
|
+
get onStepEnd() {
|
|
91
|
+
return this._onStepEnd;
|
|
71
92
|
}
|
|
72
93
|
get choiseIndex() {
|
|
73
94
|
return this._choiseIndex;
|
|
74
95
|
}
|
|
75
96
|
};
|
|
76
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
|
+
|
|
77
120
|
module.exports = Label;
|
|
78
121
|
//# sourceMappingURL=Label.js.map
|
|
79
122
|
//# sourceMappingURL=Label.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/functions/StepLabelUtility.ts","../../src/classes/Label.ts"],"names":[],"mappings":"
|
|
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,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,CA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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.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
|
@@ -1,23 +1,41 @@
|
|
|
1
1
|
import 'crypto-js/sha1';
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
var __async = (__this, __arguments, generator) => {
|
|
4
|
+
return new Promise((resolve, reject) => {
|
|
5
|
+
var fulfilled = (value) => {
|
|
6
|
+
try {
|
|
7
|
+
step(generator.next(value));
|
|
8
|
+
} catch (e) {
|
|
9
|
+
reject(e);
|
|
10
|
+
}
|
|
11
|
+
};
|
|
12
|
+
var rejected = (value) => {
|
|
13
|
+
try {
|
|
14
|
+
step(generator.throw(value));
|
|
15
|
+
} catch (e) {
|
|
16
|
+
reject(e);
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
20
|
+
step((generator = generator.apply(__this, __arguments)).next());
|
|
21
|
+
});
|
|
22
|
+
};
|
|
4
23
|
function checkIfStepsIsEqual(step1, step2) {
|
|
5
24
|
return step1 === step2;
|
|
6
25
|
}
|
|
7
26
|
|
|
8
|
-
// src/classes/
|
|
9
|
-
var
|
|
27
|
+
// src/classes/LabelAbstract.ts
|
|
28
|
+
var LabelAbstract = class {
|
|
10
29
|
/**
|
|
11
30
|
* @param id is the id of the label
|
|
12
|
-
* @param
|
|
13
|
-
* @param onStepRun is a function that will be executed before any step is executed, is useful for example to make sure all images used have been cached
|
|
14
|
-
* @param choiseIndex is the index of the choice that the label will perform
|
|
31
|
+
* @param props is the properties of the label
|
|
15
32
|
*/
|
|
16
|
-
constructor(id,
|
|
33
|
+
constructor(id, props) {
|
|
17
34
|
this._id = id;
|
|
18
|
-
this.
|
|
19
|
-
this.
|
|
20
|
-
this.
|
|
35
|
+
this._onStepStart = props == null ? void 0 : props.onStepStart;
|
|
36
|
+
this._onLoadStep = props == null ? void 0 : props.onLoadStep;
|
|
37
|
+
this._onStepEnd = props == null ? void 0 : props.onStepEnd;
|
|
38
|
+
this._choiseIndex = props == null ? void 0 : props.choiseIndex;
|
|
21
39
|
}
|
|
22
40
|
/**
|
|
23
41
|
* Get the id of the label. This variable is used in the system to get the label by id, {@link getLabelById}
|
|
@@ -25,17 +43,6 @@ var Label = class {
|
|
|
25
43
|
get id() {
|
|
26
44
|
return this._id;
|
|
27
45
|
}
|
|
28
|
-
/**
|
|
29
|
-
* Get the steps of the label.
|
|
30
|
-
* This class should be extended and the steps method should be overridden.
|
|
31
|
-
* Every time you update this list will also be updated when the other game versions load.
|
|
32
|
-
*/
|
|
33
|
-
get steps() {
|
|
34
|
-
if (typeof this._steps === "function") {
|
|
35
|
-
return this._steps();
|
|
36
|
-
}
|
|
37
|
-
return this._steps;
|
|
38
|
-
}
|
|
39
46
|
/**
|
|
40
47
|
* Get the corresponding steps number
|
|
41
48
|
* @param externalSteps
|
|
@@ -54,24 +61,60 @@ var Label = class {
|
|
|
54
61
|
return res;
|
|
55
62
|
}
|
|
56
63
|
/**
|
|
57
|
-
*
|
|
64
|
+
* 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.
|
|
65
|
+
* @returns Promise<void> or void
|
|
66
|
+
*/
|
|
67
|
+
get onStepStart() {
|
|
68
|
+
return (stepIndex, label) => __async(this, null, function* () {
|
|
69
|
+
if (this._onLoadStep) {
|
|
70
|
+
yield this._onLoadStep(stepIndex, label);
|
|
71
|
+
}
|
|
72
|
+
if (this._onStepStart) {
|
|
73
|
+
return yield this._onStepStart(stepIndex, label);
|
|
74
|
+
}
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* 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.
|
|
58
79
|
* @returns Promise<void> or void
|
|
59
|
-
* @example
|
|
60
|
-
* ```typescript
|
|
61
|
-
* newLabel("id", [], () => {
|
|
62
|
-
* Assets.load('path/to/image1.png')
|
|
63
|
-
* Assets.load('path/to/image2.png')
|
|
64
|
-
* })
|
|
65
|
-
* ```
|
|
66
80
|
*/
|
|
67
|
-
get
|
|
68
|
-
return this.
|
|
81
|
+
get onLoadStep() {
|
|
82
|
+
return this._onLoadStep;
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Is a function that will be executed when the step ends.
|
|
86
|
+
* @returns Promise<void> or void
|
|
87
|
+
*/
|
|
88
|
+
get onStepEnd() {
|
|
89
|
+
return this._onStepEnd;
|
|
69
90
|
}
|
|
70
91
|
get choiseIndex() {
|
|
71
92
|
return this._choiseIndex;
|
|
72
93
|
}
|
|
73
94
|
};
|
|
74
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
|
+
|
|
75
118
|
export { Label as default };
|
|
76
119
|
//# sourceMappingURL=Label.mjs.map
|
|
77
120
|
//# sourceMappingURL=Label.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/functions/StepLabelUtility.ts","../../src/classes/Label.ts"],"names":[],"mappings":"
|
|
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,KA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abelType } 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 };
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { LabelIdType } from '../types/LabelIdType.js';
|
|
2
|
+
import { StepLabelType } from '../types/StepLabelType.js';
|
|
3
|
+
import { StepHistoryDataType } from '../types/StepHistoryDataType.js';
|
|
4
|
+
import LabelProps from '../interface/LabelProps.js';
|
|
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 };
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
require('crypto-js/sha1');
|
|
4
|
+
|
|
5
|
+
var __async = (__this, __arguments, generator) => {
|
|
6
|
+
return new Promise((resolve, reject) => {
|
|
7
|
+
var fulfilled = (value) => {
|
|
8
|
+
try {
|
|
9
|
+
step(generator.next(value));
|
|
10
|
+
} catch (e) {
|
|
11
|
+
reject(e);
|
|
12
|
+
}
|
|
13
|
+
};
|
|
14
|
+
var rejected = (value) => {
|
|
15
|
+
try {
|
|
16
|
+
step(generator.throw(value));
|
|
17
|
+
} catch (e) {
|
|
18
|
+
reject(e);
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
22
|
+
step((generator = generator.apply(__this, __arguments)).next());
|
|
23
|
+
});
|
|
24
|
+
};
|
|
25
|
+
function checkIfStepsIsEqual(step1, step2) {
|
|
26
|
+
return step1 === step2;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
// src/classes/LabelAbstract.ts
|
|
30
|
+
var LabelAbstract = class {
|
|
31
|
+
/**
|
|
32
|
+
* @param id is the id of the label
|
|
33
|
+
* @param props is the properties of the label
|
|
34
|
+
*/
|
|
35
|
+
constructor(id, props) {
|
|
36
|
+
this._id = id;
|
|
37
|
+
this._onStepStart = props == null ? void 0 : props.onStepStart;
|
|
38
|
+
this._onLoadStep = props == null ? void 0 : props.onLoadStep;
|
|
39
|
+
this._onStepEnd = props == null ? void 0 : props.onStepEnd;
|
|
40
|
+
this._choiseIndex = props == null ? void 0 : props.choiseIndex;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Get the id of the label. This variable is used in the system to get the label by id, {@link getLabelById}
|
|
44
|
+
*/
|
|
45
|
+
get id() {
|
|
46
|
+
return this._id;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Get the corresponding steps number
|
|
50
|
+
* @param externalSteps
|
|
51
|
+
* @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
|
|
52
|
+
*/
|
|
53
|
+
getCorrespondingStepsNumber(externalSteps) {
|
|
54
|
+
if (externalSteps.length === 0) {
|
|
55
|
+
return 0;
|
|
56
|
+
}
|
|
57
|
+
let res = 0;
|
|
58
|
+
externalSteps.forEach((step, index) => {
|
|
59
|
+
if (checkIfStepsIsEqual(step, this.steps[index])) {
|
|
60
|
+
res = index;
|
|
61
|
+
}
|
|
62
|
+
});
|
|
63
|
+
return res;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* 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.
|
|
67
|
+
* @returns Promise<void> or void
|
|
68
|
+
*/
|
|
69
|
+
get onStepStart() {
|
|
70
|
+
return (stepIndex, label) => __async(this, null, function* () {
|
|
71
|
+
if (this._onLoadStep) {
|
|
72
|
+
yield this._onLoadStep(stepIndex, label);
|
|
73
|
+
}
|
|
74
|
+
if (this._onStepStart) {
|
|
75
|
+
return yield this._onStepStart(stepIndex, label);
|
|
76
|
+
}
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* 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.
|
|
81
|
+
* @returns Promise<void> or void
|
|
82
|
+
*/
|
|
83
|
+
get onLoadStep() {
|
|
84
|
+
return this._onLoadStep;
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Is a function that will be executed when the step ends.
|
|
88
|
+
* @returns Promise<void> or void
|
|
89
|
+
*/
|
|
90
|
+
get onStepEnd() {
|
|
91
|
+
return this._onStepEnd;
|
|
92
|
+
}
|
|
93
|
+
get choiseIndex() {
|
|
94
|
+
return this._choiseIndex;
|
|
95
|
+
}
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
module.exports = LabelAbstract;
|
|
99
|
+
//# sourceMappingURL=LabelAbstract.js.map
|
|
100
|
+
//# sourceMappingURL=LabelAbstract.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/functions/StepLabelUtility.ts","../../src/classes/LabelAbstract.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AA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AAA;AAAA,EAOA,IAAW,WAAwF,GAAA;AAC/F,IAAO,OAAA,CAAO,WAAmB,KAAkB,KAAA,OAAA,CAAA,IAAA,EAAA,IAAA,EAAA,aAAA;AAC/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","file":"LabelAbstract.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"]}
|