@drincs/pixi-vn 0.6.2 → 0.6.3

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 (407) hide show
  1. package/dist/classes/CanvasEvent.js +1 -1
  2. package/dist/classes/CanvasEvent.js.map +1 -1
  3. package/dist/classes/CanvasEvent.mjs +1 -1
  4. package/dist/classes/CanvasEvent.mjs.map +1 -1
  5. package/dist/classes/CharacterBaseModel.js +15 -15
  6. package/dist/classes/CharacterBaseModel.js.map +1 -1
  7. package/dist/classes/CharacterBaseModel.mjs +15 -15
  8. package/dist/classes/CharacterBaseModel.mjs.map +1 -1
  9. package/dist/classes/ChoiceMenuOption.js +15 -15
  10. package/dist/classes/ChoiceMenuOption.js.map +1 -1
  11. package/dist/classes/ChoiceMenuOption.mjs +15 -15
  12. package/dist/classes/ChoiceMenuOption.mjs.map +1 -1
  13. package/dist/classes/CloseLabel.js +1 -1
  14. package/dist/classes/CloseLabel.js.map +1 -1
  15. package/dist/classes/CloseLabel.mjs +1 -1
  16. package/dist/classes/CloseLabel.mjs.map +1 -1
  17. package/dist/classes/DialogueBaseModel.js +1 -1
  18. package/dist/classes/DialogueBaseModel.js.map +1 -1
  19. package/dist/classes/DialogueBaseModel.mjs +1 -1
  20. package/dist/classes/DialogueBaseModel.mjs.map +1 -1
  21. package/dist/classes/Label.js +1 -1
  22. package/dist/classes/Label.js.map +1 -1
  23. package/dist/classes/Label.mjs +1 -1
  24. package/dist/classes/Label.mjs.map +1 -1
  25. package/dist/classes/StoredClassModel.js +15 -15
  26. package/dist/classes/StoredClassModel.js.map +1 -1
  27. package/dist/classes/StoredClassModel.mjs +15 -15
  28. package/dist/classes/StoredClassModel.mjs.map +1 -1
  29. package/dist/classes/canvas/CanvasBase.js +1 -1
  30. package/dist/classes/canvas/CanvasBase.js.map +1 -1
  31. package/dist/classes/canvas/CanvasBase.mjs +1 -1
  32. package/dist/classes/canvas/CanvasBase.mjs.map +1 -1
  33. package/dist/classes/canvas/CanvasContainer.js +13 -13
  34. package/dist/classes/canvas/CanvasContainer.js.map +1 -1
  35. package/dist/classes/canvas/CanvasContainer.mjs +13 -13
  36. package/dist/classes/canvas/CanvasContainer.mjs.map +1 -1
  37. package/dist/classes/canvas/CanvasImage.js +2 -4
  38. package/dist/classes/canvas/CanvasImage.js.map +1 -1
  39. package/dist/classes/canvas/CanvasImage.mjs +2 -4
  40. package/dist/classes/canvas/CanvasImage.mjs.map +1 -1
  41. package/dist/classes/canvas/CanvasSprite.js +2 -4
  42. package/dist/classes/canvas/CanvasSprite.js.map +1 -1
  43. package/dist/classes/canvas/CanvasSprite.mjs +2 -4
  44. package/dist/classes/canvas/CanvasSprite.mjs.map +1 -1
  45. package/dist/classes/canvas/CanvasText.js +11 -11
  46. package/dist/classes/canvas/CanvasText.js.map +1 -1
  47. package/dist/classes/canvas/CanvasText.mjs +11 -11
  48. package/dist/classes/canvas/CanvasText.mjs.map +1 -1
  49. package/dist/classes/canvas/index.js +13 -13
  50. package/dist/classes/canvas/index.js.map +1 -1
  51. package/dist/classes/canvas/index.mjs +13 -13
  52. package/dist/classes/canvas/index.mjs.map +1 -1
  53. package/dist/classes/index.js +15 -15
  54. package/dist/classes/index.js.map +1 -1
  55. package/dist/classes/index.mjs +15 -15
  56. package/dist/classes/index.mjs.map +1 -1
  57. package/dist/classes/ticker/FadeAlphaTicker.js +15 -15
  58. package/dist/classes/ticker/FadeAlphaTicker.js.map +1 -1
  59. package/dist/classes/ticker/FadeAlphaTicker.mjs +15 -15
  60. package/dist/classes/ticker/FadeAlphaTicker.mjs.map +1 -1
  61. package/dist/classes/ticker/MoveTicker.js +15 -15
  62. package/dist/classes/ticker/MoveTicker.js.map +1 -1
  63. package/dist/classes/ticker/MoveTicker.mjs +15 -15
  64. package/dist/classes/ticker/MoveTicker.mjs.map +1 -1
  65. package/dist/classes/ticker/RotateTicker.js +15 -15
  66. package/dist/classes/ticker/RotateTicker.js.map +1 -1
  67. package/dist/classes/ticker/RotateTicker.mjs +15 -15
  68. package/dist/classes/ticker/RotateTicker.mjs.map +1 -1
  69. package/dist/classes/ticker/TickerBase.js +1 -1
  70. package/dist/classes/ticker/TickerBase.js.map +1 -1
  71. package/dist/classes/ticker/TickerBase.mjs +1 -1
  72. package/dist/classes/ticker/TickerBase.mjs.map +1 -1
  73. package/dist/classes/ticker/ZoomTicker.js +15 -15
  74. package/dist/classes/ticker/ZoomTicker.js.map +1 -1
  75. package/dist/classes/ticker/ZoomTicker.mjs +15 -15
  76. package/dist/classes/ticker/ZoomTicker.mjs.map +1 -1
  77. package/dist/classes/ticker/index.js +15 -15
  78. package/dist/classes/ticker/index.js.map +1 -1
  79. package/dist/classes/ticker/index.mjs +15 -15
  80. package/dist/classes/ticker/index.mjs.map +1 -1
  81. package/dist/constants.d.mts +1 -1
  82. package/dist/constants.d.ts +1 -1
  83. package/dist/constants.js +2 -2
  84. package/dist/constants.js.map +1 -1
  85. package/dist/constants.mjs +2 -2
  86. package/dist/constants.mjs.map +1 -1
  87. package/dist/decorators/CanvasElementDecorator.js +13 -13
  88. package/dist/decorators/CanvasElementDecorator.js.map +1 -1
  89. package/dist/decorators/CanvasElementDecorator.mjs +13 -13
  90. package/dist/decorators/CanvasElementDecorator.mjs.map +1 -1
  91. package/dist/decorators/CharacterDecorator.js +1 -1
  92. package/dist/decorators/CharacterDecorator.js.map +1 -1
  93. package/dist/decorators/CharacterDecorator.mjs +1 -1
  94. package/dist/decorators/CharacterDecorator.mjs.map +1 -1
  95. package/dist/decorators/EventDecorator.js +1 -1
  96. package/dist/decorators/EventDecorator.js.map +1 -1
  97. package/dist/decorators/EventDecorator.mjs +1 -1
  98. package/dist/decorators/EventDecorator.mjs.map +1 -1
  99. package/dist/decorators/LabelDecorator.js +15 -15
  100. package/dist/decorators/LabelDecorator.js.map +1 -1
  101. package/dist/decorators/LabelDecorator.mjs +15 -15
  102. package/dist/decorators/LabelDecorator.mjs.map +1 -1
  103. package/dist/decorators/TickerDecorator.js +1 -1
  104. package/dist/decorators/TickerDecorator.js.map +1 -1
  105. package/dist/decorators/TickerDecorator.mjs +1 -1
  106. package/dist/decorators/TickerDecorator.mjs.map +1 -1
  107. package/dist/decorators/index.js +15 -15
  108. package/dist/decorators/index.js.map +1 -1
  109. package/dist/decorators/index.mjs +15 -15
  110. package/dist/decorators/index.mjs.map +1 -1
  111. package/dist/functions/CanvasUtility.js +13 -13
  112. package/dist/functions/CanvasUtility.js.map +1 -1
  113. package/dist/functions/CanvasUtility.mjs +13 -13
  114. package/dist/functions/CanvasUtility.mjs.map +1 -1
  115. package/dist/functions/DialogueUtility.js +15 -15
  116. package/dist/functions/DialogueUtility.js.map +1 -1
  117. package/dist/functions/DialogueUtility.mjs +15 -15
  118. package/dist/functions/DialogueUtility.mjs.map +1 -1
  119. package/dist/functions/DiffUtility.js +1 -1
  120. package/dist/functions/DiffUtility.js.map +1 -1
  121. package/dist/functions/DiffUtility.mjs +1 -1
  122. package/dist/functions/DiffUtility.mjs.map +1 -1
  123. package/dist/functions/EasterEgg.js +1 -1
  124. package/dist/functions/EasterEgg.js.map +1 -1
  125. package/dist/functions/EasterEgg.mjs +1 -1
  126. package/dist/functions/EasterEgg.mjs.map +1 -1
  127. package/dist/functions/ExportUtility.js +1 -1
  128. package/dist/functions/ExportUtility.js.map +1 -1
  129. package/dist/functions/ExportUtility.mjs +1 -1
  130. package/dist/functions/ExportUtility.mjs.map +1 -1
  131. package/dist/functions/FlagsUtility.js +15 -15
  132. package/dist/functions/FlagsUtility.js.map +1 -1
  133. package/dist/functions/FlagsUtility.mjs +15 -15
  134. package/dist/functions/FlagsUtility.mjs.map +1 -1
  135. package/dist/functions/GameUtility.js +15 -15
  136. package/dist/functions/GameUtility.js.map +1 -1
  137. package/dist/functions/GameUtility.mjs +15 -15
  138. package/dist/functions/GameUtility.mjs.map +1 -1
  139. package/dist/functions/ImageUtility.js +15 -15
  140. package/dist/functions/ImageUtility.js.map +1 -1
  141. package/dist/functions/ImageUtility.mjs +15 -15
  142. package/dist/functions/ImageUtility.mjs.map +1 -1
  143. package/dist/functions/SavesUtility.js +16 -16
  144. package/dist/functions/SavesUtility.js.map +1 -1
  145. package/dist/functions/SavesUtility.mjs +16 -16
  146. package/dist/functions/SavesUtility.mjs.map +1 -1
  147. package/dist/functions/StepLabelUtility.js +1 -1
  148. package/dist/functions/StepLabelUtility.js.map +1 -1
  149. package/dist/functions/StepLabelUtility.mjs +1 -1
  150. package/dist/functions/StepLabelUtility.mjs.map +1 -1
  151. package/dist/functions/TextureUtility.js +10 -8
  152. package/dist/functions/TextureUtility.js.map +1 -1
  153. package/dist/functions/TextureUtility.mjs +10 -8
  154. package/dist/functions/TextureUtility.mjs.map +1 -1
  155. package/dist/functions/TickerUtility.js +1 -1
  156. package/dist/functions/TickerUtility.js.map +1 -1
  157. package/dist/functions/TickerUtility.mjs +1 -1
  158. package/dist/functions/TickerUtility.mjs.map +1 -1
  159. package/dist/functions/index.js +16 -16
  160. package/dist/functions/index.js.map +1 -1
  161. package/dist/functions/index.mjs +16 -16
  162. package/dist/functions/index.mjs.map +1 -1
  163. package/dist/index.js +119 -17
  164. package/dist/index.js.map +1 -1
  165. package/dist/index.mjs +120 -18
  166. package/dist/index.mjs.map +1 -1
  167. package/dist/interface/CharacterBaseModelProps.js +1 -1
  168. package/dist/interface/CharacterBaseModelProps.js.map +1 -1
  169. package/dist/interface/CharacterBaseModelProps.mjs +1 -1
  170. package/dist/interface/CharacterBaseModelProps.mjs.map +1 -1
  171. package/dist/interface/DialogueHistory.js +1 -1
  172. package/dist/interface/DialogueHistory.js.map +1 -1
  173. package/dist/interface/DialogueHistory.mjs +1 -1
  174. package/dist/interface/DialogueHistory.mjs.map +1 -1
  175. package/dist/interface/IHistoryStep.js +1 -1
  176. package/dist/interface/IHistoryStep.js.map +1 -1
  177. package/dist/interface/IHistoryStep.mjs +1 -1
  178. package/dist/interface/IHistoryStep.mjs.map +1 -1
  179. package/dist/interface/IOpenedLabel.js +1 -1
  180. package/dist/interface/IOpenedLabel.js.map +1 -1
  181. package/dist/interface/IOpenedLabel.mjs +1 -1
  182. package/dist/interface/IOpenedLabel.mjs.map +1 -1
  183. package/dist/interface/ISaveData.js +1 -1
  184. package/dist/interface/ISaveData.js.map +1 -1
  185. package/dist/interface/ISaveData.mjs +1 -1
  186. package/dist/interface/ISaveData.mjs.map +1 -1
  187. package/dist/interface/ITicker.js +1 -1
  188. package/dist/interface/ITicker.js.map +1 -1
  189. package/dist/interface/ITicker.mjs +1 -1
  190. package/dist/interface/ITicker.mjs.map +1 -1
  191. package/dist/interface/ITickersSteps.js +1 -1
  192. package/dist/interface/ITickersSteps.js.map +1 -1
  193. package/dist/interface/ITickersSteps.mjs +1 -1
  194. package/dist/interface/ITickersSteps.mjs.map +1 -1
  195. package/dist/interface/TickerHistory.js +1 -1
  196. package/dist/interface/TickerHistory.js.map +1 -1
  197. package/dist/interface/TickerHistory.mjs +1 -1
  198. package/dist/interface/TickerHistory.mjs.map +1 -1
  199. package/dist/interface/TickerProgrationType.js +1 -1
  200. package/dist/interface/TickerProgrationType.js.map +1 -1
  201. package/dist/interface/TickerProgrationType.mjs +1 -1
  202. package/dist/interface/TickerProgrationType.mjs.map +1 -1
  203. package/dist/interface/TickerTimeoutHistory.js +1 -1
  204. package/dist/interface/TickerTimeoutHistory.js.map +1 -1
  205. package/dist/interface/TickerTimeoutHistory.mjs +1 -1
  206. package/dist/interface/TickerTimeoutHistory.mjs.map +1 -1
  207. package/dist/interface/canvas/ICanvasBaseMemory.js +1 -1
  208. package/dist/interface/canvas/ICanvasBaseMemory.js.map +1 -1
  209. package/dist/interface/canvas/ICanvasBaseMemory.mjs +1 -1
  210. package/dist/interface/canvas/ICanvasBaseMemory.mjs.map +1 -1
  211. package/dist/interface/canvas/ICanvasContainerMemory.js +1 -1
  212. package/dist/interface/canvas/ICanvasContainerMemory.js.map +1 -1
  213. package/dist/interface/canvas/ICanvasContainerMemory.mjs +1 -1
  214. package/dist/interface/canvas/ICanvasContainerMemory.mjs.map +1 -1
  215. package/dist/interface/canvas/ICanvasImageMemory.js +1 -1
  216. package/dist/interface/canvas/ICanvasImageMemory.js.map +1 -1
  217. package/dist/interface/canvas/ICanvasImageMemory.mjs +1 -1
  218. package/dist/interface/canvas/ICanvasImageMemory.mjs.map +1 -1
  219. package/dist/interface/canvas/ICanvasSpriteMemory.js +1 -1
  220. package/dist/interface/canvas/ICanvasSpriteMemory.js.map +1 -1
  221. package/dist/interface/canvas/ICanvasSpriteMemory.mjs +1 -1
  222. package/dist/interface/canvas/ICanvasSpriteMemory.mjs.map +1 -1
  223. package/dist/interface/canvas/ICanvasTextTextMemory.js +1 -1
  224. package/dist/interface/canvas/ICanvasTextTextMemory.js.map +1 -1
  225. package/dist/interface/canvas/ICanvasTextTextMemory.mjs +1 -1
  226. package/dist/interface/canvas/ICanvasTextTextMemory.mjs.map +1 -1
  227. package/dist/interface/canvas/ITextureMemory.js +1 -1
  228. package/dist/interface/canvas/ITextureMemory.js.map +1 -1
  229. package/dist/interface/canvas/ITextureMemory.mjs +1 -1
  230. package/dist/interface/canvas/ITextureMemory.mjs.map +1 -1
  231. package/dist/interface/canvas/index.js +1 -1
  232. package/dist/interface/canvas/index.js.map +1 -1
  233. package/dist/interface/canvas/index.mjs +1 -1
  234. package/dist/interface/canvas/index.mjs.map +1 -1
  235. package/dist/interface/export/ExportedCanvas.js +1 -1
  236. package/dist/interface/export/ExportedCanvas.js.map +1 -1
  237. package/dist/interface/export/ExportedCanvas.mjs +1 -1
  238. package/dist/interface/export/ExportedCanvas.mjs.map +1 -1
  239. package/dist/interface/export/ExportedStep.js +1 -1
  240. package/dist/interface/export/ExportedStep.js.map +1 -1
  241. package/dist/interface/export/ExportedStep.mjs +1 -1
  242. package/dist/interface/export/ExportedStep.mjs.map +1 -1
  243. package/dist/interface/export/ExportedStorage.js +1 -1
  244. package/dist/interface/export/ExportedStorage.js.map +1 -1
  245. package/dist/interface/export/ExportedStorage.mjs +1 -1
  246. package/dist/interface/export/ExportedStorage.mjs.map +1 -1
  247. package/dist/interface/export/index.js +1 -1
  248. package/dist/interface/export/index.js.map +1 -1
  249. package/dist/interface/export/index.mjs +1 -1
  250. package/dist/interface/export/index.mjs.map +1 -1
  251. package/dist/interface/index.js +1 -1
  252. package/dist/interface/index.js.map +1 -1
  253. package/dist/interface/index.mjs +1 -1
  254. package/dist/interface/index.mjs.map +1 -1
  255. package/dist/labels/BaseCanvasElementTestLabel.js +917 -23
  256. package/dist/labels/BaseCanvasElementTestLabel.js.map +1 -1
  257. package/dist/labels/BaseCanvasElementTestLabel.mjs +917 -23
  258. package/dist/labels/BaseCanvasElementTestLabel.mjs.map +1 -1
  259. package/dist/labels/CanvasEventsTestLabel.js +15 -15
  260. package/dist/labels/CanvasEventsTestLabel.js.map +1 -1
  261. package/dist/labels/CanvasEventsTestLabel.mjs +15 -15
  262. package/dist/labels/CanvasEventsTestLabel.mjs.map +1 -1
  263. package/dist/labels/CustomTickerCanvasElementTestLabel.js +15 -18
  264. package/dist/labels/CustomTickerCanvasElementTestLabel.js.map +1 -1
  265. package/dist/labels/CustomTickerCanvasElementTestLabel.mjs +15 -18
  266. package/dist/labels/CustomTickerCanvasElementTestLabel.mjs.map +1 -1
  267. package/dist/labels/ImagesAnimationsTestLabel.js +15 -15
  268. package/dist/labels/ImagesAnimationsTestLabel.js.map +1 -1
  269. package/dist/labels/ImagesAnimationsTestLabel.mjs +15 -15
  270. package/dist/labels/ImagesAnimationsTestLabel.mjs.map +1 -1
  271. package/dist/labels/MarkdownTest.js +15 -15
  272. package/dist/labels/MarkdownTest.js.map +1 -1
  273. package/dist/labels/MarkdownTest.mjs +15 -15
  274. package/dist/labels/MarkdownTest.mjs.map +1 -1
  275. package/dist/labels/StartLabel.js +121 -19
  276. package/dist/labels/StartLabel.js.map +1 -1
  277. package/dist/labels/StartLabel.mjs +122 -20
  278. package/dist/labels/StartLabel.mjs.map +1 -1
  279. package/dist/labels/TestConstant.js +15 -15
  280. package/dist/labels/TestConstant.js.map +1 -1
  281. package/dist/labels/TestConstant.mjs +15 -15
  282. package/dist/labels/TestConstant.mjs.map +1 -1
  283. package/dist/labels/index.js +121 -19
  284. package/dist/labels/index.js.map +1 -1
  285. package/dist/labels/index.mjs +122 -20
  286. package/dist/labels/index.mjs.map +1 -1
  287. package/dist/managers/StepManager.js +15 -15
  288. package/dist/managers/StepManager.js.map +1 -1
  289. package/dist/managers/StepManager.mjs +15 -15
  290. package/dist/managers/StepManager.mjs.map +1 -1
  291. package/dist/managers/StorageManager.js +1 -1
  292. package/dist/managers/StorageManager.js.map +1 -1
  293. package/dist/managers/StorageManager.mjs +1 -1
  294. package/dist/managers/StorageManager.mjs.map +1 -1
  295. package/dist/managers/WindowManager.d.mts +1 -1
  296. package/dist/managers/WindowManager.d.ts +1 -1
  297. package/dist/managers/WindowManager.js +15 -15
  298. package/dist/managers/WindowManager.js.map +1 -1
  299. package/dist/managers/WindowManager.mjs +15 -15
  300. package/dist/managers/WindowManager.mjs.map +1 -1
  301. package/dist/managers/index.js +15 -15
  302. package/dist/managers/index.js.map +1 -1
  303. package/dist/managers/index.mjs +15 -15
  304. package/dist/managers/index.mjs.map +1 -1
  305. package/dist/override/StepLabelProps.js +1 -1
  306. package/dist/override/StepLabelProps.js.map +1 -1
  307. package/dist/override/StepLabelProps.mjs +1 -1
  308. package/dist/override/StepLabelProps.mjs.map +1 -1
  309. package/dist/override/StepLabelResult.js +1 -1
  310. package/dist/override/StepLabelResult.js.map +1 -1
  311. package/dist/override/StepLabelResult.mjs +1 -1
  312. package/dist/override/StepLabelResult.mjs.map +1 -1
  313. package/dist/override/index.js +1 -1
  314. package/dist/override/index.js.map +1 -1
  315. package/dist/override/index.mjs +1 -1
  316. package/dist/override/index.mjs.map +1 -1
  317. package/dist/types/CanvasElementTagType.js +1 -1
  318. package/dist/types/CanvasElementTagType.js.map +1 -1
  319. package/dist/types/CanvasElementTagType.mjs +1 -1
  320. package/dist/types/CanvasElementTagType.mjs.map +1 -1
  321. package/dist/types/CanvasEventNamesType.js +1 -1
  322. package/dist/types/CanvasEventNamesType.js.map +1 -1
  323. package/dist/types/CanvasEventNamesType.mjs +1 -1
  324. package/dist/types/CanvasEventNamesType.mjs.map +1 -1
  325. package/dist/types/ChoiceMenuOptionsType.js +1 -1
  326. package/dist/types/ChoiceMenuOptionsType.js.map +1 -1
  327. package/dist/types/ChoiceMenuOptionsType.mjs +1 -1
  328. package/dist/types/ChoiceMenuOptionsType.mjs.map +1 -1
  329. package/dist/types/CloseType.js +1 -1
  330. package/dist/types/CloseType.js.map +1 -1
  331. package/dist/types/CloseType.mjs +1 -1
  332. package/dist/types/CloseType.mjs.map +1 -1
  333. package/dist/types/EventIdType.js +1 -1
  334. package/dist/types/EventIdType.js.map +1 -1
  335. package/dist/types/EventIdType.mjs +1 -1
  336. package/dist/types/EventIdType.mjs.map +1 -1
  337. package/dist/types/HistoryChoiceMenuOption.js +1 -1
  338. package/dist/types/HistoryChoiceMenuOption.js.map +1 -1
  339. package/dist/types/HistoryChoiceMenuOption.mjs +1 -1
  340. package/dist/types/HistoryChoiceMenuOption.mjs.map +1 -1
  341. package/dist/types/LabelIdType.js +1 -1
  342. package/dist/types/LabelIdType.js.map +1 -1
  343. package/dist/types/LabelIdType.mjs +1 -1
  344. package/dist/types/LabelIdType.mjs.map +1 -1
  345. package/dist/types/LabelRunModeType.js +1 -1
  346. package/dist/types/LabelRunModeType.js.map +1 -1
  347. package/dist/types/LabelRunModeType.mjs +1 -1
  348. package/dist/types/LabelRunModeType.mjs.map +1 -1
  349. package/dist/types/PauseType.js +1 -1
  350. package/dist/types/PauseType.js.map +1 -1
  351. package/dist/types/PauseType.mjs +1 -1
  352. package/dist/types/PauseType.mjs.map +1 -1
  353. package/dist/types/RepeatType.js +1 -1
  354. package/dist/types/RepeatType.js.map +1 -1
  355. package/dist/types/RepeatType.mjs +1 -1
  356. package/dist/types/RepeatType.mjs.map +1 -1
  357. package/dist/types/StepHistoryDataType.js +1 -1
  358. package/dist/types/StepHistoryDataType.js.map +1 -1
  359. package/dist/types/StepHistoryDataType.mjs +1 -1
  360. package/dist/types/StepHistoryDataType.mjs.map +1 -1
  361. package/dist/types/StepLabelType.js +1 -1
  362. package/dist/types/StepLabelType.js.map +1 -1
  363. package/dist/types/StepLabelType.mjs +1 -1
  364. package/dist/types/StepLabelType.mjs.map +1 -1
  365. package/dist/types/StorageElementType.js +1 -1
  366. package/dist/types/StorageElementType.js.map +1 -1
  367. package/dist/types/StorageElementType.mjs +1 -1
  368. package/dist/types/StorageElementType.mjs.map +1 -1
  369. package/dist/types/TickerIdType.js +1 -1
  370. package/dist/types/TickerIdType.js.map +1 -1
  371. package/dist/types/TickerIdType.mjs +1 -1
  372. package/dist/types/TickerIdType.mjs.map +1 -1
  373. package/dist/types/index.js +1 -1
  374. package/dist/types/index.js.map +1 -1
  375. package/dist/types/index.mjs +1 -1
  376. package/dist/types/index.mjs.map +1 -1
  377. package/dist/types/ticker/FadeAlphaTickerProps.js +1 -1
  378. package/dist/types/ticker/FadeAlphaTickerProps.js.map +1 -1
  379. package/dist/types/ticker/FadeAlphaTickerProps.mjs +1 -1
  380. package/dist/types/ticker/FadeAlphaTickerProps.mjs.map +1 -1
  381. package/dist/types/ticker/MoveTickerProps.js +1 -1
  382. package/dist/types/ticker/MoveTickerProps.js.map +1 -1
  383. package/dist/types/ticker/MoveTickerProps.mjs +1 -1
  384. package/dist/types/ticker/MoveTickerProps.mjs.map +1 -1
  385. package/dist/types/ticker/RotateTickerProps.js +1 -1
  386. package/dist/types/ticker/RotateTickerProps.js.map +1 -1
  387. package/dist/types/ticker/RotateTickerProps.mjs +1 -1
  388. package/dist/types/ticker/RotateTickerProps.mjs.map +1 -1
  389. package/dist/types/ticker/TagToRemoveAfterType.js +1 -1
  390. package/dist/types/ticker/TagToRemoveAfterType.js.map +1 -1
  391. package/dist/types/ticker/TagToRemoveAfterType.mjs +1 -1
  392. package/dist/types/ticker/TagToRemoveAfterType.mjs.map +1 -1
  393. package/dist/types/ticker/ZoomTickerProps.js +1 -1
  394. package/dist/types/ticker/ZoomTickerProps.js.map +1 -1
  395. package/dist/types/ticker/ZoomTickerProps.mjs +1 -1
  396. package/dist/types/ticker/ZoomTickerProps.mjs.map +1 -1
  397. package/dist/types/ticker/index.js +1 -1
  398. package/dist/types/ticker/index.js.map +1 -1
  399. package/dist/types/ticker/index.mjs +1 -1
  400. package/dist/types/ticker/index.mjs.map +1 -1
  401. package/package.json +4 -4
  402. package/dist/labels/TickerTestLabel.d.mts +0 -9
  403. package/dist/labels/TickerTestLabel.d.ts +0 -9
  404. package/dist/labels/TickerTestLabel.js +0 -2675
  405. package/dist/labels/TickerTestLabel.js.map +0 -1
  406. package/dist/labels/TickerTestLabel.mjs +0 -2669
  407. package/dist/labels/TickerTestLabel.mjs.map +0 -1
@@ -1,2669 +0,0 @@
1
- import { Sprite, Container, Application, Assets, Texture, Text } from 'pixi.js';
2
- import { diff } from 'deep-diff';
3
- import sha1 from 'crypto-js/sha1';
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
- function getTexture(imageUrl) {
54
- return __async(this, null, function* () {
55
- if (Assets.cache.has(imageUrl)) {
56
- return Assets.get(imageUrl);
57
- }
58
- return Assets.load(imageUrl).then((texture) => {
59
- if (!texture) {
60
- console.error("[Pixi'VN] Texture not found", imageUrl);
61
- return;
62
- }
63
- if (!(texture instanceof Texture)) {
64
- console.error("[Pixi'VN] File not is a image", imageUrl);
65
- return;
66
- }
67
- return texture;
68
- }).catch((e) => {
69
- console.error("[Pixi'VN] Error loading image", e);
70
- return;
71
- });
72
- });
73
- }
74
- function getTextStyle(style) {
75
- let fill = style.fill;
76
- if (fill instanceof Object) {
77
- console.warn("[Pixi'VN] CanvasText.style.fill is a FillGradient or FillPattern, this is not supported yet.", fill);
78
- fill = "#00FF00";
79
- }
80
- return {
81
- align: style.align,
82
- breakWords: style.breakWords,
83
- dropShadow: style.dropShadow,
84
- fill,
85
- fontFamily: style.fontFamily,
86
- fontSize: style.fontSize,
87
- fontStyle: style.fontStyle,
88
- fontVariant: style.fontVariant,
89
- fontWeight: style.fontWeight,
90
- leading: style.leading,
91
- letterSpacing: style.letterSpacing,
92
- lineHeight: style.lineHeight,
93
- padding: style.padding,
94
- stroke: style.stroke,
95
- textBaseline: style.textBaseline,
96
- trim: style.trim,
97
- whiteSpace: style.whiteSpace,
98
- wordWrap: style.wordWrap,
99
- wordWrapWidth: style.wordWrapWidth
100
- };
101
- }
102
-
103
- // src/decorators/EventDecorator.ts
104
- var registeredEvents = {};
105
- function getEventTypeById(eventId) {
106
- try {
107
- let eventType = registeredEvents[eventId];
108
- if (!eventType) {
109
- console.error(`[Pixi'VN] Event ${eventId} not found`);
110
- return;
111
- }
112
- new eventType();
113
- return eventType;
114
- } catch (e) {
115
- console.error(`[Pixi'VN] Error while getting Event ${eventId}`, e);
116
- return;
117
- }
118
- }
119
- function getEventInstanceById(eventId) {
120
- try {
121
- let eventType = registeredEvents[eventId];
122
- if (!eventType) {
123
- console.error(`[Pixi'VN] Event ${eventId} not found`);
124
- return;
125
- }
126
- let event = new eventType();
127
- return event;
128
- } catch (e) {
129
- console.error(`[Pixi'VN] Error while getting Event ${eventId}`, e);
130
- return;
131
- }
132
- }
133
-
134
- // src/classes/canvas/CanvasSprite.ts
135
- var CANVAS_SPRITE_ID = "CanvasSprite";
136
- var CanvasSprite = class _CanvasSprite extends Sprite {
137
- constructor(options) {
138
- super(options);
139
- this.pixivnId = CANVAS_SPRITE_ID;
140
- this._onEvents = {};
141
- this.pixivnId = this.constructor.prototype.pixivnId;
142
- }
143
- get memory() {
144
- return getMemorySprite(this);
145
- }
146
- set memory(value) {
147
- setMemorySprite(this, value);
148
- }
149
- get onEvents() {
150
- return this._onEvents;
151
- }
152
- /**
153
- * is same function as on(), but it keeps in memory the children.
154
- * @param event The event type, e.g., 'click', 'mousedown', 'mouseup', 'pointerdown', etc.
155
- * @param eventClass The class that extends CanvasEvent.
156
- * @returns
157
- * @example
158
- * ```typescript
159
- * \@eventDecorator()
160
- * export class EventTest extends CanvasEvent<CanvasSprite> {
161
- * override fn(event: CanvasEventNamesType, sprite: CanvasSprite): void {
162
- * if (event === 'pointerdown') {
163
- * sprite.scale.x *= 1.25;
164
- * sprite.scale.y *= 1.25;
165
- * }
166
- * }
167
- * }
168
- * ```
169
- *
170
- * ```typescript
171
- * let sprite = addImage("alien", 'https://pixijs.com/assets/eggHead.png')
172
- * await sprite.load()
173
- *
174
- * sprite.eventMode = 'static';
175
- * sprite.cursor = 'pointer';
176
- * sprite.onEvent('pointerdown', EventTest);
177
- *
178
- * GameWindowManager.addCanvasElement("bunny", sprite);
179
- * ```
180
- */
181
- onEvent(event, eventClass) {
182
- let id = eventClass.prototype.id;
183
- let instance = getEventInstanceById(id);
184
- this._onEvents[event] = id;
185
- if (instance) {
186
- super.on(event, () => {
187
- instance.fn(event, this);
188
- });
189
- }
190
- return this;
191
- }
192
- /**
193
- * on() does not keep in memory the event class, use onEvent() instead
194
- * @deprecated
195
- * @private
196
- * @param event
197
- * @param fn
198
- * @param context
199
- */
200
- on(event, fn, context) {
201
- return super.on(event, fn, context);
202
- }
203
- static from(source, skipCache) {
204
- let sprite = Sprite.from(source, skipCache);
205
- let mySprite = new _CanvasSprite();
206
- mySprite.texture = sprite.texture;
207
- return mySprite;
208
- }
209
- };
210
- function getMemorySprite(element) {
211
- let temp = getMemoryContainer(element);
212
- return __spreadProps(__spreadValues({}, temp), {
213
- pixivnId: element.pixivnId,
214
- textureImage: getTextureMemory(element.texture),
215
- anchor: { x: element.anchor.x, y: element.anchor.y },
216
- roundPixels: element.roundPixels,
217
- onEvents: element.onEvents
218
- });
219
- }
220
- function setMemorySprite(element, memory) {
221
- setMemoryContainer(element, memory);
222
- getTexture(memory.textureImage.image).then((texture) => {
223
- if (texture) {
224
- element.texture = texture;
225
- }
226
- });
227
- if (memory.anchor) {
228
- if (typeof memory.anchor === "number") {
229
- element.anchor.set(memory.anchor, memory.anchor);
230
- } else {
231
- element.anchor.set(memory.anchor.x, memory.anchor.y);
232
- }
233
- }
234
- memory.roundPixels && (element.roundPixels = memory.roundPixels);
235
- for (let event in memory.onEvents) {
236
- let id = memory.onEvents[event];
237
- let instance = getEventTypeById(id);
238
- if (instance) {
239
- element.onEvent(event, instance);
240
- }
241
- }
242
- }
243
-
244
- // src/classes/canvas/CanvasImage.ts
245
- var CANVAS_IMAGE_ID = "CanvasImage";
246
- var CanvasImage = class _CanvasImage extends CanvasSprite {
247
- constructor(options, imageLink) {
248
- super(options);
249
- this.pixivnId = CANVAS_IMAGE_ID;
250
- this.imageLink = "";
251
- if (imageLink) {
252
- this.imageLink = imageLink;
253
- }
254
- }
255
- get memory() {
256
- return __spreadProps(__spreadValues({}, getMemorySprite(this)), {
257
- pixivnId: this.pixivnId,
258
- imageLink: this.imageLink
259
- });
260
- }
261
- set memory(memory) {
262
- setMemorySprite(this, memory);
263
- this.imageLink = memory.imageLink;
264
- }
265
- static from(source, skipCache) {
266
- let sprite = Sprite.from(source, skipCache);
267
- let mySprite = new _CanvasImage();
268
- mySprite.texture = sprite.texture;
269
- return mySprite;
270
- }
271
- /**
272
- * Load the image from the link and set the texture of the sprite.
273
- * @param image The link of the image. If it is not set, it will use the imageLink property.
274
- * @returns A promise that resolves when the image is loaded.
275
- */
276
- load(image) {
277
- return __async(this, null, function* () {
278
- if (!image) {
279
- image = this.imageLink;
280
- }
281
- return getTexture(this.imageLink).then((texture) => {
282
- if (texture) {
283
- this.texture = texture;
284
- }
285
- }).catch((e) => {
286
- console.error("[Pixi'VN] Error into CanvasImage.load()", e);
287
- });
288
- });
289
- }
290
- };
291
- var CANVAS_TEXT_ID = "CanvasText";
292
- var CanvasText = class extends Text {
293
- constructor(options) {
294
- super(options);
295
- this.pixivnId = CANVAS_TEXT_ID;
296
- this._onEvents = {};
297
- this.pixivnId = this.constructor.prototype.pixivnId;
298
- }
299
- get memory() {
300
- return getMemoryText(this);
301
- }
302
- set memory(value) {
303
- setMemoryText(this, value);
304
- }
305
- get onEvents() {
306
- return this._onEvents;
307
- }
308
- /**
309
- * is same function as on(), but it keeps in memory the children.
310
- * @param event The event type, e.g., 'click', 'mousedown', 'mouseup', 'pointerdown', etc.
311
- * @param eventClass The class that extends CanvasEvent.
312
- * @returns
313
- * @example
314
- * ```typescript
315
- * \@eventDecorator()
316
- * export class EventTest extends CanvasEvent<CanvasText> {
317
- * override fn(event: CanvasEventNamesType, text: CanvasText): void {
318
- * if (event === 'pointerdown') {
319
- * text.scale.x *= 1.25;
320
- * text.scale.y *= 1.25;
321
- * }
322
- * }
323
- * }
324
- * ```
325
- *
326
- * ```typescript
327
- * const text = new CanvasText();
328
- * text.text = "Hello World"
329
- *
330
- * text.eventMode = 'static';
331
- * text.cursor = 'pointer';
332
- * text.onEvent('pointerdown', EventTest);
333
- *
334
- * GameWindowManager.addCanvasElement("text", text);
335
- * ```
336
- */
337
- onEvent(event, eventClass) {
338
- let id = eventClass.prototype.id;
339
- let instance = getEventInstanceById(id);
340
- this._onEvents[event] = id;
341
- if (instance) {
342
- super.on(event, () => {
343
- instance.fn(event, this);
344
- });
345
- }
346
- return this;
347
- }
348
- /**
349
- * on() does not keep in memory the event class, use onEvent() instead
350
- * @deprecated
351
- * @private
352
- * @param event
353
- * @param fn
354
- * @param context
355
- */
356
- on(event, fn, context) {
357
- return super.on(event, fn, context);
358
- }
359
- };
360
- function getMemoryText(element) {
361
- let temp = getMemoryContainer(element);
362
- return __spreadProps(__spreadValues({}, temp), {
363
- pixivnId: element.pixivnId,
364
- anchor: { x: element.anchor.x, y: element.anchor.y },
365
- text: element.text,
366
- resolution: element.resolution,
367
- style: getTextStyle(element.style),
368
- roundPixels: element.roundPixels,
369
- onEvents: element.onEvents
370
- });
371
- }
372
- function setMemoryText(element, memory) {
373
- setMemoryContainer(element, memory);
374
- if (memory.anchor) {
375
- if (typeof memory.anchor === "number") {
376
- element.anchor.set(memory.anchor, memory.anchor);
377
- } else {
378
- element.anchor.set(memory.anchor.x, memory.anchor.y);
379
- }
380
- }
381
- memory.text && (element.text = memory.text);
382
- memory.resolution && (element.resolution = memory.resolution);
383
- memory.style && (element.style = memory.style);
384
- memory.roundPixels && (element.roundPixels = memory.roundPixels);
385
- for (let event in memory.onEvents) {
386
- let id = memory.onEvents[event];
387
- let instance = getEventTypeById(id);
388
- if (instance) {
389
- element.onEvent(event, instance);
390
- }
391
- }
392
- }
393
-
394
- // src/decorators/CanvasElementDecorator.ts
395
- var registeredCanvasElement = {};
396
- function getCanvasElementInstanceById(canvasId) {
397
- try {
398
- let eventType = registeredCanvasElement[canvasId];
399
- if (!eventType) {
400
- if (canvasId === CANVAS_CONTAINER_ID) {
401
- eventType = CanvasContainer;
402
- } else if (canvasId === CANVAS_IMAGE_ID) {
403
- eventType = CanvasImage;
404
- } else if (canvasId === CANVAS_SPRITE_ID) {
405
- eventType = CanvasSprite;
406
- } else if (canvasId === CANVAS_TEXT_ID) {
407
- eventType = CanvasText;
408
- }
409
- }
410
- if (!eventType) {
411
- console.error(`[Pixi'VN] CanvasElement ${canvasId} not found`);
412
- return;
413
- }
414
- let canvasElement = new eventType();
415
- return canvasElement;
416
- } catch (e) {
417
- console.error(`[Pixi'VN] Error while getting CanvasElement ${canvasId}`, e);
418
- return;
419
- }
420
- }
421
-
422
- // src/functions/CanvasUtility.ts
423
- function getTextureMemory(texture) {
424
- let sourceTexture = texture.source;
425
- let textureMemory = {
426
- image: sourceTexture.label
427
- };
428
- return textureMemory;
429
- }
430
- function exportCanvasElement(element) {
431
- return element.memory;
432
- }
433
- function importCanvasElement(memory) {
434
- let element = getCanvasElementInstanceById(memory.pixivnId);
435
- if (element) {
436
- element.memory = memory;
437
- } else {
438
- throw new Error("[Pixi'VN] The element " + memory.pixivnId + " could not be created");
439
- }
440
- return element;
441
- }
442
-
443
- // src/classes/canvas/CanvasContainer.ts
444
- var CANVAS_CONTAINER_ID = "CanvasContainer";
445
- var CanvasContainer = class extends Container {
446
- constructor(options) {
447
- super(options);
448
- this.pixivnId = CANVAS_CONTAINER_ID;
449
- this.pixivnId = this.constructor.prototype.pixivnId;
450
- }
451
- get memory() {
452
- let memory = getMemoryContainer(this);
453
- this.children.forEach((child) => {
454
- memory.elements.push(exportCanvasElement(child));
455
- });
456
- return memory;
457
- }
458
- set memory(value) {
459
- setMemoryContainer(this, value);
460
- value.elements.forEach((child) => {
461
- this.addChild(importCanvasElement(child));
462
- });
463
- }
464
- };
465
- function getMemoryContainer(element) {
466
- let className = "CanvasContainer";
467
- if (element.hasOwnProperty("pixivnId")) {
468
- className = element.pixivnId;
469
- }
470
- return {
471
- pixivnId: className,
472
- elements: [],
473
- width: element.width,
474
- height: element.height,
475
- isRenderGroup: element.isRenderGroup,
476
- blendMode: element.blendMode,
477
- tint: element.tint,
478
- alpha: element.alpha,
479
- angle: element.angle,
480
- renderable: element.renderable,
481
- rotation: element.rotation,
482
- scale: { x: element.scale.x, y: element.scale.y },
483
- pivot: { x: element.pivot.x, y: element.pivot.y },
484
- position: { x: element.position.x, y: element.position.y },
485
- skew: { x: element.skew.x, y: element.skew.y },
486
- visible: element.visible,
487
- culled: element.culled,
488
- x: element.x,
489
- y: element.y,
490
- boundsArea: element.boundsArea,
491
- cursor: element.cursor,
492
- eventMode: element.eventMode,
493
- interactive: element.interactive,
494
- interactiveChildren: element.interactiveChildren,
495
- hitArea: element.hitArea
496
- };
497
- }
498
- function setMemoryContainer(element, memory) {
499
- memory.width && (element.width = memory.width);
500
- memory.height && (element.height = memory.height);
501
- memory.isRenderGroup && (element.isRenderGroup = memory.isRenderGroup);
502
- memory.blendMode && (element.blendMode = memory.blendMode);
503
- memory.tint && (element.tint = memory.tint);
504
- memory.alpha && (element.alpha = memory.alpha);
505
- memory.angle && (element.angle = memory.angle);
506
- memory.renderable && (element.renderable = memory.renderable);
507
- memory.rotation && (element.rotation = memory.rotation);
508
- if (memory.scale) {
509
- if (typeof memory.scale === "number") {
510
- element.scale.set(memory.scale, memory.scale);
511
- } else {
512
- element.scale.set(memory.scale.x, memory.scale.y);
513
- }
514
- }
515
- if (memory.pivot) {
516
- if (typeof memory.pivot === "number") {
517
- element.pivot.set(memory.pivot, memory.pivot);
518
- } else {
519
- element.pivot.set(memory.pivot.x, memory.pivot.y);
520
- }
521
- }
522
- memory.position && element.position.set(memory.position.x, memory.position.y);
523
- memory.skew && element.skew.set(memory.skew.x, memory.skew.y);
524
- memory.visible && (element.visible = memory.visible);
525
- memory.culled && (element.culled = memory.culled);
526
- memory.x && (element.x = memory.x);
527
- memory.y && (element.y = memory.y);
528
- memory.boundsArea && (element.boundsArea = memory.boundsArea);
529
- memory.cursor && (element.cursor = memory.cursor);
530
- memory.eventMode && (element.eventMode = memory.eventMode);
531
- memory.interactive && (element.interactive = memory.interactive);
532
- memory.interactiveChildren && (element.interactiveChildren = memory.interactiveChildren);
533
- memory.hitArea && (element.hitArea = memory.hitArea);
534
- }
535
- function getStepSha1(step) {
536
- let sha1String = sha1(step.toString().toLocaleLowerCase());
537
- return sha1String.toString();
538
- }
539
- function checkIfStepsIsEqual(step1, step2) {
540
- return step1 === step2;
541
- }
542
-
543
- // src/classes/Label.ts
544
- var Label = class {
545
- /**
546
- * @param id is the id of the label
547
- * @param steps is the list of steps that the label will perform
548
- * @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
549
- * @param choiseIndex is the index of the choice that the label will perform
550
- */
551
- constructor(id, steps, onStepRun, choiseIndex) {
552
- this._id = id;
553
- this._steps = steps;
554
- this._onStepRun = onStepRun;
555
- this._choiseIndex = choiseIndex;
556
- }
557
- /**
558
- * Get the id of the label. This variable is used in the system to get the label by id, {@link getLabelById}
559
- */
560
- get id() {
561
- return this._id;
562
- }
563
- /**
564
- * Get the steps of the label.
565
- * This class should be extended and the steps method should be overridden.
566
- * Every time you update this list will also be updated when the other game versions load.
567
- */
568
- get steps() {
569
- if (typeof this._steps === "function") {
570
- return this._steps();
571
- }
572
- return this._steps;
573
- }
574
- /**
575
- * Get the corresponding steps number
576
- * @param externalSteps
577
- * @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
578
- */
579
- getCorrespondingStepsNumber(externalSteps) {
580
- if (externalSteps.length === 0) {
581
- return 0;
582
- }
583
- let res = 0;
584
- externalSteps.forEach((step, index) => {
585
- if (checkIfStepsIsEqual(step, this.steps[index])) {
586
- res = index;
587
- }
588
- });
589
- return res;
590
- }
591
- /**
592
- * 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
593
- * @returns Promise<void> or void
594
- * @example
595
- * ```typescript
596
- * newLabel("id", [], () => {
597
- * Assets.load('path/to/image1.png')
598
- * Assets.load('path/to/image2.png')
599
- * })
600
- * ```
601
- */
602
- get onStepRun() {
603
- return this._onStepRun;
604
- }
605
- get choiseIndex() {
606
- return this._choiseIndex;
607
- }
608
- };
609
-
610
- // src/classes/CloseLabel.ts
611
- var CLOSE_LABEL_ID = "__close-label-id__";
612
- function newCloseLabel(choiseIndex) {
613
- return new Label(CLOSE_LABEL_ID, [], void 0, choiseIndex);
614
- }
615
-
616
- // src/types/CloseType.ts
617
- var Close = "close";
618
-
619
- // src/functions/DialogueUtility.ts
620
- function setDialogue(props) {
621
- let text = "";
622
- let character = void 0;
623
- let dialogue;
624
- if (typeof props === "string") {
625
- text = props;
626
- dialogue = new DialogueBaseModel(text, character);
627
- } else if (!(props instanceof DialogueBaseModel)) {
628
- text = props.text;
629
- if (props.character) {
630
- if (typeof props.character === "string") {
631
- character = props.character;
632
- } else {
633
- character = props.character.id;
634
- }
635
- }
636
- dialogue = new DialogueBaseModel(text, character);
637
- } else {
638
- dialogue = props;
639
- }
640
- GameStorageManager.setVariable(GameStorageManager.keysSystem.CURRENT_DIALOGUE_MEMORY_KEY, dialogue);
641
- GameStorageManager.setVariable(GameStorageManager.keysSystem.LAST_DIALOGUE_ADDED_IN_STEP_MEMORY_KEY, GameStepManager.lastStepIndex);
642
- }
643
- function getDialogue() {
644
- return GameStorageManager.getVariable(GameStorageManager.keysSystem.CURRENT_DIALOGUE_MEMORY_KEY);
645
- }
646
- function getChoiceMenuOptions() {
647
- let d = GameStorageManager.getVariable(GameStorageManager.keysSystem.CURRENT_MENU_OPTIONS_MEMORY_KEY);
648
- if (d) {
649
- let options = [];
650
- d.forEach((option, index) => {
651
- if (option.type === Close) {
652
- let itemLabel = newCloseLabel(index);
653
- options.push({
654
- text: option.text,
655
- label: itemLabel,
656
- type: Close,
657
- closeCurrentLabel: option.closeCurrentLabel,
658
- props: {}
659
- });
660
- return;
661
- }
662
- let label = getLabelById(option.label);
663
- if (label) {
664
- let itemLabel = new Label(label.id, label.steps, label.onStepRun, index);
665
- options.push(__spreadProps(__spreadValues({}, option), {
666
- label: itemLabel
667
- }));
668
- }
669
- });
670
- return options;
671
- }
672
- return void 0;
673
- }
674
-
675
- // src/functions/TickerUtility.ts
676
- function updateTickerProgression(args, propertyName, progression) {
677
- if (args[propertyName] === void 0 || !progression || args[propertyName] === progression.limit) {
678
- return;
679
- }
680
- if (typeof args[propertyName] === "number") {
681
- if (progression.type === "linear") {
682
- args[propertyName] = getLinearProgression(args[propertyName], progression);
683
- } else if (progression.type === "exponential") {
684
- args[propertyName] = getExponentialProgression(args[propertyName], progression);
685
- }
686
- } 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") {
687
- if (progression.type === "linear") {
688
- args[propertyName].x = getLinearProgression(args[propertyName].x, progression);
689
- args[propertyName].y = getLinearProgression(args[propertyName].y, progression);
690
- } else if (progression.type === "exponential") {
691
- args[propertyName].x = getExponentialProgression(args[propertyName].x, progression);
692
- args[propertyName].y = getExponentialProgression(args[propertyName].y, progression);
693
- }
694
- }
695
- }
696
- function getLinearProgression(number, progression) {
697
- if (progression.limit !== void 0) {
698
- if (number > progression.limit && progression.amt > 0) {
699
- return progression.limit;
700
- } else if (number < progression.limit && progression.amt < 0) {
701
- return progression.limit;
702
- }
703
- }
704
- return number + progression.amt / 60;
705
- }
706
- function getExponentialProgression(number, progression) {
707
- if (progression.limit !== void 0) {
708
- if (number > progression.limit && progression.percentage > 0) {
709
- return progression.limit;
710
- } else if (number < progression.limit && progression.percentage < 0) {
711
- return progression.limit;
712
- }
713
- }
714
- return number + number * progression.percentage;
715
- }
716
-
717
- // src/classes/ticker/TickerBase.ts
718
- var TickerBase = class {
719
- /**
720
- * @param args The arguments that you want to pass to the ticker.
721
- * @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
722
- * @param priority The priority of the ticker. @default UPDATE_PRIORITY.NORMAL
723
- */
724
- constructor(args, duration, priority) {
725
- /**
726
- * Get the id of the ticker. This variable is used in the system to get the ticker by id, {@link geTickerInstanceById}
727
- */
728
- this.id = "ticker_id_not_set";
729
- this.args = args;
730
- this.duration = duration;
731
- this.priority = priority;
732
- this.id = this.constructor.prototype.id;
733
- }
734
- /**
735
- * The method that will be called every frame.
736
- * This method should be overridden and you can use GameWindowManager.addCanvasElement() to get the canvas element of the canvas, and edit them.
737
- * @param _ticker The ticker that is calling this method
738
- * @param _args The arguments that you passed when you added the ticker
739
- * @param _tags The tags of the canvas elements that are connected to this ticker
740
- * @param _tickerId The id of the ticker. You can use this to get the ticker from the {@link GameWindowManager.currentTickers}
741
- */
742
- fn(_ticker, _args, _tags, _tickerId) {
743
- throw new Error("[Pixi'VN] The method TickerBase.fn() must be overridden");
744
- }
745
- };
746
-
747
- // src/classes/ticker/ZoomTicker.ts
748
- var ZoomTicker = class extends TickerBase {
749
- fn(ticker, args, tags, tickerId) {
750
- let xSpeed = 0.1;
751
- let ySpeed = 0.1;
752
- if (args.speed) {
753
- if (typeof args.speed === "number") {
754
- xSpeed = args.speed;
755
- ySpeed = args.speed;
756
- } else {
757
- xSpeed = args.speed.x;
758
- ySpeed = args.speed.y;
759
- }
760
- }
761
- xSpeed /= 60;
762
- ySpeed /= 60;
763
- let tagToRemoveAfter2 = args.tagToRemoveAfter || [];
764
- if (typeof tagToRemoveAfter2 === "string") {
765
- tagToRemoveAfter2 = [tagToRemoveAfter2];
766
- }
767
- let type = args.type || "zoom";
768
- let xLimit = type === "zoom" ? Infinity : 0;
769
- let yLimit = type === "zoom" ? Infinity : 0;
770
- if (args.limit) {
771
- if (typeof args.limit === "number") {
772
- xLimit = args.limit;
773
- yLimit = args.limit;
774
- } else {
775
- xLimit = args.limit.x;
776
- yLimit = args.limit.y;
777
- }
778
- }
779
- tags.filter((tag) => {
780
- var _a;
781
- let element = GameWindowManager.getCanvasElement(tag);
782
- if (args.startOnlyIfHaveTexture) {
783
- if (element && element instanceof Sprite && ((_a = element.texture) == null ? void 0 : _a.label) == "EMPTY") {
784
- return false;
785
- }
786
- }
787
- return true;
788
- }).forEach((tag) => {
789
- let element = GameWindowManager.getCanvasElement(tag);
790
- if (element && element instanceof Container) {
791
- if (type === "zoom" && (element.scale.x < xLimit || element.scale.y < yLimit)) {
792
- element.scale.x += xSpeed * ticker.deltaTime;
793
- element.scale.y += ySpeed * ticker.deltaTime;
794
- } else if (type === "unzoom" && (element.scale.x > xLimit || element.scale.y > yLimit)) {
795
- element.scale.x -= xSpeed * ticker.deltaTime;
796
- element.scale.y -= ySpeed * ticker.deltaTime;
797
- }
798
- if (type === "zoom") {
799
- if (element.scale.x > xLimit) {
800
- element.scale.x = xLimit;
801
- }
802
- if (element.scale.y > yLimit) {
803
- element.scale.y = yLimit;
804
- }
805
- if (element.scale.x >= xLimit && element.scale.y >= yLimit) {
806
- element.scale.x = xLimit;
807
- element.scale.y = yLimit;
808
- this.onEndOfTicker(tag, tickerId, element, tagToRemoveAfter2);
809
- }
810
- } else if (type === "unzoom") {
811
- if (element.scale.x < xLimit) {
812
- element.scale.x = xLimit;
813
- }
814
- if (element.scale.y < yLimit) {
815
- element.scale.y = yLimit;
816
- }
817
- if (element.scale.x <= xLimit && element.scale.y <= yLimit) {
818
- element.scale.x = xLimit;
819
- element.scale.y = yLimit;
820
- this.onEndOfTicker(tag, tickerId, element, tagToRemoveAfter2);
821
- }
822
- }
823
- if (xSpeed < 1e-5 && ySpeed < 1e-5 && !(args.speedProgression && args.speedProgression.type == "linear" && args.speedProgression.amt != 0)) {
824
- this.onEndOfTicker(tag, tickerId, element, tagToRemoveAfter2);
825
- }
826
- }
827
- });
828
- if (args.speedProgression)
829
- updateTickerProgression(args, "speed", args.speedProgression);
830
- }
831
- onEndOfTicker(tag, tickerId, _element, tagToRemoveAfter2) {
832
- GameWindowManager.onEndOfTicker(tag, this, tagToRemoveAfter2, tickerId);
833
- }
834
- };
835
- ZoomTicker = __decorateClass([
836
- tickerDecorator()
837
- ], ZoomTicker);
838
-
839
- // src/constants.ts
840
- var Repeat = "repeat";
841
- function Pause(duration) {
842
- return {
843
- type: "pause",
844
- duration
845
- };
846
- }
847
-
848
- // src/functions/ImageUtility.ts
849
- function removeCanvasElement(tag) {
850
- GameWindowManager.removeCanvasElement(tag);
851
- }
852
-
853
- // src/functions/ExportUtility.ts
854
- function createExportableElement(element) {
855
- try {
856
- let elementString = JSON.stringify(element);
857
- return JSON.parse(elementString);
858
- } catch (e) {
859
- console.error("[Pixi'VN] Error creating exportable element", e);
860
- throw new Error("[Pixi'VN] Error creating exportable element");
861
- }
862
- }
863
-
864
- // src/functions/DiffUtility.ts
865
- function restoreDeepDiffChanges(data, differences) {
866
- let result = createExportableElement(data);
867
- differences.forEach((diff2) => {
868
- let dataToEdit = result;
869
- if (diff2.path && diff2.path.length > 0) {
870
- diff2.path.forEach((path, index) => {
871
- if (diff2.path && index === diff2.path.length - 1) {
872
- if (diff2.kind === "E" || diff2.kind === "D") {
873
- dataToEdit[path] = diff2.lhs;
874
- } else if (diff2.kind === "N") {
875
- if (Number.isInteger(path)) {
876
- if (Array.isArray(dataToEdit)) {
877
- dataToEdit.splice(path, 1);
878
- }
879
- } else if (typeof path === "string") {
880
- delete dataToEdit[path];
881
- }
882
- } else if (diff2.kind === "A") {
883
- let index2 = diff2.index;
884
- if (diff2.item.kind === "N") {
885
- dataToEdit[path].splice(index2, 1);
886
- } else if (diff2.item.kind === "E" || diff2.item.kind === "D") {
887
- dataToEdit[path][index2] = diff2.item.lhs;
888
- } else if (diff2.item.kind === "A") {
889
- console.warn("[Pixi'VN] Nested array found, skipping diff", diff2);
890
- } else {
891
- console.warn("[Pixi'VN] No array found, skipping diff", diff2);
892
- }
893
- }
894
- } else {
895
- dataToEdit = dataToEdit[path];
896
- }
897
- });
898
- } else {
899
- console.warn("[Pixi'VN] No path found, skipping diff", diff2);
900
- }
901
- });
902
- return result;
903
- }
904
-
905
- // src/managers/StorageManager.ts
906
- var _GameStorageManager = class _GameStorageManager {
907
- constructor() {
908
- }
909
- static get keysSystem() {
910
- return {
911
- CURRENT_DIALOGUE_MEMORY_KEY: "___current_dialogue_memory___",
912
- LAST_DIALOGUE_ADDED_IN_STEP_MEMORY_KEY: "___last_dialogue_added_in_step_memory___",
913
- CURRENT_MENU_OPTIONS_MEMORY_KEY: "___current_menu_options_memory___",
914
- LAST_MENU_OPTIONS_ADDED_IN_STEP_MEMORY_KEY: "___last_menu_options_added_in_step_memory___",
915
- CHARACTER_CATEGORY_KEY: "___character___",
916
- FLAGS_CATEGORY_KEY: "___flags___"
917
- };
918
- }
919
- /**
920
- * Set a variable in the storage
921
- * @param key The key of the variable
922
- * @param value The value of the variable. If undefined, the variable will be removed
923
- * @returns
924
- */
925
- static setVariable(key, value) {
926
- key = key.toLowerCase();
927
- if (value === void 0 || value === null) {
928
- if (_GameStorageManager.storage.hasOwnProperty(key)) {
929
- delete _GameStorageManager.storage[key];
930
- }
931
- return;
932
- }
933
- _GameStorageManager.storage[key] = value;
934
- }
935
- /**
936
- * Get a variable from the storage
937
- * @param key The key of the variable
938
- * @returns The value of the variable. If the variable does not exist, it will return undefined
939
- */
940
- static getVariable(key) {
941
- key = key.toLowerCase();
942
- if (_GameStorageManager.storage.hasOwnProperty(key)) {
943
- return _GameStorageManager.storage[key];
944
- }
945
- return void 0;
946
- }
947
- /**
948
- * Remove a variable from the storage
949
- * @param key The key of the variable
950
- * @returns
951
- */
952
- static removeVariable(key) {
953
- key = key.toLowerCase();
954
- if (_GameStorageManager.storage.hasOwnProperty(key)) {
955
- delete _GameStorageManager.storage[key];
956
- }
957
- }
958
- /**
959
- * Clear the storage and the oidsUsed
960
- * @returns
961
- */
962
- static clear() {
963
- _GameStorageManager.storage = {};
964
- }
965
- static exportJson() {
966
- return JSON.stringify(this.export());
967
- }
968
- static export() {
969
- return createExportableElement(_GameStorageManager.storage);
970
- }
971
- static importJson(dataString) {
972
- _GameStorageManager.import(JSON.parse(dataString));
973
- }
974
- static import(data) {
975
- _GameStorageManager.clear();
976
- try {
977
- if (data) {
978
- _GameStorageManager.storage = data;
979
- } else {
980
- console.warn("[Pixi'VN] No storage data found");
981
- }
982
- } catch (e) {
983
- console.error("[Pixi'VN] Error importing data", e);
984
- }
985
- }
986
- };
987
- _GameStorageManager.storage = {};
988
- var GameStorageManager = _GameStorageManager;
989
-
990
- // src/decorators/TickerDecorator.ts
991
- var registeredTickers = {};
992
- function tickerDecorator(name) {
993
- return function(target) {
994
- if (!name) {
995
- name = target.name;
996
- }
997
- if (registeredTickers[name]) {
998
- console.info(`[Pixi'VN] Ticker ${name} already exists, it will be overwritten`);
999
- }
1000
- target.prototype.id = name;
1001
- registeredTickers[name] = target;
1002
- };
1003
- }
1004
- function geTickerInstanceById(tickerId, args, duration, priority) {
1005
- try {
1006
- let ticker = registeredTickers[tickerId];
1007
- if (!ticker) {
1008
- console.error(`[Pixi'VN] Ticker ${tickerId} not found`);
1009
- return;
1010
- }
1011
- return new ticker(args, duration, priority);
1012
- } catch (e) {
1013
- console.error(`[Pixi'VN] Error while getting Ticker ${tickerId}`, e);
1014
- return;
1015
- }
1016
- }
1017
-
1018
- // src/functions/EasterEgg.ts
1019
- function asciiArtLog() {
1020
- console.info(`
1021
- ____ _ _ ___ ___ _
1022
- | _ \\(_)_ _(_| ) \\ / / \\ | |
1023
- | |_) | \\ \\/ / |/ \\ \\ / /| \\| |
1024
- | __/| |> <| | \\ V / | |\\ |
1025
- |_| |_/_/\\_\\_| \\_/ |_| \\_|
1026
- `);
1027
- }
1028
-
1029
- // src/types/ticker/TagToRemoveAfterType.ts
1030
- var tagToRemoveAfter = "tagToRemoveAfter";
1031
-
1032
- // src/managers/WindowManager.ts
1033
- var _GameWindowManager = class _GameWindowManager {
1034
- constructor() {
1035
- }
1036
- /**
1037
- * The PIXI Application instance.
1038
- * It not recommended to use this property directly.
1039
- */
1040
- static get app() {
1041
- if (!_GameWindowManager._app) {
1042
- throw new Error("[Pixi'VN] GameWindowManager.app is undefined");
1043
- }
1044
- return _GameWindowManager._app;
1045
- }
1046
- /**
1047
- * If the manager is initialized.
1048
- */
1049
- static get isInitialized() {
1050
- return _GameWindowManager._isInitialized;
1051
- }
1052
- static get screen() {
1053
- return _GameWindowManager.app.screen;
1054
- }
1055
- /**
1056
- * Initialize the PIXI Application and the interface div.
1057
- * This method should be called before any other method.
1058
- * @param element The html element where I will put the canvas. Example: document.body
1059
- * @param width The width of the canvas
1060
- * @param height The height of the canvas
1061
- * @param options The options of PIXI Application
1062
- * @example
1063
- * ```typescript
1064
- * const body = document.body
1065
- * if (!body) {
1066
- * throw new Error('body element not found')
1067
- * }
1068
- * await GameWindowManager.initialize(body, 1920, 1080, {
1069
- * backgroundColor: "#303030"
1070
- * })
1071
- * ```
1072
- */
1073
- static initialize(element, width, height, options) {
1074
- return __async(this, null, function* () {
1075
- _GameWindowManager.canvasWidth = width;
1076
- _GameWindowManager.canvasHeight = height;
1077
- _GameWindowManager._app = new Application();
1078
- return _GameWindowManager.app.init(__spreadValues({
1079
- resolution: window.devicePixelRatio || 1,
1080
- autoDensity: true,
1081
- width,
1082
- height
1083
- }, options)).then(() => {
1084
- _GameWindowManager._isInitialized = true;
1085
- this.addCanvasIntoElement(element);
1086
- window.addEventListener("resize", _GameWindowManager.resize);
1087
- _GameWindowManager.resize();
1088
- asciiArtLog();
1089
- });
1090
- });
1091
- }
1092
- /**
1093
- * Add the canvas into a html element.
1094
- * @param element it is the html element where I will put the canvas. Example: document.body
1095
- */
1096
- static addCanvasIntoElement(element) {
1097
- if (_GameWindowManager.isInitialized) {
1098
- element.appendChild(_GameWindowManager.app.canvas);
1099
- } else {
1100
- console.error("[Pixi'VN] GameWindowManager is not initialized");
1101
- }
1102
- }
1103
- /**
1104
- * Initialize the interface div and add it into a html element.
1105
- * @param element it is the html element where I will put the interface div. Example: document.getElementById('root')
1106
- * @example
1107
- * ```tsx
1108
- * const root = document.getElementById('root')
1109
- * if (!root) {
1110
- * throw new Error('root element not found')
1111
- * }
1112
- * GameWindowManager.initializeHTMLLayout(root)
1113
- * const reactRoot = createRoot(GameWindowManager.htmlLayout)
1114
- * reactRoot.render(
1115
- * <App />
1116
- * )
1117
- * ```
1118
- */
1119
- static initializeHTMLLayout(element) {
1120
- let div = document.createElement("div");
1121
- div.style.position = "absolute";
1122
- div.style.pointerEvents = "none";
1123
- element.appendChild(div);
1124
- _GameWindowManager.htmlLayout = div;
1125
- _GameWindowManager.resize();
1126
- }
1127
- /* Resize Metods */
1128
- /**
1129
- * This method returns the scale of the screen.
1130
- */
1131
- static get screenScale() {
1132
- let screenWidth = Math.max(document.documentElement.clientWidth, window.innerWidth || 0);
1133
- let screenHeight = Math.max(document.documentElement.clientHeight, window.innerHeight || 0);
1134
- return Math.min(screenWidth / _GameWindowManager.canvasWidth, screenHeight / _GameWindowManager.canvasHeight);
1135
- }
1136
- /**
1137
- * This method returns the width of the screen enlarged by the scale.
1138
- */
1139
- static get screenWidth() {
1140
- return Math.floor(_GameWindowManager.screenScale * _GameWindowManager.canvasWidth);
1141
- }
1142
- /**
1143
- * This method returns the height of the screen enlarged by the scale.
1144
- */
1145
- static get screenHeight() {
1146
- return Math.floor(_GameWindowManager.screenScale * _GameWindowManager.canvasHeight);
1147
- }
1148
- /**
1149
- * This method returns the horizontal margin of the screen.
1150
- */
1151
- static get horizontalMargin() {
1152
- let screenWidth = Math.max(document.documentElement.clientWidth, window.innerWidth || 0);
1153
- return (screenWidth - _GameWindowManager.screenWidth) / 2;
1154
- }
1155
- /**
1156
- * This method returns the vertical margin of the screen.
1157
- */
1158
- static get verticalMargin() {
1159
- let screenHeight = Math.max(document.documentElement.clientHeight, window.innerHeight || 0);
1160
- return (screenHeight - _GameWindowManager.screenHeight) / 2;
1161
- }
1162
- /**
1163
- * This method is called when the screen is resized.
1164
- */
1165
- static resize() {
1166
- if (_GameWindowManager.isInitialized) {
1167
- let style = _GameWindowManager.app.canvas.style;
1168
- style.width = `${_GameWindowManager.screenWidth}px`;
1169
- style.height = `${_GameWindowManager.screenHeight}px`;
1170
- style.marginLeft = `${_GameWindowManager.horizontalMargin}px`;
1171
- style.marginRight = `${_GameWindowManager.horizontalMargin}px`;
1172
- style.marginTop = `${_GameWindowManager.verticalMargin}px`;
1173
- style.marginBottom = `${_GameWindowManager.verticalMargin}px`;
1174
- }
1175
- if (_GameWindowManager.htmlLayout) {
1176
- _GameWindowManager.htmlLayout.style.width = `${_GameWindowManager.screenWidth}px`;
1177
- _GameWindowManager.htmlLayout.style.height = `${_GameWindowManager.screenHeight}px`;
1178
- _GameWindowManager.htmlLayout.style.marginLeft = `${_GameWindowManager.horizontalMargin}px`;
1179
- _GameWindowManager.htmlLayout.style.marginRight = `${_GameWindowManager.horizontalMargin}px`;
1180
- _GameWindowManager.htmlLayout.style.marginTop = `${_GameWindowManager.verticalMargin}px`;
1181
- _GameWindowManager.htmlLayout.style.marginBottom = `${_GameWindowManager.verticalMargin}px`;
1182
- }
1183
- }
1184
- /* Edit Canvas Elements Methods */
1185
- /**
1186
- * This is a dictionary that contains all Canvas Elements of Canvas, currently.
1187
- */
1188
- static get currentCanvasElements() {
1189
- return _GameWindowManager._children;
1190
- }
1191
- /**
1192
- * Add a canvas element to the canvas.
1193
- * If there is a canvas element with the same tag, it will be removed.
1194
- * @param tag The tag of the canvas element.
1195
- * @param canvasElement The canvas elements to be added.
1196
- * @example
1197
- * ```typescript
1198
- * const texture = await Assets.load('https://pixijs.com/assets/bunny.png');
1199
- * const sprite = CanvasSprite.from(texture);
1200
- * GameWindowManager.addCanvasElement("bunny", sprite);
1201
- * ```
1202
- */
1203
- static addCanvasElement(tag, canvasElement) {
1204
- if (_GameWindowManager._children[tag]) {
1205
- _GameWindowManager.removeCanvasElement(tag);
1206
- }
1207
- _GameWindowManager.app.stage.addChild(canvasElement);
1208
- _GameWindowManager._children[tag] = canvasElement;
1209
- _GameWindowManager.childrenTagsOrder.push(tag);
1210
- }
1211
- /**
1212
- * Remove a canvas element from the canvas.
1213
- * And remove all tickers that are not connected to any canvas element.
1214
- * @param tags The tag of the canvas element to be removed.
1215
- * @returns
1216
- * @example
1217
- * ```typescript
1218
- * GameWindowManager.removeCanvasElement("bunny");
1219
- * ```
1220
- */
1221
- static removeCanvasElement(tags) {
1222
- if (typeof tags === "string") {
1223
- tags = [tags];
1224
- }
1225
- tags.forEach((tag) => {
1226
- if (_GameWindowManager._children[tag]) {
1227
- _GameWindowManager.app.stage.removeChild(_GameWindowManager._children[tag]);
1228
- delete _GameWindowManager._children[tag];
1229
- _GameWindowManager.removeTickerByCanvasElement(tag);
1230
- }
1231
- });
1232
- _GameWindowManager.childrenTagsOrder = _GameWindowManager.childrenTagsOrder.filter((t) => !tags.includes(t));
1233
- }
1234
- /**
1235
- * Get a canvas element by the tag.
1236
- * @param tag The tag of the canvas element.
1237
- * @returns The canvas element.
1238
- * @example
1239
- * ```typescript
1240
- * const sprite = GameWindowManager.getCanvasElement<CanvasSprite>("bunny");
1241
- * ```
1242
- */
1243
- static getCanvasElement(tag) {
1244
- return _GameWindowManager._children[tag];
1245
- }
1246
- /**
1247
- * Check if a DisplayObject is on the canvas.
1248
- * @param pixiElement The DisplayObject to be checked.
1249
- * @returns If the DisplayObject is on the canvas.
1250
- */
1251
- static canvasElementIsOnCanvas(pixiElement) {
1252
- return _GameWindowManager.app.stage.children.includes(pixiElement);
1253
- }
1254
- /**
1255
- * Remove all canvas elements from the canvas.
1256
- * And remove all tickers that are not connected to any canvas element.
1257
- */
1258
- static removeCanvasElements() {
1259
- _GameWindowManager.app.stage.removeChildren();
1260
- _GameWindowManager._children = {};
1261
- _GameWindowManager.childrenTagsOrder = [];
1262
- _GameWindowManager.removeAllTickers();
1263
- }
1264
- /**
1265
- * Edit the tag of a canvas element.
1266
- * @param oldTag The old tag of the canvas element.
1267
- * @param newTag The new tag of the canvas element.
1268
- */
1269
- static editCanvasElementTag(oldTag, newTag) {
1270
- if (_GameWindowManager._children[oldTag]) {
1271
- _GameWindowManager._children[newTag] = _GameWindowManager._children[oldTag];
1272
- delete _GameWindowManager._children[oldTag];
1273
- }
1274
- if (_GameWindowManager._currentTickersSteps[oldTag]) {
1275
- _GameWindowManager._currentTickersSteps[newTag] = _GameWindowManager._currentTickersSteps[oldTag];
1276
- delete _GameWindowManager._currentTickersSteps[oldTag];
1277
- }
1278
- for (let id in _GameWindowManager._currentTickers) {
1279
- let ticker = _GameWindowManager._currentTickers[id];
1280
- if (ticker.canvasElementTags.includes(oldTag)) {
1281
- ticker.canvasElementTags = ticker.canvasElementTags.map((t) => t === oldTag ? newTag : t);
1282
- if (ticker.args.hasOwnProperty(tagToRemoveAfter)) {
1283
- let tagToRemoveAfter2 = ticker.args.tagToRemoveAfter;
1284
- if (typeof tagToRemoveAfter2 === "string") {
1285
- tagToRemoveAfter2 = [tagToRemoveAfter2];
1286
- }
1287
- if (Array.isArray(tagToRemoveAfter2)) {
1288
- ticker.args.tagToRemoveAfter = tagToRemoveAfter2.map((t) => t === oldTag ? newTag : t);
1289
- }
1290
- }
1291
- }
1292
- }
1293
- for (let timeout in _GameWindowManager._currentTickersTimeouts) {
1294
- let TickerTimeout = _GameWindowManager._currentTickersTimeouts[timeout];
1295
- if (TickerTimeout.tags.includes(oldTag)) {
1296
- TickerTimeout.tags = TickerTimeout.tags.map((t) => t === oldTag ? newTag : t);
1297
- }
1298
- }
1299
- }
1300
- /** Edit Tickers Methods */
1301
- /**
1302
- * Currently tickers that are running.
1303
- */
1304
- static get currentTickers() {
1305
- return _GameWindowManager._currentTickers;
1306
- }
1307
- static get currentTickersList() {
1308
- return Object.values(_GameWindowManager._currentTickers);
1309
- }
1310
- static get currentTickersWithoutCreatedBySteps() {
1311
- return Object.fromEntries(Object.entries(_GameWindowManager._currentTickers).filter(([_, ticker]) => !ticker.createdByTicketStepsId));
1312
- }
1313
- /**
1314
- * The steps of the tickers
1315
- */
1316
- static get currentTickersSteps() {
1317
- return _GameWindowManager._currentTickersSteps;
1318
- }
1319
- static generateTickerId(tickerData) {
1320
- try {
1321
- return sha1(JSON.stringify(tickerData)).toString() + "_" + Math.random().toString(36).substring(7);
1322
- } catch (e) {
1323
- throw new Error(`[Pixi'VN] Error to generate ticker id: ${e}`);
1324
- }
1325
- }
1326
- /**
1327
- * Run a ticker. You can run multiple addTicker with the same tag and different tickerClasses.
1328
- * If you run a ticker with the same tag and tickerClass, the old ticker will be removed.
1329
- * If already exists a sequence of tickers with the same tag, it will be removed.
1330
- * @param canvasEslementTag The tag of the canvas element that will use the ticker.
1331
- * @param ticker The ticker class to be run.
1332
- * @param args The arguments to be used in the ticker.
1333
- * @param duration The time to be used in the ticker. This number is in seconds. If it is undefined, the ticker will run forever.
1334
- * @param priority The priority to be used in the ticker.
1335
- * @returns
1336
- * @example
1337
- * ```typescript
1338
- * GameWindowManager.addTicker("alien", new RotateTicker({ speed: 0.2 }))
1339
- * ```
1340
- */
1341
- static addTicker(canvasElementTag, ticker) {
1342
- let tickerId = ticker.id;
1343
- if (typeof canvasElementTag === "string") {
1344
- canvasElementTag = [canvasElementTag];
1345
- }
1346
- if (!geTickerInstanceById(tickerId, ticker.args, ticker.duration, ticker.priority)) {
1347
- console.error(`[Pixi'VN] Ticker ${tickerId} not found`);
1348
- return;
1349
- }
1350
- let tickerHistory = {
1351
- fn: () => {
1352
- },
1353
- id: tickerId,
1354
- args: createExportableElement(ticker.args),
1355
- canvasElementTags: canvasElementTag,
1356
- priority: ticker.priority,
1357
- duration: ticker.duration
1358
- };
1359
- let id = _GameWindowManager.generateTickerId(tickerHistory);
1360
- _GameWindowManager.pushTicker(id, tickerHistory, ticker);
1361
- if (ticker.duration) {
1362
- let timeout = setTimeout(() => {
1363
- _GameWindowManager.removeTickerTimeoutInfo(timeout);
1364
- let tickerTimeoutInfo = _GameWindowManager._currentTickersTimeouts[timeout.toString()];
1365
- if (tickerTimeoutInfo) {
1366
- _GameWindowManager.removeTicker(id);
1367
- }
1368
- }, ticker.duration * 1e3);
1369
- _GameWindowManager.addTickerTimeoutInfo(canvasElementTag, tickerId, timeout.toString(), true);
1370
- }
1371
- }
1372
- static pushTicker(id, tickerData, ticker) {
1373
- _GameWindowManager.removeAssociationBetweenTickerCanvasElement(tickerData.canvasElementTags, ticker);
1374
- _GameWindowManager._currentTickers[id] = tickerData;
1375
- tickerData.fn = (t) => {
1376
- let data = _GameWindowManager._currentTickers[id];
1377
- if (data) {
1378
- ticker == null ? void 0 : ticker.fn(t, data.args, data.canvasElementTags, id);
1379
- }
1380
- };
1381
- _GameWindowManager.app.ticker.add(tickerData.fn, void 0, tickerData.priority);
1382
- }
1383
- /**
1384
- * Run a sequence of tickers. If exists a ticker steps with the same tag, it will be removed.
1385
- * @param tag The tag of canvas element that will use the tickers.
1386
- * @param steps The steps of the tickers.
1387
- * @param currentStepNumber The current step number. It is used to continue the sequence of tickers.
1388
- * @returns
1389
- * @example
1390
- * ```typescript
1391
- * GameWindowManager.addTickersSteps("alien", [
1392
- * new RotateTicker({ speed: 0.1, clockwise: true }, 2), // 2 seconds
1393
- * Pause(1), // 1 second
1394
- * new RotateTicker({ speed: 0.2, clockwise: false }, 2),
1395
- * Repeat,
1396
- * ])
1397
- * ```
1398
- */
1399
- static addTickersSteps(tag, steps, currentStepNumber = 0) {
1400
- if (steps.length == 0) {
1401
- console.warn("[Pixi'VN] The steps of the tickers is empty");
1402
- return;
1403
- }
1404
- _GameWindowManager.removeTickerStepByCanvasElement(tag);
1405
- _GameWindowManager._currentTickersSteps[tag] = {
1406
- currentStepNumber,
1407
- steps: steps.map((step) => {
1408
- if (step === Repeat) {
1409
- return step;
1410
- }
1411
- if (step.hasOwnProperty("type") && step.type === "pause") {
1412
- return step;
1413
- }
1414
- let tickerId = step.id;
1415
- return {
1416
- ticker: tickerId,
1417
- args: createExportableElement(step.args),
1418
- duration: step.duration
1419
- };
1420
- })
1421
- };
1422
- _GameWindowManager.runTickersSteps(tag);
1423
- }
1424
- static restoneTickersSteps(data) {
1425
- for (let tag in data) {
1426
- let steps = data[tag];
1427
- _GameWindowManager._currentTickersSteps[tag] = steps;
1428
- _GameWindowManager.runTickersSteps(tag);
1429
- }
1430
- }
1431
- static runTickersSteps(tag) {
1432
- let step = _GameWindowManager._currentTickersSteps[tag].steps[_GameWindowManager._currentTickersSteps[tag].currentStepNumber];
1433
- if (step === Repeat) {
1434
- step = _GameWindowManager._currentTickersSteps[tag].steps[0];
1435
- _GameWindowManager._currentTickersSteps[tag].currentStepNumber = 0;
1436
- if (step === Repeat) {
1437
- console.error("[Pixi'VN] TikersSteps has a RepeatType in the first step");
1438
- return;
1439
- }
1440
- }
1441
- if (step.hasOwnProperty("type") && step.type === "pause") {
1442
- let timeout = setTimeout(() => {
1443
- let tickerTimeoutInfo = _GameWindowManager._currentTickersTimeouts[timeout.toString()];
1444
- if (tickerTimeoutInfo) {
1445
- tickerTimeoutInfo.tags.forEach((tag2) => {
1446
- _GameWindowManager.nextTickerStep(tag2);
1447
- });
1448
- }
1449
- _GameWindowManager.removeTickerTimeoutInfo(timeout);
1450
- }, step.duration * 1e3);
1451
- _GameWindowManager.addTickerTimeoutInfo(tag, "steps", timeout.toString(), false);
1452
- return;
1453
- }
1454
- let ticker = geTickerInstanceById(step.ticker, step.args, step.duration, step.priority);
1455
- if (!ticker) {
1456
- console.error(`[Pixi'VN] Ticker ${step.ticker} not found`);
1457
- return;
1458
- }
1459
- let tickerName = ticker.id;
1460
- let tickerHistory = {
1461
- fn: () => {
1462
- },
1463
- id: tickerName,
1464
- args: createExportableElement(ticker.args),
1465
- canvasElementTags: [tag],
1466
- priority: ticker.priority,
1467
- duration: ticker.duration,
1468
- createdByTicketStepsId: tag
1469
- };
1470
- let id = _GameWindowManager.generateTickerId(tickerHistory);
1471
- _GameWindowManager.pushTicker(id, tickerHistory, ticker);
1472
- if (ticker.duration) {
1473
- let timeout = setTimeout(() => {
1474
- let tickerTimeoutInfo = _GameWindowManager._currentTickersTimeouts[timeout.toString()];
1475
- if (tickerTimeoutInfo) {
1476
- _GameWindowManager.removeTicker(id);
1477
- tickerTimeoutInfo.tags.forEach((tag2) => {
1478
- _GameWindowManager.nextTickerStep(tag2);
1479
- });
1480
- }
1481
- _GameWindowManager.removeTickerTimeoutInfo(timeout);
1482
- }, ticker.duration * 1e3);
1483
- _GameWindowManager.addTickerTimeoutInfo(tag, tickerName, timeout.toString(), false);
1484
- }
1485
- }
1486
- static nextTickerStep(tag) {
1487
- if (_GameWindowManager._currentTickersSteps[tag]) {
1488
- let steps = _GameWindowManager._currentTickersSteps[tag];
1489
- if (steps.currentStepNumber + 1 < steps.steps.length) {
1490
- steps.currentStepNumber++;
1491
- _GameWindowManager._currentTickersSteps[tag] = steps;
1492
- _GameWindowManager.runTickersSteps(tag);
1493
- } else {
1494
- _GameWindowManager.removeTickerStepByCanvasElement(tag);
1495
- }
1496
- }
1497
- }
1498
- static onEndOfTicker(canvasElementTags, ticker, canvasElementTagsToDelete, tickerId) {
1499
- let tickerData = _GameWindowManager._currentTickers[tickerId];
1500
- _GameWindowManager.removeAssociationBetweenTickerCanvasElement(canvasElementTags, ticker);
1501
- _GameWindowManager.removeCanvasElement(canvasElementTagsToDelete);
1502
- if (tickerData) {
1503
- _GameWindowManager.removeTicker(tickerId);
1504
- if (tickerData.duration == void 0 && tickerData.createdByTicketStepsId) {
1505
- _GameWindowManager.nextTickerStep(tickerData.createdByTicketStepsId);
1506
- }
1507
- }
1508
- }
1509
- /**
1510
- * Remove a connection between a canvas element and a ticker.
1511
- * And remove the ticker if there is no canvas element connected to it.
1512
- * @param tags The tag of the canvas element that will use the ticker.
1513
- * @param ticker The ticker class to be removed.
1514
- * @example
1515
- * ```typescript
1516
- * GameWindowManager.removeAssociationBetweenTickerCanvasElement("alien", RotateTicker)
1517
- * ```
1518
- */
1519
- static removeAssociationBetweenTickerCanvasElement(tags, ticker) {
1520
- let tickerId;
1521
- if (typeof ticker === "string") {
1522
- tickerId = ticker;
1523
- } else if (ticker instanceof TickerBase) {
1524
- tickerId = ticker.id;
1525
- } else {
1526
- tickerId = ticker.prototype.id;
1527
- }
1528
- if (typeof tags === "string") {
1529
- tags = [tags];
1530
- }
1531
- for (let id in _GameWindowManager._currentTickers) {
1532
- let ticker2 = _GameWindowManager._currentTickers[id];
1533
- if (ticker2.id === tickerId) {
1534
- _GameWindowManager._currentTickers[id].canvasElementTags = ticker2.canvasElementTags.filter((e) => !tags.includes(e));
1535
- }
1536
- }
1537
- for (let timeout in _GameWindowManager._currentTickersTimeouts) {
1538
- let TickerTimeout = _GameWindowManager._currentTickersTimeouts[timeout];
1539
- if (TickerTimeout.ticker === tickerId && TickerTimeout.canBeDeletedBeforeEnd) {
1540
- _GameWindowManager._currentTickersTimeouts[timeout].tags = TickerTimeout.tags.filter((t) => !tags.includes(t));
1541
- }
1542
- }
1543
- _GameWindowManager.removeTickersWithoutAssociatedCanvasElement();
1544
- }
1545
- /**
1546
- * Remove all tickers that are not connected to any existing canvas element.
1547
- */
1548
- static removeTickersWithoutAssociatedCanvasElement() {
1549
- for (let id in _GameWindowManager._currentTickers) {
1550
- let ticker = _GameWindowManager._currentTickers[id];
1551
- ticker.canvasElementTags = ticker.canvasElementTags.filter((e) => _GameWindowManager._children[e]);
1552
- if (ticker.canvasElementTags.length === 0) {
1553
- _GameWindowManager.removeTicker(id);
1554
- }
1555
- }
1556
- for (let tag in _GameWindowManager._currentTickersSteps) {
1557
- if (_GameWindowManager._children[tag] === void 0) {
1558
- delete _GameWindowManager._currentTickersSteps[tag];
1559
- }
1560
- }
1561
- Object.entries(_GameWindowManager._currentTickersTimeouts).forEach(([timeout, { tags }]) => {
1562
- if (tags.length === 0) {
1563
- _GameWindowManager.removeTickerTimeout(timeout);
1564
- }
1565
- });
1566
- }
1567
- static addTickerTimeoutInfo(tags, ticker, timeout, canBeDeletedBeforeEnd) {
1568
- if (typeof tags === "string") {
1569
- tags = [tags];
1570
- }
1571
- _GameWindowManager._currentTickersTimeouts[timeout] = {
1572
- tags,
1573
- ticker,
1574
- canBeDeletedBeforeEnd
1575
- };
1576
- }
1577
- static removeTickerTimeoutInfo(timeout) {
1578
- if (typeof timeout !== "string") {
1579
- timeout = timeout.toString();
1580
- }
1581
- if (_GameWindowManager._currentTickersTimeouts[timeout]) {
1582
- delete _GameWindowManager._currentTickersTimeouts[timeout];
1583
- }
1584
- }
1585
- static removeTickerTimeout(timeout) {
1586
- if (typeof timeout !== "string") {
1587
- timeout = timeout.toString();
1588
- }
1589
- clearTimeout(Number(timeout));
1590
- _GameWindowManager.removeTickerTimeoutInfo(timeout);
1591
- }
1592
- static removeTickerTimeoutsByTag(tag, checkCanBeDeletedBeforeEnd) {
1593
- for (let timeout in _GameWindowManager._currentTickersTimeouts) {
1594
- let tagsWithoutTagToRemove = _GameWindowManager._currentTickersTimeouts[timeout].tags.filter((t) => t !== tag);
1595
- if (tagsWithoutTagToRemove.length === 0) {
1596
- let canBeDeletedBeforeEnd = _GameWindowManager._currentTickersTimeouts[timeout].canBeDeletedBeforeEnd;
1597
- if (!checkCanBeDeletedBeforeEnd || canBeDeletedBeforeEnd) {
1598
- _GameWindowManager.removeTickerTimeout(timeout);
1599
- }
1600
- } else {
1601
- _GameWindowManager._currentTickersTimeouts[timeout].tags = tagsWithoutTagToRemove;
1602
- }
1603
- }
1604
- }
1605
- /**
1606
- * Remove all tickers from the canvas.
1607
- */
1608
- static removeAllTickers() {
1609
- _GameWindowManager._currentTickersSteps = {};
1610
- Object.keys(_GameWindowManager._currentTickers).forEach((id) => {
1611
- _GameWindowManager.removeTicker(id);
1612
- });
1613
- _GameWindowManager._currentTickers = {};
1614
- for (let timeout in _GameWindowManager._currentTickersTimeouts) {
1615
- _GameWindowManager.removeTickerTimeout(timeout);
1616
- }
1617
- }
1618
- /**
1619
- * Remove all tickers from a canvas element.
1620
- * @param tag The tag of the canvas element that will use the ticker.
1621
- */
1622
- static removeTickerByCanvasElement(tag) {
1623
- if (typeof tag === "string") {
1624
- tag = [tag];
1625
- }
1626
- tag.forEach((tag2) => {
1627
- for (let id in _GameWindowManager._currentTickers) {
1628
- let ticker = _GameWindowManager._currentTickers[id];
1629
- if (ticker.canvasElementTags.includes(tag2)) {
1630
- _GameWindowManager.removeTicker(id);
1631
- }
1632
- }
1633
- if (_GameWindowManager._currentTickersSteps[tag2]) {
1634
- delete _GameWindowManager._currentTickersSteps[tag2];
1635
- }
1636
- _GameWindowManager.removeTickerTimeoutsByTag(tag2, false);
1637
- delete _GameWindowManager._currentTickersSteps[tag2];
1638
- });
1639
- }
1640
- static removeTickerStepByCanvasElement(tag) {
1641
- if (_GameWindowManager._currentTickersSteps[tag]) {
1642
- delete _GameWindowManager._currentTickersSteps[tag];
1643
- }
1644
- for (let id in _GameWindowManager._currentTickers) {
1645
- let ticker = _GameWindowManager._currentTickers[id];
1646
- if (ticker.createdByTicketStepsId === tag) {
1647
- _GameWindowManager.removeTicker(id);
1648
- }
1649
- }
1650
- }
1651
- static removeTicker(tickerId) {
1652
- let ticker = _GameWindowManager._currentTickers[tickerId];
1653
- if (ticker) {
1654
- if (ticker.args.hasOwnProperty(tagToRemoveAfter)) {
1655
- let tagToRemoveAfter2 = ticker.args.tagToRemoveAfter;
1656
- _GameWindowManager.removeCanvasElement(tagToRemoveAfter2);
1657
- }
1658
- _GameWindowManager.app.ticker.remove(ticker.fn);
1659
- delete _GameWindowManager._currentTickers[tickerId];
1660
- }
1661
- }
1662
- /**
1663
- * Clear the canvas and the tickers.
1664
- */
1665
- static clear() {
1666
- _GameWindowManager.removeCanvasElements();
1667
- }
1668
- /* Export and Import Methods */
1669
- /**
1670
- * Export the canvas and the tickers to a JSON string.
1671
- * @returns The JSON string.
1672
- */
1673
- static exportJson() {
1674
- return JSON.stringify(this.export());
1675
- }
1676
- /**
1677
- * Export the canvas and the tickers to an object.
1678
- * @returns The object.
1679
- */
1680
- static export() {
1681
- let currentElements = {};
1682
- for (let tag in _GameWindowManager._children) {
1683
- currentElements[tag] = exportCanvasElement(_GameWindowManager._children[tag]);
1684
- }
1685
- return {
1686
- currentTickers: createExportableElement(_GameWindowManager.currentTickersWithoutCreatedBySteps),
1687
- currentTickersSteps: createExportableElement(_GameWindowManager._currentTickersSteps),
1688
- currentElements: createExportableElement(currentElements),
1689
- childrenTagsOrder: createExportableElement(_GameWindowManager.childrenTagsOrder)
1690
- };
1691
- }
1692
- /**
1693
- * Import the canvas and the tickers from a JSON string.
1694
- * @param dataString The JSON string.
1695
- */
1696
- static importJson(dataString) {
1697
- _GameWindowManager.import(JSON.parse(dataString));
1698
- }
1699
- /**
1700
- * Import the canvas and the tickers from an object.
1701
- * @param data The object.
1702
- */
1703
- static import(data) {
1704
- _GameWindowManager.clear();
1705
- try {
1706
- if (data.hasOwnProperty("childrenTagsOrder") && data.hasOwnProperty("currentElements")) {
1707
- let currentElements = data["currentElements"];
1708
- let childrenTagsOrder = data["childrenTagsOrder"];
1709
- childrenTagsOrder.forEach((tag) => {
1710
- if (currentElements[tag]) {
1711
- let element = importCanvasElement(currentElements[tag]);
1712
- _GameWindowManager.addCanvasElement(tag, element);
1713
- _GameWindowManager.childrenTagsOrder.push(tag);
1714
- }
1715
- });
1716
- } else {
1717
- console.error("[Pixi'VN] The data does not have the properties childrenTagsOrder and currentElements");
1718
- return;
1719
- }
1720
- if (data.hasOwnProperty("currentTickers")) {
1721
- let currentTickers = data["currentTickers"];
1722
- for (let id in currentTickers) {
1723
- let t = currentTickers[id];
1724
- let tags = t.canvasElementTags;
1725
- let ticker = geTickerInstanceById(t.id, t.args, t.duration, t.priority);
1726
- if (ticker) {
1727
- _GameWindowManager.addTicker(tags, ticker);
1728
- } else {
1729
- console.error(`[Pixi'VN] Ticker ${t.id} not found`);
1730
- }
1731
- }
1732
- }
1733
- if (data.hasOwnProperty("currentTickersSteps")) {
1734
- let currentTickersSteps = data["currentTickersSteps"];
1735
- _GameWindowManager.restoneTickersSteps(currentTickersSteps);
1736
- }
1737
- } catch (e) {
1738
- console.error("[Pixi'VN] Error importing data", e);
1739
- }
1740
- }
1741
- };
1742
- _GameWindowManager._app = void 0;
1743
- _GameWindowManager._isInitialized = false;
1744
- _GameWindowManager._children = {};
1745
- /**
1746
- * The order of the children tags.
1747
- */
1748
- _GameWindowManager.childrenTagsOrder = [];
1749
- _GameWindowManager._currentTickers = {};
1750
- _GameWindowManager._currentTickersSteps = {};
1751
- _GameWindowManager._currentTickersTimeouts = {};
1752
- var GameWindowManager = _GameWindowManager;
1753
-
1754
- // src/managers/StepManager.ts
1755
- var _GameStepManager = class _GameStepManager {
1756
- constructor() {
1757
- }
1758
- static get stepsHistory() {
1759
- return _GameStepManager._stepsHistory;
1760
- }
1761
- /**
1762
- * lastStepIndex is the last step index that occurred during the progression of the steps. **Not is the length of the stepsHistory - 1.**
1763
- */
1764
- static get lastStepIndex() {
1765
- return _GameStepManager._lastStepIndex;
1766
- }
1767
- /**
1768
- * Increase the last step index that occurred during the progression of the steps.
1769
- */
1770
- static increaseLastStepIndex() {
1771
- _GameStepManager._lastStepIndex++;
1772
- }
1773
- static get openedLabels() {
1774
- return _GameStepManager._openedLabels;
1775
- }
1776
- /**
1777
- * currentLabelId is the current label id that occurred during the progression of the steps.
1778
- */
1779
- static get currentLabelId() {
1780
- if (_GameStepManager._openedLabels.length > 0) {
1781
- let item = _GameStepManager._openedLabels[_GameStepManager._openedLabels.length - 1];
1782
- return item.label;
1783
- }
1784
- return void 0;
1785
- }
1786
- /**
1787
- * currentLabel is the current label that occurred during the progression of the steps.
1788
- */
1789
- static get currentLabel() {
1790
- if (_GameStepManager.currentLabelId) {
1791
- return getLabelById(_GameStepManager.currentLabelId);
1792
- }
1793
- }
1794
- static get currentLabelStepIndex() {
1795
- if (_GameStepManager._openedLabels.length > 0) {
1796
- let item = _GameStepManager._openedLabels[_GameStepManager._openedLabels.length - 1];
1797
- return item.currentStepIndex;
1798
- }
1799
- return null;
1800
- }
1801
- /**
1802
- * lastHistoryStep is the last history step that occurred during the progression of the steps.
1803
- */
1804
- static get lastHistoryStep() {
1805
- if (_GameStepManager._stepsHistory.length > 0) {
1806
- return _GameStepManager._stepsHistory[_GameStepManager._stepsHistory.length - 1];
1807
- }
1808
- return null;
1809
- }
1810
- static get originalStepData() {
1811
- if (!_GameStepManager._originalStepData) {
1812
- return {
1813
- path: "",
1814
- storage: {},
1815
- canvas: {
1816
- childrenTagsOrder: [],
1817
- currentElements: {},
1818
- currentTickers: {},
1819
- currentTickersSteps: {}
1820
- },
1821
- labelIndex: -1,
1822
- openedLabels: []
1823
- };
1824
- }
1825
- return createExportableElement(_GameStepManager._originalStepData);
1826
- }
1827
- static set originalStepData(value) {
1828
- _GameStepManager._originalStepData = createExportableElement(value);
1829
- }
1830
- /* Edit History Methods */
1831
- /**
1832
- * Add a label to the history.
1833
- * @param label The label to add to the history.
1834
- */
1835
- static addStepHistory(step, choiseMade) {
1836
- let stepHistory = getStepSha1(step);
1837
- let historyStep = {
1838
- path: window.location.pathname,
1839
- storage: GameStorageManager.export(),
1840
- canvas: GameWindowManager.export(),
1841
- labelIndex: _GameStepManager.currentLabelStepIndex || 0,
1842
- openedLabels: createExportableElement(_GameStepManager._openedLabels)
1843
- };
1844
- if (_GameStepManager.originalStepData) {
1845
- if (_GameStepManager.originalStepData.openedLabels.length === historyStep.openedLabels.length) {
1846
- try {
1847
- let lastStepDataOpenedLabelsString = JSON.stringify(_GameStepManager.originalStepData.openedLabels);
1848
- let historyStepOpenedLabelsString = JSON.stringify(historyStep.openedLabels);
1849
- if (lastStepDataOpenedLabelsString === historyStepOpenedLabelsString && _GameStepManager.originalStepData.path === historyStep.path && _GameStepManager.originalStepData.labelIndex === historyStep.labelIndex) {
1850
- return;
1851
- }
1852
- } catch (e) {
1853
- console.error("[Pixi'VN] Error comparing openedLabels", e);
1854
- }
1855
- }
1856
- }
1857
- let data = diff(_GameStepManager.originalStepData, historyStep);
1858
- if (data) {
1859
- let dialoge = void 0;
1860
- let requiredChoices = void 0;
1861
- if (GameStorageManager.getVariable(GameStorageManager.keysSystem.LAST_DIALOGUE_ADDED_IN_STEP_MEMORY_KEY) === _GameStepManager.lastStepIndex) {
1862
- dialoge = getDialogue();
1863
- }
1864
- if (GameStorageManager.getVariable(GameStorageManager.keysSystem.LAST_MENU_OPTIONS_ADDED_IN_STEP_MEMORY_KEY) === _GameStepManager.lastStepIndex) {
1865
- requiredChoices = GameStorageManager.getVariable(GameStorageManager.keysSystem.CURRENT_MENU_OPTIONS_MEMORY_KEY);
1866
- }
1867
- _GameStepManager._stepsHistory.push({
1868
- diff: data,
1869
- currentLabel: _GameStepManager.currentLabelId,
1870
- dialoge,
1871
- choices: requiredChoices,
1872
- stepSha1: stepHistory,
1873
- index: _GameStepManager.lastStepIndex,
1874
- choiceIndexMade: choiseMade
1875
- });
1876
- _GameStepManager.originalStepData = historyStep;
1877
- }
1878
- _GameStepManager.increaseLastStepIndex();
1879
- }
1880
- /**
1881
- * Add a label to the history.
1882
- * @param label The label to add to the history.
1883
- */
1884
- static pushNewLabel(label) {
1885
- let currentLabel = getLabelById(label);
1886
- if (!currentLabel) {
1887
- throw new Error(`[Pixi'VN] Label ${label} not found`);
1888
- }
1889
- _GameStepManager._openedLabels.push({
1890
- label,
1891
- currentStepIndex: 0
1892
- });
1893
- }
1894
- /**
1895
- * Close the current label and add it to the history.
1896
- * @returns
1897
- */
1898
- static closeCurrentLabel() {
1899
- if (!_GameStepManager.currentLabelId) {
1900
- console.warn("[Pixi'VN] No label to close");
1901
- return;
1902
- }
1903
- if (!_GameStepManager.currentLabel) {
1904
- console.error("[Pixi'VN] currentLabel not found");
1905
- return;
1906
- }
1907
- _GameStepManager._openedLabels.pop();
1908
- }
1909
- /**
1910
- * Close all labels and add them to the history. **Attention: This method can cause an unhandled game ending.**
1911
- */
1912
- static closeAllLabels() {
1913
- while (_GameStepManager._openedLabels.length > 0) {
1914
- _GameStepManager.closeCurrentLabel();
1915
- }
1916
- }
1917
- /**
1918
- * Increase the current step index of the current label.
1919
- */
1920
- static increaseCurrentStepIndex() {
1921
- let item = _GameStepManager._openedLabels[_GameStepManager._openedLabels.length - 1];
1922
- _GameStepManager._openedLabels[_GameStepManager._openedLabels.length - 1] = __spreadProps(__spreadValues({}, item), {
1923
- currentStepIndex: item.currentStepIndex + 1
1924
- });
1925
- }
1926
- static restorLastLabelList() {
1927
- _GameStepManager._openedLabels = _GameStepManager.originalStepData.openedLabels;
1928
- }
1929
- /* Run Methods */
1930
- static get canGoNext() {
1931
- let options = getChoiceMenuOptions();
1932
- if (options && options.length > 0) {
1933
- return false;
1934
- }
1935
- return true;
1936
- }
1937
- /**
1938
- * Execute the next step and add it to the history.
1939
- * @param props The props to pass to the step.
1940
- * @param choiseMade The index of the choise made by the player. (This params is used in the choice menu)
1941
- * @returns StepLabelResultType or undefined.
1942
- * @example
1943
- * ```typescript
1944
- * function nextOnClick() {
1945
- * setLoading(true)
1946
- * GameStepManager.goNext(yourParams)
1947
- * .then((result) => {
1948
- * setUpdate((p) => p + 1)
1949
- * setLoading(false)
1950
- * if (result) {
1951
- * // your code
1952
- * }
1953
- * })
1954
- * .catch((e) => {
1955
- * setLoading(false)
1956
- * console.error(e)
1957
- * })
1958
- * }
1959
- * ```
1960
- */
1961
- static goNext(props, choiseMade) {
1962
- return __async(this, null, function* () {
1963
- if (!_GameStepManager.canGoNext) {
1964
- console.warn("[Pixi'VN] The player must make a choice");
1965
- return;
1966
- }
1967
- _GameStepManager.increaseCurrentStepIndex();
1968
- return yield _GameStepManager.runCurrentStep(props, choiseMade);
1969
- });
1970
- }
1971
- /**
1972
- * Execute the current step and add it to the history.
1973
- * @param props The props to pass to the step.
1974
- * @param choiseMade The choise made by the player.
1975
- * @returns StepLabelResultType or undefined.
1976
- */
1977
- static runCurrentStep(props, choiseMade) {
1978
- return __async(this, null, function* () {
1979
- if (_GameStepManager.currentLabelId) {
1980
- let currentLabelStepIndex = _GameStepManager.currentLabelStepIndex;
1981
- if (currentLabelStepIndex === null) {
1982
- console.error("[Pixi'VN] currentLabelStepIndex is null");
1983
- return;
1984
- }
1985
- let currentLabel = _GameStepManager.currentLabel;
1986
- if (!currentLabel) {
1987
- console.error("[Pixi'VN] currentLabel not found");
1988
- return;
1989
- }
1990
- if (currentLabel.steps.length > currentLabelStepIndex) {
1991
- let step = currentLabel.steps[currentLabelStepIndex];
1992
- let result = yield step(props);
1993
- _GameStepManager.addStepHistory(step, choiseMade);
1994
- return result;
1995
- } else if (_GameStepManager.openedLabels.length > 1) {
1996
- _GameStepManager.closeCurrentLabel();
1997
- return yield _GameStepManager.goNext(props, choiseMade);
1998
- } else {
1999
- _GameStepManager.restorLastLabelList();
2000
- 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");
2001
- return;
2002
- }
2003
- }
2004
- });
2005
- }
2006
- /**
2007
- * Execute the label and add it to the history. (It's similar to Ren'Py's call function)
2008
- * @param label The label to execute or the id of the label
2009
- * @param props The props to pass to the label.
2010
- * @returns StepLabelResultType or undefined.
2011
- * @example
2012
- * ```typescript
2013
- * GameStepManager.callLabel(startLabel, yourParams).then((result) => {
2014
- * if (result) {
2015
- * // your code
2016
- * }
2017
- * })
2018
- * ```
2019
- * @example
2020
- * ```typescript
2021
- * // if you use it in a step label you should return the result.
2022
- * return GameStepManager.callLabel(startLabel).then((result) => {
2023
- * return result
2024
- * })
2025
- * ```
2026
- */
2027
- static callLabel(label, props) {
2028
- return __async(this, null, function* () {
2029
- let choiseMade = void 0;
2030
- let labelId;
2031
- if (typeof label === "string") {
2032
- labelId = label;
2033
- } else {
2034
- labelId = label.id;
2035
- if (typeof label.choiseIndex === "number") {
2036
- choiseMade = label.choiseIndex;
2037
- }
2038
- }
2039
- try {
2040
- if (labelId === CLOSE_LABEL_ID) {
2041
- let closeCurrentLabel = newCloseLabel(choiseMade);
2042
- let choice = {
2043
- label: closeCurrentLabel,
2044
- text: "",
2045
- closeCurrentLabel: false,
2046
- type: "close",
2047
- props: {}
2048
- };
2049
- return _GameStepManager.closeChoiceMenu(choice, props);
2050
- }
2051
- let tempLabel = getLabelById(labelId);
2052
- if (!tempLabel) {
2053
- throw new Error(`[Pixi'VN] Label ${labelId} not found`);
2054
- }
2055
- _GameStepManager.pushNewLabel(tempLabel.id);
2056
- } catch (e) {
2057
- console.error("[Pixi'VN] Error calling label", e);
2058
- return;
2059
- }
2060
- return yield _GameStepManager.runCurrentStep(props, choiseMade);
2061
- });
2062
- }
2063
- /**
2064
- * 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)
2065
- * @param label The label to execute.
2066
- * @param props The props to pass to the label or the id of the label
2067
- * @returns StepLabelResultType or undefined.
2068
- * @example
2069
- * ```typescript
2070
- * GameStepManager.jumpLabel(startLabel, yourParams).then((result) => {
2071
- * if (result) {
2072
- * // your code
2073
- * }
2074
- * })
2075
- * ```
2076
- * @example
2077
- * ```typescript
2078
- * // if you use it in a step label you should return the result.
2079
- * return GameStepManager.jumpLabel(startLabel).then((result) => {
2080
- * return result
2081
- * })
2082
- * ```
2083
- */
2084
- static jumpLabel(label, props) {
2085
- return __async(this, null, function* () {
2086
- _GameStepManager.closeCurrentLabel();
2087
- let choiseMade = void 0;
2088
- let labelId;
2089
- if (typeof label === "string") {
2090
- labelId = label;
2091
- } else {
2092
- labelId = label.id;
2093
- if (typeof label.choiseIndex === "number") {
2094
- choiseMade = label.choiseIndex;
2095
- }
2096
- }
2097
- try {
2098
- if (labelId === CLOSE_LABEL_ID) {
2099
- let closeCurrentLabel = newCloseLabel(choiseMade);
2100
- let choice = {
2101
- label: closeCurrentLabel,
2102
- text: "",
2103
- closeCurrentLabel: false,
2104
- type: "close",
2105
- props: {}
2106
- };
2107
- return _GameStepManager.closeChoiceMenu(choice, props);
2108
- }
2109
- let tempLabel = getLabelById(labelId);
2110
- if (!tempLabel) {
2111
- throw new Error(`[Pixi'VN] Label ${labelId} not found`);
2112
- }
2113
- _GameStepManager.pushNewLabel(tempLabel.id);
2114
- } catch (e) {
2115
- console.error("[Pixi'VN] Error jumping label", e);
2116
- return;
2117
- }
2118
- return yield _GameStepManager.runCurrentStep(props, choiseMade);
2119
- });
2120
- }
2121
- /**
2122
- * When the player is in a choice menu, can use this function to exit to the choice menu.
2123
- * @param choice
2124
- * @param props
2125
- * @returns StepLabelResultType or undefined.
2126
- * @example
2127
- * ```typescript
2128
- * GameStepManager.closeChoiceMenu(yourParams).then((result) => {
2129
- * if (result) {
2130
- * // your code
2131
- * }
2132
- * })
2133
- * ```
2134
- */
2135
- static closeChoiceMenu(choice, props) {
2136
- return __async(this, null, function* () {
2137
- let label = choice.label;
2138
- let choiseMade = void 0;
2139
- if (typeof label.choiseIndex === "number") {
2140
- choiseMade = label.choiseIndex;
2141
- }
2142
- if (choice.closeCurrentLabel) {
2143
- _GameStepManager.closeCurrentLabel();
2144
- }
2145
- return _GameStepManager.goNext(props, choiseMade);
2146
- });
2147
- }
2148
- /* After Update Methods */
2149
- // /**
2150
- // * After the update or code edit, some steps or labels may no longer match.
2151
- // * - In case of step mismatch, the game will be updated to the last matching step.
2152
- // * - In case of label mismatch, the game gives an error.
2153
- // * @returns
2154
- // */
2155
- // private static afterUpdate() {
2156
- // // TODO: implement
2157
- // if (!GameStepManager.currentLabel) {
2158
- // // TODO: implement
2159
- // return
2160
- // }
2161
- // let currentLabel = getLabelInstanceByClassName(GameStepManager.currentLabel)
2162
- // if (!currentLabel) {
2163
- // console.error("Label not found")
2164
- // return
2165
- // }
2166
- // let oldSteps = GameStepManager.stepsAfterLastHistoryLabel
2167
- // let currentStepIndex = currentLabel.getCorrespondingStepsNumber(oldSteps)
2168
- // let stepToRemove = oldSteps.length - currentStepIndex
2169
- // GameStepManager.removeLastHistoryNodes(stepToRemove)
2170
- // GameStepManager.loadLastStep()
2171
- // }
2172
- // private static loadLastStep() {
2173
- // // TODO: implement
2174
- // }
2175
- // /**
2176
- // * Remove a number of items from the last of the history.
2177
- // * @param itemNumber The number of items to remove from the last of the history.
2178
- // */
2179
- // private static removeLastHistoryNodes(itemNumber: number) {
2180
- // // TODO: implement
2181
- // for (let i = 0; i < itemNumber; i++) {
2182
- // GameStepManager._stepsHistory.pop()
2183
- // }
2184
- // }
2185
- // /**
2186
- // * stepsAfterLastHistoryLabel is a list of steps that occurred after the last history label.
2187
- // */
2188
- // private static get stepsAfterLastHistoryLabel(): StepHistoryDataType[] {
2189
- // let length = GameStepManager._stepsHistory.length
2190
- // let steps: StepHistoryDataType[] = []
2191
- // for (let i = length - 1; i >= 0; i--) {
2192
- // let element = GameStepManager._stepsHistory[i]
2193
- // if (typeof element === "object" && "stepSha1" in element) {
2194
- // steps.push(element.stepSha1)
2195
- // }
2196
- // else {
2197
- // break
2198
- // }
2199
- // }
2200
- // steps = steps.reverse()
2201
- // return steps
2202
- // }
2203
- /* Go Back & Refresh Methods */
2204
- /**
2205
- * Go back to the last step and add it to the history.
2206
- * @param navigate The navigate function.
2207
- * @param steps The number of steps to go back.
2208
- * @returns
2209
- * @example
2210
- * ```typescript
2211
- * export function goBack(navigate: (path: string) => void, afterBack?: () => void) {
2212
- * GameStepManager.goBack(navigate)
2213
- * afterBack && afterBack()
2214
- * }
2215
- * ```
2216
- */
2217
- static goBack(navigate, steps = 1) {
2218
- if (steps <= 0) {
2219
- console.warn("[Pixi'VN] Steps must be greater than 0");
2220
- return;
2221
- }
2222
- if (_GameStepManager._stepsHistory.length <= 1) {
2223
- console.warn("[Pixi'VN] No steps to go back");
2224
- return;
2225
- }
2226
- let restoredStep = _GameStepManager.goBackInternal(steps, _GameStepManager.originalStepData);
2227
- if (restoredStep) {
2228
- _GameStepManager._originalStepData = restoredStep;
2229
- _GameStepManager._openedLabels = createExportableElement(restoredStep.openedLabels);
2230
- GameStorageManager.import(createExportableElement(restoredStep.storage));
2231
- GameWindowManager.import(createExportableElement(restoredStep.canvas));
2232
- navigate(restoredStep.path);
2233
- } else {
2234
- console.error("[Pixi'VN] Error going back");
2235
- }
2236
- }
2237
- static goBackInternal(steps, restoredStep) {
2238
- if (steps <= 0) {
2239
- return restoredStep;
2240
- }
2241
- if (_GameStepManager._stepsHistory.length == 0) {
2242
- return restoredStep;
2243
- }
2244
- let lastHistoryStep = _GameStepManager.lastHistoryStep;
2245
- if (lastHistoryStep) {
2246
- try {
2247
- let result = restoreDeepDiffChanges(restoredStep, lastHistoryStep.diff);
2248
- _GameStepManager._lastStepIndex = lastHistoryStep.index;
2249
- _GameStepManager._stepsHistory.pop();
2250
- return _GameStepManager.goBackInternal(steps - 1, result);
2251
- } catch (e) {
2252
- console.error("[Pixi'VN] Error applying diff", e);
2253
- return restoredStep;
2254
- }
2255
- } else {
2256
- return restoredStep;
2257
- }
2258
- }
2259
- /**
2260
- * Return true if it is possible to go back.
2261
- */
2262
- static get canGoBack() {
2263
- return _GameStepManager._stepsHistory.length > 1;
2264
- }
2265
- /**
2266
- * Add a label to the history.
2267
- */
2268
- static clear() {
2269
- _GameStepManager._stepsHistory = [];
2270
- _GameStepManager._openedLabels = [];
2271
- }
2272
- /* Export and Import Methods */
2273
- /**
2274
- * Export the history to a JSON string.
2275
- * @returns The history in a JSON string.
2276
- */
2277
- static exportJson() {
2278
- return JSON.stringify(this.export());
2279
- }
2280
- /**
2281
- * Export the history to an object.
2282
- * @returns The history in an object.
2283
- */
2284
- static export() {
2285
- return {
2286
- stepsHistory: _GameStepManager._stepsHistory,
2287
- openedLabels: _GameStepManager._openedLabels,
2288
- lastStepIndex: _GameStepManager._lastStepIndex,
2289
- originalStepData: _GameStepManager._originalStepData
2290
- };
2291
- }
2292
- /**
2293
- * Import the history from a JSON string.
2294
- * @param dataString The history in a JSON string.
2295
- */
2296
- static importJson(dataString) {
2297
- _GameStepManager.import(JSON.parse(dataString));
2298
- }
2299
- /**
2300
- * Import the history from an object.
2301
- * @param data The history in an object.
2302
- */
2303
- static import(data) {
2304
- _GameStepManager.clear();
2305
- try {
2306
- if (data.hasOwnProperty("stepsHistory")) {
2307
- _GameStepManager._stepsHistory = data["stepsHistory"];
2308
- } else {
2309
- console.warn("[Pixi'VN] Could not import stepsHistory data, so will be ignored");
2310
- }
2311
- if (data.hasOwnProperty("openedLabels")) {
2312
- _GameStepManager._openedLabels = data["openedLabels"];
2313
- } else {
2314
- console.warn("[Pixi'VN] Could not import openedLabels data, so will be ignored");
2315
- }
2316
- if (data.hasOwnProperty("lastStepIndex")) {
2317
- _GameStepManager._lastStepIndex = data["lastStepIndex"];
2318
- } else {
2319
- console.warn("[Pixi'VN] Could not import lastStepIndex data, so will be ignored");
2320
- }
2321
- if (data.hasOwnProperty("originalStepData")) {
2322
- _GameStepManager._originalStepData = data["originalStepData"];
2323
- } else {
2324
- console.warn("[Pixi'VN] Could not import originalStepData data, so will be ignored");
2325
- }
2326
- } catch (e) {
2327
- console.error("[Pixi'VN] Error importing data", e);
2328
- }
2329
- }
2330
- };
2331
- /**
2332
- * stepHistory is a list of label events and steps that occurred during the progression of the steps.
2333
- */
2334
- _GameStepManager._stepsHistory = [];
2335
- _GameStepManager._lastStepIndex = 0;
2336
- _GameStepManager._openedLabels = [];
2337
- _GameStepManager._originalStepData = void 0;
2338
- var GameStepManager = _GameStepManager;
2339
-
2340
- // src/classes/DialogueBaseModel.ts
2341
- var DialogueBaseModel = class {
2342
- /**
2343
- * @param text The text of the dialogue.
2344
- * @param character The id of the character that is speaking.
2345
- * @param oltherParams Other parameters that can be stored in the dialogue.
2346
- */
2347
- constructor(text, character, oltherParams = {}) {
2348
- /**
2349
- * The text of the dialogue.
2350
- */
2351
- this.text = "";
2352
- /**
2353
- * Other parameters that can be stored in the dialogue.
2354
- */
2355
- this.oltherParams = {};
2356
- if (typeof text === "string") {
2357
- this.text = text;
2358
- if (typeof character === "string") {
2359
- this.character = character;
2360
- } else {
2361
- this.character = character == null ? void 0 : character.id;
2362
- }
2363
- this.oltherParams = oltherParams;
2364
- } else {
2365
- this.text = text.text;
2366
- if (text.character) {
2367
- this.character = text.character;
2368
- }
2369
- this.oltherParams = text.oltherParams || {};
2370
- }
2371
- }
2372
- /**
2373
- * Export the dialogue to a DialogueBaseData object.
2374
- *
2375
- * @returns The data of the dialogue.
2376
- */
2377
- export() {
2378
- return {
2379
- text: this.text,
2380
- character: this.character,
2381
- oltherParams: this.oltherParams
2382
- };
2383
- }
2384
- };
2385
-
2386
- // src/decorators/LabelDecorator.ts
2387
- var registeredLabels = {};
2388
- function newLabel(id, steps, onStepRun) {
2389
- if (registeredLabels[id]) {
2390
- console.info(`[Pixi'VN] Label ${id} already exists, it will be overwritten`);
2391
- }
2392
- let label = new Label(id, steps, onStepRun);
2393
- registeredLabels[id] = label;
2394
- return label;
2395
- }
2396
- function getLabelById(id) {
2397
- let label = registeredLabels[id];
2398
- if (!label) {
2399
- console.error(`[Pixi'VN] Label ${id} not found`);
2400
- return;
2401
- }
2402
- return label;
2403
- }
2404
-
2405
- // src/classes/ticker/FadeAlphaTicker.ts
2406
- var FadeAlphaTicker = class extends TickerBase {
2407
- fn(ticker, args, tags, tickerId) {
2408
- let type = args.type === void 0 ? "hide" : args.type;
2409
- let duration = args.duration === void 0 ? 1 : args.duration;
2410
- let speed = 1 / (duration * 60);
2411
- let limit = args.limit === void 0 ? type === "hide" ? 0 : 1 : args.limit;
2412
- let tagToRemoveAfter2 = args.tagToRemoveAfter || [];
2413
- if (typeof tagToRemoveAfter2 === "string") {
2414
- tagToRemoveAfter2 = [tagToRemoveAfter2];
2415
- }
2416
- if (type === "hide" && limit < 0) {
2417
- limit = 0;
2418
- }
2419
- if (type === "show" && limit > 1) {
2420
- limit = 1;
2421
- }
2422
- tags.filter((tag) => {
2423
- var _a;
2424
- let element = GameWindowManager.getCanvasElement(tag);
2425
- if (args.startOnlyIfHaveTexture) {
2426
- if (element && element instanceof Sprite && ((_a = element.texture) == null ? void 0 : _a.label) == "EMPTY") {
2427
- return false;
2428
- }
2429
- }
2430
- return true;
2431
- }).forEach((tag) => {
2432
- let element = GameWindowManager.getCanvasElement(tag);
2433
- if (element && element instanceof Container) {
2434
- if (type === "show" && element.alpha < limit) {
2435
- element.alpha += speed * ticker.deltaTime;
2436
- } else if (type === "hide" && element.alpha > limit) {
2437
- element.alpha -= speed * ticker.deltaTime;
2438
- }
2439
- if (type === "show" && element.alpha >= limit) {
2440
- element.alpha = limit;
2441
- GameWindowManager.onEndOfTicker(tag, this, tagToRemoveAfter2, tickerId);
2442
- } else if (type === "hide" && element.alpha <= limit) {
2443
- element.alpha = limit;
2444
- GameWindowManager.onEndOfTicker(tag, this, tagToRemoveAfter2, tickerId);
2445
- }
2446
- }
2447
- });
2448
- }
2449
- };
2450
- FadeAlphaTicker = __decorateClass([
2451
- tickerDecorator()
2452
- ], FadeAlphaTicker);
2453
- var MoveTicker = class extends TickerBase {
2454
- fn(ticker, args, tags, tickerId) {
2455
- let xSpeed = 1;
2456
- let ySpeed = 1;
2457
- if (args.speed) {
2458
- if (typeof args.speed === "number") {
2459
- xSpeed = args.speed;
2460
- ySpeed = args.speed;
2461
- } else {
2462
- xSpeed = args.speed.x;
2463
- ySpeed = args.speed.y;
2464
- }
2465
- }
2466
- xSpeed /= 60;
2467
- ySpeed /= 60;
2468
- let destination = args.destination;
2469
- let tagToRemoveAfter2 = args.tagToRemoveAfter || [];
2470
- if (typeof tagToRemoveAfter2 === "string") {
2471
- tagToRemoveAfter2 = [tagToRemoveAfter2];
2472
- }
2473
- tags.filter((tag) => {
2474
- var _a;
2475
- let element = GameWindowManager.getCanvasElement(tag);
2476
- if (args.startOnlyIfHaveTexture) {
2477
- if (element && element instanceof Sprite && ((_a = element.texture) == null ? void 0 : _a.label) == "EMPTY") {
2478
- return false;
2479
- }
2480
- }
2481
- return true;
2482
- }).forEach((tag) => {
2483
- let element = GameWindowManager.getCanvasElement(tag);
2484
- if (element && element instanceof Container) {
2485
- let xDistance = destination.x - element.x > 0 ? 1 : -1;
2486
- if (xDistance != 0) {
2487
- element.x += xDistance * xSpeed * ticker.deltaTime;
2488
- let newDistance = destination.x - element.x;
2489
- if (xDistance < 0 && newDistance > 0 || xDistance > 0 && newDistance < 0) {
2490
- element.x = destination.x;
2491
- }
2492
- }
2493
- let yDistance = destination.y - element.y > 0 ? 1 : -1;
2494
- if (yDistance != 0) {
2495
- element.y += yDistance * ySpeed * ticker.deltaTime;
2496
- let newDistance = destination.y - element.y;
2497
- if (yDistance < 0 && newDistance > 0 || yDistance > 0 && newDistance < 0) {
2498
- element.y = destination.y;
2499
- }
2500
- }
2501
- if (element.x == destination.x && element.y == destination.y) {
2502
- GameWindowManager.onEndOfTicker(tag, this, tagToRemoveAfter2, tickerId);
2503
- }
2504
- }
2505
- });
2506
- if (args.speedProgression)
2507
- updateTickerProgression(args, "speed", args.speedProgression);
2508
- }
2509
- };
2510
- MoveTicker = __decorateClass([
2511
- tickerDecorator()
2512
- ], MoveTicker);
2513
- var RotateTicker = class extends TickerBase {
2514
- fn(ticker, args, tags, tickerId) {
2515
- let speed = (args.speed === void 0 ? 1 : args.speed) / 60;
2516
- let clockwise = args.clockwise === void 0 ? true : args.clockwise;
2517
- let tagToRemoveAfter2 = args.tagToRemoveAfter || [];
2518
- if (typeof tagToRemoveAfter2 === "string") {
2519
- tagToRemoveAfter2 = [tagToRemoveAfter2];
2520
- }
2521
- tags.filter((tag) => {
2522
- var _a;
2523
- let element = GameWindowManager.getCanvasElement(tag);
2524
- if (args.startOnlyIfHaveTexture) {
2525
- if (element && element instanceof Sprite && ((_a = element.texture) == null ? void 0 : _a.label) == "EMPTY") {
2526
- return false;
2527
- }
2528
- }
2529
- return true;
2530
- }).forEach((tag) => {
2531
- let element = GameWindowManager.getCanvasElement(tag);
2532
- if (element && element instanceof Container) {
2533
- if (clockwise)
2534
- element.rotation += speed * ticker.deltaTime;
2535
- else
2536
- element.rotation -= speed * ticker.deltaTime;
2537
- if (speed < 1e-5 && !(args.speedProgression && args.speedProgression.type == "linear" && args.speedProgression.amt != 0)) {
2538
- GameWindowManager.onEndOfTicker(tag, this, tagToRemoveAfter2, tickerId);
2539
- }
2540
- }
2541
- });
2542
- if (args.speedProgression)
2543
- updateTickerProgression(args, "speed", args.speedProgression);
2544
- }
2545
- };
2546
- RotateTicker = __decorateClass([
2547
- tickerDecorator()
2548
- ], RotateTicker);
2549
-
2550
- // src/labels/TickerTestLabel.ts
2551
- var alien1Tag = "alien1";
2552
- var alien2Tag = "alien2";
2553
- var alien3Tag = "alien3";
2554
- var alien4Tag = "alien4";
2555
- var tickerTestLabel = newLabel(
2556
- "TickerTestLabel",
2557
- [
2558
- () => __async(void 0, null, function* () {
2559
- let my_speed = 0.1;
2560
- const texture = yield Assets.load("https://pixijs.com/assets/eggHead.png");
2561
- const alien = CanvasSprite.from(texture);
2562
- alien.anchor.set(0.5);
2563
- GameWindowManager.addCanvasElement(alien1Tag, alien);
2564
- alien.x = 100;
2565
- alien.y = 100;
2566
- GameWindowManager.addTicker(alien1Tag, new RotateTicker({ speed: my_speed }));
2567
- setDialogue(`I have added a image with a tag ${alien1Tag} and I connected a RotateTicker with a speed of ${my_speed} to it.`);
2568
- }),
2569
- () => __async(void 0, null, function* () {
2570
- let my_speed = 0.1;
2571
- const texture = yield Assets.load("https://pixijs.com/assets/eggHead.png");
2572
- const alien = CanvasSprite.from(texture);
2573
- alien.anchor.set(0.5);
2574
- GameWindowManager.addCanvasElement(alien2Tag, alien);
2575
- alien.x = 300;
2576
- alien.y = 100;
2577
- GameWindowManager.addTicker(alien2Tag, new RotateTicker({ speed: my_speed }));
2578
- setDialogue(`I have added a image with a tag ${alien2Tag} and I connected a RotateTicker with a speed of ${my_speed} to it.`);
2579
- }),
2580
- () => setDialogue(`Since ${alien1Tag} and ${alien2Tag} they have the same ticker with the same speed, only one RotateTicker will be performed`),
2581
- () => {
2582
- GameWindowManager.addTicker(alien1Tag, new RotateTicker({ speed: 0.2 }));
2583
- setDialogue(`I have changed the speed of the RotateTicker connected to ${alien1Tag} to 0.2`);
2584
- },
2585
- () => setDialogue(`Since ${alien1Tag} have a different speed, it will perform a different RotateTicker`),
2586
- () => {
2587
- removeCanvasElement(alien1Tag);
2588
- setDialogue(`I have remove the image with the tag ${alien1Tag}`);
2589
- },
2590
- () => setDialogue(`Since ${alien1Tag} is removed, the RotateTicker connected to it will not be performed`),
2591
- () => {
2592
- GameWindowManager.removeAssociationBetweenTickerCanvasElement(alien2Tag, RotateTicker);
2593
- setDialogue(`I have removed the RotateTicker connected to ${alien2Tag}`);
2594
- },
2595
- () => __async(void 0, null, function* () {
2596
- removeCanvasElement(alien2Tag);
2597
- let duration = 7e3;
2598
- const texture = yield Assets.load("https://pixijs.com/assets/eggHead.png");
2599
- const alien = CanvasSprite.from(texture);
2600
- alien.anchor.set(0.5);
2601
- GameWindowManager.addCanvasElement(alien3Tag, alien);
2602
- alien.x = 500;
2603
- alien.y = 100;
2604
- GameWindowManager.addTicker(alien3Tag, new RotateTicker({ speed: 0.1 }, duration));
2605
- setDialogue(`I have added a image with a tag ${alien3Tag} and I connected a RotateTicker with a speed of 0.1 and a duration of ${duration} to it. After ${duration}ms, the RotateTicker will be removed.`);
2606
- }),
2607
- () => __async(void 0, null, function* () {
2608
- let my_speed = 0.1;
2609
- let my_speed2 = 0.3;
2610
- const texture = yield Assets.load("https://pixijs.com/assets/eggHead.png");
2611
- const alien = CanvasSprite.from(texture);
2612
- alien.anchor.set(0.5);
2613
- GameWindowManager.addCanvasElement(alien1Tag, alien);
2614
- alien.x = 100;
2615
- alien.y = 100;
2616
- GameWindowManager.addTickersSteps(alien1Tag, [
2617
- new RotateTicker({ speed: my_speed }, 1e3),
2618
- new RotateTicker({ speed: my_speed2 }, 1e3)
2619
- ]);
2620
- setDialogue(`I have added a image with a tag ${alien1Tag} and I connected a RotateTicker with a speed of ${my_speed} and a duration of 1000ms and then I connected a RotateTicker with a speed of ${my_speed2} and a duration of 1000ms to it.`);
2621
- }),
2622
- () => __async(void 0, null, function* () {
2623
- const texture = yield Assets.load("https://pixijs.com/assets/eggHead.png");
2624
- const alien = CanvasSprite.from(texture);
2625
- alien.anchor.set(0.5);
2626
- GameWindowManager.addCanvasElement(alien2Tag, alien);
2627
- alien.x = 300;
2628
- alien.y = 100;
2629
- GameWindowManager.addTickersSteps(alien2Tag, [
2630
- new RotateTicker({ speed: 0.1, clockwise: true }, 2e3),
2631
- Pause(500),
2632
- new RotateTicker({ speed: 0.2, clockwise: false }, 2e3),
2633
- Repeat
2634
- ]);
2635
- setDialogue(`I have added a image with a tag ${alien2Tag} and I connected a RotateTicker with a speed of 0.1 and a duration of 2000ms and then I connected a RotateTicker with a speed of 0.2 and a duration of 2000ms to it. After 500ms, the RotateTicker will be repeated.`);
2636
- }),
2637
- () => __async(void 0, null, function* () {
2638
- const texture = yield Assets.load("https://pixijs.com/assets/eggHead.png");
2639
- const alien = CanvasSprite.from(texture);
2640
- alien.anchor.set(0.5);
2641
- GameWindowManager.addCanvasElement(alien4Tag, alien);
2642
- alien.x = 700;
2643
- alien.y = 100;
2644
- let speed = 0;
2645
- let speedLimit = 0.5;
2646
- let amt = 1e-3;
2647
- GameWindowManager.addTicker(alien4Tag, new RotateTicker({ speed, speedProgression: { type: "linear", amt, limit: speedLimit } }));
2648
- GameWindowManager.addTickersSteps(
2649
- alien2Tag,
2650
- [
2651
- new FadeAlphaTicker({
2652
- duration: 1,
2653
- type: "hide"
2654
- }, 3e3),
2655
- new FadeAlphaTicker({
2656
- duration: 1,
2657
- type: "show"
2658
- }, 3e3),
2659
- Repeat
2660
- ]
2661
- );
2662
- setDialogue(`I have added a image with a tag ${alien4Tag} and I connected a RotateTicker with a speed of ${speed} and a linear speed progression of ${amt} and a limit of ${speedLimit} to it.`);
2663
- })
2664
- ]
2665
- );
2666
-
2667
- export { tickerTestLabel };
2668
- //# sourceMappingURL=out.js.map
2669
- //# sourceMappingURL=TickerTestLabel.mjs.map