@drincs/pixi-vn 0.5.2 → 0.5.4

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.
Files changed (142) hide show
  1. package/dist/classes/CharacterBaseModel.js +110 -112
  2. package/dist/classes/CharacterBaseModel.js.map +1 -1
  3. package/dist/classes/CharacterBaseModel.mjs +110 -112
  4. package/dist/classes/CharacterBaseModel.mjs.map +1 -1
  5. package/dist/classes/ChoiceMenuOption.d.mts +19 -7
  6. package/dist/classes/ChoiceMenuOption.d.ts +19 -7
  7. package/dist/classes/ChoiceMenuOption.js +1386 -7
  8. package/dist/classes/ChoiceMenuOption.js.map +1 -1
  9. package/dist/classes/ChoiceMenuOption.mjs +1386 -7
  10. package/dist/classes/ChoiceMenuOption.mjs.map +1 -1
  11. package/dist/classes/CloseLabel.d.mts +8 -3
  12. package/dist/classes/CloseLabel.d.ts +8 -3
  13. package/dist/classes/CloseLabel.js +44 -2
  14. package/dist/classes/CloseLabel.js.map +1 -1
  15. package/dist/classes/CloseLabel.mjs +41 -2
  16. package/dist/classes/CloseLabel.mjs.map +1 -1
  17. package/dist/classes/Label.d.mts +47 -21
  18. package/dist/classes/Label.d.ts +47 -21
  19. package/dist/classes/Label.js +36 -1
  20. package/dist/classes/Label.js.map +1 -1
  21. package/dist/classes/Label.mjs +36 -1
  22. package/dist/classes/Label.mjs.map +1 -1
  23. package/dist/classes/StoredClassModel.js +55 -57
  24. package/dist/classes/StoredClassModel.js.map +1 -1
  25. package/dist/classes/StoredClassModel.mjs +55 -57
  26. package/dist/classes/StoredClassModel.mjs.map +1 -1
  27. package/dist/classes/index.d.mts +2 -2
  28. package/dist/classes/index.d.ts +2 -2
  29. package/dist/classes/index.js +125 -73
  30. package/dist/classes/index.js.map +1 -1
  31. package/dist/classes/index.mjs +125 -73
  32. package/dist/classes/index.mjs.map +1 -1
  33. package/dist/classes/ticker/TickerFadeAlpha.js +27 -27
  34. package/dist/classes/ticker/TickerFadeAlpha.js.map +1 -1
  35. package/dist/classes/ticker/TickerFadeAlpha.mjs +27 -27
  36. package/dist/classes/ticker/TickerFadeAlpha.mjs.map +1 -1
  37. package/dist/classes/ticker/TickerMove.js +57 -55
  38. package/dist/classes/ticker/TickerMove.js.map +1 -1
  39. package/dist/classes/ticker/TickerMove.mjs +57 -55
  40. package/dist/classes/ticker/TickerMove.mjs.map +1 -1
  41. package/dist/classes/ticker/TickerRotate.js +57 -55
  42. package/dist/classes/ticker/TickerRotate.js.map +1 -1
  43. package/dist/classes/ticker/TickerRotate.mjs +57 -55
  44. package/dist/classes/ticker/TickerRotate.mjs.map +1 -1
  45. package/dist/classes/ticker/index.js +17 -17
  46. package/dist/classes/ticker/index.js.map +1 -1
  47. package/dist/classes/ticker/index.mjs +17 -17
  48. package/dist/classes/ticker/index.mjs.map +1 -1
  49. package/dist/constants.d.mts +1 -1
  50. package/dist/constants.d.ts +1 -1
  51. package/dist/constants.js +1 -1
  52. package/dist/constants.js.map +1 -1
  53. package/dist/constants.mjs +1 -1
  54. package/dist/constants.mjs.map +1 -1
  55. package/dist/decorators/LabelDecorator.d.mts +13 -20
  56. package/dist/decorators/LabelDecorator.d.ts +13 -20
  57. package/dist/decorators/LabelDecorator.js +1388 -28
  58. package/dist/decorators/LabelDecorator.js.map +1 -1
  59. package/dist/decorators/LabelDecorator.mjs +1388 -25
  60. package/dist/decorators/LabelDecorator.mjs.map +1 -1
  61. package/dist/decorators/index.d.mts +4 -4
  62. package/dist/decorators/index.d.ts +4 -4
  63. package/dist/decorators/index.js +1385 -13
  64. package/dist/decorators/index.js.map +1 -1
  65. package/dist/decorators/index.mjs +1384 -13
  66. package/dist/decorators/index.mjs.map +1 -1
  67. package/dist/functions/DialogueUtility.d.mts +7 -7
  68. package/dist/functions/DialogueUtility.d.ts +7 -7
  69. package/dist/functions/DialogueUtility.js +97 -67
  70. package/dist/functions/DialogueUtility.js.map +1 -1
  71. package/dist/functions/DialogueUtility.mjs +97 -67
  72. package/dist/functions/DialogueUtility.mjs.map +1 -1
  73. package/dist/functions/FlagsUtility.js +55 -57
  74. package/dist/functions/FlagsUtility.js.map +1 -1
  75. package/dist/functions/FlagsUtility.mjs +55 -57
  76. package/dist/functions/FlagsUtility.mjs.map +1 -1
  77. package/dist/functions/GameUtility.js +55 -57
  78. package/dist/functions/GameUtility.js.map +1 -1
  79. package/dist/functions/GameUtility.mjs +55 -57
  80. package/dist/functions/GameUtility.mjs.map +1 -1
  81. package/dist/functions/ImageUtility.js +17 -17
  82. package/dist/functions/ImageUtility.js.map +1 -1
  83. package/dist/functions/ImageUtility.mjs +17 -17
  84. package/dist/functions/ImageUtility.mjs.map +1 -1
  85. package/dist/functions/SavesUtility.d.mts +2 -2
  86. package/dist/functions/SavesUtility.d.ts +2 -2
  87. package/dist/functions/SavesUtility.js +115 -143
  88. package/dist/functions/SavesUtility.js.map +1 -1
  89. package/dist/functions/SavesUtility.mjs +115 -143
  90. package/dist/functions/SavesUtility.mjs.map +1 -1
  91. package/dist/functions/StepLabelUtility.d.mts +0 -1
  92. package/dist/functions/StepLabelUtility.d.ts +0 -1
  93. package/dist/functions/index.d.mts +4 -4
  94. package/dist/functions/index.d.ts +4 -4
  95. package/dist/functions/index.js +98 -68
  96. package/dist/functions/index.js.map +1 -1
  97. package/dist/functions/index.mjs +98 -68
  98. package/dist/functions/index.mjs.map +1 -1
  99. package/dist/index.d.mts +3 -3
  100. package/dist/index.d.ts +3 -3
  101. package/dist/index.js +361 -327
  102. package/dist/index.js.map +1 -1
  103. package/dist/index.mjs +360 -327
  104. package/dist/index.mjs.map +1 -1
  105. package/dist/interface/{IDialogueHistory.d.mts → DialogueHistory.d.mts} +5 -5
  106. package/dist/interface/{IDialogueHistory.d.ts → DialogueHistory.d.ts} +5 -5
  107. package/dist/interface/{IDialogueHistory.js → DialogueHistory.js} +1 -1
  108. package/dist/interface/DialogueHistory.mjs +3 -0
  109. package/dist/interface/IHistoryStep.d.mts +2 -2
  110. package/dist/interface/IHistoryStep.d.ts +2 -2
  111. package/dist/interface/ISaveData.d.mts +2 -2
  112. package/dist/interface/ISaveData.d.ts +2 -2
  113. package/dist/interface/export/ExportedStep.d.mts +2 -2
  114. package/dist/interface/export/ExportedStep.d.ts +2 -2
  115. package/dist/interface/export/index.d.mts +2 -2
  116. package/dist/interface/export/index.d.ts +2 -2
  117. package/dist/interface/index.d.mts +6 -6
  118. package/dist/interface/index.d.ts +6 -6
  119. package/dist/managers/StepManager.d.mts +12 -12
  120. package/dist/managers/StepManager.d.ts +12 -12
  121. package/dist/managers/StepManager.js +55 -81
  122. package/dist/managers/StepManager.js.map +1 -1
  123. package/dist/managers/StepManager.mjs +55 -81
  124. package/dist/managers/StepManager.mjs.map +1 -1
  125. package/dist/managers/WindowManager.d.mts +1 -1
  126. package/dist/managers/WindowManager.d.ts +1 -1
  127. package/dist/managers/index.d.mts +2 -2
  128. package/dist/managers/index.d.ts +2 -2
  129. package/dist/managers/index.js +114 -142
  130. package/dist/managers/index.js.map +1 -1
  131. package/dist/managers/index.mjs +114 -142
  132. package/dist/managers/index.mjs.map +1 -1
  133. package/dist/types/ChoiceMenuOptionsType.d.mts +3 -3
  134. package/dist/types/ChoiceMenuOptionsType.d.ts +3 -3
  135. package/dist/types/StepLabelType.d.mts +2 -3
  136. package/dist/types/StepLabelType.d.ts +2 -3
  137. package/dist/types/index.d.mts +1 -1
  138. package/dist/types/index.d.ts +1 -1
  139. package/package.json +2 -2
  140. package/dist/interface/IDialogueHistory.mjs +0 -3
  141. /package/dist/interface/{IDialogueHistory.js.map → DialogueHistory.js.map} +0 -0
  142. /package/dist/interface/{IDialogueHistory.mjs.map → DialogueHistory.mjs.map} +0 -0
@@ -1,6 +1,6 @@
1
1
  export { default as CanvasEvent } from './CanvasEvent.mjs';
2
2
  export { default as CharacterBaseModel, CharacterBaseModelProps } from './CharacterBaseModel.mjs';
3
- export { default as ChoiceMenuOption } from './ChoiceMenuOption.mjs';
3
+ export { default as ChoiceMenuOption, HistoryChoiceMenuOption } from './ChoiceMenuOption.mjs';
4
4
  export { default as DialogueBaseModel } from './DialogueBaseModel.mjs';
5
5
  export { default as Label } from './Label.mjs';
6
6
  export { default as StoredClassModel } from './StoredClassModel.mjs';
@@ -9,6 +9,6 @@ import '../types/CloseType.mjs';
9
9
  import '../types/LabelRunModeType.mjs';
10
10
  import '../types/StorageElementType.mjs';
11
11
  import '../types/LabelIdType.mjs';
12
+ import '../types/StepHistoryDataType.mjs';
12
13
  import '../types/StepLabelType.mjs';
13
14
  import '@drincs/pixi-vn/dist/override';
14
- import '../types/StepHistoryDataType.mjs';
@@ -1,6 +1,6 @@
1
1
  export { default as CanvasEvent } from './CanvasEvent.js';
2
2
  export { default as CharacterBaseModel, CharacterBaseModelProps } from './CharacterBaseModel.js';
3
- export { default as ChoiceMenuOption } from './ChoiceMenuOption.js';
3
+ export { default as ChoiceMenuOption, HistoryChoiceMenuOption } from './ChoiceMenuOption.js';
4
4
  export { default as DialogueBaseModel } from './DialogueBaseModel.js';
5
5
  export { default as Label } from './Label.js';
6
6
  export { default as StoredClassModel } from './StoredClassModel.js';
@@ -9,6 +9,6 @@ import '../types/CloseType.js';
9
9
  import '../types/LabelRunModeType.js';
10
10
  import '../types/StorageElementType.js';
11
11
  import '../types/LabelIdType.js';
12
+ import '../types/StepHistoryDataType.js';
12
13
  import '../types/StepLabelType.js';
13
14
  import '@drincs/pixi-vn/dist/override';
14
- import '../types/StepHistoryDataType.js';
@@ -66,13 +66,31 @@ function checkIfStepsIsEqual(step1, step2) {
66
66
 
67
67
  // src/classes/Label.ts
68
68
  var Label = class {
69
+ /**
70
+ * @param id is the id of the label
71
+ * @param steps is the list of steps that the label will perform
72
+ * @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
73
+ * @param choiseIndex is the index of the choice that the label will perform
74
+ */
75
+ constructor(id, steps, onStepRun, choiseIndex) {
76
+ this._id = id;
77
+ this._steps = steps;
78
+ this._onStepRun = onStepRun;
79
+ this._choiseIndex = choiseIndex;
80
+ }
81
+ /**
82
+ * Get the id of the label
83
+ */
84
+ get id() {
85
+ return this._id;
86
+ }
69
87
  /**
70
88
  * Get the steps of the label.
71
89
  * This class should be extended and the steps method should be overridden.
72
90
  * Every time you update this list will also be updated when the other game versions load.
73
91
  */
74
92
  get steps() {
75
- throw new Error("[Pixi'VN] The method Label.steps must be overridden");
93
+ return this._steps;
76
94
  }
77
95
  /**
78
96
  * Get the corresponding steps number
@@ -91,62 +109,34 @@ var Label = class {
91
109
  });
92
110
  return res;
93
111
  }
94
- };
95
-
96
- // src/types/PauseType.ts
97
- var PauseValueType = "pause";
98
-
99
- // src/types/RepeatType.ts
100
- var Repeat = "repeat";
101
-
102
- // src/classes/ChoiceMenuOption.ts
103
- var ChoiceMenuOption = class {
104
112
  /**
105
- * @param text Text to be displayed in the menu
106
- * @param label Label to be opened when the option is selected
107
- * @param type Type of the label to be opened
108
- * @param props Properties to be passed to the label, when the label is called. it cannot contain functions or classes.
113
+ * 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
114
+ * @returns Promise<void> or void
115
+ * @example
116
+ * ```typescript
117
+ * newLabel("id", [], () => {
118
+ * Assets.load('path/to/image1.png')
119
+ * Assets.load('path/to/image2.png')
120
+ * })
121
+ * ```
109
122
  */
110
- constructor(text, label, type = "call", props) {
111
- /**
112
- * Properties to be passed to the label
113
- */
114
- this.props = {};
115
- this.text = text;
116
- this.label = new label();
117
- this.type = type;
118
- if (props) {
119
- this.props = props;
120
- }
123
+ get onStepRun() {
124
+ return this._onStepRun;
125
+ }
126
+ get choiseIndex() {
127
+ return this._choiseIndex;
121
128
  }
122
129
  };
123
130
 
124
- // src/decorators/CanvasElementDecorator.ts
125
- var registeredCanvasElement = {};
126
- function getCanvasElementInstanceByClassName(canvasName) {
127
- try {
128
- let eventType = registeredCanvasElement[canvasName];
129
- if (!eventType) {
130
- if (canvasName === "CanvasContainer") {
131
- eventType = CanvasContainer;
132
- } else if (canvasName === "CanvasImage") {
133
- eventType = CanvasImage;
134
- } else if (canvasName === "CanvasSprite") {
135
- eventType = CanvasSprite;
136
- } else if (canvasName === "CanvasText") {
137
- eventType = CanvasText;
138
- }
139
- }
140
- if (!eventType) {
141
- console.error(`[Pixi'VN] CanvasElement ${canvasName} not found`);
142
- return;
143
- }
144
- let canvasElement = new eventType();
145
- return canvasElement;
146
- } catch (e) {
147
- console.error(`[Pixi'VN] Error while getting CanvasElement ${canvasName}`, e);
131
+ // src/decorators/LabelDecorator.ts
132
+ var registeredLabels = {};
133
+ function getLabelById(id) {
134
+ let label = registeredLabels[id];
135
+ if (!label) {
136
+ console.error(`[Pixi'VN] Label ${id} not found`);
148
137
  return;
149
138
  }
139
+ return label;
150
140
  }
151
141
 
152
142
  // src/functions/CanvasUtility.ts
@@ -584,29 +574,33 @@ function setMemoryText(element, memory) {
584
574
  }
585
575
  }
586
576
 
587
- // src/classes/ticker/TickerBase.ts
588
- var TickerBase = class {
589
- /**
590
- * @param args The arguments that you want to pass to the ticker.
591
- * @param duration The duration of the ticker. If is undefined, the ticker will be called every frame.
592
- * @param priority The priority of the ticker. If is undefined, the priority will be UPDATE_PRIORITY.NORMAL.
593
- */
594
- constructor(args, duration, priority) {
595
- this.args = args;
596
- this.duration = duration;
597
- this.priority = priority;
598
- }
599
- /**
600
- * The method that will be called every frame.
601
- * This method should be overridden and you can use GameWindowManager.addCanvasElement() to get the canvas element of the canvas, and edit them.
602
- * @param t The ticker that is calling this method
603
- * @param args The arguments that you passed when you added the ticker
604
- * @param tags The tags of the canvas elements that are connected to this ticker
605
- */
606
- fn(_t, _args, _tags) {
607
- throw new Error("[Pixi'VN] The method TickerBase.fn() must be overridden");
577
+ // src/decorators/CanvasElementDecorator.ts
578
+ var registeredCanvasElement = {};
579
+ function getCanvasElementInstanceByClassName(canvasName) {
580
+ try {
581
+ let eventType = registeredCanvasElement[canvasName];
582
+ if (!eventType) {
583
+ if (canvasName === "CanvasContainer") {
584
+ eventType = CanvasContainer;
585
+ } else if (canvasName === "CanvasImage") {
586
+ eventType = CanvasImage;
587
+ } else if (canvasName === "CanvasSprite") {
588
+ eventType = CanvasSprite;
589
+ } else if (canvasName === "CanvasText") {
590
+ eventType = CanvasText;
591
+ }
592
+ }
593
+ if (!eventType) {
594
+ console.error(`[Pixi'VN] CanvasElement ${canvasName} not found`);
595
+ return;
596
+ }
597
+ let canvasElement = new eventType();
598
+ return canvasElement;
599
+ } catch (e) {
600
+ console.error(`[Pixi'VN] Error while getting CanvasElement ${canvasName}`, e);
601
+ return;
608
602
  }
609
- };
603
+ }
610
604
 
611
605
  // src/decorators/TickerDecorator.ts
612
606
  var registeredTickers = {};
@@ -635,7 +629,65 @@ function geTickerInstanceByClassName(tickerName, args, duration, priority) {
635
629
  }
636
630
  }
637
631
 
638
- // src/classes/ticker/TickerFadeAlpha.ts
632
+ // src/types/PauseType.ts
633
+ var PauseValueType = "pause";
634
+
635
+ // src/types/RepeatType.ts
636
+ var Repeat = "repeat";
637
+
638
+ // src/classes/ChoiceMenuOption.ts
639
+ var ChoiceMenuOption = class {
640
+ /**
641
+ * @param text Text to be displayed in the menu
642
+ * @param label Label to be opened when the option is selected or the id of the label
643
+ * @param type Type of the label to be opened. @default "call"
644
+ * @param props Properties to be passed to the label, when the label is called. it cannot contain functions or classes. @default {}
645
+ */
646
+ constructor(text, label, type = "call", props) {
647
+ /**
648
+ * Properties to be passed to the label
649
+ */
650
+ this.props = {};
651
+ if (typeof label === "string") {
652
+ let tLabel = getLabelById(label);
653
+ if (!tLabel) {
654
+ throw new Error(`[Pixi'VN] Label ${label} not found`);
655
+ } else {
656
+ label = tLabel;
657
+ }
658
+ }
659
+ this.text = text;
660
+ this.label = label;
661
+ this.type = type;
662
+ if (props) {
663
+ this.props = props;
664
+ }
665
+ }
666
+ };
667
+
668
+ // src/classes/ticker/TickerBase.ts
669
+ var TickerBase = class {
670
+ /**
671
+ * @param args The arguments that you want to pass to the ticker.
672
+ * @param duration The duration of the ticker. If is undefined, the ticker will be called every frame.
673
+ * @param priority The priority of the ticker. If is undefined, the priority will be UPDATE_PRIORITY.NORMAL.
674
+ */
675
+ constructor(args, duration, priority) {
676
+ this.args = args;
677
+ this.duration = duration;
678
+ this.priority = priority;
679
+ }
680
+ /**
681
+ * The method that will be called every frame.
682
+ * This method should be overridden and you can use GameWindowManager.addCanvasElement() to get the canvas element of the canvas, and edit them.
683
+ * @param t The ticker that is calling this method
684
+ * @param args The arguments that you passed when you added the ticker
685
+ * @param tags The tags of the canvas elements that are connected to this ticker
686
+ */
687
+ fn(_t, _args, _tags) {
688
+ throw new Error("[Pixi'VN] The method TickerBase.fn() must be overridden");
689
+ }
690
+ };
639
691
  var TickerFadeAlpha = class extends TickerBase {
640
692
  /**
641
693
  * The method that will be called every frame to fade the alpha of the canvas element of the canvas.