@drincs/pixi-vn 0.5.8 → 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.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 +1 -1
package/dist/managers/index.mjs
CHANGED
|
@@ -55,9 +55,79 @@ function getStepSha1(step) {
|
|
|
55
55
|
let sha1String = sha1(step.toString().toLocaleLowerCase());
|
|
56
56
|
return sha1String.toString();
|
|
57
57
|
}
|
|
58
|
+
function checkIfStepsIsEqual(step1, step2) {
|
|
59
|
+
return step1 === step2;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
// src/classes/Label.ts
|
|
63
|
+
var Label = class {
|
|
64
|
+
/**
|
|
65
|
+
* @param id is the id of the label
|
|
66
|
+
* @param steps is the list of steps that the label will perform
|
|
67
|
+
* @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
|
|
68
|
+
* @param choiseIndex is the index of the choice that the label will perform
|
|
69
|
+
*/
|
|
70
|
+
constructor(id, steps, onStepRun, choiseIndex) {
|
|
71
|
+
this._id = id;
|
|
72
|
+
this._steps = steps;
|
|
73
|
+
this._onStepRun = onStepRun;
|
|
74
|
+
this._choiseIndex = choiseIndex;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Get the id of the label
|
|
78
|
+
*/
|
|
79
|
+
get id() {
|
|
80
|
+
return this._id;
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Get the steps of the label.
|
|
84
|
+
* This class should be extended and the steps method should be overridden.
|
|
85
|
+
* Every time you update this list will also be updated when the other game versions load.
|
|
86
|
+
*/
|
|
87
|
+
get steps() {
|
|
88
|
+
return this._steps;
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Get the corresponding steps number
|
|
92
|
+
* @param externalSteps
|
|
93
|
+
* @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
|
|
94
|
+
*/
|
|
95
|
+
getCorrespondingStepsNumber(externalSteps) {
|
|
96
|
+
if (externalSteps.length === 0) {
|
|
97
|
+
return 0;
|
|
98
|
+
}
|
|
99
|
+
let res = 0;
|
|
100
|
+
externalSteps.forEach((step, index) => {
|
|
101
|
+
if (checkIfStepsIsEqual(step, this.steps[index])) {
|
|
102
|
+
res = index;
|
|
103
|
+
}
|
|
104
|
+
});
|
|
105
|
+
return res;
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* 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
|
|
109
|
+
* @returns Promise<void> or void
|
|
110
|
+
* @example
|
|
111
|
+
* ```typescript
|
|
112
|
+
* newLabel("id", [], () => {
|
|
113
|
+
* Assets.load('path/to/image1.png')
|
|
114
|
+
* Assets.load('path/to/image2.png')
|
|
115
|
+
* })
|
|
116
|
+
* ```
|
|
117
|
+
*/
|
|
118
|
+
get onStepRun() {
|
|
119
|
+
return this._onStepRun;
|
|
120
|
+
}
|
|
121
|
+
get choiseIndex() {
|
|
122
|
+
return this._choiseIndex;
|
|
123
|
+
}
|
|
124
|
+
};
|
|
58
125
|
|
|
59
126
|
// src/classes/CloseLabel.ts
|
|
60
127
|
var CLOSE_LABEL_ID = "__close-label-id__";
|
|
128
|
+
function newCloseLabel(choiseIndex) {
|
|
129
|
+
return new Label(CLOSE_LABEL_ID, [], void 0, choiseIndex);
|
|
130
|
+
}
|
|
61
131
|
|
|
62
132
|
// src/functions/CanvasUtility.ts
|
|
63
133
|
function getTextureMemory(texture) {
|
|
@@ -1705,8 +1775,8 @@ var _GameStepManager = class _GameStepManager {
|
|
|
1705
1775
|
static runCurrentStep(props, choiseMade) {
|
|
1706
1776
|
return __async(this, null, function* () {
|
|
1707
1777
|
if (_GameStepManager.currentLabelId) {
|
|
1708
|
-
let
|
|
1709
|
-
if (
|
|
1778
|
+
let lastStepsLength = _GameStepManager.currentLabelStepIndex;
|
|
1779
|
+
if (lastStepsLength === null) {
|
|
1710
1780
|
console.error("[Pixi'VN] currentLabelStepIndex is null");
|
|
1711
1781
|
return;
|
|
1712
1782
|
}
|
|
@@ -1716,12 +1786,12 @@ var _GameStepManager = class _GameStepManager {
|
|
|
1716
1786
|
return;
|
|
1717
1787
|
}
|
|
1718
1788
|
let n = currentLabel.steps.length;
|
|
1719
|
-
if (n >
|
|
1720
|
-
let
|
|
1721
|
-
let result = yield
|
|
1722
|
-
_GameStepManager.addStepHistory(
|
|
1789
|
+
if (n > lastStepsLength) {
|
|
1790
|
+
let step = currentLabel.steps[lastStepsLength];
|
|
1791
|
+
let result = yield step(props);
|
|
1792
|
+
_GameStepManager.addStepHistory(step, choiseMade);
|
|
1723
1793
|
return result;
|
|
1724
|
-
} else if (n ===
|
|
1794
|
+
} else if (n === lastStepsLength) {
|
|
1725
1795
|
_GameStepManager.closeCurrentLabel();
|
|
1726
1796
|
return yield _GameStepManager.runNextStep(props);
|
|
1727
1797
|
} else {
|
|
@@ -1766,7 +1836,8 @@ var _GameStepManager = class _GameStepManager {
|
|
|
1766
1836
|
}
|
|
1767
1837
|
try {
|
|
1768
1838
|
if (labelId === CLOSE_LABEL_ID) {
|
|
1769
|
-
|
|
1839
|
+
let closeLabel = newCloseLabel(choiseMade);
|
|
1840
|
+
return _GameStepManager.closeChoiceMenu(closeLabel, props);
|
|
1770
1841
|
}
|
|
1771
1842
|
let tempLabel = getLabelById(labelId);
|
|
1772
1843
|
if (!tempLabel) {
|
|
@@ -1805,18 +1876,20 @@ var _GameStepManager = class _GameStepManager {
|
|
|
1805
1876
|
static jumpLabel(label, props) {
|
|
1806
1877
|
return __async(this, null, function* () {
|
|
1807
1878
|
_GameStepManager.closeAllLabels();
|
|
1879
|
+
let choiseMade = void 0;
|
|
1808
1880
|
let labelId;
|
|
1809
1881
|
if (typeof label === "string") {
|
|
1810
1882
|
labelId = label;
|
|
1811
1883
|
} else {
|
|
1812
1884
|
labelId = label.id;
|
|
1813
1885
|
if (typeof label.choiseIndex === "number") {
|
|
1814
|
-
label.choiseIndex;
|
|
1886
|
+
choiseMade = label.choiseIndex;
|
|
1815
1887
|
}
|
|
1816
1888
|
}
|
|
1817
1889
|
try {
|
|
1818
1890
|
if (labelId === CLOSE_LABEL_ID) {
|
|
1819
|
-
|
|
1891
|
+
let closeLabel = newCloseLabel(choiseMade);
|
|
1892
|
+
return _GameStepManager.closeChoiceMenu(closeLabel, props);
|
|
1820
1893
|
}
|
|
1821
1894
|
let tempLabel = getLabelById(labelId);
|
|
1822
1895
|
if (!tempLabel) {
|
|
@@ -1827,7 +1900,7 @@ var _GameStepManager = class _GameStepManager {
|
|
|
1827
1900
|
console.error("[Pixi'VN] Error jumping label", e);
|
|
1828
1901
|
return;
|
|
1829
1902
|
}
|
|
1830
|
-
return yield _GameStepManager.runCurrentStep(props);
|
|
1903
|
+
return yield _GameStepManager.runCurrentStep(props, choiseMade);
|
|
1831
1904
|
});
|
|
1832
1905
|
}
|
|
1833
1906
|
/**
|
|
@@ -1843,8 +1916,14 @@ var _GameStepManager = class _GameStepManager {
|
|
|
1843
1916
|
* })
|
|
1844
1917
|
* ```
|
|
1845
1918
|
*/
|
|
1846
|
-
static closeChoiceMenu(props) {
|
|
1919
|
+
static closeChoiceMenu(label, props) {
|
|
1847
1920
|
return __async(this, null, function* () {
|
|
1921
|
+
let choiseMade = void 0;
|
|
1922
|
+
if (typeof label.choiseIndex === "number") {
|
|
1923
|
+
choiseMade = label.choiseIndex;
|
|
1924
|
+
}
|
|
1925
|
+
_GameStepManager.addStepHistory(() => {
|
|
1926
|
+
}, choiseMade);
|
|
1848
1927
|
return _GameStepManager.runNextStep(props);
|
|
1849
1928
|
});
|
|
1850
1929
|
}
|