@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
|
@@ -53,14 +53,84 @@ var __async = (__this, __arguments, generator) => {
|
|
|
53
53
|
};
|
|
54
54
|
|
|
55
55
|
// src/constants.ts
|
|
56
|
-
var PIXIVN_VERSION = "0.5.
|
|
56
|
+
var PIXIVN_VERSION = "0.5.9";
|
|
57
57
|
function getStepSha1(step) {
|
|
58
58
|
let sha1String = sha1(step.toString().toLocaleLowerCase());
|
|
59
59
|
return sha1String.toString();
|
|
60
60
|
}
|
|
61
|
+
function checkIfStepsIsEqual(step1, step2) {
|
|
62
|
+
return step1 === step2;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
// src/classes/Label.ts
|
|
66
|
+
var Label = class {
|
|
67
|
+
/**
|
|
68
|
+
* @param id is the id of the label
|
|
69
|
+
* @param steps is the list of steps that the label will perform
|
|
70
|
+
* @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
|
|
71
|
+
* @param choiseIndex is the index of the choice that the label will perform
|
|
72
|
+
*/
|
|
73
|
+
constructor(id, steps, onStepRun, choiseIndex) {
|
|
74
|
+
this._id = id;
|
|
75
|
+
this._steps = steps;
|
|
76
|
+
this._onStepRun = onStepRun;
|
|
77
|
+
this._choiseIndex = choiseIndex;
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Get the id of the label
|
|
81
|
+
*/
|
|
82
|
+
get id() {
|
|
83
|
+
return this._id;
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Get the steps of the label.
|
|
87
|
+
* This class should be extended and the steps method should be overridden.
|
|
88
|
+
* Every time you update this list will also be updated when the other game versions load.
|
|
89
|
+
*/
|
|
90
|
+
get steps() {
|
|
91
|
+
return this._steps;
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Get the corresponding steps number
|
|
95
|
+
* @param externalSteps
|
|
96
|
+
* @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
|
|
97
|
+
*/
|
|
98
|
+
getCorrespondingStepsNumber(externalSteps) {
|
|
99
|
+
if (externalSteps.length === 0) {
|
|
100
|
+
return 0;
|
|
101
|
+
}
|
|
102
|
+
let res = 0;
|
|
103
|
+
externalSteps.forEach((step, index) => {
|
|
104
|
+
if (checkIfStepsIsEqual(step, this.steps[index])) {
|
|
105
|
+
res = index;
|
|
106
|
+
}
|
|
107
|
+
});
|
|
108
|
+
return res;
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* 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
|
|
112
|
+
* @returns Promise<void> or void
|
|
113
|
+
* @example
|
|
114
|
+
* ```typescript
|
|
115
|
+
* newLabel("id", [], () => {
|
|
116
|
+
* Assets.load('path/to/image1.png')
|
|
117
|
+
* Assets.load('path/to/image2.png')
|
|
118
|
+
* })
|
|
119
|
+
* ```
|
|
120
|
+
*/
|
|
121
|
+
get onStepRun() {
|
|
122
|
+
return this._onStepRun;
|
|
123
|
+
}
|
|
124
|
+
get choiseIndex() {
|
|
125
|
+
return this._choiseIndex;
|
|
126
|
+
}
|
|
127
|
+
};
|
|
61
128
|
|
|
62
129
|
// src/classes/CloseLabel.ts
|
|
63
130
|
var CLOSE_LABEL_ID = "__close-label-id__";
|
|
131
|
+
function newCloseLabel(choiseIndex) {
|
|
132
|
+
return new Label(CLOSE_LABEL_ID, [], void 0, choiseIndex);
|
|
133
|
+
}
|
|
64
134
|
|
|
65
135
|
// src/functions/CanvasUtility.ts
|
|
66
136
|
function getTextureMemory(texture) {
|
|
@@ -1708,8 +1778,8 @@ var _GameStepManager = class _GameStepManager {
|
|
|
1708
1778
|
static runCurrentStep(props, choiseMade) {
|
|
1709
1779
|
return __async(this, null, function* () {
|
|
1710
1780
|
if (_GameStepManager.currentLabelId) {
|
|
1711
|
-
let
|
|
1712
|
-
if (
|
|
1781
|
+
let lastStepsLength = _GameStepManager.currentLabelStepIndex;
|
|
1782
|
+
if (lastStepsLength === null) {
|
|
1713
1783
|
console.error("[Pixi'VN] currentLabelStepIndex is null");
|
|
1714
1784
|
return;
|
|
1715
1785
|
}
|
|
@@ -1719,12 +1789,12 @@ var _GameStepManager = class _GameStepManager {
|
|
|
1719
1789
|
return;
|
|
1720
1790
|
}
|
|
1721
1791
|
let n = currentLabel.steps.length;
|
|
1722
|
-
if (n >
|
|
1723
|
-
let
|
|
1724
|
-
let result = yield
|
|
1725
|
-
_GameStepManager.addStepHistory(
|
|
1792
|
+
if (n > lastStepsLength) {
|
|
1793
|
+
let step = currentLabel.steps[lastStepsLength];
|
|
1794
|
+
let result = yield step(props);
|
|
1795
|
+
_GameStepManager.addStepHistory(step, choiseMade);
|
|
1726
1796
|
return result;
|
|
1727
|
-
} else if (n ===
|
|
1797
|
+
} else if (n === lastStepsLength) {
|
|
1728
1798
|
_GameStepManager.closeCurrentLabel();
|
|
1729
1799
|
return yield _GameStepManager.runNextStep(props);
|
|
1730
1800
|
} else {
|
|
@@ -1769,7 +1839,8 @@ var _GameStepManager = class _GameStepManager {
|
|
|
1769
1839
|
}
|
|
1770
1840
|
try {
|
|
1771
1841
|
if (labelId === CLOSE_LABEL_ID) {
|
|
1772
|
-
|
|
1842
|
+
let closeLabel = newCloseLabel(choiseMade);
|
|
1843
|
+
return _GameStepManager.closeChoiceMenu(closeLabel, props);
|
|
1773
1844
|
}
|
|
1774
1845
|
let tempLabel = getLabelById(labelId);
|
|
1775
1846
|
if (!tempLabel) {
|
|
@@ -1808,18 +1879,20 @@ var _GameStepManager = class _GameStepManager {
|
|
|
1808
1879
|
static jumpLabel(label, props) {
|
|
1809
1880
|
return __async(this, null, function* () {
|
|
1810
1881
|
_GameStepManager.closeAllLabels();
|
|
1882
|
+
let choiseMade = void 0;
|
|
1811
1883
|
let labelId;
|
|
1812
1884
|
if (typeof label === "string") {
|
|
1813
1885
|
labelId = label;
|
|
1814
1886
|
} else {
|
|
1815
1887
|
labelId = label.id;
|
|
1816
1888
|
if (typeof label.choiseIndex === "number") {
|
|
1817
|
-
label.choiseIndex;
|
|
1889
|
+
choiseMade = label.choiseIndex;
|
|
1818
1890
|
}
|
|
1819
1891
|
}
|
|
1820
1892
|
try {
|
|
1821
1893
|
if (labelId === CLOSE_LABEL_ID) {
|
|
1822
|
-
|
|
1894
|
+
let closeLabel = newCloseLabel(choiseMade);
|
|
1895
|
+
return _GameStepManager.closeChoiceMenu(closeLabel, props);
|
|
1823
1896
|
}
|
|
1824
1897
|
let tempLabel = getLabelById(labelId);
|
|
1825
1898
|
if (!tempLabel) {
|
|
@@ -1830,7 +1903,7 @@ var _GameStepManager = class _GameStepManager {
|
|
|
1830
1903
|
console.error("[Pixi'VN] Error jumping label", e);
|
|
1831
1904
|
return;
|
|
1832
1905
|
}
|
|
1833
|
-
return yield _GameStepManager.runCurrentStep(props);
|
|
1906
|
+
return yield _GameStepManager.runCurrentStep(props, choiseMade);
|
|
1834
1907
|
});
|
|
1835
1908
|
}
|
|
1836
1909
|
/**
|
|
@@ -1846,8 +1919,14 @@ var _GameStepManager = class _GameStepManager {
|
|
|
1846
1919
|
* })
|
|
1847
1920
|
* ```
|
|
1848
1921
|
*/
|
|
1849
|
-
static closeChoiceMenu(props) {
|
|
1922
|
+
static closeChoiceMenu(label, props) {
|
|
1850
1923
|
return __async(this, null, function* () {
|
|
1924
|
+
let choiseMade = void 0;
|
|
1925
|
+
if (typeof label.choiseIndex === "number") {
|
|
1926
|
+
choiseMade = label.choiseIndex;
|
|
1927
|
+
}
|
|
1928
|
+
_GameStepManager.addStepHistory(() => {
|
|
1929
|
+
}, choiseMade);
|
|
1851
1930
|
return _GameStepManager.runNextStep(props);
|
|
1852
1931
|
});
|
|
1853
1932
|
}
|