@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
  import { diff } from 'deep-diff';
2
- import { Sprite, Container, Application, Text, Assets, Texture } from 'pixi.js';
3
2
  import sha1 from 'crypto-js/sha1';
3
+ import { Sprite, Container, Application, Text, Assets, Texture } from 'pixi.js';
4
4
 
5
5
  var __defProp = Object.defineProperty;
6
6
  var __defProps = Object.defineProperties;
@@ -51,6 +51,13 @@ var __async = (__this, __arguments, generator) => {
51
51
  step((generator = generator.apply(__this, __arguments)).next());
52
52
  });
53
53
  };
54
+ function getStepSha1(step) {
55
+ let sha1String = sha1(step.toString().toLocaleLowerCase());
56
+ return sha1String.toString();
57
+ }
58
+
59
+ // src/classes/CloseLabel.ts
60
+ var CLOSE_LABEL_ID = "__close-label-id__";
54
61
 
55
62
  // src/functions/ExportUtility.ts
56
63
  function createExportableElement(element) {
@@ -1242,66 +1249,16 @@ _GameWindowManager._currentTickers = [];
1242
1249
  _GameWindowManager._currentTickersSteps = {};
1243
1250
  _GameWindowManager.currentTickersTimeouts = {};
1244
1251
  var GameWindowManager = _GameWindowManager;
1245
- function getStepSha1(step) {
1246
- let sha1String = sha1(step.toString().toLocaleLowerCase());
1247
- return sha1String.toString();
1248
- }
1249
- function checkIfStepsIsEqual(step1, step2) {
1250
- return step1 === step2;
1251
- }
1252
-
1253
- // src/classes/Label.ts
1254
- var Label = class {
1255
- /**
1256
- * Get the steps of the label.
1257
- * This class should be extended and the steps method should be overridden.
1258
- * Every time you update this list will also be updated when the other game versions load.
1259
- */
1260
- get steps() {
1261
- throw new Error("[Pixi'VN] The method Label.steps must be overridden");
1262
- }
1263
- /**
1264
- * Get the corresponding steps number
1265
- * @param externalSteps
1266
- * @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
1267
- */
1268
- getCorrespondingStepsNumber(externalSteps) {
1269
- if (externalSteps.length === 0) {
1270
- return 0;
1271
- }
1272
- let res = 0;
1273
- externalSteps.forEach((step, index) => {
1274
- if (checkIfStepsIsEqual(step, this.steps[index])) {
1275
- res = index;
1276
- }
1277
- });
1278
- return res;
1279
- }
1280
- };
1281
-
1282
- // src/classes/CloseLabel.ts
1283
- var CloseLabel = class extends Label {
1284
- };
1285
1252
 
1286
1253
  // src/decorators/LabelDecorator.ts
1287
1254
  var registeredLabels = {};
1288
- function getLabelInstanceByClassName(labelName) {
1289
- try {
1290
- let labelType = registeredLabels[labelName];
1291
- if (!labelType) {
1292
- console.error(`[Pixi'VN] Label ${labelName} not found`);
1293
- return;
1294
- }
1295
- let label = new labelType();
1296
- let step = label.steps;
1297
- if (step.length = 0) {
1298
- console.warn(`[Pixi'VN] Label ${labelName} has no steps`);
1299
- }
1300
- return label;
1301
- } catch (e) {
1302
- console.error(`[Pixi'VN] Error while getting Label ${labelName}`, e);
1255
+ function getLabelById(id) {
1256
+ let label = registeredLabels[id];
1257
+ if (!label) {
1258
+ console.error(`[Pixi'VN] Label ${id} not found`);
1303
1259
  return;
1304
1260
  }
1261
+ return label;
1305
1262
  }
1306
1263
 
1307
1264
  // src/functions/DialogueUtility.ts
@@ -1548,7 +1505,7 @@ var _GameStepManager = class _GameStepManager {
1548
1505
  */
1549
1506
  static get currentLabel() {
1550
1507
  if (_GameStepManager.currentLabelId) {
1551
- return getLabelInstanceByClassName(_GameStepManager.currentLabelId);
1508
+ return getLabelById(_GameStepManager.currentLabelId);
1552
1509
  }
1553
1510
  }
1554
1511
  static get currentLabelStepIndex() {
@@ -1569,7 +1526,7 @@ var _GameStepManager = class _GameStepManager {
1569
1526
  return true;
1570
1527
  } else {
1571
1528
  this.openedLabels.forEach((item) => {
1572
- let label = getLabelInstanceByClassName(item.label);
1529
+ let label = getLabelById(item.label);
1573
1530
  if (label && label.steps.length > item.currentStepIndex) {
1574
1531
  return false;
1575
1532
  }
@@ -1662,9 +1619,9 @@ var _GameStepManager = class _GameStepManager {
1662
1619
  * @param label The label to add to the history.
1663
1620
  */
1664
1621
  static pushNewLabel(label) {
1665
- let currentLabel = getLabelInstanceByClassName(label);
1622
+ let currentLabel = getLabelById(label);
1666
1623
  if (!currentLabel) {
1667
- throw new Error("[Pixi'VN] Label not found");
1624
+ throw new Error(`[Pixi'VN] Label ${label} not found`);
1668
1625
  }
1669
1626
  _GameStepManager._openedLabels.push({
1670
1627
  label,
@@ -1681,7 +1638,7 @@ var _GameStepManager = class _GameStepManager {
1681
1638
  return;
1682
1639
  }
1683
1640
  if (!_GameStepManager.currentLabel) {
1684
- console.error("[Pixi'VN] Label not found");
1641
+ console.error("[Pixi'VN] currentLabel not found");
1685
1642
  return;
1686
1643
  }
1687
1644
  _GameStepManager._openedLabels.pop();
@@ -1753,7 +1710,7 @@ var _GameStepManager = class _GameStepManager {
1753
1710
  }
1754
1711
  let currentLabel = _GameStepManager.currentLabel;
1755
1712
  if (!currentLabel) {
1756
- console.error("[Pixi'VN] Label not found");
1713
+ console.error("[Pixi'VN] currentLabel not found");
1757
1714
  return;
1758
1715
  }
1759
1716
  let n = currentLabel.steps.length;
@@ -1774,12 +1731,12 @@ var _GameStepManager = class _GameStepManager {
1774
1731
  /**
1775
1732
  * Execute the label and add it to the history.
1776
1733
  * Is a call function in Ren'Py.
1777
- * @param label The label to execute.
1734
+ * @param label The label to execute or the id of the label
1778
1735
  * @param props The props to pass to the label.
1779
1736
  * @returns StepLabelResultType or undefined.
1780
1737
  * @example
1781
1738
  * ```typescript
1782
- * GameStepManager.callLabel(StartLabel, yourParams).then((result) => {
1739
+ * GameStepManager.callLabel(startLabel, yourParams).then((result) => {
1783
1740
  * if (result) {
1784
1741
  * // your code
1785
1742
  * }
@@ -1788,7 +1745,7 @@ var _GameStepManager = class _GameStepManager {
1788
1745
  * @example
1789
1746
  * ```typescript
1790
1747
  * // if you use it in a step label you should return the result.
1791
- * return GameStepManager.callLabel(StartLabel).then((result) => {
1748
+ * return GameStepManager.callLabel(startLabel).then((result) => {
1792
1749
  * return result
1793
1750
  * })
1794
1751
  * ```
@@ -1796,16 +1753,24 @@ var _GameStepManager = class _GameStepManager {
1796
1753
  static callLabel(label, props) {
1797
1754
  return __async(this, null, function* () {
1798
1755
  let choiseMade = void 0;
1756
+ let labelId;
1757
+ if (typeof label === "string") {
1758
+ labelId = label;
1759
+ } else {
1760
+ labelId = label.id;
1761
+ if (typeof label.choiseIndex === "number") {
1762
+ choiseMade = label.choiseIndex;
1763
+ }
1764
+ }
1799
1765
  try {
1800
- if (label instanceof CloseLabel) {
1766
+ if (labelId === CLOSE_LABEL_ID) {
1801
1767
  return _GameStepManager.runNextStep(props);
1802
1768
  }
1803
- if (label instanceof Label) {
1804
- choiseMade = label.choiseIndex;
1805
- label = label.constructor;
1769
+ let tempLabel = getLabelById(labelId);
1770
+ if (!tempLabel) {
1771
+ throw new Error(`[Pixi'VN] Label ${labelId} not found`);
1806
1772
  }
1807
- let labelName = label.name;
1808
- _GameStepManager.pushNewLabel(labelName);
1773
+ _GameStepManager.pushNewLabel(tempLabel.id);
1809
1774
  } catch (e) {
1810
1775
  console.error("[Pixi'VN] Error calling label", e);
1811
1776
  return;
@@ -1817,11 +1782,11 @@ var _GameStepManager = class _GameStepManager {
1817
1782
  * Execute the label, close all labels and add them to the history.
1818
1783
  * Is a jump function in Ren'Py.
1819
1784
  * @param label The label to execute.
1820
- * @param props The props to pass to the label.
1785
+ * @param props The props to pass to the label or the id of the label
1821
1786
  * @returns StepLabelResultType or undefined.
1822
1787
  * @example
1823
1788
  * ```typescript
1824
- * GameStepManager.jumpLabel(StartLabel, yourParams).then((result) => {
1789
+ * GameStepManager.jumpLabel(startLabel, yourParams).then((result) => {
1825
1790
  * if (result) {
1826
1791
  * // your code
1827
1792
  * }
@@ -1830,7 +1795,7 @@ var _GameStepManager = class _GameStepManager {
1830
1795
  * @example
1831
1796
  * ```typescript
1832
1797
  * // if you use it in a step label you should return the result.
1833
- * return GameStepManager.jumpLabel(StartLabel).then((result) => {
1798
+ * return GameStepManager.jumpLabel(startLabel).then((result) => {
1834
1799
  * return result
1835
1800
  * })
1836
1801
  * ```
@@ -1838,15 +1803,24 @@ var _GameStepManager = class _GameStepManager {
1838
1803
  static jumpLabel(label, props) {
1839
1804
  return __async(this, null, function* () {
1840
1805
  _GameStepManager.closeAllLabels();
1806
+ let labelId;
1807
+ if (typeof label === "string") {
1808
+ labelId = label;
1809
+ } else {
1810
+ labelId = label.id;
1811
+ if (typeof label.choiseIndex === "number") {
1812
+ label.choiseIndex;
1813
+ }
1814
+ }
1841
1815
  try {
1842
- if (label instanceof CloseLabel) {
1816
+ if (labelId === CLOSE_LABEL_ID) {
1843
1817
  return _GameStepManager.runNextStep(props);
1844
1818
  }
1845
- if (label instanceof Label) {
1846
- label = label.constructor;
1819
+ let tempLabel = getLabelById(labelId);
1820
+ if (!tempLabel) {
1821
+ throw new Error(`[Pixi'VN] Label ${labelId} not found`);
1847
1822
  }
1848
- let labelName = label.name;
1849
- _GameStepManager.pushNewLabel(labelName);
1823
+ _GameStepManager.pushNewLabel(tempLabel.id);
1850
1824
  } catch (e) {
1851
1825
  console.error("[Pixi'VN] Error jumping label", e);
1852
1826
  return;
@@ -1860,14 +1834,14 @@ var _GameStepManager = class _GameStepManager {
1860
1834
  * @returns StepLabelResultType or undefined.
1861
1835
  * @example
1862
1836
  * ```typescript
1863
- * GameStepManager.exitToChoiceMenu(yourParams).then((result) => {
1837
+ * GameStepManager.closeChoiceMenu(yourParams).then((result) => {
1864
1838
  * if (result) {
1865
1839
  * // your code
1866
1840
  * }
1867
1841
  * })
1868
1842
  * ```
1869
1843
  */
1870
- static exitToChoiceMenu(props) {
1844
+ static closeChoiceMenu(props) {
1871
1845
  return __async(this, null, function* () {
1872
1846
  return _GameStepManager.runNextStep(props);
1873
1847
  });