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