@drincs/pixi-vn 0.1.4 → 0.2.0
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/README.md +1 -1
- package/dist/index.d.mts +55 -14
- package/dist/index.d.ts +55 -14
- package/dist/index.js +232 -144
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +230 -144
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -107,6 +107,7 @@ __export(src_exports, {
|
|
|
107
107
|
getChoiceMenuOptions: () => getChoiceMenuOptions,
|
|
108
108
|
getDialogue: () => getDialogue,
|
|
109
109
|
getDialogueHistory: () => getDialogueHistory,
|
|
110
|
+
getFlag: () => getFlag,
|
|
110
111
|
getSaveData: () => getSaveData,
|
|
111
112
|
getSaveJson: () => getSaveJson,
|
|
112
113
|
getTexture: () => getTexture,
|
|
@@ -117,6 +118,7 @@ __export(src_exports, {
|
|
|
117
118
|
saveCharacter: () => saveCharacter,
|
|
118
119
|
setChoiceMenuOptions: () => setChoiceMenuOptions,
|
|
119
120
|
setDialogue: () => setDialogue,
|
|
121
|
+
setFlag: () => setFlag,
|
|
120
122
|
showCanvasImages: () => showCanvasImages,
|
|
121
123
|
showImageWithDissolveTransition: () => showImageWithDissolveTransition,
|
|
122
124
|
tickerDecorator: () => tickerDecorator
|
|
@@ -256,6 +258,26 @@ function getDialogueHistory() {
|
|
|
256
258
|
return list;
|
|
257
259
|
}
|
|
258
260
|
|
|
261
|
+
// src/functions/FlagsUtility.ts
|
|
262
|
+
function setFlag(name, value) {
|
|
263
|
+
let flags = GameStorageManager.getVariable(GameStorageManager.keysSystem.FLAGS_CATEGORY_KEY) || [];
|
|
264
|
+
if (value) {
|
|
265
|
+
if (!flags.includes(name)) {
|
|
266
|
+
flags.push(name);
|
|
267
|
+
}
|
|
268
|
+
} else {
|
|
269
|
+
let index = flags.indexOf(name);
|
|
270
|
+
if (index > -1) {
|
|
271
|
+
flags.splice(index, 1);
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
GameStorageManager.setVariable(GameStorageManager.keysSystem.FLAGS_CATEGORY_KEY, flags);
|
|
275
|
+
}
|
|
276
|
+
function getFlag(name) {
|
|
277
|
+
let flags = GameStorageManager.getVariable(GameStorageManager.keysSystem.FLAGS_CATEGORY_KEY) || [];
|
|
278
|
+
return flags.includes(name);
|
|
279
|
+
}
|
|
280
|
+
|
|
259
281
|
// src/functions/GameUtility.ts
|
|
260
282
|
function clearAllGameDatas() {
|
|
261
283
|
GameStorageManager.clear();
|
|
@@ -299,6 +321,17 @@ function canvasElementDecorator(name) {
|
|
|
299
321
|
function getCanvasElementInstanceByClassName(canvasName) {
|
|
300
322
|
try {
|
|
301
323
|
let eventType = registeredCanvasElement[canvasName];
|
|
324
|
+
if (!eventType) {
|
|
325
|
+
if (canvasName === "CanvasContainer") {
|
|
326
|
+
eventType = CanvasContainer;
|
|
327
|
+
} else if (canvasName === "CanvasImage") {
|
|
328
|
+
eventType = CanvasImage;
|
|
329
|
+
} else if (canvasName === "CanvasSprite") {
|
|
330
|
+
eventType = CanvasSprite;
|
|
331
|
+
} else if (canvasName === "CanvasText") {
|
|
332
|
+
eventType = CanvasText;
|
|
333
|
+
}
|
|
334
|
+
}
|
|
302
335
|
if (!eventType) {
|
|
303
336
|
console.error(`[Pixi'VN] CanvasElement ${canvasName} not found`);
|
|
304
337
|
return;
|
|
@@ -311,101 +344,6 @@ function getCanvasElementInstanceByClassName(canvasName) {
|
|
|
311
344
|
}
|
|
312
345
|
}
|
|
313
346
|
|
|
314
|
-
// src/decorators/CharacterDecorator.ts
|
|
315
|
-
var registeredCharacters = {};
|
|
316
|
-
function saveCharacter(character) {
|
|
317
|
-
if (Array.isArray(character)) {
|
|
318
|
-
character.forEach((c) => saveCharacter(c));
|
|
319
|
-
return;
|
|
320
|
-
}
|
|
321
|
-
if (registeredCharacters[character.id]) {
|
|
322
|
-
console.warn(`[Pixi'VN] Character id ${character.id} already exists, it will be overwritten`);
|
|
323
|
-
}
|
|
324
|
-
registeredCharacters[character.id] = character;
|
|
325
|
-
}
|
|
326
|
-
function getCharacterById(id) {
|
|
327
|
-
try {
|
|
328
|
-
let character = registeredCharacters[id];
|
|
329
|
-
if (!character) {
|
|
330
|
-
console.error(`[Pixi'VN] Character ${id} not found`);
|
|
331
|
-
return;
|
|
332
|
-
}
|
|
333
|
-
return character;
|
|
334
|
-
} catch (e) {
|
|
335
|
-
console.error(`[Pixi'VN] Error while getting Character ${id}`, e);
|
|
336
|
-
return;
|
|
337
|
-
}
|
|
338
|
-
}
|
|
339
|
-
|
|
340
|
-
// src/decorators/EventDecorator.ts
|
|
341
|
-
var registeredEvents = {};
|
|
342
|
-
function eventDecorator(name) {
|
|
343
|
-
return function(target) {
|
|
344
|
-
if (!name) {
|
|
345
|
-
name = target.name;
|
|
346
|
-
}
|
|
347
|
-
if (registeredEvents[name]) {
|
|
348
|
-
console.warn(`[Pixi'VN] Event ${name} already exists, it will be overwritten`);
|
|
349
|
-
}
|
|
350
|
-
registeredEvents[name] = target;
|
|
351
|
-
};
|
|
352
|
-
}
|
|
353
|
-
function getEventTypeByClassName(eventName) {
|
|
354
|
-
try {
|
|
355
|
-
let eventType = registeredEvents[eventName];
|
|
356
|
-
if (!eventType) {
|
|
357
|
-
console.error(`[Pixi'VN] Event ${eventName} not found`);
|
|
358
|
-
return;
|
|
359
|
-
}
|
|
360
|
-
new eventType();
|
|
361
|
-
return eventType;
|
|
362
|
-
} catch (e) {
|
|
363
|
-
console.error(`[Pixi'VN] Error while getting Event ${eventName}`, e);
|
|
364
|
-
return;
|
|
365
|
-
}
|
|
366
|
-
}
|
|
367
|
-
function getEventInstanceByClassName(eventName) {
|
|
368
|
-
try {
|
|
369
|
-
let eventType = registeredEvents[eventName];
|
|
370
|
-
if (!eventType) {
|
|
371
|
-
console.error(`[Pixi'VN] Event ${eventName} not found`);
|
|
372
|
-
return;
|
|
373
|
-
}
|
|
374
|
-
let event = new eventType();
|
|
375
|
-
return event;
|
|
376
|
-
} catch (e) {
|
|
377
|
-
console.error(`[Pixi'VN] Error while getting Event ${eventName}`, e);
|
|
378
|
-
return;
|
|
379
|
-
}
|
|
380
|
-
}
|
|
381
|
-
|
|
382
|
-
// src/decorators/TickerDecorator.ts
|
|
383
|
-
var registeredTickers = {};
|
|
384
|
-
function tickerDecorator(name) {
|
|
385
|
-
return function(target) {
|
|
386
|
-
if (!name) {
|
|
387
|
-
name = target.name;
|
|
388
|
-
}
|
|
389
|
-
if (registeredTickers[name]) {
|
|
390
|
-
console.warn(`[Pixi'VN] Ticker ${name} already exists, it will be overwritten`);
|
|
391
|
-
}
|
|
392
|
-
registeredTickers[name] = target;
|
|
393
|
-
};
|
|
394
|
-
}
|
|
395
|
-
function geTickerInstanceByClassName(tickerName, args, duration, priority) {
|
|
396
|
-
try {
|
|
397
|
-
let ticker = registeredTickers[tickerName];
|
|
398
|
-
if (!ticker) {
|
|
399
|
-
console.error(`[Pixi'VN] Ticker ${tickerName} not found`);
|
|
400
|
-
return;
|
|
401
|
-
}
|
|
402
|
-
return new ticker(args, duration, priority);
|
|
403
|
-
} catch (e) {
|
|
404
|
-
console.error(`[Pixi'VN] Error while getting Ticker ${tickerName}`, e);
|
|
405
|
-
return;
|
|
406
|
-
}
|
|
407
|
-
}
|
|
408
|
-
|
|
409
347
|
// src/functions/CanvasUtility.ts
|
|
410
348
|
function getTextureMemory(texture) {
|
|
411
349
|
let sourceTexture = texture.source;
|
|
@@ -422,7 +360,7 @@ function importCanvasElement(memory) {
|
|
|
422
360
|
if (element) {
|
|
423
361
|
element.memory = memory;
|
|
424
362
|
} else {
|
|
425
|
-
throw new Error("[Pixi'VN] The element " + memory.className + "could not be created");
|
|
363
|
+
throw new Error("[Pixi'VN] The element " + memory.className + " could not be created");
|
|
426
364
|
}
|
|
427
365
|
return element;
|
|
428
366
|
}
|
|
@@ -443,9 +381,6 @@ var CanvasContainer = class extends import_pixi2.Container {
|
|
|
443
381
|
});
|
|
444
382
|
}
|
|
445
383
|
};
|
|
446
|
-
CanvasContainer = __decorateClass([
|
|
447
|
-
canvasElementDecorator()
|
|
448
|
-
], CanvasContainer);
|
|
449
384
|
function getMemoryContainer(element) {
|
|
450
385
|
return {
|
|
451
386
|
className: "CanvasContainer",
|
|
@@ -570,7 +505,51 @@ function getTextStyle(style) {
|
|
|
570
505
|
|
|
571
506
|
// src/classes/canvas/CanvasSprite.ts
|
|
572
507
|
var import_pixi4 = require("pixi.js");
|
|
573
|
-
|
|
508
|
+
|
|
509
|
+
// src/decorators/EventDecorator.ts
|
|
510
|
+
var registeredEvents = {};
|
|
511
|
+
function eventDecorator(name) {
|
|
512
|
+
return function(target) {
|
|
513
|
+
if (!name) {
|
|
514
|
+
name = target.name;
|
|
515
|
+
}
|
|
516
|
+
if (registeredEvents[name]) {
|
|
517
|
+
console.warn(`[Pixi'VN] Event ${name} already exists, it will be overwritten`);
|
|
518
|
+
}
|
|
519
|
+
registeredEvents[name] = target;
|
|
520
|
+
};
|
|
521
|
+
}
|
|
522
|
+
function getEventTypeByClassName(eventName) {
|
|
523
|
+
try {
|
|
524
|
+
let eventType = registeredEvents[eventName];
|
|
525
|
+
if (!eventType) {
|
|
526
|
+
console.error(`[Pixi'VN] Event ${eventName} not found`);
|
|
527
|
+
return;
|
|
528
|
+
}
|
|
529
|
+
new eventType();
|
|
530
|
+
return eventType;
|
|
531
|
+
} catch (e) {
|
|
532
|
+
console.error(`[Pixi'VN] Error while getting Event ${eventName}`, e);
|
|
533
|
+
return;
|
|
534
|
+
}
|
|
535
|
+
}
|
|
536
|
+
function getEventInstanceByClassName(eventName) {
|
|
537
|
+
try {
|
|
538
|
+
let eventType = registeredEvents[eventName];
|
|
539
|
+
if (!eventType) {
|
|
540
|
+
console.error(`[Pixi'VN] Event ${eventName} not found`);
|
|
541
|
+
return;
|
|
542
|
+
}
|
|
543
|
+
let event = new eventType();
|
|
544
|
+
return event;
|
|
545
|
+
} catch (e) {
|
|
546
|
+
console.error(`[Pixi'VN] Error while getting Event ${eventName}`, e);
|
|
547
|
+
return;
|
|
548
|
+
}
|
|
549
|
+
}
|
|
550
|
+
|
|
551
|
+
// src/classes/canvas/CanvasSprite.ts
|
|
552
|
+
var CanvasSprite = class _CanvasSprite extends import_pixi4.Sprite {
|
|
574
553
|
constructor() {
|
|
575
554
|
super(...arguments);
|
|
576
555
|
this._onEvents = {};
|
|
@@ -637,14 +616,11 @@ var CanvasSprite = class extends import_pixi4.Sprite {
|
|
|
637
616
|
}
|
|
638
617
|
static from(source, skipCache) {
|
|
639
618
|
let sprite = import_pixi4.Sprite.from(source, skipCache);
|
|
640
|
-
let mySprite = new
|
|
619
|
+
let mySprite = new _CanvasSprite();
|
|
641
620
|
mySprite.texture = sprite.texture;
|
|
642
621
|
return mySprite;
|
|
643
622
|
}
|
|
644
623
|
};
|
|
645
|
-
CanvasSprite = __decorateClass([
|
|
646
|
-
canvasElementDecorator()
|
|
647
|
-
], CanvasSprite);
|
|
648
624
|
function getMemorySprite(element) {
|
|
649
625
|
let temp = getMemoryContainer(element);
|
|
650
626
|
return __spreadProps(__spreadValues({}, temp), {
|
|
@@ -680,7 +656,7 @@ function setMemorySprite(element, memory) {
|
|
|
680
656
|
}
|
|
681
657
|
|
|
682
658
|
// src/classes/canvas/CanvasImage.ts
|
|
683
|
-
var CanvasImage = class extends CanvasSprite {
|
|
659
|
+
var CanvasImage = class _CanvasImage extends CanvasSprite {
|
|
684
660
|
constructor() {
|
|
685
661
|
super(...arguments);
|
|
686
662
|
this.imageLink = "";
|
|
@@ -696,7 +672,7 @@ var CanvasImage = class extends CanvasSprite {
|
|
|
696
672
|
}
|
|
697
673
|
static from(source, skipCache) {
|
|
698
674
|
let sprite = import_pixi5.Sprite.from(source, skipCache);
|
|
699
|
-
let mySprite = new
|
|
675
|
+
let mySprite = new _CanvasImage();
|
|
700
676
|
mySprite.texture = sprite.texture;
|
|
701
677
|
return mySprite;
|
|
702
678
|
}
|
|
@@ -716,9 +692,6 @@ var CanvasImage = class extends CanvasSprite {
|
|
|
716
692
|
});
|
|
717
693
|
}
|
|
718
694
|
};
|
|
719
|
-
CanvasImage = __decorateClass([
|
|
720
|
-
canvasElementDecorator()
|
|
721
|
-
], CanvasImage);
|
|
722
695
|
|
|
723
696
|
// src/classes/canvas/CanvasText.ts
|
|
724
697
|
var import_pixi6 = require("pixi.js");
|
|
@@ -788,9 +761,6 @@ var CanvasText = class extends import_pixi6.Text {
|
|
|
788
761
|
return super.on(event, fn, context);
|
|
789
762
|
}
|
|
790
763
|
};
|
|
791
|
-
CanvasText = __decorateClass([
|
|
792
|
-
canvasElementDecorator()
|
|
793
|
-
], CanvasText);
|
|
794
764
|
function getMemoryText(element) {
|
|
795
765
|
let temp = getMemoryContainer(element);
|
|
796
766
|
return __spreadProps(__spreadValues({}, temp), {
|
|
@@ -846,6 +816,61 @@ var TickerBase = class {
|
|
|
846
816
|
|
|
847
817
|
// src/classes/ticker/TickerFadeAlpha.ts
|
|
848
818
|
var import_pixi7 = require("pixi.js");
|
|
819
|
+
|
|
820
|
+
// src/decorators/CharacterDecorator.ts
|
|
821
|
+
var registeredCharacters = {};
|
|
822
|
+
function saveCharacter(character) {
|
|
823
|
+
if (Array.isArray(character)) {
|
|
824
|
+
character.forEach((c) => saveCharacter(c));
|
|
825
|
+
return;
|
|
826
|
+
}
|
|
827
|
+
if (registeredCharacters[character.id]) {
|
|
828
|
+
console.warn(`[Pixi'VN] Character id ${character.id} already exists, it will be overwritten`);
|
|
829
|
+
}
|
|
830
|
+
registeredCharacters[character.id] = character;
|
|
831
|
+
}
|
|
832
|
+
function getCharacterById(id) {
|
|
833
|
+
try {
|
|
834
|
+
let character = registeredCharacters[id];
|
|
835
|
+
if (!character) {
|
|
836
|
+
console.error(`[Pixi'VN] Character ${id} not found`);
|
|
837
|
+
return;
|
|
838
|
+
}
|
|
839
|
+
return character;
|
|
840
|
+
} catch (e) {
|
|
841
|
+
console.error(`[Pixi'VN] Error while getting Character ${id}`, e);
|
|
842
|
+
return;
|
|
843
|
+
}
|
|
844
|
+
}
|
|
845
|
+
|
|
846
|
+
// src/decorators/TickerDecorator.ts
|
|
847
|
+
var registeredTickers = {};
|
|
848
|
+
function tickerDecorator(name) {
|
|
849
|
+
return function(target) {
|
|
850
|
+
if (!name) {
|
|
851
|
+
name = target.name;
|
|
852
|
+
}
|
|
853
|
+
if (registeredTickers[name]) {
|
|
854
|
+
console.warn(`[Pixi'VN] Ticker ${name} already exists, it will be overwritten`);
|
|
855
|
+
}
|
|
856
|
+
registeredTickers[name] = target;
|
|
857
|
+
};
|
|
858
|
+
}
|
|
859
|
+
function geTickerInstanceByClassName(tickerName, args, duration, priority) {
|
|
860
|
+
try {
|
|
861
|
+
let ticker = registeredTickers[tickerName];
|
|
862
|
+
if (!ticker) {
|
|
863
|
+
console.error(`[Pixi'VN] Ticker ${tickerName} not found`);
|
|
864
|
+
return;
|
|
865
|
+
}
|
|
866
|
+
return new ticker(args, duration, priority);
|
|
867
|
+
} catch (e) {
|
|
868
|
+
console.error(`[Pixi'VN] Error while getting Ticker ${tickerName}`, e);
|
|
869
|
+
return;
|
|
870
|
+
}
|
|
871
|
+
}
|
|
872
|
+
|
|
873
|
+
// src/classes/ticker/TickerFadeAlpha.ts
|
|
849
874
|
var TickerFadeAlpha = class extends TickerBase {
|
|
850
875
|
/**
|
|
851
876
|
* The method that will be called every frame to fade the alpha of the canvas element of the canvas.
|
|
@@ -1024,12 +1049,12 @@ function showImageWithDissolveTransition(tag, imageUrl, speed, priority) {
|
|
|
1024
1049
|
}
|
|
1025
1050
|
|
|
1026
1051
|
// src/constants.ts
|
|
1027
|
-
var
|
|
1052
|
+
var PIXIVN_VERSION = "0.1.5";
|
|
1028
1053
|
|
|
1029
1054
|
// src/functions/SavesUtility.ts
|
|
1030
1055
|
function getSaveData() {
|
|
1031
1056
|
return {
|
|
1032
|
-
|
|
1057
|
+
pixivn_version: PIXIVN_VERSION,
|
|
1033
1058
|
stepData: GameStepManager.export(),
|
|
1034
1059
|
storageData: GameStorageManager.export(),
|
|
1035
1060
|
canvasData: GameWindowManager.export(),
|
|
@@ -1125,7 +1150,8 @@ var _GameStorageManager = class _GameStorageManager {
|
|
|
1125
1150
|
LAST_DIALOGUE_ADDED_IN_STEP_MEMORY_KEY: "___last_dialogue_added_in_step_memory_key___",
|
|
1126
1151
|
CURRENT_MENU_OPTIONS_MEMORY_KEY: "___current_menu_options_memory_key___",
|
|
1127
1152
|
LAST_MENU_OPTIONS_ADDED_IN_STEP_MEMORY_KEY: "___last_menu_options_added_in_step_memory_key___",
|
|
1128
|
-
|
|
1153
|
+
CHARACTER_CATEGORY_KEY: "___character___",
|
|
1154
|
+
FLAGS_CATEGORY_KEY: "___flags___"
|
|
1129
1155
|
};
|
|
1130
1156
|
}
|
|
1131
1157
|
/**
|
|
@@ -1136,7 +1162,7 @@ var _GameStorageManager = class _GameStorageManager {
|
|
|
1136
1162
|
*/
|
|
1137
1163
|
static setVariable(key, value) {
|
|
1138
1164
|
key = key.toLowerCase();
|
|
1139
|
-
if (value === void 0) {
|
|
1165
|
+
if (value === void 0 || value === null) {
|
|
1140
1166
|
if (_GameStorageManager.storage.hasOwnProperty(key)) {
|
|
1141
1167
|
delete _GameStorageManager.storage[key];
|
|
1142
1168
|
}
|
|
@@ -1202,6 +1228,17 @@ var GameStorageManager = _GameStorageManager;
|
|
|
1202
1228
|
// src/managers/WindowManager.ts
|
|
1203
1229
|
var import_pixi9 = require("pixi.js");
|
|
1204
1230
|
|
|
1231
|
+
// src/functions/EasterEgg.ts
|
|
1232
|
+
function asciiArtLog() {
|
|
1233
|
+
console.log(`
|
|
1234
|
+
____ _ _ ___ ___ _
|
|
1235
|
+
| _ (_)_ _(_| ) / / | |
|
|
1236
|
+
| |_) | / / |/ / /| | |
|
|
1237
|
+
| __/| |> <| | V / | | |
|
|
1238
|
+
|_| |_/_/__| _/ |_| _|
|
|
1239
|
+
`);
|
|
1240
|
+
}
|
|
1241
|
+
|
|
1205
1242
|
// src/types/PauseType.ts
|
|
1206
1243
|
var PauseValueType = "Pause";
|
|
1207
1244
|
function Pause(duration) {
|
|
@@ -1270,6 +1307,7 @@ var _GameWindowManager = class _GameWindowManager {
|
|
|
1270
1307
|
this.addCanvasIntoElement(element);
|
|
1271
1308
|
window.addEventListener("resize", _GameWindowManager.resize);
|
|
1272
1309
|
_GameWindowManager.resize();
|
|
1310
|
+
asciiArtLog();
|
|
1273
1311
|
});
|
|
1274
1312
|
});
|
|
1275
1313
|
}
|
|
@@ -1802,9 +1840,9 @@ var _GameStepManager = class _GameStepManager {
|
|
|
1802
1840
|
return _GameStepManager._openedLabels;
|
|
1803
1841
|
}
|
|
1804
1842
|
/**
|
|
1805
|
-
*
|
|
1843
|
+
* currentLabelId is the current label id that occurred during the progression of the steps.
|
|
1806
1844
|
*/
|
|
1807
|
-
static get
|
|
1845
|
+
static get currentLabelId() {
|
|
1808
1846
|
if (_GameStepManager._openedLabels.length > 0) {
|
|
1809
1847
|
let item = _GameStepManager._openedLabels[_GameStepManager._openedLabels.length - 1];
|
|
1810
1848
|
return item.label;
|
|
@@ -1812,8 +1850,13 @@ var _GameStepManager = class _GameStepManager {
|
|
|
1812
1850
|
return void 0;
|
|
1813
1851
|
}
|
|
1814
1852
|
/**
|
|
1815
|
-
* is the current
|
|
1853
|
+
* currentLabel is the current label that occurred during the progression of the steps.
|
|
1816
1854
|
*/
|
|
1855
|
+
static get currentLabel() {
|
|
1856
|
+
if (_GameStepManager.currentLabelId) {
|
|
1857
|
+
return getLabelInstanceByClassName(_GameStepManager.currentLabelId);
|
|
1858
|
+
}
|
|
1859
|
+
}
|
|
1817
1860
|
static get currentLabelStepIndex() {
|
|
1818
1861
|
if (_GameStepManager._openedLabels.length > 0) {
|
|
1819
1862
|
let item = _GameStepManager._openedLabels[_GameStepManager._openedLabels.length - 1];
|
|
@@ -1821,6 +1864,17 @@ var _GameStepManager = class _GameStepManager {
|
|
|
1821
1864
|
}
|
|
1822
1865
|
return null;
|
|
1823
1866
|
}
|
|
1867
|
+
/**
|
|
1868
|
+
* currentLabelStep is the current step that occurred during the progression of the steps. It can used to determine the game end.
|
|
1869
|
+
*/
|
|
1870
|
+
static get isLastGameStep() {
|
|
1871
|
+
var _a;
|
|
1872
|
+
let stepLabel = (_a = _GameStepManager.currentLabel) == null ? void 0 : _a.steps;
|
|
1873
|
+
if (stepLabel) {
|
|
1874
|
+
return _GameStepManager.currentLabelStepIndex === stepLabel.length;
|
|
1875
|
+
}
|
|
1876
|
+
return false;
|
|
1877
|
+
}
|
|
1824
1878
|
/**
|
|
1825
1879
|
* lastHistoryStep is the last history step that occurred during the progression of the steps.
|
|
1826
1880
|
*/
|
|
@@ -1888,7 +1942,7 @@ var _GameStepManager = class _GameStepManager {
|
|
|
1888
1942
|
}
|
|
1889
1943
|
_GameStepManager._stepsHistory.push({
|
|
1890
1944
|
diff: data,
|
|
1891
|
-
currentLabel: _GameStepManager.
|
|
1945
|
+
currentLabel: _GameStepManager.currentLabelId,
|
|
1892
1946
|
dialoge,
|
|
1893
1947
|
choices: requiredChoices,
|
|
1894
1948
|
stepSha1: stepHistory,
|
|
@@ -1917,12 +1971,11 @@ var _GameStepManager = class _GameStepManager {
|
|
|
1917
1971
|
* @returns
|
|
1918
1972
|
*/
|
|
1919
1973
|
static closeCurrentLabel() {
|
|
1920
|
-
if (!_GameStepManager.
|
|
1974
|
+
if (!_GameStepManager.currentLabelId) {
|
|
1921
1975
|
console.warn("[Pixi'VN] No label to close");
|
|
1922
1976
|
return;
|
|
1923
1977
|
}
|
|
1924
|
-
|
|
1925
|
-
if (!currentLabel) {
|
|
1978
|
+
if (!_GameStepManager.currentLabel) {
|
|
1926
1979
|
console.error("[Pixi'VN] Label not found");
|
|
1927
1980
|
return;
|
|
1928
1981
|
}
|
|
@@ -1981,13 +2034,13 @@ var _GameStepManager = class _GameStepManager {
|
|
|
1981
2034
|
*/
|
|
1982
2035
|
static runCurrentStep() {
|
|
1983
2036
|
return __async(this, null, function* () {
|
|
1984
|
-
if (_GameStepManager.
|
|
2037
|
+
if (_GameStepManager.currentLabelId) {
|
|
1985
2038
|
let lasteStepsLength = _GameStepManager.currentLabelStepIndex;
|
|
1986
2039
|
if (lasteStepsLength === null) {
|
|
1987
2040
|
console.error("[Pixi'VN] currentLabelStepIndex is null");
|
|
1988
2041
|
return;
|
|
1989
2042
|
}
|
|
1990
|
-
let currentLabel =
|
|
2043
|
+
let currentLabel = _GameStepManager.currentLabel;
|
|
1991
2044
|
if (!currentLabel) {
|
|
1992
2045
|
console.error("[Pixi'VN] Label not found");
|
|
1993
2046
|
return;
|
|
@@ -2168,6 +2221,12 @@ var _GameStepManager = class _GameStepManager {
|
|
|
2168
2221
|
return restoredStep;
|
|
2169
2222
|
}
|
|
2170
2223
|
}
|
|
2224
|
+
/**
|
|
2225
|
+
* Return true if it is possible to go back.
|
|
2226
|
+
*/
|
|
2227
|
+
static get canGoBack() {
|
|
2228
|
+
return _GameStepManager._stepsHistory.length > 1;
|
|
2229
|
+
}
|
|
2171
2230
|
/**
|
|
2172
2231
|
* Add a label to the history.
|
|
2173
2232
|
*/
|
|
@@ -2245,27 +2304,54 @@ var GameStepManager = _GameStepManager;
|
|
|
2245
2304
|
|
|
2246
2305
|
// src/classes/StoredClassModel.ts
|
|
2247
2306
|
var StoredClassModel = class {
|
|
2248
|
-
|
|
2249
|
-
|
|
2307
|
+
/**
|
|
2308
|
+
* @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.
|
|
2309
|
+
* @param id The id of instance of the class. This id must be unique for the category.
|
|
2310
|
+
*/
|
|
2311
|
+
constructor(categoryId, id) {
|
|
2312
|
+
this.categoryId = categoryId;
|
|
2313
|
+
this._id = id;
|
|
2250
2314
|
}
|
|
2251
|
-
|
|
2252
|
-
|
|
2315
|
+
/**
|
|
2316
|
+
* Is id of the stored class. is unique for this class.
|
|
2317
|
+
*/
|
|
2318
|
+
get id() {
|
|
2319
|
+
return this._id;
|
|
2253
2320
|
}
|
|
2254
|
-
|
|
2255
|
-
|
|
2321
|
+
/**
|
|
2322
|
+
* Update a property in the storage.
|
|
2323
|
+
* @param propertyName The name of the property to set.
|
|
2324
|
+
* @param value The value to set. If is undefined, the property will be removed from the storage.
|
|
2325
|
+
*/
|
|
2326
|
+
setStorageProperty(propertyName, value) {
|
|
2327
|
+
let storage = GameStorageManager.getVariable(this.categoryId);
|
|
2256
2328
|
if (!storage) {
|
|
2257
2329
|
storage = {};
|
|
2258
2330
|
}
|
|
2259
|
-
storage
|
|
2260
|
-
|
|
2261
|
-
}
|
|
2262
|
-
getStorageProperty(key) {
|
|
2263
|
-
let storage = GameStorageManager.getVariable(this.nameClass);
|
|
2264
|
-
if (!storage) {
|
|
2265
|
-
return void 0;
|
|
2331
|
+
if (!storage.hasOwnProperty(this.id)) {
|
|
2332
|
+
storage[this.id] = {};
|
|
2266
2333
|
}
|
|
2267
|
-
if (
|
|
2268
|
-
|
|
2334
|
+
if (value === void 0 || value === null) {
|
|
2335
|
+
if (storage[this.id].hasOwnProperty(propertyName)) {
|
|
2336
|
+
delete storage[this.id][propertyName];
|
|
2337
|
+
}
|
|
2338
|
+
} else {
|
|
2339
|
+
storage[this.id] = __spreadProps(__spreadValues({}, storage[this.id]), { [propertyName]: value });
|
|
2340
|
+
}
|
|
2341
|
+
if (Object.keys(storage[this.id]).length === 0) {
|
|
2342
|
+
delete storage[this.id];
|
|
2343
|
+
}
|
|
2344
|
+
GameStorageManager.setVariable(this.categoryId, storage);
|
|
2345
|
+
}
|
|
2346
|
+
/**
|
|
2347
|
+
* Get a property from the storage.
|
|
2348
|
+
* @param propertyName The name of the property to get.
|
|
2349
|
+
* @returns The value of the property. If the property is not found, returns undefined.
|
|
2350
|
+
*/
|
|
2351
|
+
getStorageProperty(propertyName) {
|
|
2352
|
+
let storage = GameStorageManager.getVariable(this.categoryId);
|
|
2353
|
+
if (storage && storage.hasOwnProperty(this.id) && storage[this.id].hasOwnProperty(propertyName)) {
|
|
2354
|
+
return storage[this.id][propertyName];
|
|
2269
2355
|
}
|
|
2270
2356
|
return void 0;
|
|
2271
2357
|
}
|
|
@@ -2274,7 +2360,7 @@ var StoredClassModel = class {
|
|
|
2274
2360
|
// src/classes/CharacterModelBase.ts
|
|
2275
2361
|
var CharacterModelBase2 = class extends StoredClassModel {
|
|
2276
2362
|
constructor(id, props) {
|
|
2277
|
-
super(GameStorageManager.keysSystem.
|
|
2363
|
+
super(GameStorageManager.keysSystem.CHARACTER_CATEGORY_KEY, id);
|
|
2278
2364
|
this.defaultName = "";
|
|
2279
2365
|
this.defaultName = props.name;
|
|
2280
2366
|
this.defaultSurname = props.surname;
|
|
@@ -2286,19 +2372,19 @@ var CharacterModelBase2 = class extends StoredClassModel {
|
|
|
2286
2372
|
return this.getStorageProperty("name") || this.defaultName;
|
|
2287
2373
|
}
|
|
2288
2374
|
set name(value) {
|
|
2289
|
-
this.
|
|
2375
|
+
this.setStorageProperty("name", value);
|
|
2290
2376
|
}
|
|
2291
2377
|
get surname() {
|
|
2292
2378
|
return this.getStorageProperty("surname") || this.defaultSurname;
|
|
2293
2379
|
}
|
|
2294
2380
|
set surname(value) {
|
|
2295
|
-
this.
|
|
2381
|
+
this.setStorageProperty("surname", value);
|
|
2296
2382
|
}
|
|
2297
2383
|
get age() {
|
|
2298
2384
|
return this.getStorageProperty("age") || this.defaultAge;
|
|
2299
2385
|
}
|
|
2300
2386
|
set age(value) {
|
|
2301
|
-
this.
|
|
2387
|
+
this.setStorageProperty("age", value);
|
|
2302
2388
|
}
|
|
2303
2389
|
get icon() {
|
|
2304
2390
|
return this._icon;
|
|
@@ -2402,6 +2488,7 @@ var Label = class {
|
|
|
2402
2488
|
getChoiceMenuOptions,
|
|
2403
2489
|
getDialogue,
|
|
2404
2490
|
getDialogueHistory,
|
|
2491
|
+
getFlag,
|
|
2405
2492
|
getSaveData,
|
|
2406
2493
|
getSaveJson,
|
|
2407
2494
|
getTexture,
|
|
@@ -2412,6 +2499,7 @@ var Label = class {
|
|
|
2412
2499
|
saveCharacter,
|
|
2413
2500
|
setChoiceMenuOptions,
|
|
2414
2501
|
setDialogue,
|
|
2502
|
+
setFlag,
|
|
2415
2503
|
showCanvasImages,
|
|
2416
2504
|
showImageWithDissolveTransition,
|
|
2417
2505
|
tickerDecorator
|