@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
|
@@ -59,14 +59,84 @@ var __async = (__this, __arguments, generator) => {
|
|
|
59
59
|
};
|
|
60
60
|
|
|
61
61
|
// src/constants.ts
|
|
62
|
-
var PIXIVN_VERSION = "0.5.
|
|
62
|
+
var PIXIVN_VERSION = "0.5.9";
|
|
63
63
|
function getStepSha1(step) {
|
|
64
64
|
let sha1String = sha1__default.default(step.toString().toLocaleLowerCase());
|
|
65
65
|
return sha1String.toString();
|
|
66
66
|
}
|
|
67
|
+
function checkIfStepsIsEqual(step1, step2) {
|
|
68
|
+
return step1 === step2;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
// src/classes/Label.ts
|
|
72
|
+
var Label = class {
|
|
73
|
+
/**
|
|
74
|
+
* @param id is the id of the label
|
|
75
|
+
* @param steps is the list of steps that the label will perform
|
|
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
|
|
78
|
+
*/
|
|
79
|
+
constructor(id, steps, onStepRun, choiseIndex) {
|
|
80
|
+
this._id = id;
|
|
81
|
+
this._steps = steps;
|
|
82
|
+
this._onStepRun = onStepRun;
|
|
83
|
+
this._choiseIndex = choiseIndex;
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Get the id of the label
|
|
87
|
+
*/
|
|
88
|
+
get id() {
|
|
89
|
+
return this._id;
|
|
90
|
+
}
|
|
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
|
+
return this._steps;
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Get the corresponding steps number
|
|
101
|
+
* @param externalSteps
|
|
102
|
+
* @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
|
|
103
|
+
*/
|
|
104
|
+
getCorrespondingStepsNumber(externalSteps) {
|
|
105
|
+
if (externalSteps.length === 0) {
|
|
106
|
+
return 0;
|
|
107
|
+
}
|
|
108
|
+
let res = 0;
|
|
109
|
+
externalSteps.forEach((step, index) => {
|
|
110
|
+
if (checkIfStepsIsEqual(step, this.steps[index])) {
|
|
111
|
+
res = index;
|
|
112
|
+
}
|
|
113
|
+
});
|
|
114
|
+
return res;
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* 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
|
|
118
|
+
* @returns Promise<void> or void
|
|
119
|
+
* @example
|
|
120
|
+
* ```typescript
|
|
121
|
+
* newLabel("id", [], () => {
|
|
122
|
+
* Assets.load('path/to/image1.png')
|
|
123
|
+
* Assets.load('path/to/image2.png')
|
|
124
|
+
* })
|
|
125
|
+
* ```
|
|
126
|
+
*/
|
|
127
|
+
get onStepRun() {
|
|
128
|
+
return this._onStepRun;
|
|
129
|
+
}
|
|
130
|
+
get choiseIndex() {
|
|
131
|
+
return this._choiseIndex;
|
|
132
|
+
}
|
|
133
|
+
};
|
|
67
134
|
|
|
68
135
|
// src/classes/CloseLabel.ts
|
|
69
136
|
var CLOSE_LABEL_ID = "__close-label-id__";
|
|
137
|
+
function newCloseLabel(choiseIndex) {
|
|
138
|
+
return new Label(CLOSE_LABEL_ID, [], void 0, choiseIndex);
|
|
139
|
+
}
|
|
70
140
|
|
|
71
141
|
// src/functions/CanvasUtility.ts
|
|
72
142
|
function getTextureMemory(texture) {
|
|
@@ -1714,8 +1784,8 @@ var _GameStepManager = class _GameStepManager {
|
|
|
1714
1784
|
static runCurrentStep(props, choiseMade) {
|
|
1715
1785
|
return __async(this, null, function* () {
|
|
1716
1786
|
if (_GameStepManager.currentLabelId) {
|
|
1717
|
-
let
|
|
1718
|
-
if (
|
|
1787
|
+
let lastStepsLength = _GameStepManager.currentLabelStepIndex;
|
|
1788
|
+
if (lastStepsLength === null) {
|
|
1719
1789
|
console.error("[Pixi'VN] currentLabelStepIndex is null");
|
|
1720
1790
|
return;
|
|
1721
1791
|
}
|
|
@@ -1725,12 +1795,12 @@ var _GameStepManager = class _GameStepManager {
|
|
|
1725
1795
|
return;
|
|
1726
1796
|
}
|
|
1727
1797
|
let n = currentLabel.steps.length;
|
|
1728
|
-
if (n >
|
|
1729
|
-
let
|
|
1730
|
-
let result = yield
|
|
1731
|
-
_GameStepManager.addStepHistory(
|
|
1798
|
+
if (n > lastStepsLength) {
|
|
1799
|
+
let step = currentLabel.steps[lastStepsLength];
|
|
1800
|
+
let result = yield step(props);
|
|
1801
|
+
_GameStepManager.addStepHistory(step, choiseMade);
|
|
1732
1802
|
return result;
|
|
1733
|
-
} else if (n ===
|
|
1803
|
+
} else if (n === lastStepsLength) {
|
|
1734
1804
|
_GameStepManager.closeCurrentLabel();
|
|
1735
1805
|
return yield _GameStepManager.runNextStep(props);
|
|
1736
1806
|
} else {
|
|
@@ -1775,7 +1845,8 @@ var _GameStepManager = class _GameStepManager {
|
|
|
1775
1845
|
}
|
|
1776
1846
|
try {
|
|
1777
1847
|
if (labelId === CLOSE_LABEL_ID) {
|
|
1778
|
-
|
|
1848
|
+
let closeLabel = newCloseLabel(choiseMade);
|
|
1849
|
+
return _GameStepManager.closeChoiceMenu(closeLabel, props);
|
|
1779
1850
|
}
|
|
1780
1851
|
let tempLabel = getLabelById(labelId);
|
|
1781
1852
|
if (!tempLabel) {
|
|
@@ -1814,18 +1885,20 @@ var _GameStepManager = class _GameStepManager {
|
|
|
1814
1885
|
static jumpLabel(label, props) {
|
|
1815
1886
|
return __async(this, null, function* () {
|
|
1816
1887
|
_GameStepManager.closeAllLabels();
|
|
1888
|
+
let choiseMade = void 0;
|
|
1817
1889
|
let labelId;
|
|
1818
1890
|
if (typeof label === "string") {
|
|
1819
1891
|
labelId = label;
|
|
1820
1892
|
} else {
|
|
1821
1893
|
labelId = label.id;
|
|
1822
1894
|
if (typeof label.choiseIndex === "number") {
|
|
1823
|
-
label.choiseIndex;
|
|
1895
|
+
choiseMade = label.choiseIndex;
|
|
1824
1896
|
}
|
|
1825
1897
|
}
|
|
1826
1898
|
try {
|
|
1827
1899
|
if (labelId === CLOSE_LABEL_ID) {
|
|
1828
|
-
|
|
1900
|
+
let closeLabel = newCloseLabel(choiseMade);
|
|
1901
|
+
return _GameStepManager.closeChoiceMenu(closeLabel, props);
|
|
1829
1902
|
}
|
|
1830
1903
|
let tempLabel = getLabelById(labelId);
|
|
1831
1904
|
if (!tempLabel) {
|
|
@@ -1836,7 +1909,7 @@ var _GameStepManager = class _GameStepManager {
|
|
|
1836
1909
|
console.error("[Pixi'VN] Error jumping label", e);
|
|
1837
1910
|
return;
|
|
1838
1911
|
}
|
|
1839
|
-
return yield _GameStepManager.runCurrentStep(props);
|
|
1912
|
+
return yield _GameStepManager.runCurrentStep(props, choiseMade);
|
|
1840
1913
|
});
|
|
1841
1914
|
}
|
|
1842
1915
|
/**
|
|
@@ -1852,8 +1925,14 @@ var _GameStepManager = class _GameStepManager {
|
|
|
1852
1925
|
* })
|
|
1853
1926
|
* ```
|
|
1854
1927
|
*/
|
|
1855
|
-
static closeChoiceMenu(props) {
|
|
1928
|
+
static closeChoiceMenu(label, props) {
|
|
1856
1929
|
return __async(this, null, function* () {
|
|
1930
|
+
let choiseMade = void 0;
|
|
1931
|
+
if (typeof label.choiseIndex === "number") {
|
|
1932
|
+
choiseMade = label.choiseIndex;
|
|
1933
|
+
}
|
|
1934
|
+
_GameStepManager.addStepHistory(() => {
|
|
1935
|
+
}, choiseMade);
|
|
1857
1936
|
return _GameStepManager.runNextStep(props);
|
|
1858
1937
|
});
|
|
1859
1938
|
}
|