@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/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import 'deep-diff';
|
|
1
|
+
import { diff } from 'deep-diff';
|
|
2
2
|
import sha1 from 'crypto-js/sha1';
|
|
3
3
|
import { Sprite, Container, Application, Text, Assets, Texture } from 'pixi.js';
|
|
4
4
|
|
|
@@ -64,23 +64,26 @@ var CanvasEvent = class {
|
|
|
64
64
|
throw new Error("[Pixi'VN] The method CanvasEvent.fn() must be overridden");
|
|
65
65
|
}
|
|
66
66
|
};
|
|
67
|
+
function getStepSha1(step) {
|
|
68
|
+
let sha1String = sha1(step.toString().toLocaleLowerCase());
|
|
69
|
+
return sha1String.toString();
|
|
70
|
+
}
|
|
67
71
|
function checkIfStepsIsEqual(step1, step2) {
|
|
68
72
|
return step1 === step2;
|
|
69
73
|
}
|
|
70
74
|
|
|
71
|
-
// src/classes/
|
|
72
|
-
var
|
|
75
|
+
// src/classes/LabelAbstract.ts
|
|
76
|
+
var LabelAbstract = class {
|
|
73
77
|
/**
|
|
74
78
|
* @param id is the id of the label
|
|
75
|
-
* @param
|
|
76
|
-
* @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
|
|
77
|
-
* @param choiseIndex is the index of the choice that the label will perform
|
|
79
|
+
* @param props is the properties of the label
|
|
78
80
|
*/
|
|
79
|
-
constructor(id,
|
|
81
|
+
constructor(id, props) {
|
|
80
82
|
this._id = id;
|
|
81
|
-
this.
|
|
82
|
-
this.
|
|
83
|
-
this.
|
|
83
|
+
this._onStepStart = props == null ? void 0 : props.onStepStart;
|
|
84
|
+
this._onLoadStep = props == null ? void 0 : props.onLoadStep;
|
|
85
|
+
this._onStepEnd = props == null ? void 0 : props.onStepEnd;
|
|
86
|
+
this._choiseIndex = props == null ? void 0 : props.choiseIndex;
|
|
84
87
|
}
|
|
85
88
|
/**
|
|
86
89
|
* Get the id of the label. This variable is used in the system to get the label by id, {@link getLabelById}
|
|
@@ -88,17 +91,6 @@ var Label = class {
|
|
|
88
91
|
get id() {
|
|
89
92
|
return this._id;
|
|
90
93
|
}
|
|
91
|
-
/**
|
|
92
|
-
* Get the steps of the label.
|
|
93
|
-
* This class should be extended and the steps method should be overridden.
|
|
94
|
-
* Every time you update this list will also be updated when the other game versions load.
|
|
95
|
-
*/
|
|
96
|
-
get steps() {
|
|
97
|
-
if (typeof this._steps === "function") {
|
|
98
|
-
return this._steps();
|
|
99
|
-
}
|
|
100
|
-
return this._steps;
|
|
101
|
-
}
|
|
102
94
|
/**
|
|
103
95
|
* Get the corresponding steps number
|
|
104
96
|
* @param externalSteps
|
|
@@ -117,28 +109,66 @@ var Label = class {
|
|
|
117
109
|
return res;
|
|
118
110
|
}
|
|
119
111
|
/**
|
|
120
|
-
*
|
|
112
|
+
* 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.
|
|
113
|
+
* @returns Promise<void> or void
|
|
114
|
+
*/
|
|
115
|
+
get onStepStart() {
|
|
116
|
+
return (stepIndex, label) => __async(this, null, function* () {
|
|
117
|
+
if (this._onLoadStep) {
|
|
118
|
+
yield this._onLoadStep(stepIndex, label);
|
|
119
|
+
}
|
|
120
|
+
if (this._onStepStart) {
|
|
121
|
+
return yield this._onStepStart(stepIndex, label);
|
|
122
|
+
}
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* 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.
|
|
121
127
|
* @returns Promise<void> or void
|
|
122
|
-
* @example
|
|
123
|
-
* ```typescript
|
|
124
|
-
* newLabel("id", [], () => {
|
|
125
|
-
* Assets.load('path/to/image1.png')
|
|
126
|
-
* Assets.load('path/to/image2.png')
|
|
127
|
-
* })
|
|
128
|
-
* ```
|
|
129
128
|
*/
|
|
130
|
-
get
|
|
131
|
-
return this.
|
|
129
|
+
get onLoadStep() {
|
|
130
|
+
return this._onLoadStep;
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* Is a function that will be executed when the step ends.
|
|
134
|
+
* @returns Promise<void> or void
|
|
135
|
+
*/
|
|
136
|
+
get onStepEnd() {
|
|
137
|
+
return this._onStepEnd;
|
|
132
138
|
}
|
|
133
139
|
get choiseIndex() {
|
|
134
140
|
return this._choiseIndex;
|
|
135
141
|
}
|
|
136
142
|
};
|
|
137
143
|
|
|
144
|
+
// src/classes/Label.ts
|
|
145
|
+
var Label = class extends LabelAbstract {
|
|
146
|
+
/**
|
|
147
|
+
* @param id is the id of the label
|
|
148
|
+
* @param steps is the list of steps that the label will perform
|
|
149
|
+
* @param props is the properties of the label
|
|
150
|
+
*/
|
|
151
|
+
constructor(id, steps, props) {
|
|
152
|
+
super(id, props);
|
|
153
|
+
this._steps = steps;
|
|
154
|
+
}
|
|
155
|
+
/**
|
|
156
|
+
* Get the steps of the label.
|
|
157
|
+
*/
|
|
158
|
+
get steps() {
|
|
159
|
+
if (typeof this._steps === "function") {
|
|
160
|
+
return this._steps();
|
|
161
|
+
}
|
|
162
|
+
return this._steps;
|
|
163
|
+
}
|
|
164
|
+
};
|
|
165
|
+
|
|
138
166
|
// src/classes/CloseLabel.ts
|
|
139
167
|
var CLOSE_LABEL_ID = "__close-label-id__";
|
|
140
168
|
function newCloseLabel(choiseIndex) {
|
|
141
|
-
return new Label(CLOSE_LABEL_ID, [],
|
|
169
|
+
return new Label(CLOSE_LABEL_ID, [], {
|
|
170
|
+
choiseIndex
|
|
171
|
+
});
|
|
142
172
|
}
|
|
143
173
|
|
|
144
174
|
// src/decorators/LabelDecorator.ts
|
|
@@ -228,8 +258,6 @@ function getMemoryContainer(element) {
|
|
|
228
258
|
};
|
|
229
259
|
}
|
|
230
260
|
function setMemoryContainer(element, memory) {
|
|
231
|
-
memory.width && (element.width = memory.width);
|
|
232
|
-
memory.height && (element.height = memory.height);
|
|
233
261
|
memory.isRenderGroup && (element.isRenderGroup = memory.isRenderGroup);
|
|
234
262
|
memory.blendMode && (element.blendMode = memory.blendMode);
|
|
235
263
|
memory.tint && (element.tint = memory.tint);
|
|
@@ -262,6 +290,8 @@ function setMemoryContainer(element, memory) {
|
|
|
262
290
|
memory.interactive && (element.interactive = memory.interactive);
|
|
263
291
|
memory.interactiveChildren && (element.interactiveChildren = memory.interactiveChildren);
|
|
264
292
|
memory.hitArea && (element.hitArea = memory.hitArea);
|
|
293
|
+
memory.width && (element.width = memory.width);
|
|
294
|
+
memory.height && (element.height = memory.height);
|
|
265
295
|
}
|
|
266
296
|
function getTexture(imageUrl) {
|
|
267
297
|
return __async(this, null, function* () {
|
|
@@ -670,29 +700,57 @@ var ChoiceMenuOption = class {
|
|
|
670
700
|
/**
|
|
671
701
|
* @param text Text to be displayed in the menu
|
|
672
702
|
* @param label Label to be opened when the option is selected or the id of the label
|
|
703
|
+
* @param props Properties to be passed to the label and olther parameters that you can use when get all the choice menu options. It be converted to a JSON string, so it cannot contain functions or classes.
|
|
673
704
|
* @param type Type of the label to be opened. @default "call"
|
|
674
|
-
* @param props Properties to be passed to the label, when the label is called. it cannot contain functions or classes. @default {}
|
|
675
705
|
*/
|
|
676
|
-
constructor(text, label, type = "call"
|
|
706
|
+
constructor(text, label, props, type = "call") {
|
|
677
707
|
/**
|
|
678
|
-
* Properties to be passed to the label
|
|
708
|
+
* Properties to be passed to the label and olther parameters that you can use when get all the choice menu options.
|
|
709
|
+
* @example
|
|
710
|
+
* ```tsx
|
|
711
|
+
* setChoiceMenuOptions([
|
|
712
|
+
* new ChoiceMenuOption("Hello", helloLabel, { disabled: true }),
|
|
713
|
+
* ])
|
|
714
|
+
* return <List>
|
|
715
|
+
* {getChoiceMenuOptions()?.map((item, index) => {
|
|
716
|
+
* return (
|
|
717
|
+
* <ChoiceButton
|
|
718
|
+
* disabled={item.props.disabled}
|
|
719
|
+
* onClick={() => {
|
|
720
|
+
* afterSelectChoice(item)
|
|
721
|
+
* }}
|
|
722
|
+
* >
|
|
723
|
+
* {item.text}
|
|
724
|
+
* </ChoiceButton>
|
|
725
|
+
* )
|
|
726
|
+
* })}
|
|
727
|
+
* </List>
|
|
728
|
+
* ```
|
|
679
729
|
*/
|
|
680
730
|
this.props = {};
|
|
681
|
-
if (typeof label === "string") {
|
|
682
|
-
let tLabel = getLabelById(label);
|
|
683
|
-
if (!tLabel) {
|
|
684
|
-
throw new Error(`[Pixi'VN] Label ${label} not found`);
|
|
685
|
-
} else {
|
|
686
|
-
label = tLabel;
|
|
687
|
-
}
|
|
688
|
-
}
|
|
689
731
|
this.text = text;
|
|
690
|
-
this.
|
|
732
|
+
this._label = label;
|
|
691
733
|
this.type = type;
|
|
692
734
|
if (props) {
|
|
693
735
|
this.props = props;
|
|
694
736
|
}
|
|
695
737
|
}
|
|
738
|
+
/**
|
|
739
|
+
* Label to be opened when the option is selected
|
|
740
|
+
*/
|
|
741
|
+
get label() {
|
|
742
|
+
let label = this._label;
|
|
743
|
+
if (typeof label === "string") {
|
|
744
|
+
let res = getLabelById(label);
|
|
745
|
+
if (res) {
|
|
746
|
+
label = res;
|
|
747
|
+
} else {
|
|
748
|
+
console.error(`Label ${label} not found, so it will be closed`);
|
|
749
|
+
label = newCloseLabel();
|
|
750
|
+
}
|
|
751
|
+
}
|
|
752
|
+
return label;
|
|
753
|
+
}
|
|
696
754
|
};
|
|
697
755
|
var ChoiceMenuOptionClose = class {
|
|
698
756
|
/**
|
|
@@ -709,7 +767,27 @@ var ChoiceMenuOptionClose = class {
|
|
|
709
767
|
*/
|
|
710
768
|
this.type = Close;
|
|
711
769
|
/**
|
|
712
|
-
* Properties to be passed to the label
|
|
770
|
+
* Properties to be passed to the label and olther parameters that you can use when get all the choice menu options.
|
|
771
|
+
* @example
|
|
772
|
+
* ```tsx
|
|
773
|
+
* setChoiceMenuOptions([
|
|
774
|
+
* new ChoiceMenuOption("Hello", helloLabel, { disabled: true }),
|
|
775
|
+
* ])
|
|
776
|
+
* return <List>
|
|
777
|
+
* {getChoiceMenuOptions()?.map((item, index) => {
|
|
778
|
+
* return (
|
|
779
|
+
* <ChoiceButton
|
|
780
|
+
* disabled={item.props.disabled}
|
|
781
|
+
* onClick={() => {
|
|
782
|
+
* afterSelectChoice(item)
|
|
783
|
+
* }}
|
|
784
|
+
* >
|
|
785
|
+
* {item.text}
|
|
786
|
+
* </ChoiceButton>
|
|
787
|
+
* )
|
|
788
|
+
* })}
|
|
789
|
+
* </List>
|
|
790
|
+
* ```
|
|
713
791
|
*/
|
|
714
792
|
this.props = {};
|
|
715
793
|
this.text = text;
|
|
@@ -717,6 +795,81 @@ var ChoiceMenuOptionClose = class {
|
|
|
717
795
|
}
|
|
718
796
|
};
|
|
719
797
|
|
|
798
|
+
// src/functions/DialogueUtility.ts
|
|
799
|
+
function setDialogue(props) {
|
|
800
|
+
let text = "";
|
|
801
|
+
let character = void 0;
|
|
802
|
+
let dialogue;
|
|
803
|
+
if (typeof props === "string") {
|
|
804
|
+
text = props;
|
|
805
|
+
dialogue = new DialogueBaseModel(text, character);
|
|
806
|
+
} else if (!(props instanceof DialogueBaseModel)) {
|
|
807
|
+
text = props.text;
|
|
808
|
+
if (props.character) {
|
|
809
|
+
if (typeof props.character === "string") {
|
|
810
|
+
character = props.character;
|
|
811
|
+
} else {
|
|
812
|
+
character = props.character.id;
|
|
813
|
+
}
|
|
814
|
+
}
|
|
815
|
+
dialogue = new DialogueBaseModel(text, character);
|
|
816
|
+
} else {
|
|
817
|
+
dialogue = props;
|
|
818
|
+
}
|
|
819
|
+
GameStorageManager.setVariable(GameStorageManager.keysSystem.CURRENT_DIALOGUE_MEMORY_KEY, dialogue);
|
|
820
|
+
GameStorageManager.setVariable(GameStorageManager.keysSystem.LAST_DIALOGUE_ADDED_IN_STEP_MEMORY_KEY, GameStepManager.lastStepIndex);
|
|
821
|
+
}
|
|
822
|
+
function getDialogue() {
|
|
823
|
+
return GameStorageManager.getVariable(GameStorageManager.keysSystem.CURRENT_DIALOGUE_MEMORY_KEY);
|
|
824
|
+
}
|
|
825
|
+
function clearDialogue() {
|
|
826
|
+
GameStorageManager.setVariable(GameStorageManager.keysSystem.CURRENT_DIALOGUE_MEMORY_KEY, void 0);
|
|
827
|
+
}
|
|
828
|
+
function setChoiceMenuOptions(options) {
|
|
829
|
+
let value = options.map((option) => {
|
|
830
|
+
if (option instanceof ChoiceMenuOptionClose) {
|
|
831
|
+
return {
|
|
832
|
+
text: option.text,
|
|
833
|
+
type: Close,
|
|
834
|
+
closeCurrentLabel: option.closeCurrentLabel
|
|
835
|
+
};
|
|
836
|
+
}
|
|
837
|
+
return __spreadProps(__spreadValues({}, option), {
|
|
838
|
+
label: option.label.id
|
|
839
|
+
});
|
|
840
|
+
});
|
|
841
|
+
GameStorageManager.setVariable(GameStorageManager.keysSystem.CURRENT_MENU_OPTIONS_MEMORY_KEY, value);
|
|
842
|
+
GameStorageManager.setVariable(GameStorageManager.keysSystem.LAST_MENU_OPTIONS_ADDED_IN_STEP_MEMORY_KEY, GameStepManager.lastStepIndex);
|
|
843
|
+
}
|
|
844
|
+
function getChoiceMenuOptions() {
|
|
845
|
+
let d = GameStorageManager.getVariable(GameStorageManager.keysSystem.CURRENT_MENU_OPTIONS_MEMORY_KEY);
|
|
846
|
+
if (d) {
|
|
847
|
+
let options = [];
|
|
848
|
+
d.forEach((option, index) => {
|
|
849
|
+
if (option.type === Close) {
|
|
850
|
+
let itemLabel = newCloseLabel(index);
|
|
851
|
+
let choice = new ChoiceMenuOptionClose(option.text, option.closeCurrentLabel);
|
|
852
|
+
choice.label = itemLabel;
|
|
853
|
+
options.push(choice);
|
|
854
|
+
return;
|
|
855
|
+
}
|
|
856
|
+
let label = getLabelById(option.label);
|
|
857
|
+
if (label) {
|
|
858
|
+
let itemLabel = new Label(label.id, label.steps, {
|
|
859
|
+
onStepStart: label.onStepStart,
|
|
860
|
+
choiseIndex: index
|
|
861
|
+
});
|
|
862
|
+
options.push(new ChoiceMenuOption(option.text, itemLabel, option.props, option.type));
|
|
863
|
+
}
|
|
864
|
+
});
|
|
865
|
+
return options;
|
|
866
|
+
}
|
|
867
|
+
return void 0;
|
|
868
|
+
}
|
|
869
|
+
function clearChoiceMenuOptions() {
|
|
870
|
+
GameStorageManager.setVariable(GameStorageManager.keysSystem.CURRENT_MENU_OPTIONS_MEMORY_KEY, void 0);
|
|
871
|
+
}
|
|
872
|
+
|
|
720
873
|
// src/classes/ticker/TickerBase.ts
|
|
721
874
|
var TickerBase = class {
|
|
722
875
|
/**
|
|
@@ -797,8 +950,9 @@ FadeAlphaTicker = __decorateClass([
|
|
|
797
950
|
], FadeAlphaTicker);
|
|
798
951
|
|
|
799
952
|
// src/functions/TickerUtility.ts
|
|
800
|
-
function updateTickerProgression(args, propertyName, progression) {
|
|
801
|
-
|
|
953
|
+
function updateTickerProgression(args, propertyName, progression, valueConvert) {
|
|
954
|
+
let limit = valueConvert && progression.limit ? valueConvert(progression.limit) : progression.limit;
|
|
955
|
+
if (args[propertyName] === void 0 || !progression || args[propertyName] === limit) {
|
|
802
956
|
return;
|
|
803
957
|
}
|
|
804
958
|
if (typeof args[propertyName] === "number") {
|
|
@@ -817,22 +971,25 @@ function updateTickerProgression(args, propertyName, progression) {
|
|
|
817
971
|
}
|
|
818
972
|
}
|
|
819
973
|
}
|
|
820
|
-
function getLinearProgression(number, progression) {
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
return
|
|
974
|
+
function getLinearProgression(number, progression, valueConvert) {
|
|
975
|
+
let limit = valueConvert && progression.limit ? valueConvert(progression.limit) : progression.limit;
|
|
976
|
+
let amt = valueConvert ? valueConvert(progression.amt) : progression.amt;
|
|
977
|
+
if (limit !== void 0) {
|
|
978
|
+
if (number > limit && amt > 0) {
|
|
979
|
+
return limit;
|
|
980
|
+
} else if (number < limit && amt < 0) {
|
|
981
|
+
return limit;
|
|
826
982
|
}
|
|
827
983
|
}
|
|
828
|
-
return number +
|
|
984
|
+
return number + amt;
|
|
829
985
|
}
|
|
830
|
-
function getExponentialProgression(number, progression) {
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
986
|
+
function getExponentialProgression(number, progression, valueConvert) {
|
|
987
|
+
let limit = valueConvert && progression.limit ? valueConvert(progression.limit) : progression.limit;
|
|
988
|
+
if (limit !== void 0) {
|
|
989
|
+
if (number > limit && progression.percentage > 0) {
|
|
990
|
+
return limit;
|
|
991
|
+
} else if (number < limit && progression.percentage < 0) {
|
|
992
|
+
return limit;
|
|
836
993
|
}
|
|
837
994
|
}
|
|
838
995
|
return number + number * progression.percentage;
|
|
@@ -845,15 +1002,13 @@ var MoveTicker = class extends TickerBase {
|
|
|
845
1002
|
let ySpeed = 1;
|
|
846
1003
|
if (args.speed) {
|
|
847
1004
|
if (typeof args.speed === "number") {
|
|
848
|
-
xSpeed = args.speed;
|
|
849
|
-
ySpeed = args.speed;
|
|
1005
|
+
xSpeed = this.speedConvert(args.speed);
|
|
1006
|
+
ySpeed = this.speedConvert(args.speed);
|
|
850
1007
|
} else {
|
|
851
|
-
xSpeed = args.speed.x;
|
|
852
|
-
ySpeed = args.speed.y;
|
|
1008
|
+
xSpeed = this.speedConvert(args.speed.x);
|
|
1009
|
+
ySpeed = this.speedConvert(args.speed.y);
|
|
853
1010
|
}
|
|
854
1011
|
}
|
|
855
|
-
xSpeed /= 60;
|
|
856
|
-
ySpeed /= 60;
|
|
857
1012
|
let destination = args.destination;
|
|
858
1013
|
let tagToRemoveAfter2 = args.tagToRemoveAfter || [];
|
|
859
1014
|
if (typeof tagToRemoveAfter2 === "string") {
|
|
@@ -893,7 +1048,10 @@ var MoveTicker = class extends TickerBase {
|
|
|
893
1048
|
}
|
|
894
1049
|
});
|
|
895
1050
|
if (args.speedProgression)
|
|
896
|
-
updateTickerProgression(args, "speed", args.speedProgression);
|
|
1051
|
+
updateTickerProgression(args, "speed", args.speedProgression, this.speedConvert);
|
|
1052
|
+
}
|
|
1053
|
+
speedConvert(speed) {
|
|
1054
|
+
return speed / 6;
|
|
897
1055
|
}
|
|
898
1056
|
};
|
|
899
1057
|
MoveTicker = __decorateClass([
|
|
@@ -901,7 +1059,7 @@ MoveTicker = __decorateClass([
|
|
|
901
1059
|
], MoveTicker);
|
|
902
1060
|
var RotateTicker = class extends TickerBase {
|
|
903
1061
|
fn(ticker, args, tags, tickerId) {
|
|
904
|
-
let speed = (args.speed === void 0 ? 1 : args.speed)
|
|
1062
|
+
let speed = this.speedConvert(args.speed === void 0 ? 1 : args.speed);
|
|
905
1063
|
let clockwise = args.clockwise === void 0 ? true : args.clockwise;
|
|
906
1064
|
let tagToRemoveAfter2 = args.tagToRemoveAfter || [];
|
|
907
1065
|
if (typeof tagToRemoveAfter2 === "string") {
|
|
@@ -929,7 +1087,10 @@ var RotateTicker = class extends TickerBase {
|
|
|
929
1087
|
}
|
|
930
1088
|
});
|
|
931
1089
|
if (args.speedProgression)
|
|
932
|
-
updateTickerProgression(args, "speed", args.speedProgression);
|
|
1090
|
+
updateTickerProgression(args, "speed", args.speedProgression, this.speedConvert);
|
|
1091
|
+
}
|
|
1092
|
+
speedConvert(speed) {
|
|
1093
|
+
return speed / 60;
|
|
933
1094
|
}
|
|
934
1095
|
};
|
|
935
1096
|
RotateTicker = __decorateClass([
|
|
@@ -941,15 +1102,13 @@ var ZoomTicker = class extends TickerBase {
|
|
|
941
1102
|
let ySpeed = 0.1;
|
|
942
1103
|
if (args.speed) {
|
|
943
1104
|
if (typeof args.speed === "number") {
|
|
944
|
-
xSpeed = args.speed;
|
|
945
|
-
ySpeed = args.speed;
|
|
1105
|
+
xSpeed = this.speedConvert(args.speed);
|
|
1106
|
+
ySpeed = this.speedConvert(args.speed);
|
|
946
1107
|
} else {
|
|
947
|
-
xSpeed = args.speed.x;
|
|
948
|
-
ySpeed = args.speed.y;
|
|
1108
|
+
xSpeed = this.speedConvert(args.speed.x);
|
|
1109
|
+
ySpeed = this.speedConvert(args.speed.y);
|
|
949
1110
|
}
|
|
950
1111
|
}
|
|
951
|
-
xSpeed /= 60;
|
|
952
|
-
ySpeed /= 60;
|
|
953
1112
|
let tagToRemoveAfter2 = args.tagToRemoveAfter || [];
|
|
954
1113
|
if (typeof tagToRemoveAfter2 === "string") {
|
|
955
1114
|
tagToRemoveAfter2 = [tagToRemoveAfter2];
|
|
@@ -1016,7 +1175,10 @@ var ZoomTicker = class extends TickerBase {
|
|
|
1016
1175
|
}
|
|
1017
1176
|
});
|
|
1018
1177
|
if (args.speedProgression)
|
|
1019
|
-
updateTickerProgression(args, "speed", args.speedProgression);
|
|
1178
|
+
updateTickerProgression(args, "speed", args.speedProgression, this.speedConvert);
|
|
1179
|
+
}
|
|
1180
|
+
speedConvert(speed) {
|
|
1181
|
+
return speed / 60;
|
|
1020
1182
|
}
|
|
1021
1183
|
onEndOfTicker(tag, tickerId, _element, tagToRemoveAfter2) {
|
|
1022
1184
|
GameWindowManager.onEndOfTicker(tag, this, tagToRemoveAfter2, tickerId);
|
|
@@ -1040,6 +1202,47 @@ function createExportableElement(element) {
|
|
|
1040
1202
|
}
|
|
1041
1203
|
}
|
|
1042
1204
|
|
|
1205
|
+
// src/functions/DiffUtility.ts
|
|
1206
|
+
function restoreDeepDiffChanges(data, differences) {
|
|
1207
|
+
let result = createExportableElement(data);
|
|
1208
|
+
differences.forEach((diff2) => {
|
|
1209
|
+
let dataToEdit = result;
|
|
1210
|
+
if (diff2.path && diff2.path.length > 0) {
|
|
1211
|
+
diff2.path.forEach((path, index) => {
|
|
1212
|
+
if (diff2.path && index === diff2.path.length - 1) {
|
|
1213
|
+
if (diff2.kind === "E" || diff2.kind === "D") {
|
|
1214
|
+
dataToEdit[path] = diff2.lhs;
|
|
1215
|
+
} else if (diff2.kind === "N") {
|
|
1216
|
+
if (Number.isInteger(path)) {
|
|
1217
|
+
if (Array.isArray(dataToEdit)) {
|
|
1218
|
+
dataToEdit.splice(path, 1);
|
|
1219
|
+
}
|
|
1220
|
+
} else if (typeof path === "string") {
|
|
1221
|
+
delete dataToEdit[path];
|
|
1222
|
+
}
|
|
1223
|
+
} else if (diff2.kind === "A") {
|
|
1224
|
+
let index2 = diff2.index;
|
|
1225
|
+
if (diff2.item.kind === "N") {
|
|
1226
|
+
dataToEdit[path].splice(index2, 1);
|
|
1227
|
+
} else if (diff2.item.kind === "E" || diff2.item.kind === "D") {
|
|
1228
|
+
dataToEdit[path][index2] = diff2.item.lhs;
|
|
1229
|
+
} else if (diff2.item.kind === "A") {
|
|
1230
|
+
console.warn("[Pixi'VN] Nested array found, skipping diff", diff2);
|
|
1231
|
+
} else {
|
|
1232
|
+
console.warn("[Pixi'VN] No array found, skipping diff", diff2);
|
|
1233
|
+
}
|
|
1234
|
+
}
|
|
1235
|
+
} else {
|
|
1236
|
+
dataToEdit = dataToEdit[path];
|
|
1237
|
+
}
|
|
1238
|
+
});
|
|
1239
|
+
} else {
|
|
1240
|
+
console.warn("[Pixi'VN] No path found, skipping diff", diff2);
|
|
1241
|
+
}
|
|
1242
|
+
});
|
|
1243
|
+
return result;
|
|
1244
|
+
}
|
|
1245
|
+
|
|
1043
1246
|
// src/managers/StorageManager.ts
|
|
1044
1247
|
var _GameStorageManager = class _GameStorageManager {
|
|
1045
1248
|
constructor() {
|
|
@@ -1861,6 +2064,621 @@ _GameWindowManager._currentTickersSteps = {};
|
|
|
1861
2064
|
_GameWindowManager._currentTickersTimeouts = {};
|
|
1862
2065
|
var GameWindowManager = _GameWindowManager;
|
|
1863
2066
|
|
|
2067
|
+
// src/managers/StepManager.ts
|
|
2068
|
+
var _GameStepManager = class _GameStepManager {
|
|
2069
|
+
constructor() {
|
|
2070
|
+
}
|
|
2071
|
+
static get stepsHistory() {
|
|
2072
|
+
return _GameStepManager._stepsHistory;
|
|
2073
|
+
}
|
|
2074
|
+
/**
|
|
2075
|
+
* lastStepIndex is the last step index that occurred during the progression of the steps. **Not is the length of the stepsHistory - 1.**
|
|
2076
|
+
*/
|
|
2077
|
+
static get lastStepIndex() {
|
|
2078
|
+
return _GameStepManager._lastStepIndex;
|
|
2079
|
+
}
|
|
2080
|
+
/**
|
|
2081
|
+
* Increase the last step index that occurred during the progression of the steps.
|
|
2082
|
+
*/
|
|
2083
|
+
static increaseLastStepIndex() {
|
|
2084
|
+
_GameStepManager._lastStepIndex++;
|
|
2085
|
+
}
|
|
2086
|
+
static get openedLabels() {
|
|
2087
|
+
return _GameStepManager._openedLabels;
|
|
2088
|
+
}
|
|
2089
|
+
/**
|
|
2090
|
+
* currentLabelId is the current label id that occurred during the progression of the steps.
|
|
2091
|
+
*/
|
|
2092
|
+
static get currentLabelId() {
|
|
2093
|
+
if (_GameStepManager._openedLabels.length > 0) {
|
|
2094
|
+
let item = _GameStepManager._openedLabels[_GameStepManager._openedLabels.length - 1];
|
|
2095
|
+
return item.label;
|
|
2096
|
+
}
|
|
2097
|
+
return void 0;
|
|
2098
|
+
}
|
|
2099
|
+
/**
|
|
2100
|
+
* currentLabel is the current label that occurred during the progression of the steps.
|
|
2101
|
+
*/
|
|
2102
|
+
static get currentLabel() {
|
|
2103
|
+
if (_GameStepManager.currentLabelId) {
|
|
2104
|
+
return getLabelById(_GameStepManager.currentLabelId);
|
|
2105
|
+
}
|
|
2106
|
+
}
|
|
2107
|
+
static get currentLabelStepIndex() {
|
|
2108
|
+
if (_GameStepManager._openedLabels.length > 0) {
|
|
2109
|
+
let item = _GameStepManager._openedLabels[_GameStepManager._openedLabels.length - 1];
|
|
2110
|
+
return item.currentStepIndex;
|
|
2111
|
+
}
|
|
2112
|
+
return null;
|
|
2113
|
+
}
|
|
2114
|
+
/**
|
|
2115
|
+
* lastHistoryStep is the last history step that occurred during the progression of the steps.
|
|
2116
|
+
*/
|
|
2117
|
+
static get lastHistoryStep() {
|
|
2118
|
+
if (_GameStepManager._stepsHistory.length > 0) {
|
|
2119
|
+
return _GameStepManager._stepsHistory[_GameStepManager._stepsHistory.length - 1];
|
|
2120
|
+
}
|
|
2121
|
+
return null;
|
|
2122
|
+
}
|
|
2123
|
+
static get originalStepData() {
|
|
2124
|
+
if (!_GameStepManager._originalStepData) {
|
|
2125
|
+
return {
|
|
2126
|
+
path: "",
|
|
2127
|
+
storage: {},
|
|
2128
|
+
canvas: {
|
|
2129
|
+
childrenTagsOrder: [],
|
|
2130
|
+
currentElements: {},
|
|
2131
|
+
currentTickers: {},
|
|
2132
|
+
currentTickersSteps: {}
|
|
2133
|
+
},
|
|
2134
|
+
labelIndex: -1,
|
|
2135
|
+
openedLabels: []
|
|
2136
|
+
};
|
|
2137
|
+
}
|
|
2138
|
+
return createExportableElement(_GameStepManager._originalStepData);
|
|
2139
|
+
}
|
|
2140
|
+
static set originalStepData(value) {
|
|
2141
|
+
_GameStepManager._originalStepData = createExportableElement(value);
|
|
2142
|
+
}
|
|
2143
|
+
static get currentStepData() {
|
|
2144
|
+
let currentStepData = {
|
|
2145
|
+
path: window.location.pathname,
|
|
2146
|
+
storage: GameStorageManager.export(),
|
|
2147
|
+
canvas: GameWindowManager.export(),
|
|
2148
|
+
labelIndex: _GameStepManager.currentLabelStepIndex || 0,
|
|
2149
|
+
openedLabels: createExportableElement(_GameStepManager._openedLabels)
|
|
2150
|
+
};
|
|
2151
|
+
return currentStepData;
|
|
2152
|
+
}
|
|
2153
|
+
/* Edit History Methods */
|
|
2154
|
+
/**
|
|
2155
|
+
* Add a label to the history.
|
|
2156
|
+
* @param label The label to add to the history.
|
|
2157
|
+
*/
|
|
2158
|
+
static addStepHistory(step, choiseMade) {
|
|
2159
|
+
let stepHistory = getStepSha1(step);
|
|
2160
|
+
let currentStepData = _GameStepManager.currentStepData;
|
|
2161
|
+
if (_GameStepManager.originalStepData) {
|
|
2162
|
+
if (_GameStepManager.originalStepData.openedLabels.length === currentStepData.openedLabels.length) {
|
|
2163
|
+
try {
|
|
2164
|
+
let lastStepDataOpenedLabelsString = JSON.stringify(_GameStepManager.originalStepData.openedLabels);
|
|
2165
|
+
let historyStepOpenedLabelsString = JSON.stringify(currentStepData.openedLabels);
|
|
2166
|
+
if (lastStepDataOpenedLabelsString === historyStepOpenedLabelsString && _GameStepManager.originalStepData.path === currentStepData.path && _GameStepManager.originalStepData.labelIndex === currentStepData.labelIndex) {
|
|
2167
|
+
return;
|
|
2168
|
+
}
|
|
2169
|
+
} catch (e) {
|
|
2170
|
+
console.error("[Pixi'VN] Error comparing openedLabels", e);
|
|
2171
|
+
}
|
|
2172
|
+
}
|
|
2173
|
+
}
|
|
2174
|
+
let data = diff(_GameStepManager.originalStepData, currentStepData);
|
|
2175
|
+
if (data) {
|
|
2176
|
+
let dialoge = void 0;
|
|
2177
|
+
let requiredChoices = void 0;
|
|
2178
|
+
if (GameStorageManager.getVariable(GameStorageManager.keysSystem.LAST_DIALOGUE_ADDED_IN_STEP_MEMORY_KEY) === _GameStepManager.lastStepIndex) {
|
|
2179
|
+
dialoge = getDialogue();
|
|
2180
|
+
}
|
|
2181
|
+
if (GameStorageManager.getVariable(GameStorageManager.keysSystem.LAST_MENU_OPTIONS_ADDED_IN_STEP_MEMORY_KEY) === _GameStepManager.lastStepIndex) {
|
|
2182
|
+
requiredChoices = GameStorageManager.getVariable(GameStorageManager.keysSystem.CURRENT_MENU_OPTIONS_MEMORY_KEY);
|
|
2183
|
+
}
|
|
2184
|
+
_GameStepManager._stepsHistory.push({
|
|
2185
|
+
diff: data,
|
|
2186
|
+
currentLabel: _GameStepManager.currentLabelId,
|
|
2187
|
+
dialoge,
|
|
2188
|
+
choices: requiredChoices,
|
|
2189
|
+
stepSha1: stepHistory,
|
|
2190
|
+
index: _GameStepManager.lastStepIndex,
|
|
2191
|
+
choiceIndexMade: choiseMade
|
|
2192
|
+
});
|
|
2193
|
+
_GameStepManager.originalStepData = currentStepData;
|
|
2194
|
+
}
|
|
2195
|
+
_GameStepManager.increaseLastStepIndex();
|
|
2196
|
+
}
|
|
2197
|
+
/**
|
|
2198
|
+
* Add a label to the history.
|
|
2199
|
+
* @param label The label to add to the history.
|
|
2200
|
+
*/
|
|
2201
|
+
static pushNewLabel(label) {
|
|
2202
|
+
let currentLabel = getLabelById(label);
|
|
2203
|
+
if (!currentLabel) {
|
|
2204
|
+
throw new Error(`[Pixi'VN] Label ${label} not found`);
|
|
2205
|
+
}
|
|
2206
|
+
_GameStepManager._openedLabels.push({
|
|
2207
|
+
label,
|
|
2208
|
+
currentStepIndex: 0
|
|
2209
|
+
});
|
|
2210
|
+
}
|
|
2211
|
+
/**
|
|
2212
|
+
* Close the current label and add it to the history.
|
|
2213
|
+
* @returns
|
|
2214
|
+
*/
|
|
2215
|
+
static closeCurrentLabel() {
|
|
2216
|
+
if (!_GameStepManager.currentLabelId) {
|
|
2217
|
+
console.warn("[Pixi'VN] No label to close");
|
|
2218
|
+
return;
|
|
2219
|
+
}
|
|
2220
|
+
if (!_GameStepManager.currentLabel) {
|
|
2221
|
+
console.error("[Pixi'VN] currentLabel not found");
|
|
2222
|
+
return;
|
|
2223
|
+
}
|
|
2224
|
+
_GameStepManager._openedLabels.pop();
|
|
2225
|
+
}
|
|
2226
|
+
/**
|
|
2227
|
+
* Close all labels and add them to the history. **Attention: This method can cause an unhandled game ending.**
|
|
2228
|
+
*/
|
|
2229
|
+
static closeAllLabels() {
|
|
2230
|
+
while (_GameStepManager._openedLabels.length > 0) {
|
|
2231
|
+
_GameStepManager.closeCurrentLabel();
|
|
2232
|
+
}
|
|
2233
|
+
}
|
|
2234
|
+
/**
|
|
2235
|
+
* Increase the current step index of the current label.
|
|
2236
|
+
*/
|
|
2237
|
+
static increaseCurrentStepIndex() {
|
|
2238
|
+
let item = _GameStepManager._openedLabels[_GameStepManager._openedLabels.length - 1];
|
|
2239
|
+
_GameStepManager._openedLabels[_GameStepManager._openedLabels.length - 1] = __spreadProps(__spreadValues({}, item), {
|
|
2240
|
+
currentStepIndex: item.currentStepIndex + 1
|
|
2241
|
+
});
|
|
2242
|
+
}
|
|
2243
|
+
static restorLastLabelList() {
|
|
2244
|
+
_GameStepManager._openedLabels = _GameStepManager.originalStepData.openedLabels;
|
|
2245
|
+
}
|
|
2246
|
+
/* Run Methods */
|
|
2247
|
+
static get canGoNext() {
|
|
2248
|
+
let options = getChoiceMenuOptions();
|
|
2249
|
+
if (options && options.length > 0) {
|
|
2250
|
+
return false;
|
|
2251
|
+
}
|
|
2252
|
+
return true;
|
|
2253
|
+
}
|
|
2254
|
+
/**
|
|
2255
|
+
* Execute the next step and add it to the history.
|
|
2256
|
+
* @param props The props to pass to the step.
|
|
2257
|
+
* @param choiseMade The index of the choise made by the player. (This params is used in the choice menu)
|
|
2258
|
+
* @returns StepLabelResultType or undefined.
|
|
2259
|
+
* @example
|
|
2260
|
+
* ```typescript
|
|
2261
|
+
* function nextOnClick() {
|
|
2262
|
+
* setLoading(true)
|
|
2263
|
+
* GameStepManager.goNext(yourParams)
|
|
2264
|
+
* .then((result) => {
|
|
2265
|
+
* setUpdate((p) => p + 1)
|
|
2266
|
+
* setLoading(false)
|
|
2267
|
+
* if (result) {
|
|
2268
|
+
* // your code
|
|
2269
|
+
* }
|
|
2270
|
+
* })
|
|
2271
|
+
* .catch((e) => {
|
|
2272
|
+
* setLoading(false)
|
|
2273
|
+
* console.error(e)
|
|
2274
|
+
* })
|
|
2275
|
+
* }
|
|
2276
|
+
* ```
|
|
2277
|
+
*/
|
|
2278
|
+
static goNext(props, choiseMade) {
|
|
2279
|
+
return __async(this, null, function* () {
|
|
2280
|
+
if (!_GameStepManager.canGoNext) {
|
|
2281
|
+
console.warn("[Pixi'VN] The player must make a choice");
|
|
2282
|
+
return;
|
|
2283
|
+
}
|
|
2284
|
+
if (_GameStepManager.currentLabel && _GameStepManager.currentLabel.onStepEnd) {
|
|
2285
|
+
yield _GameStepManager.currentLabel.onStepEnd(_GameStepManager.currentLabelStepIndex || 0, _GameStepManager.currentLabel);
|
|
2286
|
+
}
|
|
2287
|
+
_GameStepManager.increaseCurrentStepIndex();
|
|
2288
|
+
return yield _GameStepManager.runCurrentStep(props, choiseMade);
|
|
2289
|
+
});
|
|
2290
|
+
}
|
|
2291
|
+
/**
|
|
2292
|
+
* Execute the current step and add it to the history.
|
|
2293
|
+
* @param props The props to pass to the step.
|
|
2294
|
+
* @param choiseMade The choise made by the player.
|
|
2295
|
+
* @returns StepLabelResultType or undefined.
|
|
2296
|
+
*/
|
|
2297
|
+
static runCurrentStep(props, choiseMade) {
|
|
2298
|
+
return __async(this, null, function* () {
|
|
2299
|
+
if (_GameStepManager.currentLabelId) {
|
|
2300
|
+
let currentLabelStepIndex = _GameStepManager.currentLabelStepIndex;
|
|
2301
|
+
if (currentLabelStepIndex === null) {
|
|
2302
|
+
console.error("[Pixi'VN] currentLabelStepIndex is null");
|
|
2303
|
+
return;
|
|
2304
|
+
}
|
|
2305
|
+
let currentLabel = _GameStepManager.currentLabel;
|
|
2306
|
+
if (!currentLabel) {
|
|
2307
|
+
console.error("[Pixi'VN] currentLabel not found");
|
|
2308
|
+
return;
|
|
2309
|
+
}
|
|
2310
|
+
if (currentLabel.steps.length > currentLabelStepIndex) {
|
|
2311
|
+
let onStepRun = currentLabel.onStepStart;
|
|
2312
|
+
if (onStepRun) {
|
|
2313
|
+
yield onStepRun(currentLabelStepIndex, currentLabel);
|
|
2314
|
+
}
|
|
2315
|
+
let step = currentLabel.steps[currentLabelStepIndex];
|
|
2316
|
+
let result = yield step(props);
|
|
2317
|
+
_GameStepManager.addStepHistory(step, choiseMade);
|
|
2318
|
+
return result;
|
|
2319
|
+
} else if (_GameStepManager.openedLabels.length > 1) {
|
|
2320
|
+
_GameStepManager.closeCurrentLabel();
|
|
2321
|
+
return yield _GameStepManager.goNext(props, choiseMade);
|
|
2322
|
+
} else {
|
|
2323
|
+
_GameStepManager.restorLastLabelList();
|
|
2324
|
+
console.error("[Pixi'VN] The end of the game is not managed, so the game is blocked. Read this documentation to know how to manage the end of the game: https://pixi-vn.web.app/start/labels.html#how-manage-the-end-of-the-game");
|
|
2325
|
+
return;
|
|
2326
|
+
}
|
|
2327
|
+
}
|
|
2328
|
+
});
|
|
2329
|
+
}
|
|
2330
|
+
/**
|
|
2331
|
+
* Execute the label and add it to the history. (It's similar to Ren'Py's call function)
|
|
2332
|
+
* @param label The label to execute or the id of the label
|
|
2333
|
+
* @param props The props to pass to the label.
|
|
2334
|
+
* @returns StepLabelResultType or undefined.
|
|
2335
|
+
* @example
|
|
2336
|
+
* ```typescript
|
|
2337
|
+
* GameStepManager.callLabel(startLabel, yourParams).then((result) => {
|
|
2338
|
+
* if (result) {
|
|
2339
|
+
* // your code
|
|
2340
|
+
* }
|
|
2341
|
+
* })
|
|
2342
|
+
* ```
|
|
2343
|
+
* @example
|
|
2344
|
+
* ```typescript
|
|
2345
|
+
* // if you use it in a step label you should return the result.
|
|
2346
|
+
* return GameStepManager.callLabel(startLabel).then((result) => {
|
|
2347
|
+
* return result
|
|
2348
|
+
* })
|
|
2349
|
+
* ```
|
|
2350
|
+
*/
|
|
2351
|
+
static callLabel(label, props) {
|
|
2352
|
+
return __async(this, null, function* () {
|
|
2353
|
+
let choiseMade = void 0;
|
|
2354
|
+
let labelId;
|
|
2355
|
+
if (typeof label === "string") {
|
|
2356
|
+
labelId = label;
|
|
2357
|
+
} else {
|
|
2358
|
+
labelId = label.id;
|
|
2359
|
+
if (typeof label.choiseIndex === "number") {
|
|
2360
|
+
choiseMade = label.choiseIndex;
|
|
2361
|
+
}
|
|
2362
|
+
}
|
|
2363
|
+
try {
|
|
2364
|
+
if (labelId === CLOSE_LABEL_ID) {
|
|
2365
|
+
let closeCurrentLabel = newCloseLabel(choiseMade);
|
|
2366
|
+
let choice = {
|
|
2367
|
+
label: closeCurrentLabel,
|
|
2368
|
+
text: "",
|
|
2369
|
+
closeCurrentLabel: false,
|
|
2370
|
+
type: "close",
|
|
2371
|
+
props: {}
|
|
2372
|
+
};
|
|
2373
|
+
return _GameStepManager.closeChoiceMenu(choice, props);
|
|
2374
|
+
}
|
|
2375
|
+
let tempLabel = getLabelById(labelId);
|
|
2376
|
+
if (!tempLabel) {
|
|
2377
|
+
throw new Error(`[Pixi'VN] Label ${labelId} not found`);
|
|
2378
|
+
}
|
|
2379
|
+
if (_GameStepManager.currentLabel && _GameStepManager.currentLabel.onStepEnd) {
|
|
2380
|
+
yield _GameStepManager.currentLabel.onStepEnd(_GameStepManager.currentLabelStepIndex || 0, _GameStepManager.currentLabel);
|
|
2381
|
+
}
|
|
2382
|
+
_GameStepManager.pushNewLabel(tempLabel.id);
|
|
2383
|
+
} catch (e) {
|
|
2384
|
+
console.error("[Pixi'VN] Error calling label", e);
|
|
2385
|
+
return;
|
|
2386
|
+
}
|
|
2387
|
+
return yield _GameStepManager.runCurrentStep(props, choiseMade);
|
|
2388
|
+
});
|
|
2389
|
+
}
|
|
2390
|
+
/**
|
|
2391
|
+
* Execute the label, close the current label, execute the new label and add the new label to the history. (It's similar to Ren'Py's jump function)
|
|
2392
|
+
* @param label The label to execute.
|
|
2393
|
+
* @param props The props to pass to the label or the id of the label
|
|
2394
|
+
* @returns StepLabelResultType or undefined.
|
|
2395
|
+
* @example
|
|
2396
|
+
* ```typescript
|
|
2397
|
+
* GameStepManager.jumpLabel(startLabel, yourParams).then((result) => {
|
|
2398
|
+
* if (result) {
|
|
2399
|
+
* // your code
|
|
2400
|
+
* }
|
|
2401
|
+
* })
|
|
2402
|
+
* ```
|
|
2403
|
+
* @example
|
|
2404
|
+
* ```typescript
|
|
2405
|
+
* // if you use it in a step label you should return the result.
|
|
2406
|
+
* return GameStepManager.jumpLabel(startLabel).then((result) => {
|
|
2407
|
+
* return result
|
|
2408
|
+
* })
|
|
2409
|
+
* ```
|
|
2410
|
+
*/
|
|
2411
|
+
static jumpLabel(label, props) {
|
|
2412
|
+
return __async(this, null, function* () {
|
|
2413
|
+
_GameStepManager.closeCurrentLabel();
|
|
2414
|
+
let choiseMade = void 0;
|
|
2415
|
+
let labelId;
|
|
2416
|
+
if (typeof label === "string") {
|
|
2417
|
+
labelId = label;
|
|
2418
|
+
} else {
|
|
2419
|
+
labelId = label.id;
|
|
2420
|
+
if (typeof label.choiseIndex === "number") {
|
|
2421
|
+
choiseMade = label.choiseIndex;
|
|
2422
|
+
}
|
|
2423
|
+
}
|
|
2424
|
+
try {
|
|
2425
|
+
if (labelId === CLOSE_LABEL_ID) {
|
|
2426
|
+
let closeCurrentLabel = newCloseLabel(choiseMade);
|
|
2427
|
+
let choice = {
|
|
2428
|
+
label: closeCurrentLabel,
|
|
2429
|
+
text: "",
|
|
2430
|
+
closeCurrentLabel: false,
|
|
2431
|
+
type: "close",
|
|
2432
|
+
props: {}
|
|
2433
|
+
};
|
|
2434
|
+
return _GameStepManager.closeChoiceMenu(choice, props);
|
|
2435
|
+
}
|
|
2436
|
+
let tempLabel = getLabelById(labelId);
|
|
2437
|
+
if (!tempLabel) {
|
|
2438
|
+
throw new Error(`[Pixi'VN] Label ${labelId} not found`);
|
|
2439
|
+
}
|
|
2440
|
+
if (_GameStepManager.currentLabel && _GameStepManager.currentLabel.onStepEnd) {
|
|
2441
|
+
yield _GameStepManager.currentLabel.onStepEnd(_GameStepManager.currentLabelStepIndex || 0, _GameStepManager.currentLabel);
|
|
2442
|
+
}
|
|
2443
|
+
_GameStepManager.pushNewLabel(tempLabel.id);
|
|
2444
|
+
} catch (e) {
|
|
2445
|
+
console.error("[Pixi'VN] Error jumping label", e);
|
|
2446
|
+
return;
|
|
2447
|
+
}
|
|
2448
|
+
return yield _GameStepManager.runCurrentStep(props, choiseMade);
|
|
2449
|
+
});
|
|
2450
|
+
}
|
|
2451
|
+
/**
|
|
2452
|
+
* When the player is in a choice menu, can use this function to exit to the choice menu.
|
|
2453
|
+
* @param choice
|
|
2454
|
+
* @param props
|
|
2455
|
+
* @returns StepLabelResultType or undefined.
|
|
2456
|
+
* @example
|
|
2457
|
+
* ```typescript
|
|
2458
|
+
* GameStepManager.closeChoiceMenu(yourParams).then((result) => {
|
|
2459
|
+
* if (result) {
|
|
2460
|
+
* // your code
|
|
2461
|
+
* }
|
|
2462
|
+
* })
|
|
2463
|
+
* ```
|
|
2464
|
+
*/
|
|
2465
|
+
static closeChoiceMenu(choice, props) {
|
|
2466
|
+
return __async(this, null, function* () {
|
|
2467
|
+
let label = choice.label;
|
|
2468
|
+
let choiseMade = void 0;
|
|
2469
|
+
if (typeof label.choiseIndex === "number") {
|
|
2470
|
+
choiseMade = label.choiseIndex;
|
|
2471
|
+
}
|
|
2472
|
+
if (choice.closeCurrentLabel) {
|
|
2473
|
+
_GameStepManager.closeCurrentLabel();
|
|
2474
|
+
}
|
|
2475
|
+
return _GameStepManager.goNext(props, choiseMade);
|
|
2476
|
+
});
|
|
2477
|
+
}
|
|
2478
|
+
/* After Update Methods */
|
|
2479
|
+
// /**
|
|
2480
|
+
// * After the update or code edit, some steps or labels may no longer match.
|
|
2481
|
+
// * - In case of step mismatch, the game will be updated to the last matching step.
|
|
2482
|
+
// * - In case of label mismatch, the game gives an error.
|
|
2483
|
+
// * @returns
|
|
2484
|
+
// */
|
|
2485
|
+
// private static afterUpdate() {
|
|
2486
|
+
// // TODO: implement
|
|
2487
|
+
// if (!GameStepManager.currentLabel) {
|
|
2488
|
+
// // TODO: implement
|
|
2489
|
+
// return
|
|
2490
|
+
// }
|
|
2491
|
+
// let currentLabel = getLabelInstanceByClassName(GameStepManager.currentLabel)
|
|
2492
|
+
// if (!currentLabel) {
|
|
2493
|
+
// console.error("Label not found")
|
|
2494
|
+
// return
|
|
2495
|
+
// }
|
|
2496
|
+
// let oldSteps = GameStepManager.stepsAfterLastHistoryLabel
|
|
2497
|
+
// let currentStepIndex = currentLabel.getCorrespondingStepsNumber(oldSteps)
|
|
2498
|
+
// let stepToRemove = oldSteps.length - currentStepIndex
|
|
2499
|
+
// GameStepManager.removeLastHistoryNodes(stepToRemove)
|
|
2500
|
+
// GameStepManager.loadLastStep()
|
|
2501
|
+
// }
|
|
2502
|
+
// private static loadLastStep() {
|
|
2503
|
+
// // TODO: implement
|
|
2504
|
+
// }
|
|
2505
|
+
// /**
|
|
2506
|
+
// * Remove a number of items from the last of the history.
|
|
2507
|
+
// * @param itemNumber The number of items to remove from the last of the history.
|
|
2508
|
+
// */
|
|
2509
|
+
// private static removeLastHistoryNodes(itemNumber: number) {
|
|
2510
|
+
// // TODO: implement
|
|
2511
|
+
// for (let i = 0; i < itemNumber; i++) {
|
|
2512
|
+
// GameStepManager._stepsHistory.pop()
|
|
2513
|
+
// }
|
|
2514
|
+
// }
|
|
2515
|
+
// /**
|
|
2516
|
+
// * stepsAfterLastHistoryLabel is a list of steps that occurred after the last history label.
|
|
2517
|
+
// */
|
|
2518
|
+
// private static get stepsAfterLastHistoryLabel(): StepHistoryDataType[] {
|
|
2519
|
+
// let length = GameStepManager._stepsHistory.length
|
|
2520
|
+
// let steps: StepHistoryDataType[] = []
|
|
2521
|
+
// for (let i = length - 1; i >= 0; i--) {
|
|
2522
|
+
// let element = GameStepManager._stepsHistory[i]
|
|
2523
|
+
// if (typeof element === "object" && "stepSha1" in element) {
|
|
2524
|
+
// steps.push(element.stepSha1)
|
|
2525
|
+
// }
|
|
2526
|
+
// else {
|
|
2527
|
+
// break
|
|
2528
|
+
// }
|
|
2529
|
+
// }
|
|
2530
|
+
// steps = steps.reverse()
|
|
2531
|
+
// return steps
|
|
2532
|
+
// }
|
|
2533
|
+
/* Go Back & Refresh Methods */
|
|
2534
|
+
/**
|
|
2535
|
+
* Go back to the last step and add it to the history.
|
|
2536
|
+
* @param navigate The navigate function.
|
|
2537
|
+
* @param steps The number of steps to go back.
|
|
2538
|
+
* @returns
|
|
2539
|
+
* @example
|
|
2540
|
+
* ```typescript
|
|
2541
|
+
* export function goBack(navigate: (path: string) => void, afterBack?: () => void) {
|
|
2542
|
+
* GameStepManager.goBack(navigate)
|
|
2543
|
+
* afterBack && afterBack()
|
|
2544
|
+
* }
|
|
2545
|
+
* ```
|
|
2546
|
+
*/
|
|
2547
|
+
static goBack(navigate, steps = 1) {
|
|
2548
|
+
return __async(this, null, function* () {
|
|
2549
|
+
if (steps <= 0) {
|
|
2550
|
+
console.warn("[Pixi'VN] Steps must be greater than 0");
|
|
2551
|
+
return;
|
|
2552
|
+
}
|
|
2553
|
+
if (_GameStepManager._stepsHistory.length <= 1) {
|
|
2554
|
+
console.warn("[Pixi'VN] No steps to go back");
|
|
2555
|
+
return;
|
|
2556
|
+
}
|
|
2557
|
+
let restoredStep = _GameStepManager.goBackInternal(steps, _GameStepManager.originalStepData);
|
|
2558
|
+
if (restoredStep) {
|
|
2559
|
+
_GameStepManager._originalStepData = restoredStep;
|
|
2560
|
+
_GameStepManager._openedLabels = createExportableElement(restoredStep.openedLabels);
|
|
2561
|
+
if (_GameStepManager.currentLabel && _GameStepManager.currentLabel.onLoadStep) {
|
|
2562
|
+
yield _GameStepManager.currentLabel.onLoadStep(_GameStepManager.currentLabelStepIndex || 0, _GameStepManager.currentLabel);
|
|
2563
|
+
}
|
|
2564
|
+
GameStorageManager.import(createExportableElement(restoredStep.storage));
|
|
2565
|
+
GameWindowManager.import(createExportableElement(restoredStep.canvas));
|
|
2566
|
+
navigate(restoredStep.path);
|
|
2567
|
+
} else {
|
|
2568
|
+
console.error("[Pixi'VN] Error going back");
|
|
2569
|
+
}
|
|
2570
|
+
});
|
|
2571
|
+
}
|
|
2572
|
+
static goBackInternal(steps, restoredStep) {
|
|
2573
|
+
if (steps <= 0) {
|
|
2574
|
+
return restoredStep;
|
|
2575
|
+
}
|
|
2576
|
+
if (_GameStepManager._stepsHistory.length == 0) {
|
|
2577
|
+
return restoredStep;
|
|
2578
|
+
}
|
|
2579
|
+
let lastHistoryStep = _GameStepManager.lastHistoryStep;
|
|
2580
|
+
if (lastHistoryStep) {
|
|
2581
|
+
try {
|
|
2582
|
+
let result = restoreDeepDiffChanges(restoredStep, lastHistoryStep.diff);
|
|
2583
|
+
_GameStepManager._lastStepIndex = lastHistoryStep.index;
|
|
2584
|
+
_GameStepManager._stepsHistory.pop();
|
|
2585
|
+
return _GameStepManager.goBackInternal(steps - 1, result);
|
|
2586
|
+
} catch (e) {
|
|
2587
|
+
console.error("[Pixi'VN] Error applying diff", e);
|
|
2588
|
+
return restoredStep;
|
|
2589
|
+
}
|
|
2590
|
+
} else {
|
|
2591
|
+
return restoredStep;
|
|
2592
|
+
}
|
|
2593
|
+
}
|
|
2594
|
+
/**
|
|
2595
|
+
* Return true if it is possible to go back.
|
|
2596
|
+
*/
|
|
2597
|
+
static get canGoBack() {
|
|
2598
|
+
return _GameStepManager._stepsHistory.length > 1;
|
|
2599
|
+
}
|
|
2600
|
+
/**
|
|
2601
|
+
* Add a label to the history.
|
|
2602
|
+
*/
|
|
2603
|
+
static clear() {
|
|
2604
|
+
_GameStepManager._stepsHistory = [];
|
|
2605
|
+
_GameStepManager._openedLabels = [];
|
|
2606
|
+
}
|
|
2607
|
+
/* Export and Import Methods */
|
|
2608
|
+
/**
|
|
2609
|
+
* Export the history to a JSON string.
|
|
2610
|
+
* @returns The history in a JSON string.
|
|
2611
|
+
*/
|
|
2612
|
+
static exportJson() {
|
|
2613
|
+
return JSON.stringify(this.export());
|
|
2614
|
+
}
|
|
2615
|
+
/**
|
|
2616
|
+
* Export the history to an object.
|
|
2617
|
+
* @returns The history in an object.
|
|
2618
|
+
*/
|
|
2619
|
+
static export() {
|
|
2620
|
+
return {
|
|
2621
|
+
stepsHistory: _GameStepManager._stepsHistory,
|
|
2622
|
+
openedLabels: _GameStepManager._openedLabels,
|
|
2623
|
+
lastStepIndex: _GameStepManager._lastStepIndex,
|
|
2624
|
+
originalStepData: _GameStepManager._originalStepData
|
|
2625
|
+
};
|
|
2626
|
+
}
|
|
2627
|
+
/**
|
|
2628
|
+
* Import the history from a JSON string.
|
|
2629
|
+
* @param dataString The history in a JSON string.
|
|
2630
|
+
*/
|
|
2631
|
+
static importJson(dataString) {
|
|
2632
|
+
return __async(this, null, function* () {
|
|
2633
|
+
yield _GameStepManager.import(JSON.parse(dataString));
|
|
2634
|
+
});
|
|
2635
|
+
}
|
|
2636
|
+
/**
|
|
2637
|
+
* Import the history from an object.
|
|
2638
|
+
* @param data The history in an object.
|
|
2639
|
+
*/
|
|
2640
|
+
static import(data) {
|
|
2641
|
+
return __async(this, null, function* () {
|
|
2642
|
+
_GameStepManager.clear();
|
|
2643
|
+
try {
|
|
2644
|
+
if (data.hasOwnProperty("stepsHistory")) {
|
|
2645
|
+
_GameStepManager._stepsHistory = data["stepsHistory"];
|
|
2646
|
+
} else {
|
|
2647
|
+
console.warn("[Pixi'VN] Could not import stepsHistory data, so will be ignored");
|
|
2648
|
+
}
|
|
2649
|
+
if (data.hasOwnProperty("openedLabels")) {
|
|
2650
|
+
_GameStepManager._openedLabels = data["openedLabels"];
|
|
2651
|
+
} else {
|
|
2652
|
+
console.warn("[Pixi'VN] Could not import openedLabels data, so will be ignored");
|
|
2653
|
+
}
|
|
2654
|
+
if (data.hasOwnProperty("lastStepIndex")) {
|
|
2655
|
+
_GameStepManager._lastStepIndex = data["lastStepIndex"];
|
|
2656
|
+
} else {
|
|
2657
|
+
console.warn("[Pixi'VN] Could not import lastStepIndex data, so will be ignored");
|
|
2658
|
+
}
|
|
2659
|
+
if (data.hasOwnProperty("originalStepData")) {
|
|
2660
|
+
_GameStepManager._originalStepData = data["originalStepData"];
|
|
2661
|
+
} else {
|
|
2662
|
+
console.warn("[Pixi'VN] Could not import originalStepData data, so will be ignored");
|
|
2663
|
+
}
|
|
2664
|
+
if (_GameStepManager.currentLabel && _GameStepManager.currentLabel.onLoadStep) {
|
|
2665
|
+
yield _GameStepManager.currentLabel.onLoadStep(_GameStepManager.currentLabelStepIndex || 0, _GameStepManager.currentLabel);
|
|
2666
|
+
}
|
|
2667
|
+
} catch (e) {
|
|
2668
|
+
console.error("[Pixi'VN] Error importing data", e);
|
|
2669
|
+
}
|
|
2670
|
+
});
|
|
2671
|
+
}
|
|
2672
|
+
};
|
|
2673
|
+
/**
|
|
2674
|
+
* stepHistory is a list of label events and steps that occurred during the progression of the steps.
|
|
2675
|
+
*/
|
|
2676
|
+
_GameStepManager._stepsHistory = [];
|
|
2677
|
+
_GameStepManager._lastStepIndex = 0;
|
|
2678
|
+
_GameStepManager._openedLabels = [];
|
|
2679
|
+
_GameStepManager._originalStepData = void 0;
|
|
2680
|
+
var GameStepManager = _GameStepManager;
|
|
2681
|
+
|
|
1864
2682
|
// src/classes/StoredClassModel.ts
|
|
1865
2683
|
var StoredClassModel = class {
|
|
1866
2684
|
/**
|
|
@@ -2021,6 +2839,54 @@ var DialogueBaseModel = class {
|
|
|
2021
2839
|
}
|
|
2022
2840
|
};
|
|
2023
2841
|
|
|
2024
|
-
|
|
2842
|
+
// src/classes/LabelJson.ts
|
|
2843
|
+
var LabelJson2 = class extends LabelAbstract {
|
|
2844
|
+
/**
|
|
2845
|
+
* @param id is the id of the label
|
|
2846
|
+
* @param steps is the list of steps that the label will perform
|
|
2847
|
+
* @param props is the properties of the label
|
|
2848
|
+
*/
|
|
2849
|
+
constructor(id, steps, props) {
|
|
2850
|
+
super(id, props);
|
|
2851
|
+
this._steps = steps;
|
|
2852
|
+
}
|
|
2853
|
+
/**
|
|
2854
|
+
* Get the steps of the label.
|
|
2855
|
+
*/
|
|
2856
|
+
get steps() {
|
|
2857
|
+
if (typeof this._steps === "function") {
|
|
2858
|
+
return this._steps().map(this.stepConverter);
|
|
2859
|
+
}
|
|
2860
|
+
return this._steps.map(this.stepConverter);
|
|
2861
|
+
}
|
|
2862
|
+
stepConverter(step) {
|
|
2863
|
+
return (props) => {
|
|
2864
|
+
if (step.currentChoiceMenuOptions) {
|
|
2865
|
+
setChoiceMenuOptions(step.currentChoiceMenuOptions);
|
|
2866
|
+
} else {
|
|
2867
|
+
clearChoiceMenuOptions();
|
|
2868
|
+
}
|
|
2869
|
+
if (step.dialog) {
|
|
2870
|
+
setDialogue(step.dialog);
|
|
2871
|
+
} else {
|
|
2872
|
+
clearDialogue();
|
|
2873
|
+
}
|
|
2874
|
+
if (step.labelToOpen) {
|
|
2875
|
+
if (step.labelToOpen.type === "jump") {
|
|
2876
|
+
GameStepManager.jumpLabel(step.labelToOpen.labelId, props);
|
|
2877
|
+
} else {
|
|
2878
|
+
GameStepManager.callLabel(step.labelToOpen.labelId, props);
|
|
2879
|
+
}
|
|
2880
|
+
}
|
|
2881
|
+
if (step.end === "game_end") {
|
|
2882
|
+
console.warn("[Pixi'VN] Game end not implemented");
|
|
2883
|
+
} else if (step.end === "label_end") {
|
|
2884
|
+
GameStepManager.closeCurrentLabel();
|
|
2885
|
+
}
|
|
2886
|
+
};
|
|
2887
|
+
}
|
|
2888
|
+
};
|
|
2889
|
+
|
|
2890
|
+
export { CanvasEvent, CharacterBaseModel2 as CharacterBaseModel, ChoiceMenuOption, ChoiceMenuOptionClose, DialogueBaseModel, Label, LabelJson2 as LabelJson, StoredClassModel };
|
|
2025
2891
|
//# sourceMappingURL=index.mjs.map
|
|
2026
2892
|
//# sourceMappingURL=index.mjs.map
|