@drincs/pixi-vn 0.1.5 → 0.2.1
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/index.d.mts +50 -13
- package/dist/index.d.ts +50 -13
- package/dist/index.js +119 -30
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +117 -30
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -181,6 +181,26 @@ function getDialogueHistory() {
|
|
|
181
181
|
return list;
|
|
182
182
|
}
|
|
183
183
|
|
|
184
|
+
// src/functions/FlagsUtility.ts
|
|
185
|
+
function setFlag(name, value) {
|
|
186
|
+
let flags = GameStorageManager.getVariable(GameStorageManager.keysSystem.FLAGS_CATEGORY_KEY) || [];
|
|
187
|
+
if (value) {
|
|
188
|
+
if (!flags.includes(name)) {
|
|
189
|
+
flags.push(name);
|
|
190
|
+
}
|
|
191
|
+
} else {
|
|
192
|
+
let index = flags.indexOf(name);
|
|
193
|
+
if (index > -1) {
|
|
194
|
+
flags.splice(index, 1);
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
GameStorageManager.setVariable(GameStorageManager.keysSystem.FLAGS_CATEGORY_KEY, flags);
|
|
198
|
+
}
|
|
199
|
+
function getFlag(name) {
|
|
200
|
+
let flags = GameStorageManager.getVariable(GameStorageManager.keysSystem.FLAGS_CATEGORY_KEY) || [];
|
|
201
|
+
return flags.includes(name);
|
|
202
|
+
}
|
|
203
|
+
|
|
184
204
|
// src/functions/GameUtility.ts
|
|
185
205
|
function clearAllGameDatas() {
|
|
186
206
|
GameStorageManager.clear();
|
|
@@ -1053,7 +1073,8 @@ var _GameStorageManager = class _GameStorageManager {
|
|
|
1053
1073
|
LAST_DIALOGUE_ADDED_IN_STEP_MEMORY_KEY: "___last_dialogue_added_in_step_memory_key___",
|
|
1054
1074
|
CURRENT_MENU_OPTIONS_MEMORY_KEY: "___current_menu_options_memory_key___",
|
|
1055
1075
|
LAST_MENU_OPTIONS_ADDED_IN_STEP_MEMORY_KEY: "___last_menu_options_added_in_step_memory_key___",
|
|
1056
|
-
|
|
1076
|
+
CHARACTER_CATEGORY_KEY: "___character___",
|
|
1077
|
+
FLAGS_CATEGORY_KEY: "___flags___"
|
|
1057
1078
|
};
|
|
1058
1079
|
}
|
|
1059
1080
|
/**
|
|
@@ -1064,7 +1085,7 @@ var _GameStorageManager = class _GameStorageManager {
|
|
|
1064
1085
|
*/
|
|
1065
1086
|
static setVariable(key, value) {
|
|
1066
1087
|
key = key.toLowerCase();
|
|
1067
|
-
if (value === void 0) {
|
|
1088
|
+
if (value === void 0 || value === null) {
|
|
1068
1089
|
if (_GameStorageManager.storage.hasOwnProperty(key)) {
|
|
1069
1090
|
delete _GameStorageManager.storage[key];
|
|
1070
1091
|
}
|
|
@@ -1130,6 +1151,17 @@ var GameStorageManager = _GameStorageManager;
|
|
|
1130
1151
|
// src/managers/WindowManager.ts
|
|
1131
1152
|
import { Application } from "pixi.js";
|
|
1132
1153
|
|
|
1154
|
+
// src/functions/EasterEgg.ts
|
|
1155
|
+
function asciiArtLog() {
|
|
1156
|
+
console.log(`
|
|
1157
|
+
____ _ _ ___ ___ _
|
|
1158
|
+
| _ \\(_)_ _(_| ) \\ / / \\ | |
|
|
1159
|
+
| |_) | \\ \\/ / |/ \\ \\ / /| \\| |
|
|
1160
|
+
| __/| |> <| | \\ V / | |\\ |
|
|
1161
|
+
|_| |_/_/\\_\\_| \\_/ |_| \\_|
|
|
1162
|
+
`);
|
|
1163
|
+
}
|
|
1164
|
+
|
|
1133
1165
|
// src/types/PauseType.ts
|
|
1134
1166
|
var PauseValueType = "Pause";
|
|
1135
1167
|
function Pause(duration) {
|
|
@@ -1198,6 +1230,7 @@ var _GameWindowManager = class _GameWindowManager {
|
|
|
1198
1230
|
this.addCanvasIntoElement(element);
|
|
1199
1231
|
window.addEventListener("resize", _GameWindowManager.resize);
|
|
1200
1232
|
_GameWindowManager.resize();
|
|
1233
|
+
asciiArtLog();
|
|
1201
1234
|
});
|
|
1202
1235
|
});
|
|
1203
1236
|
}
|
|
@@ -1730,9 +1763,9 @@ var _GameStepManager = class _GameStepManager {
|
|
|
1730
1763
|
return _GameStepManager._openedLabels;
|
|
1731
1764
|
}
|
|
1732
1765
|
/**
|
|
1733
|
-
*
|
|
1766
|
+
* currentLabelId is the current label id that occurred during the progression of the steps.
|
|
1734
1767
|
*/
|
|
1735
|
-
static get
|
|
1768
|
+
static get currentLabelId() {
|
|
1736
1769
|
if (_GameStepManager._openedLabels.length > 0) {
|
|
1737
1770
|
let item = _GameStepManager._openedLabels[_GameStepManager._openedLabels.length - 1];
|
|
1738
1771
|
return item.label;
|
|
@@ -1740,8 +1773,13 @@ var _GameStepManager = class _GameStepManager {
|
|
|
1740
1773
|
return void 0;
|
|
1741
1774
|
}
|
|
1742
1775
|
/**
|
|
1743
|
-
* is the current
|
|
1776
|
+
* currentLabel is the current label that occurred during the progression of the steps.
|
|
1744
1777
|
*/
|
|
1778
|
+
static get currentLabel() {
|
|
1779
|
+
if (_GameStepManager.currentLabelId) {
|
|
1780
|
+
return getLabelInstanceByClassName(_GameStepManager.currentLabelId);
|
|
1781
|
+
}
|
|
1782
|
+
}
|
|
1745
1783
|
static get currentLabelStepIndex() {
|
|
1746
1784
|
if (_GameStepManager._openedLabels.length > 0) {
|
|
1747
1785
|
let item = _GameStepManager._openedLabels[_GameStepManager._openedLabels.length - 1];
|
|
@@ -1749,6 +1787,27 @@ var _GameStepManager = class _GameStepManager {
|
|
|
1749
1787
|
}
|
|
1750
1788
|
return null;
|
|
1751
1789
|
}
|
|
1790
|
+
/**
|
|
1791
|
+
* currentLabelStep is the current step that occurred during the progression of the steps. It can used to determine the game end.
|
|
1792
|
+
*/
|
|
1793
|
+
static get isLastGameStep() {
|
|
1794
|
+
var _a;
|
|
1795
|
+
let stepLabel = (_a = _GameStepManager.currentLabel) == null ? void 0 : _a.steps;
|
|
1796
|
+
if (stepLabel && _GameStepManager.currentLabelStepIndex === stepLabel.length) {
|
|
1797
|
+
if (this.openedLabels.length <= 1) {
|
|
1798
|
+
return true;
|
|
1799
|
+
} else {
|
|
1800
|
+
this.openedLabels.forEach((item) => {
|
|
1801
|
+
let label = getLabelInstanceByClassName(item.label);
|
|
1802
|
+
if (label && label.steps.length > item.currentStepIndex) {
|
|
1803
|
+
return false;
|
|
1804
|
+
}
|
|
1805
|
+
});
|
|
1806
|
+
return true;
|
|
1807
|
+
}
|
|
1808
|
+
}
|
|
1809
|
+
return false;
|
|
1810
|
+
}
|
|
1752
1811
|
/**
|
|
1753
1812
|
* lastHistoryStep is the last history step that occurred during the progression of the steps.
|
|
1754
1813
|
*/
|
|
@@ -1816,7 +1875,7 @@ var _GameStepManager = class _GameStepManager {
|
|
|
1816
1875
|
}
|
|
1817
1876
|
_GameStepManager._stepsHistory.push({
|
|
1818
1877
|
diff: data,
|
|
1819
|
-
currentLabel: _GameStepManager.
|
|
1878
|
+
currentLabel: _GameStepManager.currentLabelId,
|
|
1820
1879
|
dialoge,
|
|
1821
1880
|
choices: requiredChoices,
|
|
1822
1881
|
stepSha1: stepHistory,
|
|
@@ -1845,12 +1904,11 @@ var _GameStepManager = class _GameStepManager {
|
|
|
1845
1904
|
* @returns
|
|
1846
1905
|
*/
|
|
1847
1906
|
static closeCurrentLabel() {
|
|
1848
|
-
if (!_GameStepManager.
|
|
1907
|
+
if (!_GameStepManager.currentLabelId) {
|
|
1849
1908
|
console.warn("[Pixi'VN] No label to close");
|
|
1850
1909
|
return;
|
|
1851
1910
|
}
|
|
1852
|
-
|
|
1853
|
-
if (!currentLabel) {
|
|
1911
|
+
if (!_GameStepManager.currentLabel) {
|
|
1854
1912
|
console.error("[Pixi'VN] Label not found");
|
|
1855
1913
|
return;
|
|
1856
1914
|
}
|
|
@@ -1909,13 +1967,13 @@ var _GameStepManager = class _GameStepManager {
|
|
|
1909
1967
|
*/
|
|
1910
1968
|
static runCurrentStep() {
|
|
1911
1969
|
return __async(this, null, function* () {
|
|
1912
|
-
if (_GameStepManager.
|
|
1970
|
+
if (_GameStepManager.currentLabelId) {
|
|
1913
1971
|
let lasteStepsLength = _GameStepManager.currentLabelStepIndex;
|
|
1914
1972
|
if (lasteStepsLength === null) {
|
|
1915
1973
|
console.error("[Pixi'VN] currentLabelStepIndex is null");
|
|
1916
1974
|
return;
|
|
1917
1975
|
}
|
|
1918
|
-
let currentLabel =
|
|
1976
|
+
let currentLabel = _GameStepManager.currentLabel;
|
|
1919
1977
|
if (!currentLabel) {
|
|
1920
1978
|
console.error("[Pixi'VN] Label not found");
|
|
1921
1979
|
return;
|
|
@@ -2179,27 +2237,54 @@ var GameStepManager = _GameStepManager;
|
|
|
2179
2237
|
|
|
2180
2238
|
// src/classes/StoredClassModel.ts
|
|
2181
2239
|
var StoredClassModel = class {
|
|
2182
|
-
|
|
2183
|
-
|
|
2240
|
+
/**
|
|
2241
|
+
* @param categoryId The id of the category. For example if you are storing a character class, you can use "characters" as categoryId. so all instances of the character class will be stored in the "characters" category.
|
|
2242
|
+
* @param id The id of instance of the class. This id must be unique for the category.
|
|
2243
|
+
*/
|
|
2244
|
+
constructor(categoryId, id) {
|
|
2245
|
+
this.categoryId = categoryId;
|
|
2246
|
+
this._id = id;
|
|
2184
2247
|
}
|
|
2185
|
-
|
|
2186
|
-
|
|
2248
|
+
/**
|
|
2249
|
+
* Is id of the stored class. is unique for this class.
|
|
2250
|
+
*/
|
|
2251
|
+
get id() {
|
|
2252
|
+
return this._id;
|
|
2187
2253
|
}
|
|
2188
|
-
|
|
2189
|
-
|
|
2254
|
+
/**
|
|
2255
|
+
* Update a property in the storage.
|
|
2256
|
+
* @param propertyName The name of the property to set.
|
|
2257
|
+
* @param value The value to set. If is undefined, the property will be removed from the storage.
|
|
2258
|
+
*/
|
|
2259
|
+
setStorageProperty(propertyName, value) {
|
|
2260
|
+
let storage = GameStorageManager.getVariable(this.categoryId);
|
|
2190
2261
|
if (!storage) {
|
|
2191
2262
|
storage = {};
|
|
2192
2263
|
}
|
|
2193
|
-
storage
|
|
2194
|
-
|
|
2195
|
-
|
|
2196
|
-
|
|
2197
|
-
|
|
2198
|
-
|
|
2199
|
-
|
|
2264
|
+
if (!storage.hasOwnProperty(this.id)) {
|
|
2265
|
+
storage[this.id] = {};
|
|
2266
|
+
}
|
|
2267
|
+
if (value === void 0 || value === null) {
|
|
2268
|
+
if (storage[this.id].hasOwnProperty(propertyName)) {
|
|
2269
|
+
delete storage[this.id][propertyName];
|
|
2270
|
+
}
|
|
2271
|
+
} else {
|
|
2272
|
+
storage[this.id] = __spreadProps(__spreadValues({}, storage[this.id]), { [propertyName]: value });
|
|
2273
|
+
}
|
|
2274
|
+
if (Object.keys(storage[this.id]).length === 0) {
|
|
2275
|
+
delete storage[this.id];
|
|
2200
2276
|
}
|
|
2201
|
-
|
|
2202
|
-
|
|
2277
|
+
GameStorageManager.setVariable(this.categoryId, storage);
|
|
2278
|
+
}
|
|
2279
|
+
/**
|
|
2280
|
+
* Get a property from the storage.
|
|
2281
|
+
* @param propertyName The name of the property to get.
|
|
2282
|
+
* @returns The value of the property. If the property is not found, returns undefined.
|
|
2283
|
+
*/
|
|
2284
|
+
getStorageProperty(propertyName) {
|
|
2285
|
+
let storage = GameStorageManager.getVariable(this.categoryId);
|
|
2286
|
+
if (storage && storage.hasOwnProperty(this.id) && storage[this.id].hasOwnProperty(propertyName)) {
|
|
2287
|
+
return storage[this.id][propertyName];
|
|
2203
2288
|
}
|
|
2204
2289
|
return void 0;
|
|
2205
2290
|
}
|
|
@@ -2208,7 +2293,7 @@ var StoredClassModel = class {
|
|
|
2208
2293
|
// src/classes/CharacterModelBase.ts
|
|
2209
2294
|
var CharacterModelBase2 = class extends StoredClassModel {
|
|
2210
2295
|
constructor(id, props) {
|
|
2211
|
-
super(GameStorageManager.keysSystem.
|
|
2296
|
+
super(GameStorageManager.keysSystem.CHARACTER_CATEGORY_KEY, id);
|
|
2212
2297
|
this.defaultName = "";
|
|
2213
2298
|
this.defaultName = props.name;
|
|
2214
2299
|
this.defaultSurname = props.surname;
|
|
@@ -2220,19 +2305,19 @@ var CharacterModelBase2 = class extends StoredClassModel {
|
|
|
2220
2305
|
return this.getStorageProperty("name") || this.defaultName;
|
|
2221
2306
|
}
|
|
2222
2307
|
set name(value) {
|
|
2223
|
-
this.
|
|
2308
|
+
this.setStorageProperty("name", value);
|
|
2224
2309
|
}
|
|
2225
2310
|
get surname() {
|
|
2226
2311
|
return this.getStorageProperty("surname") || this.defaultSurname;
|
|
2227
2312
|
}
|
|
2228
2313
|
set surname(value) {
|
|
2229
|
-
this.
|
|
2314
|
+
this.setStorageProperty("surname", value);
|
|
2230
2315
|
}
|
|
2231
2316
|
get age() {
|
|
2232
2317
|
return this.getStorageProperty("age") || this.defaultAge;
|
|
2233
2318
|
}
|
|
2234
2319
|
set age(value) {
|
|
2235
|
-
this.
|
|
2320
|
+
this.setStorageProperty("age", value);
|
|
2236
2321
|
}
|
|
2237
2322
|
get icon() {
|
|
2238
2323
|
return this._icon;
|
|
@@ -2335,6 +2420,7 @@ export {
|
|
|
2335
2420
|
getChoiceMenuOptions,
|
|
2336
2421
|
getDialogue,
|
|
2337
2422
|
getDialogueHistory,
|
|
2423
|
+
getFlag,
|
|
2338
2424
|
getSaveData,
|
|
2339
2425
|
getSaveJson,
|
|
2340
2426
|
getTexture,
|
|
@@ -2345,6 +2431,7 @@ export {
|
|
|
2345
2431
|
saveCharacter,
|
|
2346
2432
|
setChoiceMenuOptions,
|
|
2347
2433
|
setDialogue,
|
|
2434
|
+
setFlag,
|
|
2348
2435
|
showCanvasImages,
|
|
2349
2436
|
showImageWithDissolveTransition,
|
|
2350
2437
|
tickerDecorator
|