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