@drincs/pixi-vn 0.6.0 → 0.6.2

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 (415) hide show
  1. package/dist/{TickerBase-RQDWNI4K.d.ts → TickerBase-3rLpDpmb.d.ts} +27 -13
  2. package/dist/{TickerBase-B5CQCJs8.d.mts → TickerBase-DKYzbzro.d.mts} +27 -13
  3. package/dist/classes/CanvasEvent.d.mts +7 -1
  4. package/dist/classes/CanvasEvent.d.ts +7 -1
  5. package/dist/classes/CanvasEvent.js +7 -0
  6. package/dist/classes/CanvasEvent.js.map +1 -1
  7. package/dist/classes/CanvasEvent.mjs +7 -0
  8. package/dist/classes/CanvasEvent.mjs.map +1 -1
  9. package/dist/classes/CharacterBaseModel.d.mts +2 -26
  10. package/dist/classes/CharacterBaseModel.d.ts +2 -26
  11. package/dist/classes/CharacterBaseModel.js +544 -241
  12. package/dist/classes/CharacterBaseModel.js.map +1 -1
  13. package/dist/classes/CharacterBaseModel.mjs +540 -241
  14. package/dist/classes/CharacterBaseModel.mjs.map +1 -1
  15. package/dist/classes/ChoiceMenuOption.d.mts +27 -17
  16. package/dist/classes/ChoiceMenuOption.d.ts +27 -17
  17. package/dist/classes/ChoiceMenuOption.js +548 -243
  18. package/dist/classes/ChoiceMenuOption.js.map +1 -1
  19. package/dist/classes/ChoiceMenuOption.mjs +544 -243
  20. package/dist/classes/ChoiceMenuOption.mjs.map +1 -1
  21. package/dist/classes/CloseLabel.d.mts +1 -1
  22. package/dist/classes/CloseLabel.d.ts +1 -1
  23. package/dist/classes/CloseLabel.js +1 -1
  24. package/dist/classes/CloseLabel.js.map +1 -1
  25. package/dist/classes/CloseLabel.mjs +1 -1
  26. package/dist/classes/CloseLabel.mjs.map +1 -1
  27. package/dist/classes/DialogueBaseModel.d.mts +3 -2
  28. package/dist/classes/DialogueBaseModel.d.ts +3 -2
  29. package/dist/classes/DialogueBaseModel.js +5 -5
  30. package/dist/classes/DialogueBaseModel.js.map +1 -1
  31. package/dist/classes/DialogueBaseModel.mjs +5 -5
  32. package/dist/classes/DialogueBaseModel.mjs.map +1 -1
  33. package/dist/classes/Label.d.mts +1 -1
  34. package/dist/classes/Label.d.ts +1 -1
  35. package/dist/classes/Label.js +1 -1
  36. package/dist/classes/Label.js.map +1 -1
  37. package/dist/classes/Label.mjs +1 -1
  38. package/dist/classes/Label.mjs.map +1 -1
  39. package/dist/classes/StoredClassModel.d.mts +2 -2
  40. package/dist/classes/StoredClassModel.d.ts +2 -2
  41. package/dist/classes/StoredClassModel.js +544 -241
  42. package/dist/classes/StoredClassModel.js.map +1 -1
  43. package/dist/classes/StoredClassModel.mjs +540 -241
  44. package/dist/classes/StoredClassModel.mjs.map +1 -1
  45. package/dist/classes/canvas/CanvasBase.d.mts +5 -1
  46. package/dist/classes/canvas/CanvasBase.d.ts +5 -1
  47. package/dist/classes/canvas/CanvasBase.js +7 -0
  48. package/dist/classes/canvas/CanvasBase.js.map +1 -1
  49. package/dist/classes/canvas/CanvasBase.mjs +7 -0
  50. package/dist/classes/canvas/CanvasBase.mjs.map +1 -1
  51. package/dist/classes/canvas/CanvasContainer.d.mts +4 -1
  52. package/dist/classes/canvas/CanvasContainer.d.ts +4 -1
  53. package/dist/classes/canvas/CanvasContainer.js +57 -37
  54. package/dist/classes/canvas/CanvasContainer.js.map +1 -1
  55. package/dist/classes/canvas/CanvasContainer.mjs +57 -38
  56. package/dist/classes/canvas/CanvasContainer.mjs.map +1 -1
  57. package/dist/classes/canvas/CanvasImage.d.mts +4 -2
  58. package/dist/classes/canvas/CanvasImage.d.ts +4 -2
  59. package/dist/classes/canvas/CanvasImage.js +33 -20
  60. package/dist/classes/canvas/CanvasImage.js.map +1 -1
  61. package/dist/classes/canvas/CanvasImage.mjs +30 -20
  62. package/dist/classes/canvas/CanvasImage.mjs.map +1 -1
  63. package/dist/classes/canvas/CanvasSprite.d.mts +6 -3
  64. package/dist/classes/canvas/CanvasSprite.d.ts +6 -3
  65. package/dist/classes/canvas/CanvasSprite.js +25 -17
  66. package/dist/classes/canvas/CanvasSprite.js.map +1 -1
  67. package/dist/classes/canvas/CanvasSprite.mjs +25 -18
  68. package/dist/classes/canvas/CanvasSprite.mjs.map +1 -1
  69. package/dist/classes/canvas/CanvasText.d.mts +6 -3
  70. package/dist/classes/canvas/CanvasText.d.ts +6 -3
  71. package/dist/classes/canvas/CanvasText.js +25 -17
  72. package/dist/classes/canvas/CanvasText.js.map +1 -1
  73. package/dist/classes/canvas/CanvasText.mjs +25 -18
  74. package/dist/classes/canvas/CanvasText.mjs.map +1 -1
  75. package/dist/classes/canvas/index.js +184 -158
  76. package/dist/classes/canvas/index.js.map +1 -1
  77. package/dist/classes/canvas/index.mjs +184 -158
  78. package/dist/classes/canvas/index.mjs.map +1 -1
  79. package/dist/classes/index.d.mts +6 -4
  80. package/dist/classes/index.d.ts +6 -4
  81. package/dist/classes/index.js +560 -248
  82. package/dist/classes/index.js.map +1 -1
  83. package/dist/classes/index.mjs +556 -248
  84. package/dist/classes/index.mjs.map +1 -1
  85. package/dist/classes/ticker/FadeAlphaTicker.d.mts +27 -0
  86. package/dist/classes/ticker/FadeAlphaTicker.d.ts +27 -0
  87. package/dist/classes/ticker/{TickerFadeAlpha.js → FadeAlphaTicker.js} +549 -248
  88. package/dist/classes/ticker/FadeAlphaTicker.js.map +1 -0
  89. package/dist/classes/ticker/{TickerRotate.mjs → FadeAlphaTicker.mjs} +571 -274
  90. package/dist/classes/ticker/FadeAlphaTicker.mjs.map +1 -0
  91. package/dist/classes/ticker/MoveTicker.d.mts +25 -0
  92. package/dist/classes/ticker/MoveTicker.d.ts +25 -0
  93. package/dist/classes/ticker/{TickerMove.js → MoveTicker.js} +544 -241
  94. package/dist/classes/ticker/MoveTicker.js.map +1 -0
  95. package/dist/classes/ticker/{TickerFadeAlpha.mjs → MoveTicker.mjs} +568 -269
  96. package/dist/classes/ticker/MoveTicker.mjs.map +1 -0
  97. package/dist/classes/ticker/RotateTicker.d.mts +27 -0
  98. package/dist/classes/ticker/RotateTicker.d.ts +27 -0
  99. package/dist/classes/ticker/{TickerRotate.js → RotateTicker.js} +544 -241
  100. package/dist/classes/ticker/RotateTicker.js.map +1 -0
  101. package/dist/classes/ticker/{TickerMove.mjs → RotateTicker.mjs} +558 -259
  102. package/dist/classes/ticker/RotateTicker.mjs.map +1 -0
  103. package/dist/classes/ticker/TickerBase.d.mts +2 -1
  104. package/dist/classes/ticker/TickerBase.d.ts +2 -1
  105. package/dist/classes/ticker/TickerBase.js +12 -6
  106. package/dist/classes/ticker/TickerBase.js.map +1 -1
  107. package/dist/classes/ticker/TickerBase.mjs +12 -6
  108. package/dist/classes/ticker/TickerBase.mjs.map +1 -1
  109. package/dist/classes/ticker/ZoomTicker.d.mts +31 -0
  110. package/dist/classes/ticker/ZoomTicker.d.ts +31 -0
  111. package/dist/classes/ticker/ZoomTicker.js +1647 -0
  112. package/dist/classes/ticker/ZoomTicker.js.map +1 -0
  113. package/dist/classes/ticker/ZoomTicker.mjs +1639 -0
  114. package/dist/classes/ticker/ZoomTicker.mjs.map +1 -0
  115. package/dist/classes/ticker/index.d.mts +11 -8
  116. package/dist/classes/ticker/index.d.ts +11 -8
  117. package/dist/classes/ticker/index.js +567 -266
  118. package/dist/classes/ticker/index.js.map +1 -1
  119. package/dist/classes/ticker/index.mjs +564 -267
  120. package/dist/classes/ticker/index.mjs.map +1 -1
  121. package/dist/constants.d.mts +12 -2
  122. package/dist/constants.d.ts +12 -2
  123. package/dist/constants.js +10 -1
  124. package/dist/constants.js.map +1 -1
  125. package/dist/constants.mjs +9 -2
  126. package/dist/constants.mjs.map +1 -1
  127. package/dist/decorators/CanvasElementDecorator.d.mts +3 -3
  128. package/dist/decorators/CanvasElementDecorator.d.ts +3 -3
  129. package/dist/decorators/CanvasElementDecorator.js +63 -43
  130. package/dist/decorators/CanvasElementDecorator.js.map +1 -1
  131. package/dist/decorators/CanvasElementDecorator.mjs +62 -42
  132. package/dist/decorators/CanvasElementDecorator.mjs.map +1 -1
  133. package/dist/decorators/CharacterDecorator.d.mts +1 -0
  134. package/dist/decorators/CharacterDecorator.d.ts +1 -0
  135. package/dist/decorators/CharacterDecorator.js +1 -1
  136. package/dist/decorators/CharacterDecorator.js.map +1 -1
  137. package/dist/decorators/CharacterDecorator.mjs +1 -1
  138. package/dist/decorators/CharacterDecorator.mjs.map +1 -1
  139. package/dist/decorators/EventDecorator.d.mts +7 -7
  140. package/dist/decorators/EventDecorator.d.ts +7 -7
  141. package/dist/decorators/EventDecorator.js +12 -11
  142. package/dist/decorators/EventDecorator.js.map +1 -1
  143. package/dist/decorators/EventDecorator.mjs +11 -10
  144. package/dist/decorators/EventDecorator.mjs.map +1 -1
  145. package/dist/decorators/LabelDecorator.d.mts +4 -3
  146. package/dist/decorators/LabelDecorator.d.ts +4 -3
  147. package/dist/decorators/LabelDecorator.js +546 -243
  148. package/dist/decorators/LabelDecorator.js.map +1 -1
  149. package/dist/decorators/LabelDecorator.mjs +542 -243
  150. package/dist/decorators/LabelDecorator.mjs.map +1 -1
  151. package/dist/decorators/TickerDecorator.d.mts +9 -6
  152. package/dist/decorators/TickerDecorator.d.ts +9 -6
  153. package/dist/decorators/TickerDecorator.js +7 -6
  154. package/dist/decorators/TickerDecorator.js.map +1 -1
  155. package/dist/decorators/TickerDecorator.mjs +7 -6
  156. package/dist/decorators/TickerDecorator.mjs.map +1 -1
  157. package/dist/decorators/index.d.mts +4 -3
  158. package/dist/decorators/index.d.ts +4 -3
  159. package/dist/decorators/index.js +550 -245
  160. package/dist/decorators/index.js.map +1 -1
  161. package/dist/decorators/index.mjs +546 -245
  162. package/dist/decorators/index.mjs.map +1 -1
  163. package/dist/functions/CanvasUtility.js +56 -37
  164. package/dist/functions/CanvasUtility.js.map +1 -1
  165. package/dist/functions/CanvasUtility.mjs +56 -37
  166. package/dist/functions/CanvasUtility.mjs.map +1 -1
  167. package/dist/functions/DialogueUtility.d.mts +7 -5
  168. package/dist/functions/DialogueUtility.d.ts +7 -5
  169. package/dist/functions/DialogueUtility.js +729 -397
  170. package/dist/functions/DialogueUtility.js.map +1 -1
  171. package/dist/functions/DialogueUtility.mjs +729 -397
  172. package/dist/functions/DialogueUtility.mjs.map +1 -1
  173. package/dist/functions/FlagsUtility.js +544 -241
  174. package/dist/functions/FlagsUtility.js.map +1 -1
  175. package/dist/functions/FlagsUtility.mjs +540 -241
  176. package/dist/functions/FlagsUtility.mjs.map +1 -1
  177. package/dist/functions/GameUtility.js +544 -241
  178. package/dist/functions/GameUtility.js.map +1 -1
  179. package/dist/functions/GameUtility.mjs +540 -241
  180. package/dist/functions/GameUtility.mjs.map +1 -1
  181. package/dist/functions/ImageUtility.d.mts +81 -8
  182. package/dist/functions/ImageUtility.d.ts +81 -8
  183. package/dist/functions/ImageUtility.js +911 -387
  184. package/dist/functions/ImageUtility.js.map +1 -1
  185. package/dist/functions/ImageUtility.mjs +899 -387
  186. package/dist/functions/ImageUtility.mjs.map +1 -1
  187. package/dist/functions/SavesUtility.d.mts +9 -5
  188. package/dist/functions/SavesUtility.d.ts +9 -5
  189. package/dist/functions/SavesUtility.js +611 -252
  190. package/dist/functions/SavesUtility.js.map +1 -1
  191. package/dist/functions/SavesUtility.mjs +611 -252
  192. package/dist/functions/SavesUtility.mjs.map +1 -1
  193. package/dist/functions/TickerUtility.d.mts +1 -1
  194. package/dist/functions/TickerUtility.d.ts +1 -1
  195. package/dist/functions/TickerUtility.js +32 -18
  196. package/dist/functions/TickerUtility.js.map +1 -1
  197. package/dist/functions/TickerUtility.mjs +32 -18
  198. package/dist/functions/TickerUtility.mjs.map +1 -1
  199. package/dist/functions/index.d.mts +18 -8
  200. package/dist/functions/index.d.ts +18 -8
  201. package/dist/functions/index.js +832 -279
  202. package/dist/functions/index.js.map +1 -1
  203. package/dist/functions/index.mjs +825 -280
  204. package/dist/functions/index.mjs.map +1 -1
  205. package/dist/index.d.mts +25 -16
  206. package/dist/index.d.ts +25 -16
  207. package/dist/index.js +1547 -290
  208. package/dist/index.js.map +1 -1
  209. package/dist/index.mjs +1538 -290
  210. package/dist/index.mjs.map +1 -1
  211. package/dist/interface/CharacterBaseModelProps.d.mts +27 -0
  212. package/dist/interface/CharacterBaseModelProps.d.ts +27 -0
  213. package/dist/interface/CharacterBaseModelProps.js +4 -0
  214. package/dist/interface/CharacterBaseModelProps.mjs +3 -0
  215. package/dist/interface/DialogueHistory.d.mts +3 -7
  216. package/dist/interface/DialogueHistory.d.ts +3 -7
  217. package/dist/interface/IHistoryStep.d.mts +12 -8
  218. package/dist/interface/IHistoryStep.d.ts +12 -8
  219. package/dist/interface/ISaveData.d.mts +8 -4
  220. package/dist/interface/ISaveData.d.ts +8 -4
  221. package/dist/interface/ITicker.d.mts +2 -1
  222. package/dist/interface/ITicker.d.ts +2 -1
  223. package/dist/interface/ITickersSteps.d.mts +14 -5
  224. package/dist/interface/ITickersSteps.d.ts +14 -5
  225. package/dist/interface/TickerHistory.d.mts +29 -0
  226. package/dist/interface/TickerHistory.d.ts +29 -0
  227. package/dist/{types/ticker/TickerMoveProps.js → interface/TickerHistory.js} +1 -1
  228. package/dist/interface/TickerHistory.mjs +3 -0
  229. package/dist/interface/TickerProgrationType.d.mts +13 -1
  230. package/dist/interface/TickerProgrationType.d.ts +13 -1
  231. package/dist/interface/TickerTimeoutHistory.d.mts +7 -0
  232. package/dist/interface/TickerTimeoutHistory.d.ts +7 -0
  233. package/dist/interface/TickerTimeoutHistory.js +4 -0
  234. package/dist/interface/TickerTimeoutHistory.mjs +3 -0
  235. package/dist/interface/canvas/ICanvasBaseMemory.d.mts +1 -1
  236. package/dist/interface/canvas/ICanvasBaseMemory.d.ts +1 -1
  237. package/dist/interface/canvas/ICanvasImageMemory.d.mts +1 -1
  238. package/dist/interface/canvas/ICanvasImageMemory.d.ts +1 -1
  239. package/dist/interface/canvas/ICanvasSpriteMemory.d.mts +0 -1
  240. package/dist/interface/canvas/ICanvasSpriteMemory.d.ts +0 -1
  241. package/dist/interface/canvas/ICanvasTextTextMemory.d.mts +0 -1
  242. package/dist/interface/canvas/ICanvasTextTextMemory.d.ts +0 -1
  243. package/dist/interface/export/ExportedCanvas.d.mts +11 -3
  244. package/dist/interface/export/ExportedCanvas.d.ts +11 -3
  245. package/dist/interface/export/ExportedStep.d.mts +7 -3
  246. package/dist/interface/export/ExportedStep.d.ts +7 -3
  247. package/dist/interface/export/index.d.mts +8 -4
  248. package/dist/interface/export/index.d.ts +8 -4
  249. package/dist/interface/index.d.mts +14 -11
  250. package/dist/interface/index.d.ts +14 -11
  251. package/dist/labels/BaseCanvasElementTestLabel.d.mts +9 -0
  252. package/dist/labels/BaseCanvasElementTestLabel.d.ts +9 -0
  253. package/dist/labels/BaseCanvasElementTestLabel.js +1888 -0
  254. package/dist/labels/BaseCanvasElementTestLabel.js.map +1 -0
  255. package/dist/labels/BaseCanvasElementTestLabel.mjs +1882 -0
  256. package/dist/labels/BaseCanvasElementTestLabel.mjs.map +1 -0
  257. package/dist/labels/CanvasEventsTestLabel.d.mts +27 -0
  258. package/dist/labels/CanvasEventsTestLabel.d.ts +27 -0
  259. package/dist/labels/CanvasEventsTestLabel.js +2822 -0
  260. package/dist/labels/CanvasEventsTestLabel.js.map +1 -0
  261. package/dist/labels/CanvasEventsTestLabel.mjs +2816 -0
  262. package/dist/labels/CanvasEventsTestLabel.mjs.map +1 -0
  263. package/dist/labels/CustomTickerCanvasElementTestLabel.d.mts +20 -0
  264. package/dist/labels/CustomTickerCanvasElementTestLabel.d.ts +20 -0
  265. package/dist/labels/CustomTickerCanvasElementTestLabel.js +2792 -0
  266. package/dist/labels/CustomTickerCanvasElementTestLabel.js.map +1 -0
  267. package/dist/labels/CustomTickerCanvasElementTestLabel.mjs +2786 -0
  268. package/dist/labels/CustomTickerCanvasElementTestLabel.mjs.map +1 -0
  269. package/dist/labels/ImagesAnimationsTestLabel.d.mts +9 -0
  270. package/dist/labels/ImagesAnimationsTestLabel.d.ts +9 -0
  271. package/dist/labels/ImagesAnimationsTestLabel.js +3378 -0
  272. package/dist/labels/ImagesAnimationsTestLabel.js.map +1 -0
  273. package/dist/labels/ImagesAnimationsTestLabel.mjs +3372 -0
  274. package/dist/labels/ImagesAnimationsTestLabel.mjs.map +1 -0
  275. package/dist/labels/MarkdownTest.d.mts +9 -0
  276. package/dist/labels/MarkdownTest.d.ts +9 -0
  277. package/dist/labels/MarkdownTest.js +2756 -0
  278. package/dist/labels/MarkdownTest.js.map +1 -0
  279. package/dist/labels/MarkdownTest.mjs +2750 -0
  280. package/dist/labels/MarkdownTest.mjs.map +1 -0
  281. package/dist/labels/StartLabel.d.mts +10 -0
  282. package/dist/labels/StartLabel.d.ts +10 -0
  283. package/dist/labels/StartLabel.js +3736 -0
  284. package/dist/labels/StartLabel.js.map +1 -0
  285. package/dist/labels/StartLabel.mjs +3729 -0
  286. package/dist/labels/StartLabel.mjs.map +1 -0
  287. package/dist/labels/TestConstant.d.mts +17 -0
  288. package/dist/labels/TestConstant.d.ts +17 -0
  289. package/dist/labels/TestConstant.js +1872 -0
  290. package/dist/labels/TestConstant.js.map +1 -0
  291. package/dist/labels/TestConstant.mjs +1856 -0
  292. package/dist/labels/TestConstant.mjs.map +1 -0
  293. package/dist/labels/TickerTestLabel.d.mts +9 -0
  294. package/dist/labels/TickerTestLabel.d.ts +9 -0
  295. package/dist/labels/TickerTestLabel.js +2675 -0
  296. package/dist/labels/TickerTestLabel.js.map +1 -0
  297. package/dist/labels/TickerTestLabel.mjs +2669 -0
  298. package/dist/labels/TickerTestLabel.mjs.map +1 -0
  299. package/dist/labels/index.d.mts +10 -0
  300. package/dist/labels/index.d.ts +10 -0
  301. package/dist/labels/index.js +3736 -0
  302. package/dist/labels/index.js.map +1 -0
  303. package/dist/labels/index.mjs +3729 -0
  304. package/dist/labels/index.mjs.map +1 -0
  305. package/dist/managers/StepManager.d.mts +21 -15
  306. package/dist/managers/StepManager.d.ts +21 -15
  307. package/dist/managers/StepManager.js +610 -251
  308. package/dist/managers/StepManager.js.map +1 -1
  309. package/dist/managers/StepManager.mjs +610 -251
  310. package/dist/managers/StepManager.mjs.map +1 -1
  311. package/dist/managers/WindowManager.d.mts +38 -24
  312. package/dist/managers/WindowManager.d.ts +38 -24
  313. package/dist/managers/WindowManager.js +356 -170
  314. package/dist/managers/WindowManager.js.map +1 -1
  315. package/dist/managers/WindowManager.mjs +352 -170
  316. package/dist/managers/WindowManager.mjs.map +1 -1
  317. package/dist/managers/index.d.mts +15 -14
  318. package/dist/managers/index.d.ts +15 -14
  319. package/dist/managers/index.js +612 -251
  320. package/dist/managers/index.js.map +1 -1
  321. package/dist/managers/index.mjs +612 -251
  322. package/dist/managers/index.mjs.map +1 -1
  323. package/dist/types/CanvasEventNamesType.d.mts +1 -1
  324. package/dist/types/CanvasEventNamesType.d.ts +1 -1
  325. package/dist/types/ChoiceMenuOptionsType.d.mts +2 -2
  326. package/dist/types/ChoiceMenuOptionsType.d.ts +2 -2
  327. package/dist/types/HistoryChoiceMenuOption.d.mts +22 -0
  328. package/dist/types/HistoryChoiceMenuOption.d.ts +22 -0
  329. package/dist/types/HistoryChoiceMenuOption.js +4 -0
  330. package/dist/types/HistoryChoiceMenuOption.mjs +3 -0
  331. package/dist/types/PauseType.d.mts +8 -4
  332. package/dist/types/PauseType.d.ts +8 -4
  333. package/dist/types/PauseType.js +0 -11
  334. package/dist/types/PauseType.js.map +1 -1
  335. package/dist/types/PauseType.mjs +0 -9
  336. package/dist/types/PauseType.mjs.map +1 -1
  337. package/dist/types/RepeatType.d.mts +1 -2
  338. package/dist/types/RepeatType.d.ts +1 -2
  339. package/dist/types/RepeatType.js +0 -4
  340. package/dist/types/RepeatType.js.map +1 -1
  341. package/dist/types/RepeatType.mjs +0 -3
  342. package/dist/types/RepeatType.mjs.map +1 -1
  343. package/dist/types/index.d.mts +5 -4
  344. package/dist/types/index.d.ts +5 -4
  345. package/dist/types/index.js +0 -15
  346. package/dist/types/index.js.map +1 -1
  347. package/dist/types/index.mjs +1 -13
  348. package/dist/types/index.mjs.map +1 -1
  349. package/dist/types/ticker/{TickerFadeAlphaProps.d.mts → FadeAlphaTickerProps.d.mts} +9 -5
  350. package/dist/types/ticker/{TickerFadeAlphaProps.d.ts → FadeAlphaTickerProps.d.ts} +9 -5
  351. package/dist/types/ticker/FadeAlphaTickerProps.js +4 -0
  352. package/dist/types/ticker/FadeAlphaTickerProps.js.map +1 -0
  353. package/dist/types/ticker/FadeAlphaTickerProps.mjs +3 -0
  354. package/dist/types/ticker/FadeAlphaTickerProps.mjs.map +1 -0
  355. package/dist/types/ticker/{TickerMoveProps.d.mts → MoveTickerProps.d.mts} +14 -5
  356. package/dist/types/ticker/{TickerMoveProps.d.ts → MoveTickerProps.d.ts} +14 -5
  357. package/dist/types/ticker/{TickerRotateProps.js → MoveTickerProps.js} +1 -1
  358. package/dist/types/ticker/MoveTickerProps.js.map +1 -0
  359. package/dist/types/ticker/MoveTickerProps.mjs +3 -0
  360. package/dist/types/ticker/MoveTickerProps.mjs.map +1 -0
  361. package/dist/types/ticker/{TickerRotateProps.d.mts → RotateTickerProps.d.mts} +10 -4
  362. package/dist/types/ticker/{TickerRotateProps.d.ts → RotateTickerProps.d.ts} +10 -4
  363. package/dist/types/ticker/RotateTickerProps.js +4 -0
  364. package/dist/types/ticker/RotateTickerProps.js.map +1 -0
  365. package/dist/types/ticker/RotateTickerProps.mjs +3 -0
  366. package/dist/types/ticker/RotateTickerProps.mjs.map +1 -0
  367. package/dist/types/ticker/TagToRemoveAfterType.d.mts +4 -0
  368. package/dist/types/ticker/TagToRemoveAfterType.d.ts +4 -0
  369. package/dist/types/ticker/TagToRemoveAfterType.js +8 -0
  370. package/dist/types/ticker/TagToRemoveAfterType.js.map +1 -0
  371. package/dist/types/ticker/TagToRemoveAfterType.mjs +6 -0
  372. package/dist/types/ticker/TagToRemoveAfterType.mjs.map +1 -0
  373. package/dist/types/ticker/ZoomTickerProps.d.mts +45 -0
  374. package/dist/types/ticker/ZoomTickerProps.d.ts +45 -0
  375. package/dist/types/ticker/ZoomTickerProps.js +4 -0
  376. package/dist/types/ticker/ZoomTickerProps.js.map +1 -0
  377. package/dist/types/ticker/ZoomTickerProps.mjs +3 -0
  378. package/dist/types/ticker/ZoomTickerProps.mjs.map +1 -0
  379. package/dist/types/ticker/index.d.mts +4 -2
  380. package/dist/types/ticker/index.d.ts +4 -2
  381. package/package.json +7 -7
  382. package/dist/classes/ticker/TickerFadeAlpha.d.mts +0 -31
  383. package/dist/classes/ticker/TickerFadeAlpha.d.ts +0 -31
  384. package/dist/classes/ticker/TickerFadeAlpha.js.map +0 -1
  385. package/dist/classes/ticker/TickerFadeAlpha.mjs.map +0 -1
  386. package/dist/classes/ticker/TickerMove.d.mts +0 -29
  387. package/dist/classes/ticker/TickerMove.d.ts +0 -29
  388. package/dist/classes/ticker/TickerMove.js.map +0 -1
  389. package/dist/classes/ticker/TickerMove.mjs.map +0 -1
  390. package/dist/classes/ticker/TickerRotate.d.mts +0 -30
  391. package/dist/classes/ticker/TickerRotate.d.ts +0 -30
  392. package/dist/classes/ticker/TickerRotate.js.map +0 -1
  393. package/dist/classes/ticker/TickerRotate.mjs.map +0 -1
  394. package/dist/functions/ErrorUtility.d.mts +0 -24
  395. package/dist/functions/ErrorUtility.d.ts +0 -24
  396. package/dist/functions/ErrorUtility.js +0 -261
  397. package/dist/functions/ErrorUtility.js.map +0 -1
  398. package/dist/functions/ErrorUtility.mjs +0 -258
  399. package/dist/functions/ErrorUtility.mjs.map +0 -1
  400. package/dist/interface/IClassWithArgsHistory.d.mts +0 -25
  401. package/dist/interface/IClassWithArgsHistory.d.ts +0 -25
  402. package/dist/interface/IClassWithArgsHistory.js +0 -4
  403. package/dist/interface/IClassWithArgsHistory.mjs +0 -3
  404. package/dist/types/ticker/TickerFadeAlphaProps.js +0 -4
  405. package/dist/types/ticker/TickerFadeAlphaProps.mjs +0 -3
  406. package/dist/types/ticker/TickerMoveProps.mjs +0 -3
  407. package/dist/types/ticker/TickerRotateProps.mjs +0 -3
  408. /package/dist/interface/{IClassWithArgsHistory.js.map → CharacterBaseModelProps.js.map} +0 -0
  409. /package/dist/interface/{IClassWithArgsHistory.mjs.map → CharacterBaseModelProps.mjs.map} +0 -0
  410. /package/dist/{types/ticker/TickerFadeAlphaProps.js.map → interface/TickerHistory.js.map} +0 -0
  411. /package/dist/{types/ticker/TickerFadeAlphaProps.mjs.map → interface/TickerHistory.mjs.map} +0 -0
  412. /package/dist/{types/ticker/TickerMoveProps.js.map → interface/TickerTimeoutHistory.js.map} +0 -0
  413. /package/dist/{types/ticker/TickerMoveProps.mjs.map → interface/TickerTimeoutHistory.mjs.map} +0 -0
  414. /package/dist/types/{ticker/TickerRotateProps.js.map → HistoryChoiceMenuOption.js.map} +0 -0
  415. /package/dist/types/{ticker/TickerRotateProps.mjs.map → HistoryChoiceMenuOption.mjs.map} +0 -0
@@ -0,0 +1,3736 @@
1
+ 'use strict';
2
+
3
+ var deepDiff = require('deep-diff');
4
+ var sha1 = require('crypto-js/sha1');
5
+ var pixi_js = require('pixi.js');
6
+
7
+ function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
8
+
9
+ var sha1__default = /*#__PURE__*/_interopDefault(sha1);
10
+
11
+ var __defProp = Object.defineProperty;
12
+ var __defProps = Object.defineProperties;
13
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
14
+ var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
15
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
16
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
17
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
18
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
19
+ var __spreadValues = (a, b) => {
20
+ for (var prop in b || (b = {}))
21
+ if (__hasOwnProp.call(b, prop))
22
+ __defNormalProp(a, prop, b[prop]);
23
+ if (__getOwnPropSymbols)
24
+ for (var prop of __getOwnPropSymbols(b)) {
25
+ if (__propIsEnum.call(b, prop))
26
+ __defNormalProp(a, prop, b[prop]);
27
+ }
28
+ return a;
29
+ };
30
+ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
31
+ var __decorateClass = (decorators, target, key, kind) => {
32
+ var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
33
+ for (var i = decorators.length - 1, decorator; i >= 0; i--)
34
+ if (decorator = decorators[i])
35
+ result = (kind ? decorator(target, key, result) : decorator(result)) || result;
36
+ if (kind && result) __defProp(target, key, result);
37
+ return result;
38
+ };
39
+ var __async = (__this, __arguments, generator) => {
40
+ return new Promise((resolve, reject) => {
41
+ var fulfilled = (value) => {
42
+ try {
43
+ step(generator.next(value));
44
+ } catch (e) {
45
+ reject(e);
46
+ }
47
+ };
48
+ var rejected = (value) => {
49
+ try {
50
+ step(generator.throw(value));
51
+ } catch (e) {
52
+ reject(e);
53
+ }
54
+ };
55
+ var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
56
+ step((generator = generator.apply(__this, __arguments)).next());
57
+ });
58
+ };
59
+
60
+ // src/classes/CanvasEvent.ts
61
+ var CanvasEvent = class {
62
+ constructor() {
63
+ /**
64
+ * Get the id of the event. This variable is used in the system to get the event by id, {@link getEventInstanceById}
65
+ */
66
+ this.id = "event_id_not_set";
67
+ this.id = this.constructor.prototype.id;
68
+ }
69
+ fn(_event, _element) {
70
+ throw new Error("[Pixi'VN] The method CanvasEvent.fn() must be overridden");
71
+ }
72
+ };
73
+ function getStepSha1(step) {
74
+ let sha1String = sha1__default.default(step.toString().toLocaleLowerCase());
75
+ return sha1String.toString();
76
+ }
77
+ function checkIfStepsIsEqual(step1, step2) {
78
+ return step1 === step2;
79
+ }
80
+
81
+ // src/classes/Label.ts
82
+ var Label = class {
83
+ /**
84
+ * @param id is the id of the label
85
+ * @param steps is the list of steps that the label will perform
86
+ * @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
87
+ * @param choiseIndex is the index of the choice that the label will perform
88
+ */
89
+ constructor(id, steps, onStepRun, choiseIndex) {
90
+ this._id = id;
91
+ this._steps = steps;
92
+ this._onStepRun = onStepRun;
93
+ this._choiseIndex = choiseIndex;
94
+ }
95
+ /**
96
+ * Get the id of the label. This variable is used in the system to get the label by id, {@link getLabelById}
97
+ */
98
+ get id() {
99
+ return this._id;
100
+ }
101
+ /**
102
+ * Get the steps of the label.
103
+ * This class should be extended and the steps method should be overridden.
104
+ * Every time you update this list will also be updated when the other game versions load.
105
+ */
106
+ get steps() {
107
+ if (typeof this._steps === "function") {
108
+ return this._steps();
109
+ }
110
+ return this._steps;
111
+ }
112
+ /**
113
+ * Get the corresponding steps number
114
+ * @param externalSteps
115
+ * @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
116
+ */
117
+ getCorrespondingStepsNumber(externalSteps) {
118
+ if (externalSteps.length === 0) {
119
+ return 0;
120
+ }
121
+ let res = 0;
122
+ externalSteps.forEach((step, index) => {
123
+ if (checkIfStepsIsEqual(step, this.steps[index])) {
124
+ res = index;
125
+ }
126
+ });
127
+ return res;
128
+ }
129
+ /**
130
+ * 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
131
+ * @returns Promise<void> or void
132
+ * @example
133
+ * ```typescript
134
+ * newLabel("id", [], () => {
135
+ * Assets.load('path/to/image1.png')
136
+ * Assets.load('path/to/image2.png')
137
+ * })
138
+ * ```
139
+ */
140
+ get onStepRun() {
141
+ return this._onStepRun;
142
+ }
143
+ get choiseIndex() {
144
+ return this._choiseIndex;
145
+ }
146
+ };
147
+
148
+ // src/classes/CloseLabel.ts
149
+ var CLOSE_LABEL_ID = "__close-label-id__";
150
+ function newCloseLabel(choiseIndex) {
151
+ return new Label(CLOSE_LABEL_ID, [], void 0, choiseIndex);
152
+ }
153
+
154
+ // src/decorators/LabelDecorator.ts
155
+ var registeredLabels = {};
156
+ function newLabel(id, steps, onStepRun) {
157
+ if (registeredLabels[id]) {
158
+ console.info(`[Pixi'VN] Label ${id} already exists, it will be overwritten`);
159
+ }
160
+ let label = new Label(id, steps, onStepRun);
161
+ registeredLabels[id] = label;
162
+ return label;
163
+ }
164
+ function getLabelById(id) {
165
+ let label = registeredLabels[id];
166
+ if (!label) {
167
+ console.error(`[Pixi'VN] Label ${id} not found`);
168
+ return;
169
+ }
170
+ return label;
171
+ }
172
+
173
+ // src/functions/CanvasUtility.ts
174
+ function getTextureMemory(texture) {
175
+ let sourceTexture = texture.source;
176
+ let textureMemory = {
177
+ image: sourceTexture.label
178
+ };
179
+ return textureMemory;
180
+ }
181
+ function exportCanvasElement(element) {
182
+ return element.memory;
183
+ }
184
+ function importCanvasElement(memory) {
185
+ let element = getCanvasElementInstanceById(memory.pixivnId);
186
+ if (element) {
187
+ element.memory = memory;
188
+ } else {
189
+ throw new Error("[Pixi'VN] The element " + memory.pixivnId + " could not be created");
190
+ }
191
+ return element;
192
+ }
193
+
194
+ // src/classes/canvas/CanvasContainer.ts
195
+ var CANVAS_CONTAINER_ID = "CanvasContainer";
196
+ var CanvasContainer = class extends pixi_js.Container {
197
+ constructor(options) {
198
+ super(options);
199
+ this.pixivnId = CANVAS_CONTAINER_ID;
200
+ this.pixivnId = this.constructor.prototype.pixivnId;
201
+ }
202
+ get memory() {
203
+ let memory = getMemoryContainer(this);
204
+ this.children.forEach((child) => {
205
+ memory.elements.push(exportCanvasElement(child));
206
+ });
207
+ return memory;
208
+ }
209
+ set memory(value) {
210
+ setMemoryContainer(this, value);
211
+ value.elements.forEach((child) => {
212
+ this.addChild(importCanvasElement(child));
213
+ });
214
+ }
215
+ };
216
+ function getMemoryContainer(element) {
217
+ let className = "CanvasContainer";
218
+ if (element.hasOwnProperty("pixivnId")) {
219
+ className = element.pixivnId;
220
+ }
221
+ return {
222
+ pixivnId: className,
223
+ elements: [],
224
+ width: element.width,
225
+ height: element.height,
226
+ isRenderGroup: element.isRenderGroup,
227
+ blendMode: element.blendMode,
228
+ tint: element.tint,
229
+ alpha: element.alpha,
230
+ angle: element.angle,
231
+ renderable: element.renderable,
232
+ rotation: element.rotation,
233
+ scale: { x: element.scale.x, y: element.scale.y },
234
+ pivot: { x: element.pivot.x, y: element.pivot.y },
235
+ position: { x: element.position.x, y: element.position.y },
236
+ skew: { x: element.skew.x, y: element.skew.y },
237
+ visible: element.visible,
238
+ culled: element.culled,
239
+ x: element.x,
240
+ y: element.y,
241
+ boundsArea: element.boundsArea,
242
+ cursor: element.cursor,
243
+ eventMode: element.eventMode,
244
+ interactive: element.interactive,
245
+ interactiveChildren: element.interactiveChildren,
246
+ hitArea: element.hitArea
247
+ };
248
+ }
249
+ function setMemoryContainer(element, memory) {
250
+ memory.width && (element.width = memory.width);
251
+ memory.height && (element.height = memory.height);
252
+ memory.isRenderGroup && (element.isRenderGroup = memory.isRenderGroup);
253
+ memory.blendMode && (element.blendMode = memory.blendMode);
254
+ memory.tint && (element.tint = memory.tint);
255
+ memory.alpha && (element.alpha = memory.alpha);
256
+ memory.angle && (element.angle = memory.angle);
257
+ memory.renderable && (element.renderable = memory.renderable);
258
+ memory.rotation && (element.rotation = memory.rotation);
259
+ if (memory.scale) {
260
+ if (typeof memory.scale === "number") {
261
+ element.scale.set(memory.scale, memory.scale);
262
+ } else {
263
+ element.scale.set(memory.scale.x, memory.scale.y);
264
+ }
265
+ }
266
+ if (memory.pivot) {
267
+ if (typeof memory.pivot === "number") {
268
+ element.pivot.set(memory.pivot, memory.pivot);
269
+ } else {
270
+ element.pivot.set(memory.pivot.x, memory.pivot.y);
271
+ }
272
+ }
273
+ memory.position && element.position.set(memory.position.x, memory.position.y);
274
+ memory.skew && element.skew.set(memory.skew.x, memory.skew.y);
275
+ memory.visible && (element.visible = memory.visible);
276
+ memory.culled && (element.culled = memory.culled);
277
+ memory.x && (element.x = memory.x);
278
+ memory.y && (element.y = memory.y);
279
+ memory.boundsArea && (element.boundsArea = memory.boundsArea);
280
+ memory.cursor && (element.cursor = memory.cursor);
281
+ memory.eventMode && (element.eventMode = memory.eventMode);
282
+ memory.interactive && (element.interactive = memory.interactive);
283
+ memory.interactiveChildren && (element.interactiveChildren = memory.interactiveChildren);
284
+ memory.hitArea && (element.hitArea = memory.hitArea);
285
+ }
286
+ function getTexture(imageUrl) {
287
+ return __async(this, null, function* () {
288
+ if (pixi_js.Assets.cache.has(imageUrl)) {
289
+ return pixi_js.Assets.get(imageUrl);
290
+ }
291
+ return pixi_js.Assets.load(imageUrl).then((texture) => {
292
+ if (!texture) {
293
+ console.error("[Pixi'VN] Texture not found", imageUrl);
294
+ return;
295
+ }
296
+ if (!(texture instanceof pixi_js.Texture)) {
297
+ console.error("[Pixi'VN] File not is a image", imageUrl);
298
+ return;
299
+ }
300
+ return texture;
301
+ }).catch((e) => {
302
+ console.error("[Pixi'VN] Error loading image", e);
303
+ return;
304
+ });
305
+ });
306
+ }
307
+ function getTextStyle(style) {
308
+ let fill = style.fill;
309
+ if (fill instanceof Object) {
310
+ console.warn("[Pixi'VN] CanvasText.style.fill is a FillGradient or FillPattern, this is not supported yet.", fill);
311
+ fill = "#00FF00";
312
+ }
313
+ return {
314
+ align: style.align,
315
+ breakWords: style.breakWords,
316
+ dropShadow: style.dropShadow,
317
+ fill,
318
+ fontFamily: style.fontFamily,
319
+ fontSize: style.fontSize,
320
+ fontStyle: style.fontStyle,
321
+ fontVariant: style.fontVariant,
322
+ fontWeight: style.fontWeight,
323
+ leading: style.leading,
324
+ letterSpacing: style.letterSpacing,
325
+ lineHeight: style.lineHeight,
326
+ padding: style.padding,
327
+ stroke: style.stroke,
328
+ textBaseline: style.textBaseline,
329
+ trim: style.trim,
330
+ whiteSpace: style.whiteSpace,
331
+ wordWrap: style.wordWrap,
332
+ wordWrapWidth: style.wordWrapWidth
333
+ };
334
+ }
335
+
336
+ // src/decorators/EventDecorator.ts
337
+ var registeredEvents = {};
338
+ function eventDecorator(name) {
339
+ return function(target) {
340
+ if (!name) {
341
+ name = target.name;
342
+ }
343
+ if (registeredEvents[name]) {
344
+ console.info(`[Pixi'VN] Event ${name} already exists, it will be overwritten`);
345
+ }
346
+ target.prototype.id = name;
347
+ registeredEvents[name] = target;
348
+ };
349
+ }
350
+ function getEventTypeById(eventId) {
351
+ try {
352
+ let eventType = registeredEvents[eventId];
353
+ if (!eventType) {
354
+ console.error(`[Pixi'VN] Event ${eventId} not found`);
355
+ return;
356
+ }
357
+ new eventType();
358
+ return eventType;
359
+ } catch (e) {
360
+ console.error(`[Pixi'VN] Error while getting Event ${eventId}`, e);
361
+ return;
362
+ }
363
+ }
364
+ function getEventInstanceById(eventId) {
365
+ try {
366
+ let eventType = registeredEvents[eventId];
367
+ if (!eventType) {
368
+ console.error(`[Pixi'VN] Event ${eventId} not found`);
369
+ return;
370
+ }
371
+ let event = new eventType();
372
+ return event;
373
+ } catch (e) {
374
+ console.error(`[Pixi'VN] Error while getting Event ${eventId}`, e);
375
+ return;
376
+ }
377
+ }
378
+
379
+ // src/classes/canvas/CanvasSprite.ts
380
+ var CANVAS_SPRITE_ID = "CanvasSprite";
381
+ var CanvasSprite = class _CanvasSprite extends pixi_js.Sprite {
382
+ constructor(options) {
383
+ super(options);
384
+ this.pixivnId = CANVAS_SPRITE_ID;
385
+ this._onEvents = {};
386
+ this.pixivnId = this.constructor.prototype.pixivnId;
387
+ }
388
+ get memory() {
389
+ return getMemorySprite(this);
390
+ }
391
+ set memory(value) {
392
+ setMemorySprite(this, value);
393
+ }
394
+ get onEvents() {
395
+ return this._onEvents;
396
+ }
397
+ /**
398
+ * is same function as on(), but it keeps in memory the children.
399
+ * @param event The event type, e.g., 'click', 'mousedown', 'mouseup', 'pointerdown', etc.
400
+ * @param eventClass The class that extends CanvasEvent.
401
+ * @returns
402
+ * @example
403
+ * ```typescript
404
+ * \@eventDecorator()
405
+ * export class EventTest extends CanvasEvent<CanvasSprite> {
406
+ * override fn(event: CanvasEventNamesType, sprite: CanvasSprite): void {
407
+ * if (event === 'pointerdown') {
408
+ * sprite.scale.x *= 1.25;
409
+ * sprite.scale.y *= 1.25;
410
+ * }
411
+ * }
412
+ * }
413
+ * ```
414
+ *
415
+ * ```typescript
416
+ * let sprite = addImage("alien", 'https://pixijs.com/assets/eggHead.png')
417
+ * await sprite.load()
418
+ *
419
+ * sprite.eventMode = 'static';
420
+ * sprite.cursor = 'pointer';
421
+ * sprite.onEvent('pointerdown', EventTest);
422
+ *
423
+ * GameWindowManager.addCanvasElement("bunny", sprite);
424
+ * ```
425
+ */
426
+ onEvent(event, eventClass) {
427
+ let id = eventClass.prototype.id;
428
+ let instance = getEventInstanceById(id);
429
+ this._onEvents[event] = id;
430
+ if (instance) {
431
+ super.on(event, () => {
432
+ instance.fn(event, this);
433
+ });
434
+ }
435
+ return this;
436
+ }
437
+ /**
438
+ * on() does not keep in memory the event class, use onEvent() instead
439
+ * @deprecated
440
+ * @private
441
+ * @param event
442
+ * @param fn
443
+ * @param context
444
+ */
445
+ on(event, fn, context) {
446
+ return super.on(event, fn, context);
447
+ }
448
+ static from(source, skipCache) {
449
+ let sprite = pixi_js.Sprite.from(source, skipCache);
450
+ let mySprite = new _CanvasSprite();
451
+ mySprite.texture = sprite.texture;
452
+ return mySprite;
453
+ }
454
+ };
455
+ function getMemorySprite(element) {
456
+ let temp = getMemoryContainer(element);
457
+ return __spreadProps(__spreadValues({}, temp), {
458
+ pixivnId: element.pixivnId,
459
+ textureImage: getTextureMemory(element.texture),
460
+ anchor: { x: element.anchor.x, y: element.anchor.y },
461
+ roundPixels: element.roundPixels,
462
+ onEvents: element.onEvents
463
+ });
464
+ }
465
+ function setMemorySprite(element, memory) {
466
+ setMemoryContainer(element, memory);
467
+ getTexture(memory.textureImage.image).then((texture) => {
468
+ if (texture) {
469
+ element.texture = texture;
470
+ }
471
+ });
472
+ if (memory.anchor) {
473
+ if (typeof memory.anchor === "number") {
474
+ element.anchor.set(memory.anchor, memory.anchor);
475
+ } else {
476
+ element.anchor.set(memory.anchor.x, memory.anchor.y);
477
+ }
478
+ }
479
+ memory.roundPixels && (element.roundPixels = memory.roundPixels);
480
+ for (let event in memory.onEvents) {
481
+ let id = memory.onEvents[event];
482
+ let instance = getEventTypeById(id);
483
+ if (instance) {
484
+ element.onEvent(event, instance);
485
+ }
486
+ }
487
+ }
488
+
489
+ // src/classes/canvas/CanvasImage.ts
490
+ var CANVAS_IMAGE_ID = "CanvasImage";
491
+ var CanvasImage = class _CanvasImage extends CanvasSprite {
492
+ constructor(options, imageLink) {
493
+ super(options);
494
+ this.pixivnId = CANVAS_IMAGE_ID;
495
+ this.imageLink = "";
496
+ if (imageLink) {
497
+ this.imageLink = imageLink;
498
+ }
499
+ }
500
+ get memory() {
501
+ return __spreadProps(__spreadValues({}, getMemorySprite(this)), {
502
+ pixivnId: this.pixivnId,
503
+ imageLink: this.imageLink
504
+ });
505
+ }
506
+ set memory(memory) {
507
+ setMemorySprite(this, memory);
508
+ this.imageLink = memory.imageLink;
509
+ }
510
+ static from(source, skipCache) {
511
+ let sprite = pixi_js.Sprite.from(source, skipCache);
512
+ let mySprite = new _CanvasImage();
513
+ mySprite.texture = sprite.texture;
514
+ return mySprite;
515
+ }
516
+ /**
517
+ * Load the image from the link and set the texture of the sprite.
518
+ * @param image The link of the image. If it is not set, it will use the imageLink property.
519
+ * @returns A promise that resolves when the image is loaded.
520
+ */
521
+ load(image) {
522
+ return __async(this, null, function* () {
523
+ if (!image) {
524
+ image = this.imageLink;
525
+ }
526
+ return getTexture(this.imageLink).then((texture) => {
527
+ if (texture) {
528
+ this.texture = texture;
529
+ }
530
+ }).catch((e) => {
531
+ console.error("[Pixi'VN] Error into CanvasImage.load()", e);
532
+ });
533
+ });
534
+ }
535
+ };
536
+ var CANVAS_TEXT_ID = "CanvasText";
537
+ var CanvasText = class extends pixi_js.Text {
538
+ constructor(options) {
539
+ super(options);
540
+ this.pixivnId = CANVAS_TEXT_ID;
541
+ this._onEvents = {};
542
+ this.pixivnId = this.constructor.prototype.pixivnId;
543
+ }
544
+ get memory() {
545
+ return getMemoryText(this);
546
+ }
547
+ set memory(value) {
548
+ setMemoryText(this, value);
549
+ }
550
+ get onEvents() {
551
+ return this._onEvents;
552
+ }
553
+ /**
554
+ * is same function as on(), but it keeps in memory the children.
555
+ * @param event The event type, e.g., 'click', 'mousedown', 'mouseup', 'pointerdown', etc.
556
+ * @param eventClass The class that extends CanvasEvent.
557
+ * @returns
558
+ * @example
559
+ * ```typescript
560
+ * \@eventDecorator()
561
+ * export class EventTest extends CanvasEvent<CanvasText> {
562
+ * override fn(event: CanvasEventNamesType, text: CanvasText): void {
563
+ * if (event === 'pointerdown') {
564
+ * text.scale.x *= 1.25;
565
+ * text.scale.y *= 1.25;
566
+ * }
567
+ * }
568
+ * }
569
+ * ```
570
+ *
571
+ * ```typescript
572
+ * const text = new CanvasText();
573
+ * text.text = "Hello World"
574
+ *
575
+ * text.eventMode = 'static';
576
+ * text.cursor = 'pointer';
577
+ * text.onEvent('pointerdown', EventTest);
578
+ *
579
+ * GameWindowManager.addCanvasElement("text", text);
580
+ * ```
581
+ */
582
+ onEvent(event, eventClass) {
583
+ let id = eventClass.prototype.id;
584
+ let instance = getEventInstanceById(id);
585
+ this._onEvents[event] = id;
586
+ if (instance) {
587
+ super.on(event, () => {
588
+ instance.fn(event, this);
589
+ });
590
+ }
591
+ return this;
592
+ }
593
+ /**
594
+ * on() does not keep in memory the event class, use onEvent() instead
595
+ * @deprecated
596
+ * @private
597
+ * @param event
598
+ * @param fn
599
+ * @param context
600
+ */
601
+ on(event, fn, context) {
602
+ return super.on(event, fn, context);
603
+ }
604
+ };
605
+ function getMemoryText(element) {
606
+ let temp = getMemoryContainer(element);
607
+ return __spreadProps(__spreadValues({}, temp), {
608
+ pixivnId: element.pixivnId,
609
+ anchor: { x: element.anchor.x, y: element.anchor.y },
610
+ text: element.text,
611
+ resolution: element.resolution,
612
+ style: getTextStyle(element.style),
613
+ roundPixels: element.roundPixels,
614
+ onEvents: element.onEvents
615
+ });
616
+ }
617
+ function setMemoryText(element, memory) {
618
+ setMemoryContainer(element, memory);
619
+ if (memory.anchor) {
620
+ if (typeof memory.anchor === "number") {
621
+ element.anchor.set(memory.anchor, memory.anchor);
622
+ } else {
623
+ element.anchor.set(memory.anchor.x, memory.anchor.y);
624
+ }
625
+ }
626
+ memory.text && (element.text = memory.text);
627
+ memory.resolution && (element.resolution = memory.resolution);
628
+ memory.style && (element.style = memory.style);
629
+ memory.roundPixels && (element.roundPixels = memory.roundPixels);
630
+ for (let event in memory.onEvents) {
631
+ let id = memory.onEvents[event];
632
+ let instance = getEventTypeById(id);
633
+ if (instance) {
634
+ element.onEvent(event, instance);
635
+ }
636
+ }
637
+ }
638
+
639
+ // src/decorators/CanvasElementDecorator.ts
640
+ var registeredCanvasElement = {};
641
+ function canvasElementDecorator(name) {
642
+ return function(target) {
643
+ if (!name) {
644
+ name = target.name;
645
+ }
646
+ if (registeredCanvasElement[name]) {
647
+ console.warn(`[Pixi'VN] CanvasElement ${name} already registered`);
648
+ }
649
+ target.prototype.pixivnId = name;
650
+ registeredCanvasElement[name] = target;
651
+ };
652
+ }
653
+ function getCanvasElementInstanceById(canvasId) {
654
+ try {
655
+ let eventType = registeredCanvasElement[canvasId];
656
+ if (!eventType) {
657
+ if (canvasId === CANVAS_CONTAINER_ID) {
658
+ eventType = CanvasContainer;
659
+ } else if (canvasId === CANVAS_IMAGE_ID) {
660
+ eventType = CanvasImage;
661
+ } else if (canvasId === CANVAS_SPRITE_ID) {
662
+ eventType = CanvasSprite;
663
+ } else if (canvasId === CANVAS_TEXT_ID) {
664
+ eventType = CanvasText;
665
+ }
666
+ }
667
+ if (!eventType) {
668
+ console.error(`[Pixi'VN] CanvasElement ${canvasId} not found`);
669
+ return;
670
+ }
671
+ let canvasElement = new eventType();
672
+ return canvasElement;
673
+ } catch (e) {
674
+ console.error(`[Pixi'VN] Error while getting CanvasElement ${canvasId}`, e);
675
+ return;
676
+ }
677
+ }
678
+
679
+ // src/decorators/CharacterDecorator.ts
680
+ var registeredCharacters = {};
681
+ function saveCharacter(character) {
682
+ if (Array.isArray(character)) {
683
+ character.forEach((c) => saveCharacter(c));
684
+ return;
685
+ }
686
+ if (registeredCharacters[character.id]) {
687
+ console.info(`[Pixi'VN] Character id ${character.id} already exists, it will be overwritten`);
688
+ }
689
+ registeredCharacters[character.id] = character;
690
+ }
691
+
692
+ // src/decorators/TickerDecorator.ts
693
+ var registeredTickers = {};
694
+ function tickerDecorator(name) {
695
+ return function(target) {
696
+ if (!name) {
697
+ name = target.name;
698
+ }
699
+ if (registeredTickers[name]) {
700
+ console.info(`[Pixi'VN] Ticker ${name} already exists, it will be overwritten`);
701
+ }
702
+ target.prototype.id = name;
703
+ registeredTickers[name] = target;
704
+ };
705
+ }
706
+ function geTickerInstanceById(tickerId, args, duration, priority) {
707
+ try {
708
+ let ticker = registeredTickers[tickerId];
709
+ if (!ticker) {
710
+ console.error(`[Pixi'VN] Ticker ${tickerId} not found`);
711
+ return;
712
+ }
713
+ return new ticker(args, duration, priority);
714
+ } catch (e) {
715
+ console.error(`[Pixi'VN] Error while getting Ticker ${tickerId}`, e);
716
+ return;
717
+ }
718
+ }
719
+
720
+ // src/types/CloseType.ts
721
+ var Close = "close";
722
+
723
+ // src/classes/ChoiceMenuOption.ts
724
+ var ChoiceMenuOption = class {
725
+ /**
726
+ * @param text Text to be displayed in the menu
727
+ * @param label Label to be opened when the option is selected or the id of the label
728
+ * @param type Type of the label to be opened. @default "call"
729
+ * @param props Properties to be passed to the label, when the label is called. it cannot contain functions or classes. @default {}
730
+ */
731
+ constructor(text, label, type = "call", props) {
732
+ /**
733
+ * Properties to be passed to the label
734
+ */
735
+ this.props = {};
736
+ if (typeof label === "string") {
737
+ let tLabel = getLabelById(label);
738
+ if (!tLabel) {
739
+ throw new Error(`[Pixi'VN] Label ${label} not found`);
740
+ } else {
741
+ label = tLabel;
742
+ }
743
+ }
744
+ this.text = text;
745
+ this.label = label;
746
+ this.type = type;
747
+ if (props) {
748
+ this.props = props;
749
+ }
750
+ }
751
+ };
752
+ var ChoiceMenuOptionClose = class {
753
+ /**
754
+ * @param text Text to be displayed in the menu
755
+ * @param closeCurrentLabel If true, the current label will be closed. @default false
756
+ */
757
+ constructor(text, closeCurrentLabel = false) {
758
+ /**
759
+ * Label to be opened when the option is selected
760
+ */
761
+ this.label = newCloseLabel();
762
+ /**
763
+ * Type of the label to be opened
764
+ */
765
+ this.type = Close;
766
+ /**
767
+ * Properties to be passed to the label
768
+ */
769
+ this.props = {};
770
+ this.text = text;
771
+ this.closeCurrentLabel = closeCurrentLabel;
772
+ }
773
+ };
774
+
775
+ // src/functions/DialogueUtility.ts
776
+ function setDialogue(props) {
777
+ let text = "";
778
+ let character = void 0;
779
+ let dialogue;
780
+ if (typeof props === "string") {
781
+ text = props;
782
+ dialogue = new DialogueBaseModel(text, character);
783
+ } else if (!(props instanceof DialogueBaseModel)) {
784
+ text = props.text;
785
+ if (props.character) {
786
+ if (typeof props.character === "string") {
787
+ character = props.character;
788
+ } else {
789
+ character = props.character.id;
790
+ }
791
+ }
792
+ dialogue = new DialogueBaseModel(text, character);
793
+ } else {
794
+ dialogue = props;
795
+ }
796
+ GameStorageManager.setVariable(GameStorageManager.keysSystem.CURRENT_DIALOGUE_MEMORY_KEY, dialogue);
797
+ GameStorageManager.setVariable(GameStorageManager.keysSystem.LAST_DIALOGUE_ADDED_IN_STEP_MEMORY_KEY, GameStepManager.lastStepIndex);
798
+ }
799
+ function getDialogue() {
800
+ return GameStorageManager.getVariable(GameStorageManager.keysSystem.CURRENT_DIALOGUE_MEMORY_KEY);
801
+ }
802
+ function setChoiceMenuOptions(options) {
803
+ let value = options.map((option) => {
804
+ if (option instanceof ChoiceMenuOptionClose) {
805
+ return {
806
+ text: option.text,
807
+ type: Close,
808
+ closeCurrentLabel: option.closeCurrentLabel
809
+ };
810
+ }
811
+ return __spreadProps(__spreadValues({}, option), {
812
+ label: option.label.id
813
+ });
814
+ });
815
+ GameStorageManager.setVariable(GameStorageManager.keysSystem.CURRENT_MENU_OPTIONS_MEMORY_KEY, value);
816
+ GameStorageManager.setVariable(GameStorageManager.keysSystem.LAST_MENU_OPTIONS_ADDED_IN_STEP_MEMORY_KEY, GameStepManager.lastStepIndex);
817
+ }
818
+ function getChoiceMenuOptions() {
819
+ let d = GameStorageManager.getVariable(GameStorageManager.keysSystem.CURRENT_MENU_OPTIONS_MEMORY_KEY);
820
+ if (d) {
821
+ let options = [];
822
+ d.forEach((option, index) => {
823
+ if (option.type === Close) {
824
+ let itemLabel = newCloseLabel(index);
825
+ options.push({
826
+ text: option.text,
827
+ label: itemLabel,
828
+ type: Close,
829
+ closeCurrentLabel: option.closeCurrentLabel,
830
+ props: {}
831
+ });
832
+ return;
833
+ }
834
+ let label = getLabelById(option.label);
835
+ if (label) {
836
+ let itemLabel = new Label(label.id, label.steps, label.onStepRun, index);
837
+ options.push(__spreadProps(__spreadValues({}, option), {
838
+ label: itemLabel
839
+ }));
840
+ }
841
+ });
842
+ return options;
843
+ }
844
+ return void 0;
845
+ }
846
+
847
+ // src/classes/ticker/TickerBase.ts
848
+ var TickerBase = class {
849
+ /**
850
+ * @param args The arguments that you want to pass to the ticker.
851
+ * @param duration The duration of the ticker in seconds. If is undefined, the step will end only when the animation is finished (if the animation doesn't have a goal to reach then it won't finish). @default undefined
852
+ * @param priority The priority of the ticker. @default UPDATE_PRIORITY.NORMAL
853
+ */
854
+ constructor(args, duration, priority) {
855
+ /**
856
+ * Get the id of the ticker. This variable is used in the system to get the ticker by id, {@link geTickerInstanceById}
857
+ */
858
+ this.id = "ticker_id_not_set";
859
+ this.args = args;
860
+ this.duration = duration;
861
+ this.priority = priority;
862
+ this.id = this.constructor.prototype.id;
863
+ }
864
+ /**
865
+ * The method that will be called every frame.
866
+ * This method should be overridden and you can use GameWindowManager.addCanvasElement() to get the canvas element of the canvas, and edit them.
867
+ * @param _ticker The ticker that is calling this method
868
+ * @param _args The arguments that you passed when you added the ticker
869
+ * @param _tags The tags of the canvas elements that are connected to this ticker
870
+ * @param _tickerId The id of the ticker. You can use this to get the ticker from the {@link GameWindowManager.currentTickers}
871
+ */
872
+ fn(_ticker, _args, _tags, _tickerId) {
873
+ throw new Error("[Pixi'VN] The method TickerBase.fn() must be overridden");
874
+ }
875
+ };
876
+
877
+ // src/classes/ticker/FadeAlphaTicker.ts
878
+ var FadeAlphaTicker = class extends TickerBase {
879
+ fn(ticker, args, tags, tickerId) {
880
+ let type = args.type === void 0 ? "hide" : args.type;
881
+ let duration = args.duration === void 0 ? 1 : args.duration;
882
+ let speed = 1 / (duration * 60);
883
+ let limit = args.limit === void 0 ? type === "hide" ? 0 : 1 : args.limit;
884
+ let tagToRemoveAfter2 = args.tagToRemoveAfter || [];
885
+ if (typeof tagToRemoveAfter2 === "string") {
886
+ tagToRemoveAfter2 = [tagToRemoveAfter2];
887
+ }
888
+ if (type === "hide" && limit < 0) {
889
+ limit = 0;
890
+ }
891
+ if (type === "show" && limit > 1) {
892
+ limit = 1;
893
+ }
894
+ tags.filter((tag) => {
895
+ var _a;
896
+ let element = GameWindowManager.getCanvasElement(tag);
897
+ if (args.startOnlyIfHaveTexture) {
898
+ if (element && element instanceof pixi_js.Sprite && ((_a = element.texture) == null ? void 0 : _a.label) == "EMPTY") {
899
+ return false;
900
+ }
901
+ }
902
+ return true;
903
+ }).forEach((tag) => {
904
+ let element = GameWindowManager.getCanvasElement(tag);
905
+ if (element && element instanceof pixi_js.Container) {
906
+ if (type === "show" && element.alpha < limit) {
907
+ element.alpha += speed * ticker.deltaTime;
908
+ } else if (type === "hide" && element.alpha > limit) {
909
+ element.alpha -= speed * ticker.deltaTime;
910
+ }
911
+ if (type === "show" && element.alpha >= limit) {
912
+ element.alpha = limit;
913
+ GameWindowManager.onEndOfTicker(tag, this, tagToRemoveAfter2, tickerId);
914
+ } else if (type === "hide" && element.alpha <= limit) {
915
+ element.alpha = limit;
916
+ GameWindowManager.onEndOfTicker(tag, this, tagToRemoveAfter2, tickerId);
917
+ }
918
+ }
919
+ });
920
+ }
921
+ };
922
+ FadeAlphaTicker = __decorateClass([
923
+ tickerDecorator()
924
+ ], FadeAlphaTicker);
925
+
926
+ // src/functions/TickerUtility.ts
927
+ function updateTickerProgression(args, propertyName, progression) {
928
+ if (args[propertyName] === void 0 || !progression || args[propertyName] === progression.limit) {
929
+ return;
930
+ }
931
+ if (typeof args[propertyName] === "number") {
932
+ if (progression.type === "linear") {
933
+ args[propertyName] = getLinearProgression(args[propertyName], progression);
934
+ } else if (progression.type === "exponential") {
935
+ args[propertyName] = getExponentialProgression(args[propertyName], progression);
936
+ }
937
+ } else if (args[propertyName] !== void 0 && typeof args[propertyName] === "object" && args[propertyName].haveOwnProperty("x") && args[propertyName].haveOwnProperty("y") && typeof args[propertyName].x === "number" && typeof args[propertyName].y === "number") {
938
+ if (progression.type === "linear") {
939
+ args[propertyName].x = getLinearProgression(args[propertyName].x, progression);
940
+ args[propertyName].y = getLinearProgression(args[propertyName].y, progression);
941
+ } else if (progression.type === "exponential") {
942
+ args[propertyName].x = getExponentialProgression(args[propertyName].x, progression);
943
+ args[propertyName].y = getExponentialProgression(args[propertyName].y, progression);
944
+ }
945
+ }
946
+ }
947
+ function getLinearProgression(number, progression) {
948
+ if (progression.limit !== void 0) {
949
+ if (number > progression.limit && progression.amt > 0) {
950
+ return progression.limit;
951
+ } else if (number < progression.limit && progression.amt < 0) {
952
+ return progression.limit;
953
+ }
954
+ }
955
+ return number + progression.amt / 60;
956
+ }
957
+ function getExponentialProgression(number, progression) {
958
+ if (progression.limit !== void 0) {
959
+ if (number > progression.limit && progression.percentage > 0) {
960
+ return progression.limit;
961
+ } else if (number < progression.limit && progression.percentage < 0) {
962
+ return progression.limit;
963
+ }
964
+ }
965
+ return number + number * progression.percentage;
966
+ }
967
+
968
+ // src/classes/ticker/MoveTicker.ts
969
+ var MoveTicker = class extends TickerBase {
970
+ fn(ticker, args, tags, tickerId) {
971
+ let xSpeed = 1;
972
+ let ySpeed = 1;
973
+ if (args.speed) {
974
+ if (typeof args.speed === "number") {
975
+ xSpeed = args.speed;
976
+ ySpeed = args.speed;
977
+ } else {
978
+ xSpeed = args.speed.x;
979
+ ySpeed = args.speed.y;
980
+ }
981
+ }
982
+ xSpeed /= 60;
983
+ ySpeed /= 60;
984
+ let destination = args.destination;
985
+ let tagToRemoveAfter2 = args.tagToRemoveAfter || [];
986
+ if (typeof tagToRemoveAfter2 === "string") {
987
+ tagToRemoveAfter2 = [tagToRemoveAfter2];
988
+ }
989
+ tags.filter((tag) => {
990
+ var _a;
991
+ let element = GameWindowManager.getCanvasElement(tag);
992
+ if (args.startOnlyIfHaveTexture) {
993
+ if (element && element instanceof pixi_js.Sprite && ((_a = element.texture) == null ? void 0 : _a.label) == "EMPTY") {
994
+ return false;
995
+ }
996
+ }
997
+ return true;
998
+ }).forEach((tag) => {
999
+ let element = GameWindowManager.getCanvasElement(tag);
1000
+ if (element && element instanceof pixi_js.Container) {
1001
+ let xDistance = destination.x - element.x > 0 ? 1 : -1;
1002
+ if (xDistance != 0) {
1003
+ element.x += xDistance * xSpeed * ticker.deltaTime;
1004
+ let newDistance = destination.x - element.x;
1005
+ if (xDistance < 0 && newDistance > 0 || xDistance > 0 && newDistance < 0) {
1006
+ element.x = destination.x;
1007
+ }
1008
+ }
1009
+ let yDistance = destination.y - element.y > 0 ? 1 : -1;
1010
+ if (yDistance != 0) {
1011
+ element.y += yDistance * ySpeed * ticker.deltaTime;
1012
+ let newDistance = destination.y - element.y;
1013
+ if (yDistance < 0 && newDistance > 0 || yDistance > 0 && newDistance < 0) {
1014
+ element.y = destination.y;
1015
+ }
1016
+ }
1017
+ if (element.x == destination.x && element.y == destination.y) {
1018
+ GameWindowManager.onEndOfTicker(tag, this, tagToRemoveAfter2, tickerId);
1019
+ }
1020
+ }
1021
+ });
1022
+ if (args.speedProgression)
1023
+ updateTickerProgression(args, "speed", args.speedProgression);
1024
+ }
1025
+ };
1026
+ MoveTicker = __decorateClass([
1027
+ tickerDecorator()
1028
+ ], MoveTicker);
1029
+ var RotateTicker = class extends TickerBase {
1030
+ fn(ticker, args, tags, tickerId) {
1031
+ let speed = (args.speed === void 0 ? 1 : args.speed) / 60;
1032
+ let clockwise = args.clockwise === void 0 ? true : args.clockwise;
1033
+ let tagToRemoveAfter2 = args.tagToRemoveAfter || [];
1034
+ if (typeof tagToRemoveAfter2 === "string") {
1035
+ tagToRemoveAfter2 = [tagToRemoveAfter2];
1036
+ }
1037
+ tags.filter((tag) => {
1038
+ var _a;
1039
+ let element = GameWindowManager.getCanvasElement(tag);
1040
+ if (args.startOnlyIfHaveTexture) {
1041
+ if (element && element instanceof pixi_js.Sprite && ((_a = element.texture) == null ? void 0 : _a.label) == "EMPTY") {
1042
+ return false;
1043
+ }
1044
+ }
1045
+ return true;
1046
+ }).forEach((tag) => {
1047
+ let element = GameWindowManager.getCanvasElement(tag);
1048
+ if (element && element instanceof pixi_js.Container) {
1049
+ if (clockwise)
1050
+ element.rotation += speed * ticker.deltaTime;
1051
+ else
1052
+ element.rotation -= speed * ticker.deltaTime;
1053
+ if (speed < 1e-5 && !(args.speedProgression && args.speedProgression.type == "linear" && args.speedProgression.amt != 0)) {
1054
+ GameWindowManager.onEndOfTicker(tag, this, tagToRemoveAfter2, tickerId);
1055
+ }
1056
+ }
1057
+ });
1058
+ if (args.speedProgression)
1059
+ updateTickerProgression(args, "speed", args.speedProgression);
1060
+ }
1061
+ };
1062
+ RotateTicker = __decorateClass([
1063
+ tickerDecorator()
1064
+ ], RotateTicker);
1065
+ var ZoomTicker = class extends TickerBase {
1066
+ fn(ticker, args, tags, tickerId) {
1067
+ let xSpeed = 0.1;
1068
+ let ySpeed = 0.1;
1069
+ if (args.speed) {
1070
+ if (typeof args.speed === "number") {
1071
+ xSpeed = args.speed;
1072
+ ySpeed = args.speed;
1073
+ } else {
1074
+ xSpeed = args.speed.x;
1075
+ ySpeed = args.speed.y;
1076
+ }
1077
+ }
1078
+ xSpeed /= 60;
1079
+ ySpeed /= 60;
1080
+ let tagToRemoveAfter2 = args.tagToRemoveAfter || [];
1081
+ if (typeof tagToRemoveAfter2 === "string") {
1082
+ tagToRemoveAfter2 = [tagToRemoveAfter2];
1083
+ }
1084
+ let type = args.type || "zoom";
1085
+ let xLimit = type === "zoom" ? Infinity : 0;
1086
+ let yLimit = type === "zoom" ? Infinity : 0;
1087
+ if (args.limit) {
1088
+ if (typeof args.limit === "number") {
1089
+ xLimit = args.limit;
1090
+ yLimit = args.limit;
1091
+ } else {
1092
+ xLimit = args.limit.x;
1093
+ yLimit = args.limit.y;
1094
+ }
1095
+ }
1096
+ tags.filter((tag) => {
1097
+ var _a;
1098
+ let element = GameWindowManager.getCanvasElement(tag);
1099
+ if (args.startOnlyIfHaveTexture) {
1100
+ if (element && element instanceof pixi_js.Sprite && ((_a = element.texture) == null ? void 0 : _a.label) == "EMPTY") {
1101
+ return false;
1102
+ }
1103
+ }
1104
+ return true;
1105
+ }).forEach((tag) => {
1106
+ let element = GameWindowManager.getCanvasElement(tag);
1107
+ if (element && element instanceof pixi_js.Container) {
1108
+ if (type === "zoom" && (element.scale.x < xLimit || element.scale.y < yLimit)) {
1109
+ element.scale.x += xSpeed * ticker.deltaTime;
1110
+ element.scale.y += ySpeed * ticker.deltaTime;
1111
+ } else if (type === "unzoom" && (element.scale.x > xLimit || element.scale.y > yLimit)) {
1112
+ element.scale.x -= xSpeed * ticker.deltaTime;
1113
+ element.scale.y -= ySpeed * ticker.deltaTime;
1114
+ }
1115
+ if (type === "zoom") {
1116
+ if (element.scale.x > xLimit) {
1117
+ element.scale.x = xLimit;
1118
+ }
1119
+ if (element.scale.y > yLimit) {
1120
+ element.scale.y = yLimit;
1121
+ }
1122
+ if (element.scale.x >= xLimit && element.scale.y >= yLimit) {
1123
+ element.scale.x = xLimit;
1124
+ element.scale.y = yLimit;
1125
+ this.onEndOfTicker(tag, tickerId, element, tagToRemoveAfter2);
1126
+ }
1127
+ } else if (type === "unzoom") {
1128
+ if (element.scale.x < xLimit) {
1129
+ element.scale.x = xLimit;
1130
+ }
1131
+ if (element.scale.y < yLimit) {
1132
+ element.scale.y = yLimit;
1133
+ }
1134
+ if (element.scale.x <= xLimit && element.scale.y <= yLimit) {
1135
+ element.scale.x = xLimit;
1136
+ element.scale.y = yLimit;
1137
+ this.onEndOfTicker(tag, tickerId, element, tagToRemoveAfter2);
1138
+ }
1139
+ }
1140
+ if (xSpeed < 1e-5 && ySpeed < 1e-5 && !(args.speedProgression && args.speedProgression.type == "linear" && args.speedProgression.amt != 0)) {
1141
+ this.onEndOfTicker(tag, tickerId, element, tagToRemoveAfter2);
1142
+ }
1143
+ }
1144
+ });
1145
+ if (args.speedProgression)
1146
+ updateTickerProgression(args, "speed", args.speedProgression);
1147
+ }
1148
+ onEndOfTicker(tag, tickerId, _element, tagToRemoveAfter2) {
1149
+ GameWindowManager.onEndOfTicker(tag, this, tagToRemoveAfter2, tickerId);
1150
+ }
1151
+ };
1152
+ ZoomTicker = __decorateClass([
1153
+ tickerDecorator()
1154
+ ], ZoomTicker);
1155
+ var ZoomInOutTicker = class extends ZoomTicker {
1156
+ constructor(props, duration, priority) {
1157
+ super(props, duration, priority);
1158
+ }
1159
+ onEndOfTicker(tag, tickerId, element, tagToRemoveAfter2) {
1160
+ if (element.children.length > 0) {
1161
+ let elementChild = element.children[0];
1162
+ GameWindowManager.addCanvasElement(tag, elementChild);
1163
+ }
1164
+ super.onEndOfTicker(tag, tickerId, element, tagToRemoveAfter2);
1165
+ }
1166
+ };
1167
+
1168
+ // src/constants.ts
1169
+ var Repeat = "repeat";
1170
+ function Pause(duration) {
1171
+ return {
1172
+ type: "pause",
1173
+ duration
1174
+ };
1175
+ }
1176
+
1177
+ // src/functions/ImageUtility.ts
1178
+ function addImage(tag, imageUrl) {
1179
+ let image = new CanvasImage();
1180
+ image.imageLink = imageUrl;
1181
+ GameWindowManager.addCanvasElement(tag, image);
1182
+ return image;
1183
+ }
1184
+ function loadImage(canvasImages) {
1185
+ return __async(this, null, function* () {
1186
+ if (!Array.isArray(canvasImages)) {
1187
+ return [canvasImages];
1188
+ }
1189
+ let promises = Array(canvasImages.length);
1190
+ for (let i = 0; i < canvasImages.length; i++) {
1191
+ promises[i] = getTexture(canvasImages[i].imageLink);
1192
+ }
1193
+ return Promise.all(promises).then((textures) => {
1194
+ return textures.map((texture, index) => {
1195
+ if (texture) {
1196
+ canvasImages[index].texture = texture;
1197
+ return canvasImages[index];
1198
+ }
1199
+ canvasImages[index].load();
1200
+ return canvasImages[index];
1201
+ });
1202
+ });
1203
+ });
1204
+ }
1205
+ function showWithDissolveTransition(_0, _1) {
1206
+ return __async(this, arguments, function* (tag, image, props = {}, priority) {
1207
+ var _a;
1208
+ let oldCanvasTag = void 0;
1209
+ if (GameWindowManager.getCanvasElement(tag)) {
1210
+ oldCanvasTag = tag + "_temp_disolve";
1211
+ GameWindowManager.editCanvasElementTag(tag, oldCanvasTag);
1212
+ }
1213
+ let canvasElement;
1214
+ if (typeof image === "string") {
1215
+ canvasElement = addImage(tag, image);
1216
+ } else {
1217
+ canvasElement = image;
1218
+ GameWindowManager.addCanvasElement(tag, canvasElement);
1219
+ }
1220
+ if (canvasElement instanceof CanvasImage && ((_a = canvasElement.texture) == null ? void 0 : _a.label) == "EMPTY") {
1221
+ yield canvasElement.load();
1222
+ }
1223
+ canvasElement.alpha = 0;
1224
+ let effect = new FadeAlphaTicker(__spreadProps(__spreadValues({}, props), {
1225
+ type: "show",
1226
+ tagToRemoveAfter: oldCanvasTag,
1227
+ startOnlyIfHaveTexture: true
1228
+ }), 10, priority);
1229
+ GameWindowManager.addTicker(tag, effect);
1230
+ return;
1231
+ });
1232
+ }
1233
+ function removeWithDissolveTransition(tag, props = {}, priority) {
1234
+ if (typeof tag === "string") {
1235
+ tag = [tag];
1236
+ }
1237
+ let effect = new FadeAlphaTicker(__spreadProps(__spreadValues({}, props), {
1238
+ type: "hide",
1239
+ tagToRemoveAfter: tag,
1240
+ startOnlyIfHaveTexture: true
1241
+ }), 10, priority);
1242
+ GameWindowManager.addTicker(tag, effect);
1243
+ }
1244
+ function showWithFadeTransition(_0, _1) {
1245
+ return __async(this, arguments, function* (tag, image, props = {}, priority) {
1246
+ var _a;
1247
+ if (!GameWindowManager.getCanvasElement(tag)) {
1248
+ return showWithDissolveTransition(tag, image, props, priority);
1249
+ }
1250
+ let oldCanvasTag = tag + "_temp_fade";
1251
+ GameWindowManager.editCanvasElementTag(tag, oldCanvasTag);
1252
+ let canvasElement;
1253
+ if (typeof image === "string") {
1254
+ canvasElement = addImage(tag, image);
1255
+ } else {
1256
+ canvasElement = image;
1257
+ GameWindowManager.addCanvasElement(tag, canvasElement);
1258
+ }
1259
+ if (canvasElement instanceof CanvasImage && ((_a = canvasElement.texture) == null ? void 0 : _a.label) == "EMPTY") {
1260
+ yield canvasElement.load();
1261
+ }
1262
+ canvasElement.alpha = 0;
1263
+ GameWindowManager.addTickersSteps(oldCanvasTag, [
1264
+ new FadeAlphaTicker(__spreadProps(__spreadValues({}, props), {
1265
+ type: "hide",
1266
+ startOnlyIfHaveTexture: true
1267
+ }))
1268
+ ]);
1269
+ GameWindowManager.addTickersSteps(tag, [
1270
+ Pause(props.duration || 1),
1271
+ new FadeAlphaTicker(__spreadProps(__spreadValues({}, props), {
1272
+ type: "show",
1273
+ startOnlyIfHaveTexture: true
1274
+ }))
1275
+ ]);
1276
+ });
1277
+ }
1278
+ function removeWithFadeTransition(tag, props = {}, priority) {
1279
+ return removeWithDissolveTransition(tag, props, priority);
1280
+ }
1281
+ function moveIn(_0, _1) {
1282
+ return __async(this, arguments, function* (tag, image, props = { direction: "right" }, priority) {
1283
+ var _a;
1284
+ let canvasElement;
1285
+ if (typeof image === "string") {
1286
+ canvasElement = addImage(tag, image);
1287
+ } else {
1288
+ canvasElement = image;
1289
+ GameWindowManager.addCanvasElement(tag, canvasElement);
1290
+ }
1291
+ if (canvasElement instanceof CanvasImage && ((_a = canvasElement.texture) == null ? void 0 : _a.label) == "EMPTY") {
1292
+ yield canvasElement.load();
1293
+ }
1294
+ let destination = { x: canvasElement.x, y: canvasElement.y };
1295
+ if (props.direction == "up") {
1296
+ canvasElement.y = GameWindowManager.canvasHeight + canvasElement.height;
1297
+ } else if (props.direction == "down") {
1298
+ canvasElement.y = -canvasElement.height;
1299
+ } else if (props.direction == "left") {
1300
+ canvasElement.x = GameWindowManager.canvasWidth + canvasElement.width;
1301
+ } else if (props.direction == "right") {
1302
+ canvasElement.x = -canvasElement.width;
1303
+ }
1304
+ let effect = new MoveTicker(__spreadProps(__spreadValues({}, props), {
1305
+ destination,
1306
+ startOnlyIfHaveTexture: true
1307
+ }), priority);
1308
+ GameWindowManager.addTicker(tag, effect);
1309
+ });
1310
+ }
1311
+ function moveOut(tag, props = { direction: "right" }, priority) {
1312
+ let canvasElement = GameWindowManager.getCanvasElement(tag);
1313
+ if (!canvasElement) {
1314
+ console.warn("[Pixi'VN] The canvas element is not found.");
1315
+ return;
1316
+ }
1317
+ let destination = { x: canvasElement.x, y: canvasElement.y };
1318
+ if (props.direction == "up") {
1319
+ destination.y = -canvasElement.height;
1320
+ } else if (props.direction == "down") {
1321
+ destination.y = GameWindowManager.canvasHeight + canvasElement.height;
1322
+ } else if (props.direction == "left") {
1323
+ destination.x = -canvasElement.width;
1324
+ } else if (props.direction == "right") {
1325
+ destination.x = GameWindowManager.canvasWidth + canvasElement.width;
1326
+ }
1327
+ let effect = new MoveTicker(__spreadProps(__spreadValues({}, props), {
1328
+ destination,
1329
+ startOnlyIfHaveTexture: true,
1330
+ tagToRemoveAfter: tag
1331
+ }), priority);
1332
+ GameWindowManager.addTicker(tag, effect);
1333
+ }
1334
+ function zoomIn(_0, _1) {
1335
+ return __async(this, arguments, function* (tag, image, props = { direction: "right" }, priority) {
1336
+ var _a;
1337
+ let canvasElement;
1338
+ if (typeof image === "string") {
1339
+ canvasElement = new CanvasImage({}, image);
1340
+ } else {
1341
+ canvasElement = image;
1342
+ }
1343
+ if (canvasElement instanceof CanvasImage && ((_a = canvasElement.texture) == null ? void 0 : _a.label) == "EMPTY") {
1344
+ yield canvasElement.load();
1345
+ }
1346
+ let container = new CanvasContainer();
1347
+ container.addChild(canvasElement);
1348
+ container.height = GameWindowManager.canvasHeight;
1349
+ container.width = GameWindowManager.canvasWidth;
1350
+ GameWindowManager.addCanvasElement(tag, container);
1351
+ if (props.direction == "up") {
1352
+ container.pivot.y = GameWindowManager.canvasHeight;
1353
+ container.pivot.x = GameWindowManager.canvasWidth / 2;
1354
+ container.y = GameWindowManager.canvasHeight;
1355
+ container.x = GameWindowManager.canvasWidth / 2;
1356
+ } else if (props.direction == "down") {
1357
+ container.pivot.y = 0;
1358
+ container.pivot.x = GameWindowManager.canvasWidth / 2;
1359
+ container.y = 0;
1360
+ container.x = GameWindowManager.canvasWidth / 2;
1361
+ } else if (props.direction == "left") {
1362
+ container.pivot.x = GameWindowManager.canvasWidth;
1363
+ container.pivot.y = GameWindowManager.canvasHeight / 2;
1364
+ container.x = GameWindowManager.canvasWidth;
1365
+ container.y = GameWindowManager.canvasHeight / 2;
1366
+ } else if (props.direction == "right") {
1367
+ container.pivot.x = 0;
1368
+ container.pivot.y = GameWindowManager.canvasHeight / 2;
1369
+ container.x = 0;
1370
+ container.y = GameWindowManager.canvasHeight / 2;
1371
+ }
1372
+ container.scale.set(0);
1373
+ let effect = new ZoomInOutTicker(__spreadProps(__spreadValues({}, props), {
1374
+ startOnlyIfHaveTexture: true,
1375
+ type: "zoom",
1376
+ limit: 1
1377
+ }), priority);
1378
+ GameWindowManager.addTicker(tag, effect);
1379
+ });
1380
+ }
1381
+ function zoomOut(tag, props = { direction: "right" }, priority) {
1382
+ let canvasElement = GameWindowManager.getCanvasElement(tag);
1383
+ if (!canvasElement) {
1384
+ console.warn("[Pixi'VN] The canvas element is not found.");
1385
+ return;
1386
+ }
1387
+ let container = new CanvasContainer();
1388
+ container.addChild(canvasElement);
1389
+ container.height = GameWindowManager.canvasHeight;
1390
+ container.width = GameWindowManager.canvasWidth;
1391
+ GameWindowManager.addCanvasElement(tag, container);
1392
+ if (props.direction == "up") {
1393
+ container.pivot.y = GameWindowManager.canvasHeight;
1394
+ container.pivot.x = GameWindowManager.canvasWidth / 2;
1395
+ container.y = GameWindowManager.canvasHeight;
1396
+ container.x = GameWindowManager.canvasWidth / 2;
1397
+ } else if (props.direction == "down") {
1398
+ container.pivot.y = 0;
1399
+ container.pivot.x = GameWindowManager.canvasWidth / 2;
1400
+ container.y = 0;
1401
+ container.x = GameWindowManager.canvasWidth / 2;
1402
+ } else if (props.direction == "left") {
1403
+ container.pivot.x = GameWindowManager.canvasWidth;
1404
+ container.pivot.y = GameWindowManager.canvasHeight / 2;
1405
+ container.x = GameWindowManager.canvasWidth;
1406
+ container.y = GameWindowManager.canvasHeight / 2;
1407
+ } else if (props.direction == "right") {
1408
+ container.pivot.x = 0;
1409
+ container.pivot.y = GameWindowManager.canvasHeight / 2;
1410
+ container.x = 0;
1411
+ container.y = GameWindowManager.canvasHeight / 2;
1412
+ }
1413
+ container.scale.set(1);
1414
+ let effect = new ZoomInOutTicker(__spreadProps(__spreadValues({}, props), {
1415
+ startOnlyIfHaveTexture: true,
1416
+ type: "unzoom",
1417
+ limit: 0,
1418
+ tagToRemoveAfter: tag
1419
+ }), priority);
1420
+ GameWindowManager.addTicker(tag, effect);
1421
+ }
1422
+
1423
+ // src/functions/ExportUtility.ts
1424
+ function createExportableElement(element) {
1425
+ try {
1426
+ let elementString = JSON.stringify(element);
1427
+ return JSON.parse(elementString);
1428
+ } catch (e) {
1429
+ console.error("[Pixi'VN] Error creating exportable element", e);
1430
+ throw new Error("[Pixi'VN] Error creating exportable element");
1431
+ }
1432
+ }
1433
+
1434
+ // src/functions/DiffUtility.ts
1435
+ function restoreDeepDiffChanges(data, differences) {
1436
+ let result = createExportableElement(data);
1437
+ differences.forEach((diff2) => {
1438
+ let dataToEdit = result;
1439
+ if (diff2.path && diff2.path.length > 0) {
1440
+ diff2.path.forEach((path, index) => {
1441
+ if (diff2.path && index === diff2.path.length - 1) {
1442
+ if (diff2.kind === "E" || diff2.kind === "D") {
1443
+ dataToEdit[path] = diff2.lhs;
1444
+ } else if (diff2.kind === "N") {
1445
+ if (Number.isInteger(path)) {
1446
+ if (Array.isArray(dataToEdit)) {
1447
+ dataToEdit.splice(path, 1);
1448
+ }
1449
+ } else if (typeof path === "string") {
1450
+ delete dataToEdit[path];
1451
+ }
1452
+ } else if (diff2.kind === "A") {
1453
+ let index2 = diff2.index;
1454
+ if (diff2.item.kind === "N") {
1455
+ dataToEdit[path].splice(index2, 1);
1456
+ } else if (diff2.item.kind === "E" || diff2.item.kind === "D") {
1457
+ dataToEdit[path][index2] = diff2.item.lhs;
1458
+ } else if (diff2.item.kind === "A") {
1459
+ console.warn("[Pixi'VN] Nested array found, skipping diff", diff2);
1460
+ } else {
1461
+ console.warn("[Pixi'VN] No array found, skipping diff", diff2);
1462
+ }
1463
+ }
1464
+ } else {
1465
+ dataToEdit = dataToEdit[path];
1466
+ }
1467
+ });
1468
+ } else {
1469
+ console.warn("[Pixi'VN] No path found, skipping diff", diff2);
1470
+ }
1471
+ });
1472
+ return result;
1473
+ }
1474
+
1475
+ // src/managers/StorageManager.ts
1476
+ var _GameStorageManager = class _GameStorageManager {
1477
+ constructor() {
1478
+ }
1479
+ static get keysSystem() {
1480
+ return {
1481
+ CURRENT_DIALOGUE_MEMORY_KEY: "___current_dialogue_memory___",
1482
+ LAST_DIALOGUE_ADDED_IN_STEP_MEMORY_KEY: "___last_dialogue_added_in_step_memory___",
1483
+ CURRENT_MENU_OPTIONS_MEMORY_KEY: "___current_menu_options_memory___",
1484
+ LAST_MENU_OPTIONS_ADDED_IN_STEP_MEMORY_KEY: "___last_menu_options_added_in_step_memory___",
1485
+ CHARACTER_CATEGORY_KEY: "___character___",
1486
+ FLAGS_CATEGORY_KEY: "___flags___"
1487
+ };
1488
+ }
1489
+ /**
1490
+ * Set a variable in the storage
1491
+ * @param key The key of the variable
1492
+ * @param value The value of the variable. If undefined, the variable will be removed
1493
+ * @returns
1494
+ */
1495
+ static setVariable(key, value) {
1496
+ key = key.toLowerCase();
1497
+ if (value === void 0 || value === null) {
1498
+ if (_GameStorageManager.storage.hasOwnProperty(key)) {
1499
+ delete _GameStorageManager.storage[key];
1500
+ }
1501
+ return;
1502
+ }
1503
+ _GameStorageManager.storage[key] = value;
1504
+ }
1505
+ /**
1506
+ * Get a variable from the storage
1507
+ * @param key The key of the variable
1508
+ * @returns The value of the variable. If the variable does not exist, it will return undefined
1509
+ */
1510
+ static getVariable(key) {
1511
+ key = key.toLowerCase();
1512
+ if (_GameStorageManager.storage.hasOwnProperty(key)) {
1513
+ return _GameStorageManager.storage[key];
1514
+ }
1515
+ return void 0;
1516
+ }
1517
+ /**
1518
+ * Remove a variable from the storage
1519
+ * @param key The key of the variable
1520
+ * @returns
1521
+ */
1522
+ static removeVariable(key) {
1523
+ key = key.toLowerCase();
1524
+ if (_GameStorageManager.storage.hasOwnProperty(key)) {
1525
+ delete _GameStorageManager.storage[key];
1526
+ }
1527
+ }
1528
+ /**
1529
+ * Clear the storage and the oidsUsed
1530
+ * @returns
1531
+ */
1532
+ static clear() {
1533
+ _GameStorageManager.storage = {};
1534
+ }
1535
+ static exportJson() {
1536
+ return JSON.stringify(this.export());
1537
+ }
1538
+ static export() {
1539
+ return createExportableElement(_GameStorageManager.storage);
1540
+ }
1541
+ static importJson(dataString) {
1542
+ _GameStorageManager.import(JSON.parse(dataString));
1543
+ }
1544
+ static import(data) {
1545
+ _GameStorageManager.clear();
1546
+ try {
1547
+ if (data) {
1548
+ _GameStorageManager.storage = data;
1549
+ } else {
1550
+ console.warn("[Pixi'VN] No storage data found");
1551
+ }
1552
+ } catch (e) {
1553
+ console.error("[Pixi'VN] Error importing data", e);
1554
+ }
1555
+ }
1556
+ };
1557
+ _GameStorageManager.storage = {};
1558
+ var GameStorageManager = _GameStorageManager;
1559
+
1560
+ // src/functions/EasterEgg.ts
1561
+ function asciiArtLog() {
1562
+ console.info(`
1563
+ ____ _ _ ___ ___ _
1564
+ | _ \\(_)_ _(_| ) \\ / / \\ | |
1565
+ | |_) | \\ \\/ / |/ \\ \\ / /| \\| |
1566
+ | __/| |> <| | \\ V / | |\\ |
1567
+ |_| |_/_/\\_\\_| \\_/ |_| \\_|
1568
+ `);
1569
+ }
1570
+
1571
+ // src/types/ticker/TagToRemoveAfterType.ts
1572
+ var tagToRemoveAfter = "tagToRemoveAfter";
1573
+
1574
+ // src/managers/WindowManager.ts
1575
+ var _GameWindowManager = class _GameWindowManager {
1576
+ constructor() {
1577
+ }
1578
+ /**
1579
+ * The PIXI Application instance.
1580
+ * It not recommended to use this property directly.
1581
+ */
1582
+ static get app() {
1583
+ if (!_GameWindowManager._app) {
1584
+ throw new Error("[Pixi'VN] GameWindowManager.app is undefined");
1585
+ }
1586
+ return _GameWindowManager._app;
1587
+ }
1588
+ /**
1589
+ * If the manager is initialized.
1590
+ */
1591
+ static get isInitialized() {
1592
+ return _GameWindowManager._isInitialized;
1593
+ }
1594
+ static get screen() {
1595
+ return _GameWindowManager.app.screen;
1596
+ }
1597
+ /**
1598
+ * Initialize the PIXI Application and the interface div.
1599
+ * This method should be called before any other method.
1600
+ * @param element The html element where I will put the canvas. Example: document.body
1601
+ * @param width The width of the canvas
1602
+ * @param height The height of the canvas
1603
+ * @param options The options of PIXI Application
1604
+ * @example
1605
+ * ```typescript
1606
+ * const body = document.body
1607
+ * if (!body) {
1608
+ * throw new Error('body element not found')
1609
+ * }
1610
+ * await GameWindowManager.initialize(body, 1920, 1080, {
1611
+ * backgroundColor: "#303030"
1612
+ * })
1613
+ * ```
1614
+ */
1615
+ static initialize(element, width, height, options) {
1616
+ return __async(this, null, function* () {
1617
+ _GameWindowManager.canvasWidth = width;
1618
+ _GameWindowManager.canvasHeight = height;
1619
+ _GameWindowManager._app = new pixi_js.Application();
1620
+ return _GameWindowManager.app.init(__spreadValues({
1621
+ resolution: window.devicePixelRatio || 1,
1622
+ autoDensity: true,
1623
+ width,
1624
+ height
1625
+ }, options)).then(() => {
1626
+ _GameWindowManager._isInitialized = true;
1627
+ this.addCanvasIntoElement(element);
1628
+ window.addEventListener("resize", _GameWindowManager.resize);
1629
+ _GameWindowManager.resize();
1630
+ asciiArtLog();
1631
+ });
1632
+ });
1633
+ }
1634
+ /**
1635
+ * Add the canvas into a html element.
1636
+ * @param element it is the html element where I will put the canvas. Example: document.body
1637
+ */
1638
+ static addCanvasIntoElement(element) {
1639
+ if (_GameWindowManager.isInitialized) {
1640
+ element.appendChild(_GameWindowManager.app.canvas);
1641
+ } else {
1642
+ console.error("[Pixi'VN] GameWindowManager is not initialized");
1643
+ }
1644
+ }
1645
+ /**
1646
+ * Initialize the interface div and add it into a html element.
1647
+ * @param element it is the html element where I will put the interface div. Example: document.getElementById('root')
1648
+ * @example
1649
+ * ```tsx
1650
+ * const root = document.getElementById('root')
1651
+ * if (!root) {
1652
+ * throw new Error('root element not found')
1653
+ * }
1654
+ * GameWindowManager.initializeHTMLLayout(root)
1655
+ * const reactRoot = createRoot(GameWindowManager.htmlLayout)
1656
+ * reactRoot.render(
1657
+ * <App />
1658
+ * )
1659
+ * ```
1660
+ */
1661
+ static initializeHTMLLayout(element) {
1662
+ let div = document.createElement("div");
1663
+ div.style.position = "absolute";
1664
+ div.style.pointerEvents = "none";
1665
+ element.appendChild(div);
1666
+ _GameWindowManager.htmlLayout = div;
1667
+ _GameWindowManager.resize();
1668
+ }
1669
+ /* Resize Metods */
1670
+ /**
1671
+ * This method returns the scale of the screen.
1672
+ */
1673
+ static get screenScale() {
1674
+ let screenWidth = Math.max(document.documentElement.clientWidth, window.innerWidth || 0);
1675
+ let screenHeight = Math.max(document.documentElement.clientHeight, window.innerHeight || 0);
1676
+ return Math.min(screenWidth / _GameWindowManager.canvasWidth, screenHeight / _GameWindowManager.canvasHeight);
1677
+ }
1678
+ /**
1679
+ * This method returns the width of the screen enlarged by the scale.
1680
+ */
1681
+ static get screenWidth() {
1682
+ return Math.floor(_GameWindowManager.screenScale * _GameWindowManager.canvasWidth);
1683
+ }
1684
+ /**
1685
+ * This method returns the height of the screen enlarged by the scale.
1686
+ */
1687
+ static get screenHeight() {
1688
+ return Math.floor(_GameWindowManager.screenScale * _GameWindowManager.canvasHeight);
1689
+ }
1690
+ /**
1691
+ * This method returns the horizontal margin of the screen.
1692
+ */
1693
+ static get horizontalMargin() {
1694
+ let screenWidth = Math.max(document.documentElement.clientWidth, window.innerWidth || 0);
1695
+ return (screenWidth - _GameWindowManager.screenWidth) / 2;
1696
+ }
1697
+ /**
1698
+ * This method returns the vertical margin of the screen.
1699
+ */
1700
+ static get verticalMargin() {
1701
+ let screenHeight = Math.max(document.documentElement.clientHeight, window.innerHeight || 0);
1702
+ return (screenHeight - _GameWindowManager.screenHeight) / 2;
1703
+ }
1704
+ /**
1705
+ * This method is called when the screen is resized.
1706
+ */
1707
+ static resize() {
1708
+ if (_GameWindowManager.isInitialized) {
1709
+ let style = _GameWindowManager.app.canvas.style;
1710
+ style.width = `${_GameWindowManager.screenWidth}px`;
1711
+ style.height = `${_GameWindowManager.screenHeight}px`;
1712
+ style.marginLeft = `${_GameWindowManager.horizontalMargin}px`;
1713
+ style.marginRight = `${_GameWindowManager.horizontalMargin}px`;
1714
+ style.marginTop = `${_GameWindowManager.verticalMargin}px`;
1715
+ style.marginBottom = `${_GameWindowManager.verticalMargin}px`;
1716
+ }
1717
+ if (_GameWindowManager.htmlLayout) {
1718
+ _GameWindowManager.htmlLayout.style.width = `${_GameWindowManager.screenWidth}px`;
1719
+ _GameWindowManager.htmlLayout.style.height = `${_GameWindowManager.screenHeight}px`;
1720
+ _GameWindowManager.htmlLayout.style.marginLeft = `${_GameWindowManager.horizontalMargin}px`;
1721
+ _GameWindowManager.htmlLayout.style.marginRight = `${_GameWindowManager.horizontalMargin}px`;
1722
+ _GameWindowManager.htmlLayout.style.marginTop = `${_GameWindowManager.verticalMargin}px`;
1723
+ _GameWindowManager.htmlLayout.style.marginBottom = `${_GameWindowManager.verticalMargin}px`;
1724
+ }
1725
+ }
1726
+ /* Edit Canvas Elements Methods */
1727
+ /**
1728
+ * This is a dictionary that contains all Canvas Elements of Canvas, currently.
1729
+ */
1730
+ static get currentCanvasElements() {
1731
+ return _GameWindowManager._children;
1732
+ }
1733
+ /**
1734
+ * Add a canvas element to the canvas.
1735
+ * If there is a canvas element with the same tag, it will be removed.
1736
+ * @param tag The tag of the canvas element.
1737
+ * @param canvasElement The canvas elements to be added.
1738
+ * @example
1739
+ * ```typescript
1740
+ * const texture = await Assets.load('https://pixijs.com/assets/bunny.png');
1741
+ * const sprite = CanvasSprite.from(texture);
1742
+ * GameWindowManager.addCanvasElement("bunny", sprite);
1743
+ * ```
1744
+ */
1745
+ static addCanvasElement(tag, canvasElement) {
1746
+ if (_GameWindowManager._children[tag]) {
1747
+ _GameWindowManager.removeCanvasElement(tag);
1748
+ }
1749
+ _GameWindowManager.app.stage.addChild(canvasElement);
1750
+ _GameWindowManager._children[tag] = canvasElement;
1751
+ _GameWindowManager.childrenTagsOrder.push(tag);
1752
+ }
1753
+ /**
1754
+ * Remove a canvas element from the canvas.
1755
+ * And remove all tickers that are not connected to any canvas element.
1756
+ * @param tags The tag of the canvas element to be removed.
1757
+ * @returns
1758
+ * @example
1759
+ * ```typescript
1760
+ * GameWindowManager.removeCanvasElement("bunny");
1761
+ * ```
1762
+ */
1763
+ static removeCanvasElement(tags) {
1764
+ if (typeof tags === "string") {
1765
+ tags = [tags];
1766
+ }
1767
+ tags.forEach((tag) => {
1768
+ if (_GameWindowManager._children[tag]) {
1769
+ _GameWindowManager.app.stage.removeChild(_GameWindowManager._children[tag]);
1770
+ delete _GameWindowManager._children[tag];
1771
+ _GameWindowManager.removeTickerByCanvasElement(tag);
1772
+ }
1773
+ });
1774
+ _GameWindowManager.childrenTagsOrder = _GameWindowManager.childrenTagsOrder.filter((t) => !tags.includes(t));
1775
+ }
1776
+ /**
1777
+ * Get a canvas element by the tag.
1778
+ * @param tag The tag of the canvas element.
1779
+ * @returns The canvas element.
1780
+ * @example
1781
+ * ```typescript
1782
+ * const sprite = GameWindowManager.getCanvasElement<CanvasSprite>("bunny");
1783
+ * ```
1784
+ */
1785
+ static getCanvasElement(tag) {
1786
+ return _GameWindowManager._children[tag];
1787
+ }
1788
+ /**
1789
+ * Check if a DisplayObject is on the canvas.
1790
+ * @param pixiElement The DisplayObject to be checked.
1791
+ * @returns If the DisplayObject is on the canvas.
1792
+ */
1793
+ static canvasElementIsOnCanvas(pixiElement) {
1794
+ return _GameWindowManager.app.stage.children.includes(pixiElement);
1795
+ }
1796
+ /**
1797
+ * Remove all canvas elements from the canvas.
1798
+ * And remove all tickers that are not connected to any canvas element.
1799
+ */
1800
+ static removeCanvasElements() {
1801
+ _GameWindowManager.app.stage.removeChildren();
1802
+ _GameWindowManager._children = {};
1803
+ _GameWindowManager.childrenTagsOrder = [];
1804
+ _GameWindowManager.removeAllTickers();
1805
+ }
1806
+ /**
1807
+ * Edit the tag of a canvas element.
1808
+ * @param oldTag The old tag of the canvas element.
1809
+ * @param newTag The new tag of the canvas element.
1810
+ */
1811
+ static editCanvasElementTag(oldTag, newTag) {
1812
+ if (_GameWindowManager._children[oldTag]) {
1813
+ _GameWindowManager._children[newTag] = _GameWindowManager._children[oldTag];
1814
+ delete _GameWindowManager._children[oldTag];
1815
+ }
1816
+ if (_GameWindowManager._currentTickersSteps[oldTag]) {
1817
+ _GameWindowManager._currentTickersSteps[newTag] = _GameWindowManager._currentTickersSteps[oldTag];
1818
+ delete _GameWindowManager._currentTickersSteps[oldTag];
1819
+ }
1820
+ for (let id in _GameWindowManager._currentTickers) {
1821
+ let ticker = _GameWindowManager._currentTickers[id];
1822
+ if (ticker.canvasElementTags.includes(oldTag)) {
1823
+ ticker.canvasElementTags = ticker.canvasElementTags.map((t) => t === oldTag ? newTag : t);
1824
+ if (ticker.args.hasOwnProperty(tagToRemoveAfter)) {
1825
+ let tagToRemoveAfter2 = ticker.args.tagToRemoveAfter;
1826
+ if (typeof tagToRemoveAfter2 === "string") {
1827
+ tagToRemoveAfter2 = [tagToRemoveAfter2];
1828
+ }
1829
+ if (Array.isArray(tagToRemoveAfter2)) {
1830
+ ticker.args.tagToRemoveAfter = tagToRemoveAfter2.map((t) => t === oldTag ? newTag : t);
1831
+ }
1832
+ }
1833
+ }
1834
+ }
1835
+ for (let timeout in _GameWindowManager._currentTickersTimeouts) {
1836
+ let TickerTimeout = _GameWindowManager._currentTickersTimeouts[timeout];
1837
+ if (TickerTimeout.tags.includes(oldTag)) {
1838
+ TickerTimeout.tags = TickerTimeout.tags.map((t) => t === oldTag ? newTag : t);
1839
+ }
1840
+ }
1841
+ }
1842
+ /** Edit Tickers Methods */
1843
+ /**
1844
+ * Currently tickers that are running.
1845
+ */
1846
+ static get currentTickers() {
1847
+ return _GameWindowManager._currentTickers;
1848
+ }
1849
+ static get currentTickersList() {
1850
+ return Object.values(_GameWindowManager._currentTickers);
1851
+ }
1852
+ static get currentTickersWithoutCreatedBySteps() {
1853
+ return Object.fromEntries(Object.entries(_GameWindowManager._currentTickers).filter(([_, ticker]) => !ticker.createdByTicketStepsId));
1854
+ }
1855
+ /**
1856
+ * The steps of the tickers
1857
+ */
1858
+ static get currentTickersSteps() {
1859
+ return _GameWindowManager._currentTickersSteps;
1860
+ }
1861
+ static generateTickerId(tickerData) {
1862
+ try {
1863
+ return sha1__default.default(JSON.stringify(tickerData)).toString() + "_" + Math.random().toString(36).substring(7);
1864
+ } catch (e) {
1865
+ throw new Error(`[Pixi'VN] Error to generate ticker id: ${e}`);
1866
+ }
1867
+ }
1868
+ /**
1869
+ * Run a ticker. You can run multiple addTicker with the same tag and different tickerClasses.
1870
+ * If you run a ticker with the same tag and tickerClass, the old ticker will be removed.
1871
+ * If already exists a sequence of tickers with the same tag, it will be removed.
1872
+ * @param canvasEslementTag The tag of the canvas element that will use the ticker.
1873
+ * @param ticker The ticker class to be run.
1874
+ * @param args The arguments to be used in the ticker.
1875
+ * @param duration The time to be used in the ticker. This number is in seconds. If it is undefined, the ticker will run forever.
1876
+ * @param priority The priority to be used in the ticker.
1877
+ * @returns
1878
+ * @example
1879
+ * ```typescript
1880
+ * GameWindowManager.addTicker("alien", new RotateTicker({ speed: 0.2 }))
1881
+ * ```
1882
+ */
1883
+ static addTicker(canvasElementTag, ticker) {
1884
+ let tickerId = ticker.id;
1885
+ if (typeof canvasElementTag === "string") {
1886
+ canvasElementTag = [canvasElementTag];
1887
+ }
1888
+ if (!geTickerInstanceById(tickerId, ticker.args, ticker.duration, ticker.priority)) {
1889
+ console.error(`[Pixi'VN] Ticker ${tickerId} not found`);
1890
+ return;
1891
+ }
1892
+ let tickerHistory = {
1893
+ fn: () => {
1894
+ },
1895
+ id: tickerId,
1896
+ args: createExportableElement(ticker.args),
1897
+ canvasElementTags: canvasElementTag,
1898
+ priority: ticker.priority,
1899
+ duration: ticker.duration
1900
+ };
1901
+ let id = _GameWindowManager.generateTickerId(tickerHistory);
1902
+ _GameWindowManager.pushTicker(id, tickerHistory, ticker);
1903
+ if (ticker.duration) {
1904
+ let timeout = setTimeout(() => {
1905
+ _GameWindowManager.removeTickerTimeoutInfo(timeout);
1906
+ let tickerTimeoutInfo = _GameWindowManager._currentTickersTimeouts[timeout.toString()];
1907
+ if (tickerTimeoutInfo) {
1908
+ _GameWindowManager.removeTicker(id);
1909
+ }
1910
+ }, ticker.duration * 1e3);
1911
+ _GameWindowManager.addTickerTimeoutInfo(canvasElementTag, tickerId, timeout.toString(), true);
1912
+ }
1913
+ }
1914
+ static pushTicker(id, tickerData, ticker) {
1915
+ _GameWindowManager.removeAssociationBetweenTickerCanvasElement(tickerData.canvasElementTags, ticker);
1916
+ _GameWindowManager._currentTickers[id] = tickerData;
1917
+ tickerData.fn = (t) => {
1918
+ let data = _GameWindowManager._currentTickers[id];
1919
+ if (data) {
1920
+ ticker == null ? void 0 : ticker.fn(t, data.args, data.canvasElementTags, id);
1921
+ }
1922
+ };
1923
+ _GameWindowManager.app.ticker.add(tickerData.fn, void 0, tickerData.priority);
1924
+ }
1925
+ /**
1926
+ * Run a sequence of tickers. If exists a ticker steps with the same tag, it will be removed.
1927
+ * @param tag The tag of canvas element that will use the tickers.
1928
+ * @param steps The steps of the tickers.
1929
+ * @param currentStepNumber The current step number. It is used to continue the sequence of tickers.
1930
+ * @returns
1931
+ * @example
1932
+ * ```typescript
1933
+ * GameWindowManager.addTickersSteps("alien", [
1934
+ * new RotateTicker({ speed: 0.1, clockwise: true }, 2), // 2 seconds
1935
+ * Pause(1), // 1 second
1936
+ * new RotateTicker({ speed: 0.2, clockwise: false }, 2),
1937
+ * Repeat,
1938
+ * ])
1939
+ * ```
1940
+ */
1941
+ static addTickersSteps(tag, steps, currentStepNumber = 0) {
1942
+ if (steps.length == 0) {
1943
+ console.warn("[Pixi'VN] The steps of the tickers is empty");
1944
+ return;
1945
+ }
1946
+ _GameWindowManager.removeTickerStepByCanvasElement(tag);
1947
+ _GameWindowManager._currentTickersSteps[tag] = {
1948
+ currentStepNumber,
1949
+ steps: steps.map((step) => {
1950
+ if (step === Repeat) {
1951
+ return step;
1952
+ }
1953
+ if (step.hasOwnProperty("type") && step.type === "pause") {
1954
+ return step;
1955
+ }
1956
+ let tickerId = step.id;
1957
+ return {
1958
+ ticker: tickerId,
1959
+ args: createExportableElement(step.args),
1960
+ duration: step.duration
1961
+ };
1962
+ })
1963
+ };
1964
+ _GameWindowManager.runTickersSteps(tag);
1965
+ }
1966
+ static restoneTickersSteps(data) {
1967
+ for (let tag in data) {
1968
+ let steps = data[tag];
1969
+ _GameWindowManager._currentTickersSteps[tag] = steps;
1970
+ _GameWindowManager.runTickersSteps(tag);
1971
+ }
1972
+ }
1973
+ static runTickersSteps(tag) {
1974
+ let step = _GameWindowManager._currentTickersSteps[tag].steps[_GameWindowManager._currentTickersSteps[tag].currentStepNumber];
1975
+ if (step === Repeat) {
1976
+ step = _GameWindowManager._currentTickersSteps[tag].steps[0];
1977
+ _GameWindowManager._currentTickersSteps[tag].currentStepNumber = 0;
1978
+ if (step === Repeat) {
1979
+ console.error("[Pixi'VN] TikersSteps has a RepeatType in the first step");
1980
+ return;
1981
+ }
1982
+ }
1983
+ if (step.hasOwnProperty("type") && step.type === "pause") {
1984
+ let timeout = setTimeout(() => {
1985
+ let tickerTimeoutInfo = _GameWindowManager._currentTickersTimeouts[timeout.toString()];
1986
+ if (tickerTimeoutInfo) {
1987
+ tickerTimeoutInfo.tags.forEach((tag2) => {
1988
+ _GameWindowManager.nextTickerStep(tag2);
1989
+ });
1990
+ }
1991
+ _GameWindowManager.removeTickerTimeoutInfo(timeout);
1992
+ }, step.duration * 1e3);
1993
+ _GameWindowManager.addTickerTimeoutInfo(tag, "steps", timeout.toString(), false);
1994
+ return;
1995
+ }
1996
+ let ticker = geTickerInstanceById(step.ticker, step.args, step.duration, step.priority);
1997
+ if (!ticker) {
1998
+ console.error(`[Pixi'VN] Ticker ${step.ticker} not found`);
1999
+ return;
2000
+ }
2001
+ let tickerName = ticker.id;
2002
+ let tickerHistory = {
2003
+ fn: () => {
2004
+ },
2005
+ id: tickerName,
2006
+ args: createExportableElement(ticker.args),
2007
+ canvasElementTags: [tag],
2008
+ priority: ticker.priority,
2009
+ duration: ticker.duration,
2010
+ createdByTicketStepsId: tag
2011
+ };
2012
+ let id = _GameWindowManager.generateTickerId(tickerHistory);
2013
+ _GameWindowManager.pushTicker(id, tickerHistory, ticker);
2014
+ if (ticker.duration) {
2015
+ let timeout = setTimeout(() => {
2016
+ let tickerTimeoutInfo = _GameWindowManager._currentTickersTimeouts[timeout.toString()];
2017
+ if (tickerTimeoutInfo) {
2018
+ _GameWindowManager.removeTicker(id);
2019
+ tickerTimeoutInfo.tags.forEach((tag2) => {
2020
+ _GameWindowManager.nextTickerStep(tag2);
2021
+ });
2022
+ }
2023
+ _GameWindowManager.removeTickerTimeoutInfo(timeout);
2024
+ }, ticker.duration * 1e3);
2025
+ _GameWindowManager.addTickerTimeoutInfo(tag, tickerName, timeout.toString(), false);
2026
+ }
2027
+ }
2028
+ static nextTickerStep(tag) {
2029
+ if (_GameWindowManager._currentTickersSteps[tag]) {
2030
+ let steps = _GameWindowManager._currentTickersSteps[tag];
2031
+ if (steps.currentStepNumber + 1 < steps.steps.length) {
2032
+ steps.currentStepNumber++;
2033
+ _GameWindowManager._currentTickersSteps[tag] = steps;
2034
+ _GameWindowManager.runTickersSteps(tag);
2035
+ } else {
2036
+ _GameWindowManager.removeTickerStepByCanvasElement(tag);
2037
+ }
2038
+ }
2039
+ }
2040
+ static onEndOfTicker(canvasElementTags, ticker, canvasElementTagsToDelete, tickerId) {
2041
+ let tickerData = _GameWindowManager._currentTickers[tickerId];
2042
+ _GameWindowManager.removeAssociationBetweenTickerCanvasElement(canvasElementTags, ticker);
2043
+ _GameWindowManager.removeCanvasElement(canvasElementTagsToDelete);
2044
+ if (tickerData) {
2045
+ _GameWindowManager.removeTicker(tickerId);
2046
+ if (tickerData.duration == void 0 && tickerData.createdByTicketStepsId) {
2047
+ _GameWindowManager.nextTickerStep(tickerData.createdByTicketStepsId);
2048
+ }
2049
+ }
2050
+ }
2051
+ /**
2052
+ * Remove a connection between a canvas element and a ticker.
2053
+ * And remove the ticker if there is no canvas element connected to it.
2054
+ * @param tags The tag of the canvas element that will use the ticker.
2055
+ * @param ticker The ticker class to be removed.
2056
+ * @example
2057
+ * ```typescript
2058
+ * GameWindowManager.removeAssociationBetweenTickerCanvasElement("alien", RotateTicker)
2059
+ * ```
2060
+ */
2061
+ static removeAssociationBetweenTickerCanvasElement(tags, ticker) {
2062
+ let tickerId;
2063
+ if (typeof ticker === "string") {
2064
+ tickerId = ticker;
2065
+ } else if (ticker instanceof TickerBase) {
2066
+ tickerId = ticker.id;
2067
+ } else {
2068
+ tickerId = ticker.prototype.id;
2069
+ }
2070
+ if (typeof tags === "string") {
2071
+ tags = [tags];
2072
+ }
2073
+ for (let id in _GameWindowManager._currentTickers) {
2074
+ let ticker2 = _GameWindowManager._currentTickers[id];
2075
+ if (ticker2.id === tickerId) {
2076
+ _GameWindowManager._currentTickers[id].canvasElementTags = ticker2.canvasElementTags.filter((e) => !tags.includes(e));
2077
+ }
2078
+ }
2079
+ for (let timeout in _GameWindowManager._currentTickersTimeouts) {
2080
+ let TickerTimeout = _GameWindowManager._currentTickersTimeouts[timeout];
2081
+ if (TickerTimeout.ticker === tickerId && TickerTimeout.canBeDeletedBeforeEnd) {
2082
+ _GameWindowManager._currentTickersTimeouts[timeout].tags = TickerTimeout.tags.filter((t) => !tags.includes(t));
2083
+ }
2084
+ }
2085
+ _GameWindowManager.removeTickersWithoutAssociatedCanvasElement();
2086
+ }
2087
+ /**
2088
+ * Remove all tickers that are not connected to any existing canvas element.
2089
+ */
2090
+ static removeTickersWithoutAssociatedCanvasElement() {
2091
+ for (let id in _GameWindowManager._currentTickers) {
2092
+ let ticker = _GameWindowManager._currentTickers[id];
2093
+ ticker.canvasElementTags = ticker.canvasElementTags.filter((e) => _GameWindowManager._children[e]);
2094
+ if (ticker.canvasElementTags.length === 0) {
2095
+ _GameWindowManager.removeTicker(id);
2096
+ }
2097
+ }
2098
+ for (let tag in _GameWindowManager._currentTickersSteps) {
2099
+ if (_GameWindowManager._children[tag] === void 0) {
2100
+ delete _GameWindowManager._currentTickersSteps[tag];
2101
+ }
2102
+ }
2103
+ Object.entries(_GameWindowManager._currentTickersTimeouts).forEach(([timeout, { tags }]) => {
2104
+ if (tags.length === 0) {
2105
+ _GameWindowManager.removeTickerTimeout(timeout);
2106
+ }
2107
+ });
2108
+ }
2109
+ static addTickerTimeoutInfo(tags, ticker, timeout, canBeDeletedBeforeEnd) {
2110
+ if (typeof tags === "string") {
2111
+ tags = [tags];
2112
+ }
2113
+ _GameWindowManager._currentTickersTimeouts[timeout] = {
2114
+ tags,
2115
+ ticker,
2116
+ canBeDeletedBeforeEnd
2117
+ };
2118
+ }
2119
+ static removeTickerTimeoutInfo(timeout) {
2120
+ if (typeof timeout !== "string") {
2121
+ timeout = timeout.toString();
2122
+ }
2123
+ if (_GameWindowManager._currentTickersTimeouts[timeout]) {
2124
+ delete _GameWindowManager._currentTickersTimeouts[timeout];
2125
+ }
2126
+ }
2127
+ static removeTickerTimeout(timeout) {
2128
+ if (typeof timeout !== "string") {
2129
+ timeout = timeout.toString();
2130
+ }
2131
+ clearTimeout(Number(timeout));
2132
+ _GameWindowManager.removeTickerTimeoutInfo(timeout);
2133
+ }
2134
+ static removeTickerTimeoutsByTag(tag, checkCanBeDeletedBeforeEnd) {
2135
+ for (let timeout in _GameWindowManager._currentTickersTimeouts) {
2136
+ let tagsWithoutTagToRemove = _GameWindowManager._currentTickersTimeouts[timeout].tags.filter((t) => t !== tag);
2137
+ if (tagsWithoutTagToRemove.length === 0) {
2138
+ let canBeDeletedBeforeEnd = _GameWindowManager._currentTickersTimeouts[timeout].canBeDeletedBeforeEnd;
2139
+ if (!checkCanBeDeletedBeforeEnd || canBeDeletedBeforeEnd) {
2140
+ _GameWindowManager.removeTickerTimeout(timeout);
2141
+ }
2142
+ } else {
2143
+ _GameWindowManager._currentTickersTimeouts[timeout].tags = tagsWithoutTagToRemove;
2144
+ }
2145
+ }
2146
+ }
2147
+ /**
2148
+ * Remove all tickers from the canvas.
2149
+ */
2150
+ static removeAllTickers() {
2151
+ _GameWindowManager._currentTickersSteps = {};
2152
+ Object.keys(_GameWindowManager._currentTickers).forEach((id) => {
2153
+ _GameWindowManager.removeTicker(id);
2154
+ });
2155
+ _GameWindowManager._currentTickers = {};
2156
+ for (let timeout in _GameWindowManager._currentTickersTimeouts) {
2157
+ _GameWindowManager.removeTickerTimeout(timeout);
2158
+ }
2159
+ }
2160
+ /**
2161
+ * Remove all tickers from a canvas element.
2162
+ * @param tag The tag of the canvas element that will use the ticker.
2163
+ */
2164
+ static removeTickerByCanvasElement(tag) {
2165
+ if (typeof tag === "string") {
2166
+ tag = [tag];
2167
+ }
2168
+ tag.forEach((tag2) => {
2169
+ for (let id in _GameWindowManager._currentTickers) {
2170
+ let ticker = _GameWindowManager._currentTickers[id];
2171
+ if (ticker.canvasElementTags.includes(tag2)) {
2172
+ _GameWindowManager.removeTicker(id);
2173
+ }
2174
+ }
2175
+ if (_GameWindowManager._currentTickersSteps[tag2]) {
2176
+ delete _GameWindowManager._currentTickersSteps[tag2];
2177
+ }
2178
+ _GameWindowManager.removeTickerTimeoutsByTag(tag2, false);
2179
+ delete _GameWindowManager._currentTickersSteps[tag2];
2180
+ });
2181
+ }
2182
+ static removeTickerStepByCanvasElement(tag) {
2183
+ if (_GameWindowManager._currentTickersSteps[tag]) {
2184
+ delete _GameWindowManager._currentTickersSteps[tag];
2185
+ }
2186
+ for (let id in _GameWindowManager._currentTickers) {
2187
+ let ticker = _GameWindowManager._currentTickers[id];
2188
+ if (ticker.createdByTicketStepsId === tag) {
2189
+ _GameWindowManager.removeTicker(id);
2190
+ }
2191
+ }
2192
+ }
2193
+ static removeTicker(tickerId) {
2194
+ let ticker = _GameWindowManager._currentTickers[tickerId];
2195
+ if (ticker) {
2196
+ if (ticker.args.hasOwnProperty(tagToRemoveAfter)) {
2197
+ let tagToRemoveAfter2 = ticker.args.tagToRemoveAfter;
2198
+ _GameWindowManager.removeCanvasElement(tagToRemoveAfter2);
2199
+ }
2200
+ _GameWindowManager.app.ticker.remove(ticker.fn);
2201
+ delete _GameWindowManager._currentTickers[tickerId];
2202
+ }
2203
+ }
2204
+ /**
2205
+ * Clear the canvas and the tickers.
2206
+ */
2207
+ static clear() {
2208
+ _GameWindowManager.removeCanvasElements();
2209
+ }
2210
+ /* Export and Import Methods */
2211
+ /**
2212
+ * Export the canvas and the tickers to a JSON string.
2213
+ * @returns The JSON string.
2214
+ */
2215
+ static exportJson() {
2216
+ return JSON.stringify(this.export());
2217
+ }
2218
+ /**
2219
+ * Export the canvas and the tickers to an object.
2220
+ * @returns The object.
2221
+ */
2222
+ static export() {
2223
+ let currentElements = {};
2224
+ for (let tag in _GameWindowManager._children) {
2225
+ currentElements[tag] = exportCanvasElement(_GameWindowManager._children[tag]);
2226
+ }
2227
+ return {
2228
+ currentTickers: createExportableElement(_GameWindowManager.currentTickersWithoutCreatedBySteps),
2229
+ currentTickersSteps: createExportableElement(_GameWindowManager._currentTickersSteps),
2230
+ currentElements: createExportableElement(currentElements),
2231
+ childrenTagsOrder: createExportableElement(_GameWindowManager.childrenTagsOrder)
2232
+ };
2233
+ }
2234
+ /**
2235
+ * Import the canvas and the tickers from a JSON string.
2236
+ * @param dataString The JSON string.
2237
+ */
2238
+ static importJson(dataString) {
2239
+ _GameWindowManager.import(JSON.parse(dataString));
2240
+ }
2241
+ /**
2242
+ * Import the canvas and the tickers from an object.
2243
+ * @param data The object.
2244
+ */
2245
+ static import(data) {
2246
+ _GameWindowManager.clear();
2247
+ try {
2248
+ if (data.hasOwnProperty("childrenTagsOrder") && data.hasOwnProperty("currentElements")) {
2249
+ let currentElements = data["currentElements"];
2250
+ let childrenTagsOrder = data["childrenTagsOrder"];
2251
+ childrenTagsOrder.forEach((tag) => {
2252
+ if (currentElements[tag]) {
2253
+ let element = importCanvasElement(currentElements[tag]);
2254
+ _GameWindowManager.addCanvasElement(tag, element);
2255
+ _GameWindowManager.childrenTagsOrder.push(tag);
2256
+ }
2257
+ });
2258
+ } else {
2259
+ console.error("[Pixi'VN] The data does not have the properties childrenTagsOrder and currentElements");
2260
+ return;
2261
+ }
2262
+ if (data.hasOwnProperty("currentTickers")) {
2263
+ let currentTickers = data["currentTickers"];
2264
+ for (let id in currentTickers) {
2265
+ let t = currentTickers[id];
2266
+ let tags = t.canvasElementTags;
2267
+ let ticker = geTickerInstanceById(t.id, t.args, t.duration, t.priority);
2268
+ if (ticker) {
2269
+ _GameWindowManager.addTicker(tags, ticker);
2270
+ } else {
2271
+ console.error(`[Pixi'VN] Ticker ${t.id} not found`);
2272
+ }
2273
+ }
2274
+ }
2275
+ if (data.hasOwnProperty("currentTickersSteps")) {
2276
+ let currentTickersSteps = data["currentTickersSteps"];
2277
+ _GameWindowManager.restoneTickersSteps(currentTickersSteps);
2278
+ }
2279
+ } catch (e) {
2280
+ console.error("[Pixi'VN] Error importing data", e);
2281
+ }
2282
+ }
2283
+ };
2284
+ _GameWindowManager._app = void 0;
2285
+ _GameWindowManager._isInitialized = false;
2286
+ _GameWindowManager._children = {};
2287
+ /**
2288
+ * The order of the children tags.
2289
+ */
2290
+ _GameWindowManager.childrenTagsOrder = [];
2291
+ _GameWindowManager._currentTickers = {};
2292
+ _GameWindowManager._currentTickersSteps = {};
2293
+ _GameWindowManager._currentTickersTimeouts = {};
2294
+ var GameWindowManager = _GameWindowManager;
2295
+
2296
+ // src/managers/StepManager.ts
2297
+ var _GameStepManager = class _GameStepManager {
2298
+ constructor() {
2299
+ }
2300
+ static get stepsHistory() {
2301
+ return _GameStepManager._stepsHistory;
2302
+ }
2303
+ /**
2304
+ * lastStepIndex is the last step index that occurred during the progression of the steps. **Not is the length of the stepsHistory - 1.**
2305
+ */
2306
+ static get lastStepIndex() {
2307
+ return _GameStepManager._lastStepIndex;
2308
+ }
2309
+ /**
2310
+ * Increase the last step index that occurred during the progression of the steps.
2311
+ */
2312
+ static increaseLastStepIndex() {
2313
+ _GameStepManager._lastStepIndex++;
2314
+ }
2315
+ static get openedLabels() {
2316
+ return _GameStepManager._openedLabels;
2317
+ }
2318
+ /**
2319
+ * currentLabelId is the current label id that occurred during the progression of the steps.
2320
+ */
2321
+ static get currentLabelId() {
2322
+ if (_GameStepManager._openedLabels.length > 0) {
2323
+ let item = _GameStepManager._openedLabels[_GameStepManager._openedLabels.length - 1];
2324
+ return item.label;
2325
+ }
2326
+ return void 0;
2327
+ }
2328
+ /**
2329
+ * currentLabel is the current label that occurred during the progression of the steps.
2330
+ */
2331
+ static get currentLabel() {
2332
+ if (_GameStepManager.currentLabelId) {
2333
+ return getLabelById(_GameStepManager.currentLabelId);
2334
+ }
2335
+ }
2336
+ static get currentLabelStepIndex() {
2337
+ if (_GameStepManager._openedLabels.length > 0) {
2338
+ let item = _GameStepManager._openedLabels[_GameStepManager._openedLabels.length - 1];
2339
+ return item.currentStepIndex;
2340
+ }
2341
+ return null;
2342
+ }
2343
+ /**
2344
+ * lastHistoryStep is the last history step that occurred during the progression of the steps.
2345
+ */
2346
+ static get lastHistoryStep() {
2347
+ if (_GameStepManager._stepsHistory.length > 0) {
2348
+ return _GameStepManager._stepsHistory[_GameStepManager._stepsHistory.length - 1];
2349
+ }
2350
+ return null;
2351
+ }
2352
+ static get originalStepData() {
2353
+ if (!_GameStepManager._originalStepData) {
2354
+ return {
2355
+ path: "",
2356
+ storage: {},
2357
+ canvas: {
2358
+ childrenTagsOrder: [],
2359
+ currentElements: {},
2360
+ currentTickers: {},
2361
+ currentTickersSteps: {}
2362
+ },
2363
+ labelIndex: -1,
2364
+ openedLabels: []
2365
+ };
2366
+ }
2367
+ return createExportableElement(_GameStepManager._originalStepData);
2368
+ }
2369
+ static set originalStepData(value) {
2370
+ _GameStepManager._originalStepData = createExportableElement(value);
2371
+ }
2372
+ /* Edit History Methods */
2373
+ /**
2374
+ * Add a label to the history.
2375
+ * @param label The label to add to the history.
2376
+ */
2377
+ static addStepHistory(step, choiseMade) {
2378
+ let stepHistory = getStepSha1(step);
2379
+ let historyStep = {
2380
+ path: window.location.pathname,
2381
+ storage: GameStorageManager.export(),
2382
+ canvas: GameWindowManager.export(),
2383
+ labelIndex: _GameStepManager.currentLabelStepIndex || 0,
2384
+ openedLabels: createExportableElement(_GameStepManager._openedLabels)
2385
+ };
2386
+ if (_GameStepManager.originalStepData) {
2387
+ if (_GameStepManager.originalStepData.openedLabels.length === historyStep.openedLabels.length) {
2388
+ try {
2389
+ let lastStepDataOpenedLabelsString = JSON.stringify(_GameStepManager.originalStepData.openedLabels);
2390
+ let historyStepOpenedLabelsString = JSON.stringify(historyStep.openedLabels);
2391
+ if (lastStepDataOpenedLabelsString === historyStepOpenedLabelsString && _GameStepManager.originalStepData.path === historyStep.path && _GameStepManager.originalStepData.labelIndex === historyStep.labelIndex) {
2392
+ return;
2393
+ }
2394
+ } catch (e) {
2395
+ console.error("[Pixi'VN] Error comparing openedLabels", e);
2396
+ }
2397
+ }
2398
+ }
2399
+ let data = deepDiff.diff(_GameStepManager.originalStepData, historyStep);
2400
+ if (data) {
2401
+ let dialoge = void 0;
2402
+ let requiredChoices = void 0;
2403
+ if (GameStorageManager.getVariable(GameStorageManager.keysSystem.LAST_DIALOGUE_ADDED_IN_STEP_MEMORY_KEY) === _GameStepManager.lastStepIndex) {
2404
+ dialoge = getDialogue();
2405
+ }
2406
+ if (GameStorageManager.getVariable(GameStorageManager.keysSystem.LAST_MENU_OPTIONS_ADDED_IN_STEP_MEMORY_KEY) === _GameStepManager.lastStepIndex) {
2407
+ requiredChoices = GameStorageManager.getVariable(GameStorageManager.keysSystem.CURRENT_MENU_OPTIONS_MEMORY_KEY);
2408
+ }
2409
+ _GameStepManager._stepsHistory.push({
2410
+ diff: data,
2411
+ currentLabel: _GameStepManager.currentLabelId,
2412
+ dialoge,
2413
+ choices: requiredChoices,
2414
+ stepSha1: stepHistory,
2415
+ index: _GameStepManager.lastStepIndex,
2416
+ choiceIndexMade: choiseMade
2417
+ });
2418
+ _GameStepManager.originalStepData = historyStep;
2419
+ }
2420
+ _GameStepManager.increaseLastStepIndex();
2421
+ }
2422
+ /**
2423
+ * Add a label to the history.
2424
+ * @param label The label to add to the history.
2425
+ */
2426
+ static pushNewLabel(label) {
2427
+ let currentLabel = getLabelById(label);
2428
+ if (!currentLabel) {
2429
+ throw new Error(`[Pixi'VN] Label ${label} not found`);
2430
+ }
2431
+ _GameStepManager._openedLabels.push({
2432
+ label,
2433
+ currentStepIndex: 0
2434
+ });
2435
+ }
2436
+ /**
2437
+ * Close the current label and add it to the history.
2438
+ * @returns
2439
+ */
2440
+ static closeCurrentLabel() {
2441
+ if (!_GameStepManager.currentLabelId) {
2442
+ console.warn("[Pixi'VN] No label to close");
2443
+ return;
2444
+ }
2445
+ if (!_GameStepManager.currentLabel) {
2446
+ console.error("[Pixi'VN] currentLabel not found");
2447
+ return;
2448
+ }
2449
+ _GameStepManager._openedLabels.pop();
2450
+ }
2451
+ /**
2452
+ * Close all labels and add them to the history. **Attention: This method can cause an unhandled game ending.**
2453
+ */
2454
+ static closeAllLabels() {
2455
+ while (_GameStepManager._openedLabels.length > 0) {
2456
+ _GameStepManager.closeCurrentLabel();
2457
+ }
2458
+ }
2459
+ /**
2460
+ * Increase the current step index of the current label.
2461
+ */
2462
+ static increaseCurrentStepIndex() {
2463
+ let item = _GameStepManager._openedLabels[_GameStepManager._openedLabels.length - 1];
2464
+ _GameStepManager._openedLabels[_GameStepManager._openedLabels.length - 1] = __spreadProps(__spreadValues({}, item), {
2465
+ currentStepIndex: item.currentStepIndex + 1
2466
+ });
2467
+ }
2468
+ static restorLastLabelList() {
2469
+ _GameStepManager._openedLabels = _GameStepManager.originalStepData.openedLabels;
2470
+ }
2471
+ /* Run Methods */
2472
+ static get canGoNext() {
2473
+ let options = getChoiceMenuOptions();
2474
+ if (options && options.length > 0) {
2475
+ return false;
2476
+ }
2477
+ return true;
2478
+ }
2479
+ /**
2480
+ * Execute the next step and add it to the history.
2481
+ * @param props The props to pass to the step.
2482
+ * @param choiseMade The index of the choise made by the player. (This params is used in the choice menu)
2483
+ * @returns StepLabelResultType or undefined.
2484
+ * @example
2485
+ * ```typescript
2486
+ * function nextOnClick() {
2487
+ * setLoading(true)
2488
+ * GameStepManager.goNext(yourParams)
2489
+ * .then((result) => {
2490
+ * setUpdate((p) => p + 1)
2491
+ * setLoading(false)
2492
+ * if (result) {
2493
+ * // your code
2494
+ * }
2495
+ * })
2496
+ * .catch((e) => {
2497
+ * setLoading(false)
2498
+ * console.error(e)
2499
+ * })
2500
+ * }
2501
+ * ```
2502
+ */
2503
+ static goNext(props, choiseMade) {
2504
+ return __async(this, null, function* () {
2505
+ if (!_GameStepManager.canGoNext) {
2506
+ console.warn("[Pixi'VN] The player must make a choice");
2507
+ return;
2508
+ }
2509
+ _GameStepManager.increaseCurrentStepIndex();
2510
+ return yield _GameStepManager.runCurrentStep(props, choiseMade);
2511
+ });
2512
+ }
2513
+ /**
2514
+ * Execute the current step and add it to the history.
2515
+ * @param props The props to pass to the step.
2516
+ * @param choiseMade The choise made by the player.
2517
+ * @returns StepLabelResultType or undefined.
2518
+ */
2519
+ static runCurrentStep(props, choiseMade) {
2520
+ return __async(this, null, function* () {
2521
+ if (_GameStepManager.currentLabelId) {
2522
+ let currentLabelStepIndex = _GameStepManager.currentLabelStepIndex;
2523
+ if (currentLabelStepIndex === null) {
2524
+ console.error("[Pixi'VN] currentLabelStepIndex is null");
2525
+ return;
2526
+ }
2527
+ let currentLabel = _GameStepManager.currentLabel;
2528
+ if (!currentLabel) {
2529
+ console.error("[Pixi'VN] currentLabel not found");
2530
+ return;
2531
+ }
2532
+ if (currentLabel.steps.length > currentLabelStepIndex) {
2533
+ let step = currentLabel.steps[currentLabelStepIndex];
2534
+ let result = yield step(props);
2535
+ _GameStepManager.addStepHistory(step, choiseMade);
2536
+ return result;
2537
+ } else if (_GameStepManager.openedLabels.length > 1) {
2538
+ _GameStepManager.closeCurrentLabel();
2539
+ return yield _GameStepManager.goNext(props, choiseMade);
2540
+ } else {
2541
+ _GameStepManager.restorLastLabelList();
2542
+ console.error("[Pixi'VN] The end of the game is not managed, so the game is blocked. Read this documentation to know how to manage the end of the game: https://pixi-vn.web.app/start/labels.html#how-manage-the-end-of-the-game");
2543
+ return;
2544
+ }
2545
+ }
2546
+ });
2547
+ }
2548
+ /**
2549
+ * Execute the label and add it to the history. (It's similar to Ren'Py's call function)
2550
+ * @param label The label to execute or the id of the label
2551
+ * @param props The props to pass to the label.
2552
+ * @returns StepLabelResultType or undefined.
2553
+ * @example
2554
+ * ```typescript
2555
+ * GameStepManager.callLabel(startLabel, yourParams).then((result) => {
2556
+ * if (result) {
2557
+ * // your code
2558
+ * }
2559
+ * })
2560
+ * ```
2561
+ * @example
2562
+ * ```typescript
2563
+ * // if you use it in a step label you should return the result.
2564
+ * return GameStepManager.callLabel(startLabel).then((result) => {
2565
+ * return result
2566
+ * })
2567
+ * ```
2568
+ */
2569
+ static callLabel(label, props) {
2570
+ return __async(this, null, function* () {
2571
+ let choiseMade = void 0;
2572
+ let labelId;
2573
+ if (typeof label === "string") {
2574
+ labelId = label;
2575
+ } else {
2576
+ labelId = label.id;
2577
+ if (typeof label.choiseIndex === "number") {
2578
+ choiseMade = label.choiseIndex;
2579
+ }
2580
+ }
2581
+ try {
2582
+ if (labelId === CLOSE_LABEL_ID) {
2583
+ let closeCurrentLabel = newCloseLabel(choiseMade);
2584
+ let choice = {
2585
+ label: closeCurrentLabel,
2586
+ text: "",
2587
+ closeCurrentLabel: false,
2588
+ type: "close",
2589
+ props: {}
2590
+ };
2591
+ return _GameStepManager.closeChoiceMenu(choice, props);
2592
+ }
2593
+ let tempLabel = getLabelById(labelId);
2594
+ if (!tempLabel) {
2595
+ throw new Error(`[Pixi'VN] Label ${labelId} not found`);
2596
+ }
2597
+ _GameStepManager.pushNewLabel(tempLabel.id);
2598
+ } catch (e) {
2599
+ console.error("[Pixi'VN] Error calling label", e);
2600
+ return;
2601
+ }
2602
+ return yield _GameStepManager.runCurrentStep(props, choiseMade);
2603
+ });
2604
+ }
2605
+ /**
2606
+ * Execute the label, close the current label, execute the new label and add the new label to the history. (It's similar to Ren'Py's jump function)
2607
+ * @param label The label to execute.
2608
+ * @param props The props to pass to the label or the id of the label
2609
+ * @returns StepLabelResultType or undefined.
2610
+ * @example
2611
+ * ```typescript
2612
+ * GameStepManager.jumpLabel(startLabel, yourParams).then((result) => {
2613
+ * if (result) {
2614
+ * // your code
2615
+ * }
2616
+ * })
2617
+ * ```
2618
+ * @example
2619
+ * ```typescript
2620
+ * // if you use it in a step label you should return the result.
2621
+ * return GameStepManager.jumpLabel(startLabel).then((result) => {
2622
+ * return result
2623
+ * })
2624
+ * ```
2625
+ */
2626
+ static jumpLabel(label, props) {
2627
+ return __async(this, null, function* () {
2628
+ _GameStepManager.closeCurrentLabel();
2629
+ let choiseMade = void 0;
2630
+ let labelId;
2631
+ if (typeof label === "string") {
2632
+ labelId = label;
2633
+ } else {
2634
+ labelId = label.id;
2635
+ if (typeof label.choiseIndex === "number") {
2636
+ choiseMade = label.choiseIndex;
2637
+ }
2638
+ }
2639
+ try {
2640
+ if (labelId === CLOSE_LABEL_ID) {
2641
+ let closeCurrentLabel = newCloseLabel(choiseMade);
2642
+ let choice = {
2643
+ label: closeCurrentLabel,
2644
+ text: "",
2645
+ closeCurrentLabel: false,
2646
+ type: "close",
2647
+ props: {}
2648
+ };
2649
+ return _GameStepManager.closeChoiceMenu(choice, props);
2650
+ }
2651
+ let tempLabel = getLabelById(labelId);
2652
+ if (!tempLabel) {
2653
+ throw new Error(`[Pixi'VN] Label ${labelId} not found`);
2654
+ }
2655
+ _GameStepManager.pushNewLabel(tempLabel.id);
2656
+ } catch (e) {
2657
+ console.error("[Pixi'VN] Error jumping label", e);
2658
+ return;
2659
+ }
2660
+ return yield _GameStepManager.runCurrentStep(props, choiseMade);
2661
+ });
2662
+ }
2663
+ /**
2664
+ * When the player is in a choice menu, can use this function to exit to the choice menu.
2665
+ * @param choice
2666
+ * @param props
2667
+ * @returns StepLabelResultType or undefined.
2668
+ * @example
2669
+ * ```typescript
2670
+ * GameStepManager.closeChoiceMenu(yourParams).then((result) => {
2671
+ * if (result) {
2672
+ * // your code
2673
+ * }
2674
+ * })
2675
+ * ```
2676
+ */
2677
+ static closeChoiceMenu(choice, props) {
2678
+ return __async(this, null, function* () {
2679
+ let label = choice.label;
2680
+ let choiseMade = void 0;
2681
+ if (typeof label.choiseIndex === "number") {
2682
+ choiseMade = label.choiseIndex;
2683
+ }
2684
+ if (choice.closeCurrentLabel) {
2685
+ _GameStepManager.closeCurrentLabel();
2686
+ }
2687
+ return _GameStepManager.goNext(props, choiseMade);
2688
+ });
2689
+ }
2690
+ /* After Update Methods */
2691
+ // /**
2692
+ // * After the update or code edit, some steps or labels may no longer match.
2693
+ // * - In case of step mismatch, the game will be updated to the last matching step.
2694
+ // * - In case of label mismatch, the game gives an error.
2695
+ // * @returns
2696
+ // */
2697
+ // private static afterUpdate() {
2698
+ // // TODO: implement
2699
+ // if (!GameStepManager.currentLabel) {
2700
+ // // TODO: implement
2701
+ // return
2702
+ // }
2703
+ // let currentLabel = getLabelInstanceByClassName(GameStepManager.currentLabel)
2704
+ // if (!currentLabel) {
2705
+ // console.error("Label not found")
2706
+ // return
2707
+ // }
2708
+ // let oldSteps = GameStepManager.stepsAfterLastHistoryLabel
2709
+ // let currentStepIndex = currentLabel.getCorrespondingStepsNumber(oldSteps)
2710
+ // let stepToRemove = oldSteps.length - currentStepIndex
2711
+ // GameStepManager.removeLastHistoryNodes(stepToRemove)
2712
+ // GameStepManager.loadLastStep()
2713
+ // }
2714
+ // private static loadLastStep() {
2715
+ // // TODO: implement
2716
+ // }
2717
+ // /**
2718
+ // * Remove a number of items from the last of the history.
2719
+ // * @param itemNumber The number of items to remove from the last of the history.
2720
+ // */
2721
+ // private static removeLastHistoryNodes(itemNumber: number) {
2722
+ // // TODO: implement
2723
+ // for (let i = 0; i < itemNumber; i++) {
2724
+ // GameStepManager._stepsHistory.pop()
2725
+ // }
2726
+ // }
2727
+ // /**
2728
+ // * stepsAfterLastHistoryLabel is a list of steps that occurred after the last history label.
2729
+ // */
2730
+ // private static get stepsAfterLastHistoryLabel(): StepHistoryDataType[] {
2731
+ // let length = GameStepManager._stepsHistory.length
2732
+ // let steps: StepHistoryDataType[] = []
2733
+ // for (let i = length - 1; i >= 0; i--) {
2734
+ // let element = GameStepManager._stepsHistory[i]
2735
+ // if (typeof element === "object" && "stepSha1" in element) {
2736
+ // steps.push(element.stepSha1)
2737
+ // }
2738
+ // else {
2739
+ // break
2740
+ // }
2741
+ // }
2742
+ // steps = steps.reverse()
2743
+ // return steps
2744
+ // }
2745
+ /* Go Back & Refresh Methods */
2746
+ /**
2747
+ * Go back to the last step and add it to the history.
2748
+ * @param navigate The navigate function.
2749
+ * @param steps The number of steps to go back.
2750
+ * @returns
2751
+ * @example
2752
+ * ```typescript
2753
+ * export function goBack(navigate: (path: string) => void, afterBack?: () => void) {
2754
+ * GameStepManager.goBack(navigate)
2755
+ * afterBack && afterBack()
2756
+ * }
2757
+ * ```
2758
+ */
2759
+ static goBack(navigate, steps = 1) {
2760
+ if (steps <= 0) {
2761
+ console.warn("[Pixi'VN] Steps must be greater than 0");
2762
+ return;
2763
+ }
2764
+ if (_GameStepManager._stepsHistory.length <= 1) {
2765
+ console.warn("[Pixi'VN] No steps to go back");
2766
+ return;
2767
+ }
2768
+ let restoredStep = _GameStepManager.goBackInternal(steps, _GameStepManager.originalStepData);
2769
+ if (restoredStep) {
2770
+ _GameStepManager._originalStepData = restoredStep;
2771
+ _GameStepManager._openedLabels = createExportableElement(restoredStep.openedLabels);
2772
+ GameStorageManager.import(createExportableElement(restoredStep.storage));
2773
+ GameWindowManager.import(createExportableElement(restoredStep.canvas));
2774
+ navigate(restoredStep.path);
2775
+ } else {
2776
+ console.error("[Pixi'VN] Error going back");
2777
+ }
2778
+ }
2779
+ static goBackInternal(steps, restoredStep) {
2780
+ if (steps <= 0) {
2781
+ return restoredStep;
2782
+ }
2783
+ if (_GameStepManager._stepsHistory.length == 0) {
2784
+ return restoredStep;
2785
+ }
2786
+ let lastHistoryStep = _GameStepManager.lastHistoryStep;
2787
+ if (lastHistoryStep) {
2788
+ try {
2789
+ let result = restoreDeepDiffChanges(restoredStep, lastHistoryStep.diff);
2790
+ _GameStepManager._lastStepIndex = lastHistoryStep.index;
2791
+ _GameStepManager._stepsHistory.pop();
2792
+ return _GameStepManager.goBackInternal(steps - 1, result);
2793
+ } catch (e) {
2794
+ console.error("[Pixi'VN] Error applying diff", e);
2795
+ return restoredStep;
2796
+ }
2797
+ } else {
2798
+ return restoredStep;
2799
+ }
2800
+ }
2801
+ /**
2802
+ * Return true if it is possible to go back.
2803
+ */
2804
+ static get canGoBack() {
2805
+ return _GameStepManager._stepsHistory.length > 1;
2806
+ }
2807
+ /**
2808
+ * Add a label to the history.
2809
+ */
2810
+ static clear() {
2811
+ _GameStepManager._stepsHistory = [];
2812
+ _GameStepManager._openedLabels = [];
2813
+ }
2814
+ /* Export and Import Methods */
2815
+ /**
2816
+ * Export the history to a JSON string.
2817
+ * @returns The history in a JSON string.
2818
+ */
2819
+ static exportJson() {
2820
+ return JSON.stringify(this.export());
2821
+ }
2822
+ /**
2823
+ * Export the history to an object.
2824
+ * @returns The history in an object.
2825
+ */
2826
+ static export() {
2827
+ return {
2828
+ stepsHistory: _GameStepManager._stepsHistory,
2829
+ openedLabels: _GameStepManager._openedLabels,
2830
+ lastStepIndex: _GameStepManager._lastStepIndex,
2831
+ originalStepData: _GameStepManager._originalStepData
2832
+ };
2833
+ }
2834
+ /**
2835
+ * Import the history from a JSON string.
2836
+ * @param dataString The history in a JSON string.
2837
+ */
2838
+ static importJson(dataString) {
2839
+ _GameStepManager.import(JSON.parse(dataString));
2840
+ }
2841
+ /**
2842
+ * Import the history from an object.
2843
+ * @param data The history in an object.
2844
+ */
2845
+ static import(data) {
2846
+ _GameStepManager.clear();
2847
+ try {
2848
+ if (data.hasOwnProperty("stepsHistory")) {
2849
+ _GameStepManager._stepsHistory = data["stepsHistory"];
2850
+ } else {
2851
+ console.warn("[Pixi'VN] Could not import stepsHistory data, so will be ignored");
2852
+ }
2853
+ if (data.hasOwnProperty("openedLabels")) {
2854
+ _GameStepManager._openedLabels = data["openedLabels"];
2855
+ } else {
2856
+ console.warn("[Pixi'VN] Could not import openedLabels data, so will be ignored");
2857
+ }
2858
+ if (data.hasOwnProperty("lastStepIndex")) {
2859
+ _GameStepManager._lastStepIndex = data["lastStepIndex"];
2860
+ } else {
2861
+ console.warn("[Pixi'VN] Could not import lastStepIndex data, so will be ignored");
2862
+ }
2863
+ if (data.hasOwnProperty("originalStepData")) {
2864
+ _GameStepManager._originalStepData = data["originalStepData"];
2865
+ } else {
2866
+ console.warn("[Pixi'VN] Could not import originalStepData data, so will be ignored");
2867
+ }
2868
+ } catch (e) {
2869
+ console.error("[Pixi'VN] Error importing data", e);
2870
+ }
2871
+ }
2872
+ };
2873
+ /**
2874
+ * stepHistory is a list of label events and steps that occurred during the progression of the steps.
2875
+ */
2876
+ _GameStepManager._stepsHistory = [];
2877
+ _GameStepManager._lastStepIndex = 0;
2878
+ _GameStepManager._openedLabels = [];
2879
+ _GameStepManager._originalStepData = void 0;
2880
+ var GameStepManager = _GameStepManager;
2881
+
2882
+ // src/classes/StoredClassModel.ts
2883
+ var StoredClassModel = class {
2884
+ /**
2885
+ * @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.
2886
+ * @param id The id of instance of the class. This id must be unique for the category.
2887
+ */
2888
+ constructor(categoryId, id) {
2889
+ this.categoryId = categoryId;
2890
+ this._id = id;
2891
+ }
2892
+ /**
2893
+ * Is id of the stored class. is unique for this class.
2894
+ */
2895
+ get id() {
2896
+ return this._id;
2897
+ }
2898
+ /**
2899
+ * Update a property in the storage.
2900
+ * @param propertyName The name of the property to set.
2901
+ * @param value The value to set. If is undefined, the property will be removed from the storage.
2902
+ */
2903
+ setStorageProperty(propertyName, value) {
2904
+ let storage = GameStorageManager.getVariable(this.categoryId);
2905
+ if (!storage) {
2906
+ storage = {};
2907
+ }
2908
+ if (!storage.hasOwnProperty(this.id)) {
2909
+ storage[this.id] = {};
2910
+ }
2911
+ if (value === void 0 || value === null) {
2912
+ if (storage[this.id].hasOwnProperty(propertyName)) {
2913
+ delete storage[this.id][propertyName];
2914
+ }
2915
+ } else {
2916
+ storage[this.id] = __spreadProps(__spreadValues({}, storage[this.id]), { [propertyName]: value });
2917
+ }
2918
+ if (Object.keys(storage[this.id]).length === 0) {
2919
+ delete storage[this.id];
2920
+ }
2921
+ GameStorageManager.setVariable(this.categoryId, storage);
2922
+ }
2923
+ /**
2924
+ * Get a property from the storage.
2925
+ * @param propertyName The name of the property to get.
2926
+ * @returns The value of the property. If the property is not found, returns undefined.
2927
+ */
2928
+ getStorageProperty(propertyName) {
2929
+ let storage = GameStorageManager.getVariable(this.categoryId);
2930
+ if (storage && storage.hasOwnProperty(this.id) && storage[this.id].hasOwnProperty(propertyName)) {
2931
+ return storage[this.id][propertyName];
2932
+ }
2933
+ return void 0;
2934
+ }
2935
+ };
2936
+
2937
+ // src/classes/CharacterBaseModel.ts
2938
+ var CharacterBaseModel2 = class extends StoredClassModel {
2939
+ /**
2940
+ * @param id The id of the character.
2941
+ * @param props The properties of the character.
2942
+ */
2943
+ constructor(id, props) {
2944
+ super(GameStorageManager.keysSystem.CHARACTER_CATEGORY_KEY, id);
2945
+ this.defaultName = "";
2946
+ this.defaultName = props.name;
2947
+ this.defaultSurname = props.surname;
2948
+ this.defaultAge = props.age;
2949
+ this._icon = props.icon;
2950
+ this._color = props.color;
2951
+ }
2952
+ /***
2953
+ * The name of the character.
2954
+ * If you set undefined, it will return the default name.
2955
+ */
2956
+ get name() {
2957
+ return this.getStorageProperty("name") || this.defaultName;
2958
+ }
2959
+ set name(value) {
2960
+ this.setStorageProperty("name", value);
2961
+ }
2962
+ /**
2963
+ * The surname of the character.
2964
+ * If you set undefined, it will return the default surname.
2965
+ */
2966
+ get surname() {
2967
+ return this.getStorageProperty("surname") || this.defaultSurname;
2968
+ }
2969
+ set surname(value) {
2970
+ this.setStorageProperty("surname", value);
2971
+ }
2972
+ /**
2973
+ * The age of the character.
2974
+ * If you set undefined, it will return the default age.
2975
+ */
2976
+ get age() {
2977
+ return this.getStorageProperty("age") || this.defaultAge;
2978
+ }
2979
+ set age(value) {
2980
+ this.setStorageProperty("age", value);
2981
+ }
2982
+ /**
2983
+ * The icon of the character.
2984
+ */
2985
+ get icon() {
2986
+ return this._icon;
2987
+ }
2988
+ /**
2989
+ * The color of the character.
2990
+ */
2991
+ get color() {
2992
+ return this._color;
2993
+ }
2994
+ };
2995
+
2996
+ // src/classes/DialogueBaseModel.ts
2997
+ var DialogueBaseModel = class {
2998
+ /**
2999
+ * @param text The text of the dialogue.
3000
+ * @param character The id of the character that is speaking.
3001
+ * @param oltherParams Other parameters that can be stored in the dialogue.
3002
+ */
3003
+ constructor(text, character, oltherParams = {}) {
3004
+ /**
3005
+ * The text of the dialogue.
3006
+ */
3007
+ this.text = "";
3008
+ /**
3009
+ * Other parameters that can be stored in the dialogue.
3010
+ */
3011
+ this.oltherParams = {};
3012
+ if (typeof text === "string") {
3013
+ this.text = text;
3014
+ if (typeof character === "string") {
3015
+ this.character = character;
3016
+ } else {
3017
+ this.character = character == null ? void 0 : character.id;
3018
+ }
3019
+ this.oltherParams = oltherParams;
3020
+ } else {
3021
+ this.text = text.text;
3022
+ if (text.character) {
3023
+ this.character = text.character;
3024
+ }
3025
+ this.oltherParams = text.oltherParams || {};
3026
+ }
3027
+ }
3028
+ /**
3029
+ * Export the dialogue to a DialogueBaseData object.
3030
+ *
3031
+ * @returns The data of the dialogue.
3032
+ */
3033
+ export() {
3034
+ return {
3035
+ text: this.text,
3036
+ character: this.character,
3037
+ oltherParams: this.oltherParams
3038
+ };
3039
+ }
3040
+ };
3041
+
3042
+ // src/labels/TestConstant.ts
3043
+ var juliette = new CharacterBaseModel2("___pixivn_juliette___", {
3044
+ name: "Juliette",
3045
+ age: 25,
3046
+ icon: "https://firebasestorage.googleapis.com/v0/b/pixi-vn.appspot.com/o/public%2Fcharacters%2Fjuliette-square.webp?alt=media&token=5856ae7b-d99e-4563-86ec-cbc48cc9c6b4",
3047
+ color: "#ac0086"
3048
+ });
3049
+ saveCharacter(juliette);
3050
+ var eggHeadImage = "https://pixijs.com/assets/eggHead.png";
3051
+ var eggHeadName = `<span style="color:purple">Egg Head</span>`;
3052
+ var flowerTopImage = "https://pixijs.com/assets/flowerTop.png";
3053
+ var flowerTopName = `<span style="color:green">Flower Top</span>`;
3054
+ var helmlokImage = "https://pixijs.com/assets/helmlok.png";
3055
+ var helmlokName = `<span style="color:blue">Helmlok</span>`;
3056
+ var skullyImage = "https://pixijs.com/assets/skully.png";
3057
+ var skullyName = `<span style="color:red">Skully</span>`;
3058
+ var bunnyImage = "https://pixijs.com/assets/bunny.png";
3059
+ var bunnyName = `Bunny`;
3060
+
3061
+ // src/labels/CanvasEventsTestLabel.ts
3062
+ var EventTest1 = class extends CanvasEvent {
3063
+ fn(event, sprite) {
3064
+ if (event === "pointerdown") {
3065
+ sprite.scale.x *= 1.25;
3066
+ sprite.scale.y *= 1.25;
3067
+ }
3068
+ }
3069
+ };
3070
+ EventTest1 = __decorateClass([
3071
+ eventDecorator("___pixi_vn_canvas_events_test_event1___")
3072
+ ], EventTest1);
3073
+ var EventTest2 = class extends CanvasEvent {
3074
+ constructor() {
3075
+ super(...arguments);
3076
+ this.textureButtonDown = pixi_js.Texture.from("https://pixijs.com/assets/button_down.png");
3077
+ this.textureButtonOver = pixi_js.Texture.from("https://pixijs.com/assets/button_over.png");
3078
+ this.textureButton = pixi_js.Texture.from("https://pixijs.com/assets/button.png");
3079
+ }
3080
+ fn(event, sprite) {
3081
+ if (event === "pointerdown") {
3082
+ sprite.isdown = true;
3083
+ sprite.texture = this.textureButtonDown;
3084
+ sprite.alpha = 1;
3085
+ } else if (event === "pointerup" || event === "pointerupoutside") {
3086
+ sprite.isdown = false;
3087
+ if (sprite.isOver) {
3088
+ sprite.texture = this.textureButtonOver;
3089
+ } else {
3090
+ sprite.texture = this.textureButton;
3091
+ }
3092
+ } else if (event === "pointerover") {
3093
+ sprite.isOver = true;
3094
+ if (sprite.isdown) {
3095
+ return;
3096
+ }
3097
+ sprite.texture = this.textureButtonOver;
3098
+ } else if (event === "pointerout") {
3099
+ sprite.isOver = false;
3100
+ if (sprite.isdown) {
3101
+ return;
3102
+ }
3103
+ sprite.texture = this.textureButton;
3104
+ }
3105
+ }
3106
+ };
3107
+ EventTest2 = __decorateClass([
3108
+ eventDecorator("___pixi_vn_canvas_events_test_event2___")
3109
+ ], EventTest2);
3110
+ var CANVAS_EVENTS_TEST_LABEL = "___pixi_vn_canvas_events_test___";
3111
+ var canvasEventsTestLabel = newLabel(
3112
+ CANVAS_EVENTS_TEST_LABEL,
3113
+ [
3114
+ () => setDialogue({
3115
+ character: juliette,
3116
+ text: "This is the test of clickable elements in a canvas."
3117
+ }),
3118
+ () => __async(void 0, null, function* () {
3119
+ setDialogue({
3120
+ character: juliette,
3121
+ text: `This is my friend, ${bunnyName}. It's small now, but if you try to click on it it will get bigger and bigger. (This example is from the official [PixiJS website](https://pixijs.com/8.x/examples/events/click).)`
3122
+ });
3123
+ const texture = yield pixi_js.Assets.load(bunnyImage);
3124
+ const sprite = CanvasSprite.from(texture);
3125
+ sprite.anchor.set(0.5);
3126
+ sprite.x = GameWindowManager.screen.width / 2;
3127
+ sprite.y = GameWindowManager.screen.height / 2;
3128
+ sprite.eventMode = "static";
3129
+ sprite.cursor = "pointer";
3130
+ sprite.onEvent("pointerdown", EventTest1);
3131
+ GameWindowManager.addCanvasElement("bunny", sprite);
3132
+ }),
3133
+ () => __async(void 0, null, function* () {
3134
+ GameWindowManager.clear();
3135
+ setDialogue({
3136
+ character: juliette,
3137
+ text: `This is the test of buttons in a canvas. (This example is from the official [PixiJS website](https://pixijs.com/8.x/examples/events/interactivity).)`
3138
+ });
3139
+ yield pixi_js.Assets.load([
3140
+ "https://pixijs.com/assets/bg_button.jpg",
3141
+ "https://pixijs.com/assets/button.png",
3142
+ "https://pixijs.com/assets/button_down.png",
3143
+ "https://pixijs.com/assets/button_over.png"
3144
+ ]);
3145
+ const background = CanvasSprite.from("https://pixijs.com/assets/bg_button.jpg");
3146
+ background.width = GameWindowManager.screen.width;
3147
+ background.height = GameWindowManager.screen.height;
3148
+ GameWindowManager.addCanvasElement("bg", background);
3149
+ const textureButton = pixi_js.Texture.from("https://pixijs.com/assets/button.png");
3150
+ const buttons = [];
3151
+ const buttonPositions = [175, 75, 655, 75, 410, 325, 150, 465, 685, 445];
3152
+ for (let i = 0; i < 5; i++) {
3153
+ const button = new CanvasSprite(textureButton);
3154
+ button.anchor.set(0.5);
3155
+ button.x = buttonPositions[i * 2];
3156
+ button.y = buttonPositions[i * 2 + 1];
3157
+ button.eventMode = "static";
3158
+ button.cursor = "pointer";
3159
+ button.onEvent("pointerdown", EventTest2).onEvent("pointerup", EventTest2).onEvent("pointerupoutside", EventTest2).onEvent("pointerover", EventTest2).onEvent("pointerout", EventTest2);
3160
+ GameWindowManager.addCanvasElement("button" + i, button);
3161
+ buttons.push(button);
3162
+ }
3163
+ buttons[0].scale.set(1.2);
3164
+ buttons[2].rotation = Math.PI / 10;
3165
+ buttons[3].scale.set(0.8);
3166
+ buttons[4].scale.set(0.8, 1.2);
3167
+ buttons[4].rotation = Math.PI;
3168
+ })
3169
+ ]
3170
+ );
3171
+ var AlienTintingTest = class extends CanvasSprite {
3172
+ constructor() {
3173
+ super(...arguments);
3174
+ this.direction = 0;
3175
+ this.turningSpeed = 0;
3176
+ this.speed = 0;
3177
+ }
3178
+ get memory() {
3179
+ return __spreadProps(__spreadValues({}, super.memory), {
3180
+ direction: this.direction,
3181
+ turningSpeed: this.turningSpeed,
3182
+ speed: this.speed
3183
+ });
3184
+ }
3185
+ set memory(memory) {
3186
+ super.memory = memory;
3187
+ this.direction = memory.direction;
3188
+ this.turningSpeed = memory.turningSpeed;
3189
+ this.speed = memory.speed;
3190
+ }
3191
+ static from(source, skipCache) {
3192
+ let sprite = pixi_js.Sprite.from(source, skipCache);
3193
+ let mySprite = new AlienTintingTest();
3194
+ mySprite.texture = sprite.texture;
3195
+ return mySprite;
3196
+ }
3197
+ };
3198
+ AlienTintingTest = __decorateClass([
3199
+ canvasElementDecorator("___pixi_vn_custom_canvas_element___")
3200
+ ], AlienTintingTest);
3201
+ var TintingTestTicker = class extends TickerBase {
3202
+ constructor() {
3203
+ super({});
3204
+ }
3205
+ fn(_t, _args, tags) {
3206
+ tags.forEach((tag) => {
3207
+ const dudeBoundsPadding = 100;
3208
+ const dudeBounds = new pixi_js.Rectangle(
3209
+ -dudeBoundsPadding,
3210
+ -dudeBoundsPadding,
3211
+ GameWindowManager.screen.width + dudeBoundsPadding * 2,
3212
+ GameWindowManager.screen.height + dudeBoundsPadding * 2
3213
+ );
3214
+ let dude = GameWindowManager.getCanvasElement(tag);
3215
+ if (dude && dude instanceof AlienTintingTest) {
3216
+ dude.direction += dude.turningSpeed * 0.01;
3217
+ dude.x += Math.sin(dude.direction) * dude.speed;
3218
+ dude.y += Math.cos(dude.direction) * dude.speed;
3219
+ dude.rotation = -dude.direction - Math.PI / 2;
3220
+ if (dude.x < dudeBounds.x) {
3221
+ dude.x += dudeBounds.width;
3222
+ } else if (dude.x > dudeBounds.x + dudeBounds.width) {
3223
+ dude.x -= dudeBounds.width;
3224
+ }
3225
+ if (dude.y < dudeBounds.y) {
3226
+ dude.y += dudeBounds.height;
3227
+ } else if (dude.y > dudeBounds.y + dudeBounds.height) {
3228
+ dude.y -= dudeBounds.height;
3229
+ }
3230
+ }
3231
+ });
3232
+ }
3233
+ };
3234
+ TintingTestTicker = __decorateClass([
3235
+ tickerDecorator("___pixi_vn_custom_ticker___")
3236
+ ], TintingTestTicker);
3237
+ var CUSTOM_TICKER_CANVAS_ELEMENT_TEST_LABEL = "___pixi_vn_custom_ticker_canvas_element_test___";
3238
+ var customTickerCanvasElementTestLabel = newLabel(
3239
+ CUSTOM_TICKER_CANVAS_ELEMENT_TEST_LABEL,
3240
+ [
3241
+ () => __async(void 0, null, function* () {
3242
+ const totalDudes = 100;
3243
+ for (let i = 0; i < totalDudes; i++) {
3244
+ const texture = yield pixi_js.Assets.load(eggHeadImage);
3245
+ const dude = AlienTintingTest.from(texture);
3246
+ dude.anchor.set(0.5);
3247
+ dude.scale.set(0.8 + Math.random() * 0.3);
3248
+ dude.x = Math.random() * GameWindowManager.screen.width;
3249
+ dude.y = Math.random() * GameWindowManager.screen.height;
3250
+ dude.tint = Math.random() * 16777215;
3251
+ dude.direction = Math.random() * Math.PI * 2;
3252
+ dude.turningSpeed = Math.random() - 0.8;
3253
+ dude.speed = 2 + Math.random() * 2;
3254
+ GameWindowManager.addCanvasElement("alien" + i, dude);
3255
+ GameWindowManager.addTicker("alien" + i, new TintingTestTicker());
3256
+ }
3257
+ setDialogue({
3258
+ character: juliette,
3259
+ text: `This is a test of custom ticker and canvas element. In this test, we have created ${totalDudes} ${eggHeadName} with random tint, scale, position, direction, turning speed, and speed. With the custom ticker, we are moving the custom canvas element in a random direction. (This example is from the official [PixiJS website](https://pixijs.com/8.x/examples/events/interactivity).)`
3260
+ });
3261
+ })
3262
+ ]
3263
+ );
3264
+
3265
+ // src/labels/ImagesAnimationsTestLabel.ts
3266
+ var IMAGE_ANIMAIONS_TEST_LABEL = "___pixi_vn_images_animations_test___";
3267
+ var imagesAnimationsTest = newLabel(IMAGE_ANIMAIONS_TEST_LABEL, [
3268
+ () => __async(void 0, null, function* () {
3269
+ setDialogue({ character: juliette, text: `These are my 4 puppets: ${eggHeadName}, ${flowerTopName}, ${helmlokName} and ${skullyName}. They can appear, disappear and animate at my will.` });
3270
+ let eggHead = addImage("eggHead", eggHeadImage);
3271
+ yield eggHead.load();
3272
+ eggHead.x = 100;
3273
+ eggHead.y = 100;
3274
+ let flowerTop = addImage("flowerTop", flowerTopImage);
3275
+ flowerTop.x = 300;
3276
+ flowerTop.y = 100;
3277
+ flowerTop.load();
3278
+ let helmlok = addImage("helmlok", helmlokImage);
3279
+ helmlok.x = 100;
3280
+ helmlok.y = 300;
3281
+ let skully = addImage("skully", skullyImage);
3282
+ skully.x = 300;
3283
+ skully.y = 300;
3284
+ yield loadImage([helmlok, skully]);
3285
+ }),
3286
+ () => __async(void 0, null, function* () {
3287
+ setDialogue({ character: juliette, text: "Here's what they can do." });
3288
+ setChoiceMenuOptions([
3289
+ new ChoiceMenuOption("Dissolve effect", imagesDissolveTest),
3290
+ new ChoiceMenuOption("Fade effect", imagesFadeTest),
3291
+ new ChoiceMenuOption("Rotate", imagesRotateTest),
3292
+ new ChoiceMenuOption("Move", imagesMoveTest),
3293
+ new ChoiceMenuOption("Zoom", imagesZoomTest),
3294
+ new ChoiceMenuOption("Move in/out", imagesMoveInOutTest),
3295
+ new ChoiceMenuOption("Zoom in/out", imagesZoomInOutTest),
3296
+ new ChoiceMenuOptionClose("Cancel", true)
3297
+ ]);
3298
+ }),
3299
+ (props) => GameStepManager.jumpLabel(IMAGE_ANIMAIONS_TEST_LABEL, props)
3300
+ ]);
3301
+ var imagesDissolveTest = newLabel("___pixi_vn_images_dissolve_test___", [
3302
+ () => {
3303
+ setDialogue({
3304
+ character: juliette,
3305
+ text: `Here's what's going to happen:
3306
+ - ${eggHeadName} will disappear with a dissolve effect. If you go next, ${eggHeadName} reappears with a dissolve effect without stopping the dissolve effect
3307
+ - ${eggHeadName} will appear instead of ${flowerTopName}.
3308
+ - ${helmlokName} will disappear with a fade effect and reappear with a fade effect, and repeat.
3309
+ - ${skullyName} will disappear with a fade effect, wait for 0.5 seconds, and reappear with a fade effect.`
3310
+ });
3311
+ removeWithDissolveTransition(["eggHead"], { duration: 2 });
3312
+ let eggHead = new CanvasImage({ x: 300, y: 100 }, eggHeadImage);
3313
+ showWithDissolveTransition("flowerTop", eggHead, { duration: 1 });
3314
+ GameWindowManager.addTickersSteps(
3315
+ "helmlok",
3316
+ [
3317
+ new FadeAlphaTicker({
3318
+ duration: 1,
3319
+ type: "hide"
3320
+ }, 1),
3321
+ new FadeAlphaTicker({
3322
+ duration: 1,
3323
+ type: "show"
3324
+ }, 1),
3325
+ Repeat
3326
+ ]
3327
+ );
3328
+ GameWindowManager.addTickersSteps(
3329
+ "skully",
3330
+ [
3331
+ new FadeAlphaTicker({
3332
+ duration: 0.5,
3333
+ type: "hide",
3334
+ limit: 0.3
3335
+ }, 1),
3336
+ Pause(0.5),
3337
+ new FadeAlphaTicker({
3338
+ duration: 1,
3339
+ type: "show"
3340
+ }, 1)
3341
+ ]
3342
+ );
3343
+ },
3344
+ () => __async(void 0, null, function* () {
3345
+ showWithDissolveTransition("eggHead", eggHeadImage, { duration: 0.5 });
3346
+ })
3347
+ ]);
3348
+ var imagesFadeTest = newLabel("___pixi_vn_images_fade_test___", [
3349
+ () => {
3350
+ setDialogue({
3351
+ character: juliette,
3352
+ text: `Here's what's going to happen:
3353
+ - ${eggHeadName} will disappear with a dissolve effect. If you go next, ${eggHeadName} reappears with a dissolve effect with stopping the dissolve effect
3354
+ - ${eggHeadName} will appear instead of ${flowerTopName}.
3355
+ - ${helmlokName} will disappear with a fade effect and reappear with a fade effect, and repeat.
3356
+ - ${skullyName} will disappear with a fade effect, wait for 0.5 seconds, and reappear with a fade effect.`
3357
+ });
3358
+ removeWithFadeTransition(["eggHead"], { duration: 2 });
3359
+ let eggHead = new CanvasImage({ x: 300, y: 100 }, eggHeadImage);
3360
+ showWithFadeTransition("flowerTop", eggHead, { duration: 1 });
3361
+ GameWindowManager.addTickersSteps(
3362
+ "helmlok",
3363
+ [
3364
+ new FadeAlphaTicker({
3365
+ duration: 1,
3366
+ type: "hide"
3367
+ }),
3368
+ new FadeAlphaTicker({
3369
+ duration: 1,
3370
+ type: "show"
3371
+ }),
3372
+ Repeat
3373
+ ]
3374
+ );
3375
+ GameWindowManager.addTickersSteps(
3376
+ "skully",
3377
+ [
3378
+ new FadeAlphaTicker({
3379
+ duration: 0.5,
3380
+ type: "hide",
3381
+ limit: 0.3
3382
+ }),
3383
+ Pause(0.5),
3384
+ new FadeAlphaTicker({
3385
+ duration: 1,
3386
+ type: "show"
3387
+ })
3388
+ ]
3389
+ );
3390
+ },
3391
+ () => __async(void 0, null, function* () {
3392
+ let eggHeadOld = GameWindowManager.getCanvasElement("eggHead");
3393
+ if (eggHeadOld)
3394
+ eggHeadOld.alpha = 0;
3395
+ showWithFadeTransition("eggHead", eggHeadImage, { duration: 0.5 });
3396
+ })
3397
+ ]);
3398
+ var imagesRotateTest = newLabel("___pixi_vn_images_rotate_test___", [
3399
+ () => {
3400
+ setDialogue({
3401
+ character: juliette,
3402
+ text: `Here's what's going to happen:
3403
+ - ${eggHeadName} will rotate with a anchor set to 0.
3404
+ - ${flowerTopName} will rotate with a anchor set to 0.5 and a exponential speed progression.
3405
+ - ${helmlokName} will rotate with a anchor set to 0.5, rotate 2 times, move to the right, rotate 5 times, and repeat.
3406
+ - ${skullyName} will rotate with a anchor set to 1, rotate 3 times, wait for 0.5 seconds, rotate 7 times.`
3407
+ });
3408
+ let eggHead = GameWindowManager.getCanvasElement("eggHead");
3409
+ if (eggHead)
3410
+ eggHead.anchor.set(0);
3411
+ let flowerTop = GameWindowManager.getCanvasElement("flowerTop");
3412
+ if (flowerTop)
3413
+ flowerTop.anchor.set(0.5);
3414
+ let helmlok = GameWindowManager.getCanvasElement("helmlok");
3415
+ if (helmlok)
3416
+ helmlok.anchor.set(0.5);
3417
+ let skully = GameWindowManager.getCanvasElement("skully");
3418
+ if (skully)
3419
+ skully.anchor.set(1);
3420
+ GameWindowManager.addTicker("eggHead", new RotateTicker({
3421
+ speed: 6,
3422
+ clockwise: true
3423
+ }));
3424
+ GameWindowManager.addTicker("flowerTop", new RotateTicker({
3425
+ speed: 6,
3426
+ clockwise: false,
3427
+ speedProgression: { type: "exponential", percentage: 0.01, limit: 300 }
3428
+ }));
3429
+ GameWindowManager.addTickersSteps("helmlok", [
3430
+ new RotateTicker({
3431
+ speed: 6,
3432
+ clockwise: true
3433
+ }, 2),
3434
+ new RotateTicker({
3435
+ speed: 100,
3436
+ clockwise: false,
3437
+ speedProgression: { type: "exponential", percentage: -0.05 }
3438
+ }),
3439
+ Repeat
3440
+ ]);
3441
+ GameWindowManager.addTickersSteps("skully", [
3442
+ new RotateTicker({
3443
+ speed: 6,
3444
+ clockwise: true
3445
+ }, 3),
3446
+ Pause(0.5),
3447
+ new RotateTicker({
3448
+ speed: 6,
3449
+ clockwise: false
3450
+ }, 7)
3451
+ ]);
3452
+ }
3453
+ ]);
3454
+ var imagesMoveTest = newLabel("___pixi_vn_images_move_test___", [
3455
+ () => {
3456
+ setDialogue({
3457
+ character: juliette,
3458
+ text: `Here's what's going to happen:
3459
+ - ${eggHeadName} will move to { x: 500, y: 100 } with a speed of 0.4.
3460
+ - ${flowerTopName} will move to { x: 500, y: 300 } with a speed of 0.3.
3461
+ - ${helmlokName} will move to the right with a speed of 20 and a linear speed progression of -0.2, and then move to the left with a speed of 0.1 and a linear speed progression of 0.05.
3462
+ - ${skullyName} will move to { x: 500, y: 500 } with a speed of 0.5, wait for 0.5 seconds, and move to { x: 100, y: 100 } with a speed of 0.5.`
3463
+ });
3464
+ GameWindowManager.addTicker("eggHead", new MoveTicker({
3465
+ destination: { x: 500, y: 100 },
3466
+ speed: 24
3467
+ }));
3468
+ GameWindowManager.addTicker("flowerTop", new MoveTicker({
3469
+ destination: { x: 500, y: 300 },
3470
+ speed: 18
3471
+ }));
3472
+ GameWindowManager.addTickersSteps("helmlok", [
3473
+ new MoveTicker({
3474
+ destination: { x: 100, y: 500 },
3475
+ speed: 1200,
3476
+ speedProgression: { type: "linear", amt: -12, limit: 60 }
3477
+ }),
3478
+ new MoveTicker({
3479
+ destination: { x: 1700, y: 500 },
3480
+ speed: 6,
3481
+ speedProgression: { type: "linear", amt: 3 }
3482
+ }),
3483
+ Repeat
3484
+ ]);
3485
+ GameWindowManager.addTickersSteps("skully", [
3486
+ new MoveTicker({
3487
+ destination: { x: 500, y: 500 },
3488
+ speed: 60
3489
+ }),
3490
+ Pause(0.5),
3491
+ new MoveTicker({
3492
+ destination: { x: 100, y: 100 },
3493
+ speed: 60
3494
+ })
3495
+ ]);
3496
+ }
3497
+ ]);
3498
+ var imagesZoomTest = newLabel("___pixi_vn_images_zoom_test___", [
3499
+ () => {
3500
+ setDialogue({
3501
+ character: juliette,
3502
+ text: `Here's what's going to happen:
3503
+ - ${eggHeadName} will zoom out with a speed of 3 and a limit of -0.5.
3504
+ - ${flowerTopName} will zoom in with a speed of 3 and a limit of 2.
3505
+ - ${helmlokName} will unzoom with a speed of 3 and a limit of -1, and zoom in with a speed of 3 and a limit of 1, and repeat.
3506
+ - ${skullyName} will zoom in with a speed of 0.1 and a limit of 5, wait for 0.5 seconds, and zoom out with a speed of 3 and a limit of 1.`
3507
+ });
3508
+ let eggHead = GameWindowManager.getCanvasElement("eggHead");
3509
+ if (eggHead)
3510
+ eggHead.scale.set(2);
3511
+ let helmlok = GameWindowManager.getCanvasElement("helmlok");
3512
+ if (helmlok)
3513
+ helmlok.anchor.set(0.5);
3514
+ GameWindowManager.addTicker("eggHead", new ZoomTicker({
3515
+ speed: 3,
3516
+ limit: -0.5,
3517
+ type: "unzoom"
3518
+ }));
3519
+ GameWindowManager.addTicker("flowerTop", new ZoomTicker({
3520
+ speed: 3,
3521
+ limit: 2
3522
+ }));
3523
+ GameWindowManager.addTickersSteps("helmlok", [
3524
+ new ZoomTicker({
3525
+ speed: 3,
3526
+ limit: -1,
3527
+ type: "unzoom"
3528
+ }),
3529
+ new ZoomTicker({
3530
+ speed: 3,
3531
+ limit: 1
3532
+ }),
3533
+ Repeat
3534
+ ]);
3535
+ GameWindowManager.addTickersSteps("skully", [
3536
+ new ZoomTicker({
3537
+ speed: 0.1,
3538
+ limit: 5,
3539
+ speedProgression: { type: "exponential", percentage: 0.02 }
3540
+ }),
3541
+ Pause(0.5),
3542
+ new ZoomTicker({
3543
+ "type": "unzoom",
3544
+ speed: 3,
3545
+ limit: 1
3546
+ })
3547
+ ]);
3548
+ }
3549
+ ]);
3550
+ var imagesMoveInOutTest = newLabel("___pixi_vn_images_move_in_out_test___", [
3551
+ () => __async(void 0, null, function* () {
3552
+ setDialogue({
3553
+ character: juliette,
3554
+ text: `Here's what's going to happen:
3555
+ - ${eggHeadName} will move in from the top with a speed of 800. If you go next, ${eggHeadName} will move out from the bottom with a speed of 800.
3556
+ - ${flowerTopName} will move in from the right with a speed of 800 and a speed progression of 0.02. If you go next, ${flowerTopName} will move out from the left with a speed of 800 and a speed progression of 0.02.
3557
+ - ${helmlokName} will move in from the left with a speed of 800. If you go next, ${helmlokName} will move out from the right with a speed of 800.
3558
+ - ${skullyName} will move in from the bottom with a speed of 800 and a speed progression of 0.02. If you go next, ${skullyName} will move out from the top with a speed of 800 and a speed progression of 0.02.`
3559
+ });
3560
+ let eggHead = new CanvasImage({ x: 100, y: 100 }, eggHeadImage);
3561
+ let flowerTop = new CanvasImage({ x: 300, y: 100 }, flowerTopImage);
3562
+ let helmlok = new CanvasImage({ x: 100, y: 300 }, helmlokImage);
3563
+ let skully = new CanvasImage({ x: 300, y: 300 }, skullyImage);
3564
+ moveIn("eggHead", eggHead, { speed: 800, direction: "down" });
3565
+ moveIn("flowerTop", flowerTop, {
3566
+ speed: 800,
3567
+ direction: "left",
3568
+ speedProgression: { type: "exponential", percentage: 0.02 }
3569
+ });
3570
+ moveIn("helmlok", helmlok, { speed: 800, direction: "right" });
3571
+ moveIn("skully", skully, {
3572
+ speed: 800,
3573
+ direction: "up",
3574
+ speedProgression: { type: "exponential", percentage: 0.02 }
3575
+ });
3576
+ }),
3577
+ () => {
3578
+ moveOut("eggHead", { speed: 800, direction: "down" });
3579
+ moveOut("flowerTop", { speed: 800, direction: "left" });
3580
+ moveOut("helmlok", { speed: 800, direction: "right" });
3581
+ moveOut("skully", { speed: 800, direction: "up" });
3582
+ }
3583
+ ]);
3584
+ var imagesZoomInOutTest = newLabel("___pixi_vn_images_zoom_in_out_test___", [
3585
+ () => __async(void 0, null, function* () {
3586
+ GameWindowManager.removeCanvasElements();
3587
+ let eggHead = new CanvasImage({ x: 100, y: 100 }, eggHeadImage);
3588
+ let flowerTop = new CanvasImage({ x: 300, y: 100 }, flowerTopImage);
3589
+ let helmlok = new CanvasImage({ x: 100, y: 300 }, helmlokImage);
3590
+ let skully = new CanvasImage({ x: 300, y: 300 }, skullyImage);
3591
+ zoomIn("eggHead", eggHead, { speed: 3, direction: "down" });
3592
+ zoomIn("flowerTop", flowerTop, {
3593
+ speed: 3,
3594
+ direction: "left",
3595
+ speedProgression: { type: "exponential", percentage: 0.02 }
3596
+ });
3597
+ zoomIn("helmlok", helmlok, { speed: 3, direction: "right" });
3598
+ zoomIn("skully", skully, {
3599
+ speed: 3,
3600
+ direction: "up",
3601
+ speedProgression: { type: "exponential", percentage: 0.02 }
3602
+ });
3603
+ }),
3604
+ () => __async(void 0, null, function* () {
3605
+ zoomOut("eggHead", {
3606
+ speed: 3,
3607
+ direction: "down",
3608
+ speedProgression: { type: "exponential", percentage: 0.02 }
3609
+ });
3610
+ zoomOut("flowerTop", { speed: 3, direction: "left" });
3611
+ zoomOut("helmlok", { speed: 3, direction: "right" });
3612
+ zoomOut("skully", {
3613
+ speed: 3,
3614
+ direction: "up",
3615
+ speedProgression: { type: "exponential", percentage: 0.02 }
3616
+ });
3617
+ })
3618
+ ]);
3619
+
3620
+ // src/labels/MarkdownTest.ts
3621
+ var MARKDOWN_TEST_LABEL = "___pixi_vn_markdown_test___";
3622
+ var markdownTest = newLabel(MARKDOWN_TEST_LABEL, [
3623
+ () => __async(void 0, null, function* () {
3624
+ setDialogue({
3625
+ character: juliette,
3626
+ text: `
3627
+ # Markdown Test
3628
+
3629
+ Hello, this is a test of the markdown parser. Pixi'VN does not manage markdown, but you can implement a markdown parser to display text with markdown syntax.
3630
+
3631
+ For example in React, you can use the library [react-markdown](https://www.npmjs.com/package/react-markdown).
3632
+
3633
+ ## Colored Text
3634
+
3635
+ <span style="color:blue">some *blue* text</span>.
3636
+
3637
+ <span style="color:red">some *red* text</span>.
3638
+
3639
+ <span style="color:green">some *green* text</span>.
3640
+
3641
+ ## Bold Text
3642
+
3643
+ **This is bold text.**
3644
+
3645
+ ## Italic Text
3646
+
3647
+ *This is italic text.*
3648
+
3649
+ ## Delete Text
3650
+
3651
+ ~~This is deleted text.~~
3652
+
3653
+ ## Link Test
3654
+
3655
+ [Link to Google](https://www.google.com)
3656
+
3657
+ ## H2 Test
3658
+
3659
+ ### H3 Test
3660
+
3661
+ #### H4 Test
3662
+
3663
+ ## Code Test
3664
+
3665
+ \`Hello World\`
3666
+
3667
+ \`\`\`js
3668
+ console.log("Hello World")
3669
+ \`\`\`
3670
+
3671
+ ## List Test
3672
+
3673
+ - Item 1
3674
+ * Item 2
3675
+ - [x] Item 3
3676
+
3677
+ ## Table Test
3678
+
3679
+ | Header 1 | Header 2 |
3680
+ | -------- | -------- |
3681
+ | Cell 1 | Cell 2 |
3682
+
3683
+ ## Separator Test
3684
+
3685
+ ***
3686
+ Footer
3687
+
3688
+ `
3689
+ });
3690
+ })
3691
+ ]);
3692
+
3693
+ // src/labels/StartLabel.ts
3694
+ var pixivnTestStartLabel = newLabel(
3695
+ "___pixi_vn_example_start_label___",
3696
+ [
3697
+ () => {
3698
+ let currentTimeName = "";
3699
+ const hour = (/* @__PURE__ */ new Date()).getHours();
3700
+ if (hour >= 5 && hour < 12) {
3701
+ currentTimeName = "morning";
3702
+ } else if (hour >= 12 && hour < 18) {
3703
+ currentTimeName = "afternoon";
3704
+ } else if (hour >= 18 && hour < 22) {
3705
+ currentTimeName = "evening";
3706
+ } else {
3707
+ currentTimeName = "night";
3708
+ }
3709
+ setDialogue({ character: juliette, text: `Good ${currentTimeName}! I'm ${juliette.name}, your virtual assistant. I'm here to help you with your tests.` });
3710
+ },
3711
+ () => setDialogue({ character: juliette, text: `You are running the Pixi\u2019VN test. This test will guide you through the different features of the library.` }),
3712
+ (props) => GameStepManager.jumpLabel(pixivnTestStartLabel2, props)
3713
+ ]
3714
+ );
3715
+ var RESTART_TEST_LABEL = "___pixi_vn_restart_test_label___";
3716
+ var pixivnTestStartLabel2 = newLabel(
3717
+ RESTART_TEST_LABEL,
3718
+ [
3719
+ () => {
3720
+ GameWindowManager.clear();
3721
+ setDialogue({ character: juliette, text: "Which test would you like to start with?" });
3722
+ setChoiceMenuOptions([
3723
+ new ChoiceMenuOption("Images, Transitions and Animations Test", imagesAnimationsTest),
3724
+ new ChoiceMenuOption("Canvas Events Test Label", canvasEventsTestLabel),
3725
+ new ChoiceMenuOption("Custom Ticker Canvas Element Test", customTickerCanvasElementTestLabel),
3726
+ new ChoiceMenuOption("Markdown Test", markdownTest)
3727
+ ]);
3728
+ },
3729
+ (props) => GameStepManager.jumpLabel(RESTART_TEST_LABEL, props)
3730
+ ]
3731
+ );
3732
+
3733
+ exports.pixivnTestStartLabel = pixivnTestStartLabel;
3734
+ exports.pixivnTestStartLabel2 = pixivnTestStartLabel2;
3735
+ //# sourceMappingURL=out.js.map
3736
+ //# sourceMappingURL=StartLabel.js.map