@drincs/pixi-vn 0.5.7 → 0.5.9
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/dist/classes/CharacterBaseModel.js.map +1 -1
- package/dist/classes/CharacterBaseModel.mjs.map +1 -1
- package/dist/classes/ChoiceMenuOption.js.map +1 -1
- package/dist/classes/ChoiceMenuOption.mjs.map +1 -1
- package/dist/classes/StoredClassModel.js.map +1 -1
- package/dist/classes/StoredClassModel.mjs.map +1 -1
- package/dist/classes/index.js.map +1 -1
- package/dist/classes/index.mjs.map +1 -1
- package/dist/classes/ticker/TickerFadeAlpha.js.map +1 -1
- package/dist/classes/ticker/TickerFadeAlpha.mjs.map +1 -1
- package/dist/classes/ticker/TickerMove.js.map +1 -1
- package/dist/classes/ticker/TickerMove.mjs.map +1 -1
- package/dist/classes/ticker/TickerRotate.js.map +1 -1
- package/dist/classes/ticker/TickerRotate.mjs.map +1 -1
- package/dist/classes/ticker/index.js.map +1 -1
- package/dist/classes/ticker/index.mjs.map +1 -1
- package/dist/constants.d.mts +1 -1
- package/dist/constants.d.ts +1 -1
- package/dist/constants.js +1 -1
- package/dist/constants.js.map +1 -1
- package/dist/constants.mjs +1 -1
- package/dist/constants.mjs.map +1 -1
- package/dist/decorators/LabelDecorator.js.map +1 -1
- package/dist/decorators/LabelDecorator.mjs.map +1 -1
- package/dist/decorators/index.js.map +1 -1
- package/dist/decorators/index.mjs.map +1 -1
- package/dist/functions/DialogueUtility.d.mts +4 -2
- package/dist/functions/DialogueUtility.d.ts +4 -2
- package/dist/functions/DialogueUtility.js +21 -12
- package/dist/functions/DialogueUtility.js.map +1 -1
- package/dist/functions/DialogueUtility.mjs +21 -12
- package/dist/functions/DialogueUtility.mjs.map +1 -1
- package/dist/functions/FlagsUtility.js.map +1 -1
- package/dist/functions/FlagsUtility.mjs.map +1 -1
- package/dist/functions/GameUtility.js.map +1 -1
- package/dist/functions/GameUtility.mjs.map +1 -1
- package/dist/functions/ImageUtility.js.map +1 -1
- package/dist/functions/ImageUtility.mjs.map +1 -1
- package/dist/functions/SavesUtility.js +92 -13
- package/dist/functions/SavesUtility.js.map +1 -1
- package/dist/functions/SavesUtility.mjs +92 -13
- package/dist/functions/SavesUtility.mjs.map +1 -1
- package/dist/functions/index.js +22 -13
- package/dist/functions/index.js.map +1 -1
- package/dist/functions/index.mjs +22 -13
- package/dist/functions/index.mjs.map +1 -1
- package/dist/index.js +22 -13
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +22 -13
- package/dist/index.mjs.map +1 -1
- package/dist/managers/StepManager.d.mts +1 -1
- package/dist/managers/StepManager.d.ts +1 -1
- package/dist/managers/StepManager.js +91 -12
- package/dist/managers/StepManager.js.map +1 -1
- package/dist/managers/StepManager.mjs +91 -12
- package/dist/managers/StepManager.mjs.map +1 -1
- package/dist/managers/index.js +91 -12
- package/dist/managers/index.js.map +1 -1
- package/dist/managers/index.mjs +91 -12
- package/dist/managers/index.mjs.map +1 -1
- package/package.json +2 -2
|
@@ -176,7 +176,7 @@ declare class GameStepManager {
|
|
|
176
176
|
* })
|
|
177
177
|
* ```
|
|
178
178
|
*/
|
|
179
|
-
static closeChoiceMenu<T extends {}>(props: StepLabelPropsType<T>): Promise<StepLabelResultType>;
|
|
179
|
+
static closeChoiceMenu<T extends {}>(label: Label<T>, props: StepLabelPropsType<T>): Promise<StepLabelResultType>;
|
|
180
180
|
/**
|
|
181
181
|
* Go back to the last step and add it to the history.
|
|
182
182
|
* @param navigate The navigate function.
|
|
@@ -176,7 +176,7 @@ declare class GameStepManager {
|
|
|
176
176
|
* })
|
|
177
177
|
* ```
|
|
178
178
|
*/
|
|
179
|
-
static closeChoiceMenu<T extends {}>(props: StepLabelPropsType<T>): Promise<StepLabelResultType>;
|
|
179
|
+
static closeChoiceMenu<T extends {}>(label: Label<T>, props: StepLabelPropsType<T>): Promise<StepLabelResultType>;
|
|
180
180
|
/**
|
|
181
181
|
* Go back to the last step and add it to the history.
|
|
182
182
|
* @param navigate The navigate function.
|
|
@@ -61,9 +61,79 @@ function getStepSha1(step) {
|
|
|
61
61
|
let sha1String = sha1__default.default(step.toString().toLocaleLowerCase());
|
|
62
62
|
return sha1String.toString();
|
|
63
63
|
}
|
|
64
|
+
function checkIfStepsIsEqual(step1, step2) {
|
|
65
|
+
return step1 === step2;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
// src/classes/Label.ts
|
|
69
|
+
var Label = class {
|
|
70
|
+
/**
|
|
71
|
+
* @param id is the id of the label
|
|
72
|
+
* @param steps is the list of steps that the label will perform
|
|
73
|
+
* @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
|
|
74
|
+
* @param choiseIndex is the index of the choice that the label will perform
|
|
75
|
+
*/
|
|
76
|
+
constructor(id, steps, onStepRun, choiseIndex) {
|
|
77
|
+
this._id = id;
|
|
78
|
+
this._steps = steps;
|
|
79
|
+
this._onStepRun = onStepRun;
|
|
80
|
+
this._choiseIndex = choiseIndex;
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Get the id of the label
|
|
84
|
+
*/
|
|
85
|
+
get id() {
|
|
86
|
+
return this._id;
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Get the steps of the label.
|
|
90
|
+
* This class should be extended and the steps method should be overridden.
|
|
91
|
+
* Every time you update this list will also be updated when the other game versions load.
|
|
92
|
+
*/
|
|
93
|
+
get steps() {
|
|
94
|
+
return this._steps;
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Get the corresponding steps number
|
|
98
|
+
* @param externalSteps
|
|
99
|
+
* @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
|
|
100
|
+
*/
|
|
101
|
+
getCorrespondingStepsNumber(externalSteps) {
|
|
102
|
+
if (externalSteps.length === 0) {
|
|
103
|
+
return 0;
|
|
104
|
+
}
|
|
105
|
+
let res = 0;
|
|
106
|
+
externalSteps.forEach((step, index) => {
|
|
107
|
+
if (checkIfStepsIsEqual(step, this.steps[index])) {
|
|
108
|
+
res = index;
|
|
109
|
+
}
|
|
110
|
+
});
|
|
111
|
+
return res;
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* Get the function that will be executed before any step is executed, is useful for example to make sure all images used have been cached
|
|
115
|
+
* @returns Promise<void> or void
|
|
116
|
+
* @example
|
|
117
|
+
* ```typescript
|
|
118
|
+
* newLabel("id", [], () => {
|
|
119
|
+
* Assets.load('path/to/image1.png')
|
|
120
|
+
* Assets.load('path/to/image2.png')
|
|
121
|
+
* })
|
|
122
|
+
* ```
|
|
123
|
+
*/
|
|
124
|
+
get onStepRun() {
|
|
125
|
+
return this._onStepRun;
|
|
126
|
+
}
|
|
127
|
+
get choiseIndex() {
|
|
128
|
+
return this._choiseIndex;
|
|
129
|
+
}
|
|
130
|
+
};
|
|
64
131
|
|
|
65
132
|
// src/classes/CloseLabel.ts
|
|
66
133
|
var CLOSE_LABEL_ID = "__close-label-id__";
|
|
134
|
+
function newCloseLabel(choiseIndex) {
|
|
135
|
+
return new Label(CLOSE_LABEL_ID, [], void 0, choiseIndex);
|
|
136
|
+
}
|
|
67
137
|
|
|
68
138
|
// src/functions/ExportUtility.ts
|
|
69
139
|
function createExportableElement(element) {
|
|
@@ -1709,8 +1779,8 @@ var _GameStepManager = class _GameStepManager {
|
|
|
1709
1779
|
static runCurrentStep(props, choiseMade) {
|
|
1710
1780
|
return __async(this, null, function* () {
|
|
1711
1781
|
if (_GameStepManager.currentLabelId) {
|
|
1712
|
-
let
|
|
1713
|
-
if (
|
|
1782
|
+
let lastStepsLength = _GameStepManager.currentLabelStepIndex;
|
|
1783
|
+
if (lastStepsLength === null) {
|
|
1714
1784
|
console.error("[Pixi'VN] currentLabelStepIndex is null");
|
|
1715
1785
|
return;
|
|
1716
1786
|
}
|
|
@@ -1720,12 +1790,12 @@ var _GameStepManager = class _GameStepManager {
|
|
|
1720
1790
|
return;
|
|
1721
1791
|
}
|
|
1722
1792
|
let n = currentLabel.steps.length;
|
|
1723
|
-
if (n >
|
|
1724
|
-
let
|
|
1725
|
-
let result = yield
|
|
1726
|
-
_GameStepManager.addStepHistory(
|
|
1793
|
+
if (n > lastStepsLength) {
|
|
1794
|
+
let step = currentLabel.steps[lastStepsLength];
|
|
1795
|
+
let result = yield step(props);
|
|
1796
|
+
_GameStepManager.addStepHistory(step, choiseMade);
|
|
1727
1797
|
return result;
|
|
1728
|
-
} else if (n ===
|
|
1798
|
+
} else if (n === lastStepsLength) {
|
|
1729
1799
|
_GameStepManager.closeCurrentLabel();
|
|
1730
1800
|
return yield _GameStepManager.runNextStep(props);
|
|
1731
1801
|
} else {
|
|
@@ -1770,7 +1840,8 @@ var _GameStepManager = class _GameStepManager {
|
|
|
1770
1840
|
}
|
|
1771
1841
|
try {
|
|
1772
1842
|
if (labelId === CLOSE_LABEL_ID) {
|
|
1773
|
-
|
|
1843
|
+
let closeLabel = newCloseLabel(choiseMade);
|
|
1844
|
+
return _GameStepManager.closeChoiceMenu(closeLabel, props);
|
|
1774
1845
|
}
|
|
1775
1846
|
let tempLabel = getLabelById(labelId);
|
|
1776
1847
|
if (!tempLabel) {
|
|
@@ -1809,18 +1880,20 @@ var _GameStepManager = class _GameStepManager {
|
|
|
1809
1880
|
static jumpLabel(label, props) {
|
|
1810
1881
|
return __async(this, null, function* () {
|
|
1811
1882
|
_GameStepManager.closeAllLabels();
|
|
1883
|
+
let choiseMade = void 0;
|
|
1812
1884
|
let labelId;
|
|
1813
1885
|
if (typeof label === "string") {
|
|
1814
1886
|
labelId = label;
|
|
1815
1887
|
} else {
|
|
1816
1888
|
labelId = label.id;
|
|
1817
1889
|
if (typeof label.choiseIndex === "number") {
|
|
1818
|
-
label.choiseIndex;
|
|
1890
|
+
choiseMade = label.choiseIndex;
|
|
1819
1891
|
}
|
|
1820
1892
|
}
|
|
1821
1893
|
try {
|
|
1822
1894
|
if (labelId === CLOSE_LABEL_ID) {
|
|
1823
|
-
|
|
1895
|
+
let closeLabel = newCloseLabel(choiseMade);
|
|
1896
|
+
return _GameStepManager.closeChoiceMenu(closeLabel, props);
|
|
1824
1897
|
}
|
|
1825
1898
|
let tempLabel = getLabelById(labelId);
|
|
1826
1899
|
if (!tempLabel) {
|
|
@@ -1831,7 +1904,7 @@ var _GameStepManager = class _GameStepManager {
|
|
|
1831
1904
|
console.error("[Pixi'VN] Error jumping label", e);
|
|
1832
1905
|
return;
|
|
1833
1906
|
}
|
|
1834
|
-
return yield _GameStepManager.runCurrentStep(props);
|
|
1907
|
+
return yield _GameStepManager.runCurrentStep(props, choiseMade);
|
|
1835
1908
|
});
|
|
1836
1909
|
}
|
|
1837
1910
|
/**
|
|
@@ -1847,8 +1920,14 @@ var _GameStepManager = class _GameStepManager {
|
|
|
1847
1920
|
* })
|
|
1848
1921
|
* ```
|
|
1849
1922
|
*/
|
|
1850
|
-
static closeChoiceMenu(props) {
|
|
1923
|
+
static closeChoiceMenu(label, props) {
|
|
1851
1924
|
return __async(this, null, function* () {
|
|
1925
|
+
let choiseMade = void 0;
|
|
1926
|
+
if (typeof label.choiseIndex === "number") {
|
|
1927
|
+
choiseMade = label.choiseIndex;
|
|
1928
|
+
}
|
|
1929
|
+
_GameStepManager.addStepHistory(() => {
|
|
1930
|
+
}, choiseMade);
|
|
1852
1931
|
return _GameStepManager.runNextStep(props);
|
|
1853
1932
|
});
|
|
1854
1933
|
}
|