@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
|
@@ -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/ExportUtility.ts
|
|
63
133
|
function createExportableElement(element) {
|
|
@@ -1703,8 +1773,8 @@ var _GameStepManager = class _GameStepManager {
|
|
|
1703
1773
|
static runCurrentStep(props, choiseMade) {
|
|
1704
1774
|
return __async(this, null, function* () {
|
|
1705
1775
|
if (_GameStepManager.currentLabelId) {
|
|
1706
|
-
let
|
|
1707
|
-
if (
|
|
1776
|
+
let lastStepsLength = _GameStepManager.currentLabelStepIndex;
|
|
1777
|
+
if (lastStepsLength === null) {
|
|
1708
1778
|
console.error("[Pixi'VN] currentLabelStepIndex is null");
|
|
1709
1779
|
return;
|
|
1710
1780
|
}
|
|
@@ -1714,12 +1784,12 @@ var _GameStepManager = class _GameStepManager {
|
|
|
1714
1784
|
return;
|
|
1715
1785
|
}
|
|
1716
1786
|
let n = currentLabel.steps.length;
|
|
1717
|
-
if (n >
|
|
1718
|
-
let
|
|
1719
|
-
let result = yield
|
|
1720
|
-
_GameStepManager.addStepHistory(
|
|
1787
|
+
if (n > lastStepsLength) {
|
|
1788
|
+
let step = currentLabel.steps[lastStepsLength];
|
|
1789
|
+
let result = yield step(props);
|
|
1790
|
+
_GameStepManager.addStepHistory(step, choiseMade);
|
|
1721
1791
|
return result;
|
|
1722
|
-
} else if (n ===
|
|
1792
|
+
} else if (n === lastStepsLength) {
|
|
1723
1793
|
_GameStepManager.closeCurrentLabel();
|
|
1724
1794
|
return yield _GameStepManager.runNextStep(props);
|
|
1725
1795
|
} else {
|
|
@@ -1764,7 +1834,8 @@ var _GameStepManager = class _GameStepManager {
|
|
|
1764
1834
|
}
|
|
1765
1835
|
try {
|
|
1766
1836
|
if (labelId === CLOSE_LABEL_ID) {
|
|
1767
|
-
|
|
1837
|
+
let closeLabel = newCloseLabel(choiseMade);
|
|
1838
|
+
return _GameStepManager.closeChoiceMenu(closeLabel, props);
|
|
1768
1839
|
}
|
|
1769
1840
|
let tempLabel = getLabelById(labelId);
|
|
1770
1841
|
if (!tempLabel) {
|
|
@@ -1803,18 +1874,20 @@ var _GameStepManager = class _GameStepManager {
|
|
|
1803
1874
|
static jumpLabel(label, props) {
|
|
1804
1875
|
return __async(this, null, function* () {
|
|
1805
1876
|
_GameStepManager.closeAllLabels();
|
|
1877
|
+
let choiseMade = void 0;
|
|
1806
1878
|
let labelId;
|
|
1807
1879
|
if (typeof label === "string") {
|
|
1808
1880
|
labelId = label;
|
|
1809
1881
|
} else {
|
|
1810
1882
|
labelId = label.id;
|
|
1811
1883
|
if (typeof label.choiseIndex === "number") {
|
|
1812
|
-
label.choiseIndex;
|
|
1884
|
+
choiseMade = label.choiseIndex;
|
|
1813
1885
|
}
|
|
1814
1886
|
}
|
|
1815
1887
|
try {
|
|
1816
1888
|
if (labelId === CLOSE_LABEL_ID) {
|
|
1817
|
-
|
|
1889
|
+
let closeLabel = newCloseLabel(choiseMade);
|
|
1890
|
+
return _GameStepManager.closeChoiceMenu(closeLabel, props);
|
|
1818
1891
|
}
|
|
1819
1892
|
let tempLabel = getLabelById(labelId);
|
|
1820
1893
|
if (!tempLabel) {
|
|
@@ -1825,7 +1898,7 @@ var _GameStepManager = class _GameStepManager {
|
|
|
1825
1898
|
console.error("[Pixi'VN] Error jumping label", e);
|
|
1826
1899
|
return;
|
|
1827
1900
|
}
|
|
1828
|
-
return yield _GameStepManager.runCurrentStep(props);
|
|
1901
|
+
return yield _GameStepManager.runCurrentStep(props, choiseMade);
|
|
1829
1902
|
});
|
|
1830
1903
|
}
|
|
1831
1904
|
/**
|
|
@@ -1841,8 +1914,14 @@ var _GameStepManager = class _GameStepManager {
|
|
|
1841
1914
|
* })
|
|
1842
1915
|
* ```
|
|
1843
1916
|
*/
|
|
1844
|
-
static closeChoiceMenu(props) {
|
|
1917
|
+
static closeChoiceMenu(label, props) {
|
|
1845
1918
|
return __async(this, null, function* () {
|
|
1919
|
+
let choiseMade = void 0;
|
|
1920
|
+
if (typeof label.choiseIndex === "number") {
|
|
1921
|
+
choiseMade = label.choiseIndex;
|
|
1922
|
+
}
|
|
1923
|
+
_GameStepManager.addStepHistory(() => {
|
|
1924
|
+
}, choiseMade);
|
|
1846
1925
|
return _GameStepManager.runNextStep(props);
|
|
1847
1926
|
});
|
|
1848
1927
|
}
|