bard-legends-framework 0.11.0 → 0.12.0
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/actions-performance.test.d.ts +1 -0
- package/dist/actions-performance.test.js +83 -0
- package/dist/game-entities/controller/controller.d.ts +2 -2
- package/dist/game-entities/controller/controller.js +8 -8
- package/dist/game-entities/controller/controller.test.js +2 -2
- package/dist/game-entities/entity/entity.d.ts +7 -7
- package/dist/game-entities/entity/entity.js +18 -12
- package/dist/game-entities/entity/entity.test.js +93 -30
- package/dist/game-entities/entity/helpers/entity-store.helper.d.ts +3 -3
- package/dist/game-entities/entity/helpers/entity-store.helper.js +12 -12
- package/dist/game-entities/entity/helpers/entity-store.helper.test.js +11 -11
- package/dist/game-entities/entity/helpers/entity-views.helper.d.ts +6 -6
- package/dist/game-entities/entity/helpers/entity-views.helper.js +25 -22
- package/dist/game-entities/entity/singleton-entity.test.js +9 -4
- package/dist/game-entities/hard-reset.d.ts +5 -0
- package/dist/game-entities/hard-reset.js +14 -0
- package/dist/game-entities/index.d.ts +1 -1
- package/dist/game-entities/index.js +3 -3
- package/dist/game-entities/scene/scene.d.ts +13 -13
- package/dist/game-entities/scene/scene.js +41 -46
- package/dist/game-entities/scene/scene.test.js +95 -37
- package/dist/game-entities/service/service.d.ts +1 -4
- package/dist/game-entities/service/service.js +12 -13
- package/dist/game-entities/service/service.test.js +33 -12
- package/dist/game-entities/unit-test.helper.js +1 -1
- package/dist/game-entities/update-cycle.d.ts +7 -17
- package/dist/game-entities/update-cycle.js +25 -19
- package/dist/game-entities/view/view.d.ts +6 -6
- package/dist/game-entities/view/view.js +15 -21
- package/dist/game-entities/view/view.test.js +40 -9
- package/dist/physics/entity-types/immovable-physics-entity.d.ts +1 -1
- package/dist/physics/entity-types/immovable-physics-entity.js +4 -4
- package/dist/physics/entity-types/movable-entity.d.ts +1 -1
- package/dist/physics/entity-types/movable-entity.js +2 -2
- package/dist/physics/entity-types/movable-physics-entity.d.ts +8 -8
- package/dist/physics/entity-types/movable-physics-entity.js +27 -27
- package/dist/physics/entity-types/physics-entity.d.ts +10 -14
- package/dist/physics/entity-types/physics-entity.js +27 -26
- package/dist/physics/interfaces.d.ts +6 -6
- package/dist/physics/interfaces.js +4 -4
- package/dist/physics/module//342/232/234/357/270/217gateways/controllers/physics-internal.controller.d.ts +16 -16
- package/dist/physics/module//342/232/234/357/270/217gateways/controllers/physics-internal.controller.js +22 -22
- package/dist/physics/module//342/232/234/357/270/217gateways/controllers/physics.controller.d.ts +19 -19
- package/dist/physics/module//342/232/234/357/270/217gateways/controllers/physics.controller.js +30 -30
- package/dist/physics/module//342/232/234/357/270/217gateways/dtos/requests.dto.d.ts +3 -3
- package/dist/physics/module//342/232/234/357/270/217gateways/physics-internal.gateway.d.ts +10 -10
- package/dist/physics/module//342/232/234/357/270/217gateways/physics-internal.gateway.js +16 -16
- package/dist/physics/module//342/232/234/357/270/217gateways/physics.gateway.d.ts +10 -10
- package/dist/physics/module//342/232/234/357/270/217gateways/physics.gateway.js +18 -18
- package/dist/physics/module//360/237/223/220services/collision/collisions.service.d.ts +5 -5
- package/dist/physics/module//360/237/223/220services/collision/collisions.service.js +17 -17
- package/dist/physics/module//360/237/223/220services/collision/hit-test.service.d.ts +4 -4
- package/dist/physics/module//360/237/223/220services/collision/hit-test.service.js +11 -11
- package/dist/physics/module//360/237/223/220services/collision/physics-body-group.service.d.ts +2 -2
- package/dist/physics/module//360/237/223/220services/collision/physics-body-group.service.js +4 -4
- package/dist/physics/module//360/237/223/220services/creation/border.service.d.ts +2 -2
- package/dist/physics/module//360/237/223/220services/creation/border.service.js +9 -9
- package/dist/physics/module//360/237/223/220services/creation/materials.service.d.ts +7 -7
- package/dist/physics/module//360/237/223/220services/creation/materials.service.js +17 -17
- package/dist/physics/module//360/237/223/220services/creation/physics-world.service.d.ts +11 -11
- package/dist/physics/module//360/237/223/220services/creation/physics-world.service.js +27 -26
- package/dist/physics/module//360/237/223/220services/creation/shape-creation.service.d.ts +4 -4
- package/dist/physics/module//360/237/223/220services/creation/shape-creation.service.js +13 -13
- package/dist/physics/module//360/237/223/220services/impact/eliptic-explosion.service.d.ts +9 -9
- package/dist/physics/module//360/237/223/220services/impact/eliptic-explosion.service.js +19 -19
- package/dist/physics/module//360/237/223/220services/impact/explosion.service.d.ts +9 -9
- package/dist/physics/module//360/237/223/220services/impact/explosion.service.js +20 -20
- package/dist/physics/module//360/237/223/220services/impact/ray-cast-hit-converter.d.ts +1 -1
- package/dist/physics/module//360/237/223/220services/impact/ray-cast-hit-converter.js +4 -4
- package/dist/physics/module//360/237/223/220services/path-finding/availability-grid-cache.service.d.ts +2 -2
- package/dist/physics/module//360/237/223/220services/path-finding/availability-grid-cache.service.js +3 -3
- package/dist/physics/module//360/237/223/220services/path-finding/availability-grid.service.d.ts +5 -5
- package/dist/physics/module//360/237/223/220services/path-finding/availability-grid.service.js +12 -12
- package/dist/physics/module//360/237/223/220services/path-finding/path-finder.service.d.ts +4 -4
- package/dist/physics/module//360/237/223/220services/path-finding/path-finder.service.js +12 -12
- package/dist/physics/module//360/237/223/220services/query/physics-query.service.d.ts +4 -4
- package/dist/physics/module//360/237/223/220services/query/physics-query.service.js +4 -4
- package/dist/physics/module//360/237/223/220services/ray-casting/ray-casting.service.d.ts +1 -4
- package/dist/physics/module//360/237/223/220services/ray-casting/ray-casting.service.js +7 -15
- package/dist/physics/module//360/237/223/220services/test-visuals/test-visuals.service.d.ts +9 -9
- package/dist/physics/module//360/237/223/220services/test-visuals/test-visuals.service.js +43 -42
- package/dist/physics/module//360/237/247/212entities/border.entity.d.ts +1 -1
- package/dist/physics/module//360/237/247/212entities/border.entity.js +3 -3
- package/dist/pixi/components/display-object-array.d.ts +5 -5
- package/dist/pixi/components/display-object-array.js +14 -14
- package/dist/pixi/components/helpers/smooth-scroller.d.ts +7 -7
- package/dist/pixi/components/helpers/smooth-scroller.js +23 -23
- package/dist/pixi/components/helpers/smooth-scroller.test.js +14 -14
- package/dist/pixi/components/menu/menu-entity.d.ts +14 -0
- package/dist/pixi/components/menu/menu-entity.js +48 -0
- package/dist/pixi/components/menu/menu.ui.d.ts +23 -0
- package/dist/pixi/components/menu/menu.ui.js +97 -0
- package/dist/pixi/components/mouse-wheel-listener.ui.d.ts +2 -2
- package/dist/pixi/components/mouse-wheel-listener.ui.js +11 -11
- package/dist/pixi/components/scroll-area.ui.d.ts +1 -1
- package/dist/pixi/components/scroll-area.ui.js +9 -9
- package/dist/pixi/components/scroll-mask.ui.d.ts +9 -8
- package/dist/pixi/components/scroll-mask.ui.js +25 -24
- package/dist/pixi/display-object/container-attributes.d.ts +24 -25
- package/dist/pixi/display-object/container-attributes.js +26 -26
- package/dist/pixi/display-object/container.d.ts +3 -3
- package/dist/pixi/display-object/container.js +2 -2
- package/dist/pixi/display-object/filters/base-filters/blur.filter.d.ts +9 -9
- package/dist/pixi/display-object/filters/base-filters/blur.filter.js +25 -25
- package/dist/pixi/display-object/filters/base-filters/expand-with-color.filter.d.ts +7 -7
- package/dist/pixi/display-object/filters/base-filters/expand-with-color.filter.js +17 -17
- package/dist/pixi/display-object/filters/composite-filters/glow-filter.d.ts +6 -6
- package/dist/pixi/display-object/filters/composite-filters/glow-filter.js +10 -11
- package/dist/pixi/display-object/filters/helpers/gaussian-values.helper.d.ts +2 -2
- package/dist/pixi/display-object/filters/helpers/gaussian-values.helper.js +5 -5
- package/dist/pixi/display-object/filters/templates/checking-neighbors.template.d.ts +5 -5
- package/dist/pixi/display-object/filters/templates/checking-neighbors.template.js +8 -8
- package/dist/pixi/display-object/filters/templates/plane.template.d.ts +5 -5
- package/dist/pixi/display-object/filters/templates/plane.template.js +7 -7
- package/dist/pixi/display-object/filters.d.ts +7 -7
- package/dist/pixi/display-object/filters.js +34 -34
- package/dist/pixi/display-object/index.d.ts +1 -1
- package/dist/pixi/display-object/objects/graphics/graphics.d.ts +9 -9
- package/dist/pixi/display-object/objects/graphics/graphics.js +25 -25
- package/dist/pixi/display-object/objects/placeholder.d.ts +1 -1
- package/dist/pixi/display-object/objects/placeholder.js +7 -7
- package/dist/pixi/display-object/objects/sprite/glow-sprite-generator.d.ts +9 -9
- package/dist/pixi/display-object/objects/sprite/glow-sprite-generator.js +26 -25
- package/dist/pixi/display-object/objects/sprite/sprite.d.ts +10 -9
- package/dist/pixi/display-object/objects/sprite/sprite.js +62 -53
- package/dist/pixi/display-object/objects/text/helpers/process-steps/1-data-in-converter/pixi-text-style-converter.d.ts +4 -3
- package/dist/pixi/display-object/objects/text/helpers/process-steps/1-data-in-converter/rich-text-data-in-converter.d.ts +6 -6
- package/dist/pixi/display-object/objects/text/helpers/process-steps/1-data-in-converter/rich-text-data-in-converter.js +16 -16
- package/dist/pixi/display-object/objects/text/helpers/process-steps/1-data-in-converter/rich-text-data-in-converter.test.js +28 -28
- package/dist/pixi/display-object/objects/text/helpers/process-steps/2-wrapping-text/consistent-space-text-wrapper.d.ts +1 -1
- package/dist/pixi/display-object/objects/text/helpers/process-steps/2-wrapping-text/consistent-space-text-wrapper.js +3 -3
- package/dist/pixi/display-object/objects/text/helpers/process-steps/2-wrapping-text/rich-text-typewriter.d.ts +17 -17
- package/dist/pixi/display-object/objects/text/helpers/process-steps/2-wrapping-text/rich-text-typewriter.js +62 -62
- package/dist/pixi/display-object/objects/text/helpers/process-steps/2-wrapping-text/rich-text-typewriter.test.js +2 -2
- package/dist/pixi/display-object/objects/text/helpers/process-steps/3-data-out-converter/rich-text-data-out-converter.d.ts +3 -3
- package/dist/pixi/display-object/objects/text/helpers/process-steps/3-data-out-converter/rich-text-data-out-converter.js +6 -6
- package/dist/pixi/display-object/objects/text/helpers/process-steps/3-data-out-converter/rich-text-data-out-converter.test.js +12 -12
- package/dist/pixi/display-object/objects/text/helpers/rich-text-to-plane-text.d.ts +2 -2
- package/dist/pixi/display-object/objects/text/helpers/rich-text-to-plane-text.test.js +5 -5
- package/dist/pixi/display-object/objects/text/rich-text.d.ts +0 -1
- package/dist/pixi/display-object/objects/text/rich-text.js +0 -1
- package/dist/pixi/display-object/objects/text/text.d.ts +9 -10
- package/dist/pixi/display-object/objects/text/text.js +34 -35
- package/dist/pixi/game.d.ts +20 -15
- package/dist/pixi/game.js +40 -35
- package/dist/pixi/helpers/game-assets.d.ts +5 -5
- package/dist/pixi/helpers/game-assets.js +14 -11
- package/dist/pixi/helpers/position-conversion.helper.d.ts +4 -4
- package/dist/pixi/helpers/position-conversion.helper.js +3 -3
- package/dist/pixi/index.d.ts +3 -37
- package/dist/pixi/index.js +6 -22
- package/dist/pixi/modules/CAMERA/camera.d.ts +5 -4
- package/dist/pixi/modules/CAMERA/camera.js +9 -9
- package/dist/pixi/modules/CAMERA//342/232/234/357/270/217gateways/camera-view.gateway.d.ts +3 -2
- package/dist/pixi/modules/CAMERA//342/232/234/357/270/217gateways/camera-view.gateway.js +1 -1
- package/dist/pixi/modules/CAMERA//342/232/234/357/270/217gateways/controllers/camera-view.controller.d.ts +3 -2
- package/dist/pixi/modules/CAMERA//342/232/234/357/270/217gateways/controllers/camera-view.controller.js +5 -5
- package/dist/pixi/modules/CAMERA//342/232/234/357/270/217gateways/controllers/camera.controller.d.ts +3 -3
- package/dist/pixi/modules/CAMERA//342/232/234/357/270/217gateways/controllers/camera.controller.js +7 -7
- package/dist/pixi/modules/CAMERA//342/232/234/357/270/217gateways/dtos/requests.dto.d.ts +8 -8
- package/dist/pixi/modules/CAMERA//342/232/234/357/270/217gateways/dtos/requests.dto.js +8 -8
- package/dist/pixi/modules/CAMERA//360/237/223/220services/camera.service.d.ts +2 -2
- package/dist/pixi/modules/CAMERA//360/237/223/220services/camera.service.js +12 -12
- package/dist/pixi/modules/CAMERA//360/237/247/251views/camera.view.d.ts +17 -16
- package/dist/pixi/modules/CAMERA//360/237/247/251views/camera.view.js +49 -48
- package/dist/pixi/pixi-definitions.d.ts +38 -0
- package/dist/pixi/pixi-definitions.js +37 -0
- package/dist/pixi/services/keyboard/keyboard.d.ts +2 -2
- package/dist/pixi/services/keyboard/keyboard.js +9 -9
- package/dist/pixi/services/mouse/mouse-target-focus.service.d.ts +10 -10
- package/dist/pixi/services/mouse/mouse-target-focus.service.js +28 -28
- package/dist/pixi/services/mouse/mouse.service.d.ts +1 -1
- package/dist/pixi/services/mouse/mouse.service.js +5 -5
- package/dist/utilities/animator/animating-content/fade-in-content.test.d.ts +1 -0
- package/dist/utilities/animator/animating-content/fade-in-content.test.js +10 -0
- package/dist/utilities/animator/animating-content/slide-in-content.test.d.ts +1 -0
- package/dist/utilities/animator/animating-content/slide-in-content.test.js +10 -0
- package/dist/utilities/animator/animations.d.ts +14 -6
- package/dist/utilities/animator/animations.js +15 -11
- package/dist/utilities/animator/animator/animator.d.ts +44 -0
- package/dist/utilities/animator/animator/animator.js +234 -0
- package/dist/utilities/animator/animator/animator.memory-leak.test.d.ts +1 -0
- package/dist/utilities/animator/animator/animator.memory-leak.test.js +73 -0
- package/dist/utilities/animator/animator/animator.performance.test.d.ts +1 -0
- package/dist/utilities/animator/animator/animator.performance.test.js +116 -0
- package/dist/utilities/animator/animator/animator.test.d.ts +1 -0
- package/dist/utilities/animator/animator/animator.test.js +1046 -0
- package/dist/utilities/animator/animator.d.ts +2 -3
- package/dist/utilities/animator/animator.js +66 -59
- package/dist/utilities/animator/animator.performance.test.d.ts +1 -0
- package/dist/utilities/animator/animator.performance.test.js +46 -0
- package/dist/utilities/animator/animator.test.js +89 -28
- package/dist/utilities/animator/animator2/animator.d.ts +42 -0
- package/dist/utilities/animator/animator2/animator.js +222 -0
- package/dist/utilities/animator/animator2/animator.memory-leak.test.d.ts +1 -0
- package/dist/utilities/animator/animator2/animator.memory-leak.test.js +73 -0
- package/dist/utilities/animator/animator2/animator.performance.test.d.ts +1 -0
- package/dist/utilities/animator/animator2/animator.performance.test.js +65 -0
- package/dist/utilities/animator/animator2/animator.test.d.ts +1 -0
- package/dist/utilities/animator/animator2/animator.test.js +1007 -0
- package/dist/utilities/animator/animator_old/animator.d.ts +60 -0
- package/dist/utilities/animator/animator_old/animator.js +337 -0
- package/dist/utilities/animator/animator_old/animator.performance.test.d.ts +1 -0
- package/dist/utilities/animator/animator_old/animator.performance.test.js +121 -0
- package/dist/utilities/animator/animator_old/animator.test.d.ts +1 -0
- package/dist/utilities/animator/animator_old/animator.test.js +996 -0
- package/dist/utilities/animator/content-animations/fade-in/fade-in-content.d.ts +18 -0
- package/dist/utilities/animator/content-animations/fade-in/fade-in-content.js +37 -0
- package/dist/utilities/animator/content-animations/fade-in/fade-in-content.test.d.ts +1 -0
- package/dist/utilities/animator/content-animations/fade-in/fade-in-content.test.js +10 -0
- package/dist/utilities/animator/content-animations/fade-in/fade-in-state-animation.d.ts +38 -0
- package/dist/utilities/animator/content-animations/fade-in/fade-in-state-animation.js +208 -0
- package/dist/utilities/animator/content-animations/fade-in/fade-in-state-animation.test.d.ts +1 -0
- package/dist/utilities/animator/content-animations/fade-in/fade-in-state-animation.test.js +439 -0
- package/dist/utilities/animator/content-animations/slide/slide-in-content.d.ts +41 -0
- package/dist/utilities/animator/content-animations/slide/slide-in-content.js +107 -0
- package/dist/utilities/animator/content-animations/slide/slide-in-content.test.d.ts +1 -0
- package/dist/utilities/animator/content-animations/slide/slide-in-content.test.js +10 -0
- package/dist/utilities/animator/content-animations/slide/slide-state-animation.d.ts +24 -0
- package/dist/utilities/animator/content-animations/slide/slide-state-animation.js +138 -0
- package/dist/utilities/animator/content-animations/slide/slide-state-animation.test.d.ts +1 -0
- package/dist/utilities/animator/content-animations/slide/slide-state-animation.test.js +307 -0
- package/dist/utilities/animator/content-animations/slide/state-animation.d.ts +37 -0
- package/dist/utilities/animator/content-animations/slide/state-animation.js +170 -0
- package/dist/utilities/animator/content-animations/slide/state-animation.test.d.ts +1 -0
- package/dist/utilities/animator/content-animations/slide/state-animation.test.js +340 -0
- package/dist/utilities/animator/index.d.ts +6 -6
- package/dist/utilities/animator/index.js +6 -6
- package/dist/utilities/animator/state-animation/fade-in/fade-in-content.d.ts +18 -0
- package/dist/utilities/animator/state-animation/fade-in/fade-in-content.js +37 -0
- package/dist/utilities/animator/state-animation/fade-in/fade-in-content.test.d.ts +1 -0
- package/dist/utilities/animator/state-animation/fade-in/fade-in-content.test.js +10 -0
- package/dist/utilities/animator/state-animation/fade-in/fade-in-state-animation.d.ts +32 -0
- package/dist/utilities/animator/state-animation/fade-in/fade-in-state-animation.js +168 -0
- package/dist/utilities/animator/state-animation/fade-in/fade-in-state-animation.test.d.ts +1 -0
- package/dist/utilities/animator/state-animation/fade-in/fade-in-state-animation.test.js +431 -0
- package/dist/utilities/animator/state-animation/slide/slide-in-content.d.ts +37 -0
- package/dist/utilities/animator/state-animation/slide/slide-in-content.js +100 -0
- package/dist/utilities/animator/state-animation/slide/slide-in-content.test.d.ts +1 -0
- package/dist/utilities/animator/state-animation/slide/slide-in-content.test.js +10 -0
- package/dist/utilities/animator/state-animation/slide/slide-state-animation.d.ts +24 -0
- package/dist/utilities/animator/state-animation/slide/slide-state-animation.js +130 -0
- package/dist/utilities/animator/state-animation/slide/slide-state-animation.test.d.ts +1 -0
- package/dist/utilities/animator/state-animation/slide/slide-state-animation.test.js +301 -0
- package/dist/utilities/animator/state-animation/slide-state-animation.test.js +30 -30
- package/dist/utilities/animator/state-animation/state-animation.js +7 -7
- package/dist/utilities/animator/state-animation/state-animation.test.js +24 -24
- package/dist/utilities/animator/state-animation/visit-disappear-state-animation.test.js +30 -30
- package/dist/utilities/data-structures/vector-set/vector-set.d.ts +1 -1
- package/dist/utilities/data-structures/vector-set/vector-set.js +5 -5
- package/dist/utilities/grid-algorithms/closest-available-space/closest-available-space.helper.d.ts +1 -1
- package/dist/utilities/grid-algorithms/closest-available-space/closest-available-space.helper.js +5 -5
- package/dist/utilities/grid-algorithms/path-finder/path-finder.js +21 -21
- package/dist/utilities/grid-algorithms/path-finder/path-finder.test.js +9 -9
- package/dist/utilities/grid-algorithms/vector-field-path-finder/vector-field-path-finder.d.ts +14 -14
- package/dist/utilities/grid-algorithms/vector-field-path-finder/vector-field-path-finder.js +43 -43
- package/dist/utilities/grid-algorithms/vector-field-path-finder/vector-field-path-finder.test.js +21 -21
- package/package.json +7 -5
|
@@ -14,7 +14,7 @@ const rich_text_data_out_converter_1 = require("./rich-text-data-out-converter")
|
|
|
14
14
|
{ chunk: (0, rich_text_to_plane_text_test_1.CreateSampleChunkData)(' world'), position: new helpers_lib_1.Vector(50, 0) }
|
|
15
15
|
]
|
|
16
16
|
];
|
|
17
|
-
let result = rich_text_data_out_converter_1.RichTextDataOutConverter['
|
|
17
|
+
let result = rich_text_data_out_converter_1.RichTextDataOutConverter['_mergeSameStyleChunks'](chunks);
|
|
18
18
|
(0, vitest_1.expect)(result).toEqual([[{ chunk: (0, rich_text_to_plane_text_test_1.CreateSampleChunkData)('hello world'), position: new helpers_lib_1.Vector(0, 0) }]]);
|
|
19
19
|
});
|
|
20
20
|
(0, vitest_1.test)('does not merge chunks with different styles', () => {
|
|
@@ -24,7 +24,7 @@ const rich_text_data_out_converter_1 = require("./rich-text-data-out-converter")
|
|
|
24
24
|
{ chunk: (0, rich_text_to_plane_text_test_1.CreateSampleChunkData)(' world', { fontSize: 20 }), position: new helpers_lib_1.Vector(50, 0) }
|
|
25
25
|
]
|
|
26
26
|
];
|
|
27
|
-
let result = rich_text_data_out_converter_1.RichTextDataOutConverter['
|
|
27
|
+
let result = rich_text_data_out_converter_1.RichTextDataOutConverter['_mergeSameStyleChunks'](chunks);
|
|
28
28
|
(0, vitest_1.expect)(result).toEqual([
|
|
29
29
|
[
|
|
30
30
|
{ chunk: (0, rich_text_to_plane_text_test_1.CreateSampleChunkData)('hello'), position: new helpers_lib_1.Vector(0, 0) },
|
|
@@ -43,7 +43,7 @@ const rich_text_data_out_converter_1 = require("./rich-text-data-out-converter")
|
|
|
43
43
|
{ chunk: (0, rich_text_to_plane_text_test_1.CreateSampleChunkData)(' bar'), position: new helpers_lib_1.Vector(30, 20) }
|
|
44
44
|
]
|
|
45
45
|
];
|
|
46
|
-
let result = rich_text_data_out_converter_1.RichTextDataOutConverter['
|
|
46
|
+
let result = rich_text_data_out_converter_1.RichTextDataOutConverter['_mergeSameStyleChunks'](chunks);
|
|
47
47
|
(0, vitest_1.expect)(result).toEqual([
|
|
48
48
|
[{ chunk: (0, rich_text_to_plane_text_test_1.CreateSampleChunkData)('hello world'), position: new helpers_lib_1.Vector(0, 0) }],
|
|
49
49
|
[{ chunk: (0, rich_text_to_plane_text_test_1.CreateSampleChunkData)('foo bar'), position: new helpers_lib_1.Vector(0, 20) }]
|
|
@@ -58,24 +58,24 @@ const rich_text_data_out_converter_1 = require("./rich-text-data-out-converter")
|
|
|
58
58
|
{ chunk: (0, rich_text_to_plane_text_test_1.CreateSampleChunkData)(' '), position: new helpers_lib_1.Vector(50, 0) }
|
|
59
59
|
]
|
|
60
60
|
];
|
|
61
|
-
let result = rich_text_data_out_converter_1.RichTextDataOutConverter['
|
|
61
|
+
let result = rich_text_data_out_converter_1.RichTextDataOutConverter['_trimEmptySpaces'](chunks);
|
|
62
62
|
(0, vitest_1.expect)(result).toEqual([[{ chunk: (0, rich_text_to_plane_text_test_1.CreateSampleChunkData)('hello'), position: new helpers_lib_1.Vector(0, 0) }]]);
|
|
63
63
|
});
|
|
64
64
|
(0, vitest_1.test)('does not trim non-whitespace', () => {
|
|
65
65
|
let chunks = [[{ chunk: (0, rich_text_to_plane_text_test_1.CreateSampleChunkData)('hello'), position: new helpers_lib_1.Vector(0, 0) }]];
|
|
66
|
-
let result = rich_text_data_out_converter_1.RichTextDataOutConverter['
|
|
66
|
+
let result = rich_text_data_out_converter_1.RichTextDataOutConverter['_trimEmptySpaces'](chunks);
|
|
67
67
|
(0, vitest_1.expect)(result).toEqual([[{ chunk: (0, rich_text_to_plane_text_test_1.CreateSampleChunkData)('hello'), position: new helpers_lib_1.Vector(0, 0) }]]);
|
|
68
68
|
});
|
|
69
69
|
(0, vitest_1.test)('handles empty lines', () => {
|
|
70
70
|
let chunks = [];
|
|
71
|
-
let result = rich_text_data_out_converter_1.RichTextDataOutConverter['
|
|
71
|
+
let result = rich_text_data_out_converter_1.RichTextDataOutConverter['_trimEmptySpaces'](chunks);
|
|
72
72
|
(0, vitest_1.expect)(result).toEqual([]);
|
|
73
73
|
});
|
|
74
74
|
});
|
|
75
75
|
(0, vitest_1.describe)('chunksToTextData', () => {
|
|
76
76
|
(0, vitest_1.test)('single line with one chunk', () => {
|
|
77
77
|
let chunks = [[{ chunk: (0, rich_text_to_plane_text_test_1.CreateSampleChunkData)('Hello'), position: new helpers_lib_1.Vector(0, 0) }]];
|
|
78
|
-
let result = rich_text_data_out_converter_1.RichTextDataOutConverter['
|
|
78
|
+
let result = rich_text_data_out_converter_1.RichTextDataOutConverter['_chunksToTextData'](chunks);
|
|
79
79
|
(0, vitest_1.expect)(result).toEqual([
|
|
80
80
|
{
|
|
81
81
|
text: 'Hello',
|
|
@@ -91,7 +91,7 @@ const rich_text_data_out_converter_1 = require("./rich-text-data-out-converter")
|
|
|
91
91
|
{ chunk: (0, rich_text_to_plane_text_test_1.CreateSampleChunkData)(' World'), position: new helpers_lib_1.Vector(50, 0) }
|
|
92
92
|
]
|
|
93
93
|
];
|
|
94
|
-
let result = rich_text_data_out_converter_1.RichTextDataOutConverter['
|
|
94
|
+
let result = rich_text_data_out_converter_1.RichTextDataOutConverter['_chunksToTextData'](chunks);
|
|
95
95
|
(0, vitest_1.expect)(result).toEqual([
|
|
96
96
|
{
|
|
97
97
|
text: 'Hello',
|
|
@@ -113,7 +113,7 @@ const rich_text_data_out_converter_1 = require("./rich-text-data-out-converter")
|
|
|
113
113
|
],
|
|
114
114
|
[{ chunk: (0, rich_text_to_plane_text_test_1.CreateSampleChunkData)('012'), position: new helpers_lib_1.Vector(0, 24) }]
|
|
115
115
|
];
|
|
116
|
-
let result = rich_text_data_out_converter_1.RichTextDataOutConverter['
|
|
116
|
+
let result = rich_text_data_out_converter_1.RichTextDataOutConverter['_chunksToTextData'](chunks);
|
|
117
117
|
(0, vitest_1.expect)(result).toEqual([
|
|
118
118
|
{
|
|
119
119
|
text: '012',
|
|
@@ -134,17 +134,17 @@ const rich_text_data_out_converter_1 = require("./rich-text-data-out-converter")
|
|
|
134
134
|
});
|
|
135
135
|
(0, vitest_1.test)('empty chunks array', () => {
|
|
136
136
|
let chunks = [];
|
|
137
|
-
let result = rich_text_data_out_converter_1.RichTextDataOutConverter['
|
|
137
|
+
let result = rich_text_data_out_converter_1.RichTextDataOutConverter['_chunksToTextData'](chunks);
|
|
138
138
|
(0, vitest_1.expect)(result).toEqual([]);
|
|
139
139
|
});
|
|
140
140
|
(0, vitest_1.test)('empty string array', () => {
|
|
141
141
|
let chunks = [[{ chunk: (0, rich_text_to_plane_text_test_1.CreateSampleChunkData)(''), position: new helpers_lib_1.Vector(0, 0) }]];
|
|
142
|
-
let result = rich_text_data_out_converter_1.RichTextDataOutConverter['
|
|
142
|
+
let result = rich_text_data_out_converter_1.RichTextDataOutConverter['_chunksToTextData'](chunks);
|
|
143
143
|
(0, vitest_1.expect)(result).toEqual([]);
|
|
144
144
|
});
|
|
145
145
|
(0, vitest_1.test)('line with whitespace only chunks', () => {
|
|
146
146
|
let chunks = [[{ chunk: (0, rich_text_to_plane_text_test_1.CreateSampleChunkData)(' '), position: new helpers_lib_1.Vector(0, 0) }]];
|
|
147
|
-
let result = rich_text_data_out_converter_1.RichTextDataOutConverter['
|
|
147
|
+
let result = rich_text_data_out_converter_1.RichTextDataOutConverter['_chunksToTextData'](chunks);
|
|
148
148
|
(0, vitest_1.expect)(result).toEqual([]);
|
|
149
149
|
});
|
|
150
150
|
});
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as Pixi from 'pixi.js';
|
|
2
2
|
import { RichTextOptions } from '../rich-text';
|
|
3
3
|
import { TextData } from '.';
|
|
4
4
|
import { PartialTextOptions } from './process-steps/1-data-in-converter/pixi-text-style-converter';
|
|
@@ -10,7 +10,7 @@ export interface ChunkStyle {
|
|
|
10
10
|
readonly descent: number;
|
|
11
11
|
readonly spaceWidth: number;
|
|
12
12
|
readonly style: PartialTextOptions;
|
|
13
|
-
readonly pixiStyle:
|
|
13
|
+
readonly pixiStyle: Pixi.TextStyle;
|
|
14
14
|
}
|
|
15
15
|
export interface ChunkData {
|
|
16
16
|
readonly text: string;
|
|
@@ -25,7 +25,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
26
|
exports.MockPixiMeasureText = exports.CreateSampleChunkData = void 0;
|
|
27
27
|
const helpers_lib_1 = require("helpers-lib");
|
|
28
|
-
const
|
|
28
|
+
const Pixi = __importStar(require("pixi.js"));
|
|
29
29
|
const vitest_1 = require("vitest");
|
|
30
30
|
const rich_text_to_plane_text_1 = require("./rich-text-to-plane-text");
|
|
31
31
|
const CreateSampleChunkData = (text, options) => ({
|
|
@@ -34,7 +34,7 @@ const CreateSampleChunkData = (text, options) => ({
|
|
|
34
34
|
style: {
|
|
35
35
|
cacheKey: JSON.stringify(options) ?? 'empty',
|
|
36
36
|
style: { fontSize: options?.fontSize ?? 16, fontFamily: 'Arial' },
|
|
37
|
-
pixiStyle: new
|
|
37
|
+
pixiStyle: new Pixi.TextStyle({ fontSize: options?.fontSize ?? 16, fontFamily: 'Arial' }),
|
|
38
38
|
height: options?.fontSize ?? 16,
|
|
39
39
|
ascent: options?.fontSize ? options.fontSize - 4 : 12,
|
|
40
40
|
descent: 4,
|
|
@@ -44,10 +44,10 @@ const CreateSampleChunkData = (text, options) => ({
|
|
|
44
44
|
});
|
|
45
45
|
exports.CreateSampleChunkData = CreateSampleChunkData;
|
|
46
46
|
const MockPixiMeasureText = () => {
|
|
47
|
-
const
|
|
47
|
+
const OriginalMeasureText = Pixi.TextMetrics.measureText;
|
|
48
48
|
(0, vitest_1.beforeEach)(() => {
|
|
49
49
|
// Mock PIXI.TextMetrics.measureText to return predictable widths
|
|
50
|
-
|
|
50
|
+
Pixi.TextMetrics.measureText = vitest_1.vi.fn().mockImplementation((text, style) => ({
|
|
51
51
|
width: text.length * 10,
|
|
52
52
|
height: style.fontSize,
|
|
53
53
|
fontProperties: { ascent: +style.fontSize - 4, descent: 4 }
|
|
@@ -55,7 +55,7 @@ const MockPixiMeasureText = () => {
|
|
|
55
55
|
});
|
|
56
56
|
(0, vitest_1.afterEach)(() => {
|
|
57
57
|
// Restore original implementation
|
|
58
|
-
|
|
58
|
+
Pixi.TextMetrics.measureText = OriginalMeasureText;
|
|
59
59
|
});
|
|
60
60
|
};
|
|
61
61
|
exports.MockPixiMeasureText = MockPixiMeasureText;
|
|
@@ -7,7 +7,6 @@ const text_1 = require("./text");
|
|
|
7
7
|
class RichText extends container_1.Container {
|
|
8
8
|
constructor(text, options) {
|
|
9
9
|
super();
|
|
10
|
-
this.text = text;
|
|
11
10
|
let textData = helpers_1.RichTextToPlaneText.process(text, options);
|
|
12
11
|
textData.forEach(textDatum => new text_1.Text(textDatum.text, textDatum.style).setPosition(textDatum.position).displayParent(this).attach(this));
|
|
13
12
|
}
|
|
@@ -2,15 +2,14 @@ import { RGBColor, Vector } from 'helpers-lib';
|
|
|
2
2
|
import { Container } from '../../container';
|
|
3
3
|
import { PartialTextOptions } from './helpers/process-steps/1-data-in-converter/pixi-text-style-converter';
|
|
4
4
|
export declare class Text extends Container {
|
|
5
|
-
private
|
|
6
|
-
private
|
|
7
|
-
private
|
|
8
|
-
private
|
|
9
|
-
private
|
|
10
|
-
private _textMetrics
|
|
11
|
-
private get textMetrics();
|
|
5
|
+
private _pixiText;
|
|
6
|
+
private _strikethroughGraphics?;
|
|
7
|
+
private _pixiTextStyle;
|
|
8
|
+
private _text;
|
|
9
|
+
private _textMetricsVar?;
|
|
10
|
+
private get _textMetrics();
|
|
12
11
|
get ascent(): number;
|
|
13
|
-
constructor(text: string, partialOptions?: PartialTextOptions
|
|
12
|
+
constructor(text: string, partialOptions?: PartialTextOptions);
|
|
14
13
|
destroy(): void;
|
|
15
14
|
setAnchor(value: Vector): this;
|
|
16
15
|
get anchor(): Vector;
|
|
@@ -21,6 +20,6 @@ export declare class Text extends Container {
|
|
|
21
20
|
} | undefined): this;
|
|
22
21
|
setText(text: string): this;
|
|
23
22
|
setColor(color: RGBColor): this;
|
|
24
|
-
private
|
|
25
|
-
private
|
|
23
|
+
private _regeneratePixiText;
|
|
24
|
+
private _addStrikethroughToText;
|
|
26
25
|
}
|
|
@@ -25,32 +25,31 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
26
|
exports.Text = void 0;
|
|
27
27
|
const helpers_lib_1 = require("helpers-lib");
|
|
28
|
-
const
|
|
28
|
+
const Pixi = __importStar(require("pixi.js"));
|
|
29
29
|
const container_1 = require("../../container");
|
|
30
30
|
const pixi_text_style_converter_1 = require("./helpers/process-steps/1-data-in-converter/pixi-text-style-converter");
|
|
31
31
|
const FONT_SIZE_MULTIPLIER = 1;
|
|
32
32
|
const FONT_SIZE_MULTIPLIER_INVERSE = 1 / FONT_SIZE_MULTIPLIER;
|
|
33
33
|
class Text extends container_1.Container {
|
|
34
|
-
get
|
|
35
|
-
if (!this.
|
|
36
|
-
let pixiTextStyle = new
|
|
37
|
-
this.
|
|
34
|
+
get _textMetrics() {
|
|
35
|
+
if (!this._textMetricsVar) {
|
|
36
|
+
let pixiTextStyle = new Pixi.TextStyle(this._pixiTextStyle);
|
|
37
|
+
this._textMetricsVar = Pixi.TextMetrics.measureText(this._text, pixiTextStyle);
|
|
38
38
|
}
|
|
39
|
-
return this.
|
|
39
|
+
return this._textMetricsVar;
|
|
40
40
|
}
|
|
41
41
|
get ascent() {
|
|
42
|
-
return this.
|
|
42
|
+
return this._textMetrics.fontProperties.ascent;
|
|
43
43
|
}
|
|
44
44
|
constructor(text, partialOptions) {
|
|
45
45
|
super();
|
|
46
|
-
this.
|
|
47
|
-
this.pixiTextStyle = pixi_text_style_converter_1.TextStyleConverter.getPixiTextStyle(partialOptions);
|
|
46
|
+
this._pixiTextStyle = pixi_text_style_converter_1.TextStyleConverter.getPixiTextStyle(partialOptions);
|
|
48
47
|
this.setText(text);
|
|
49
48
|
}
|
|
50
49
|
destroy() {
|
|
51
50
|
if (!this.destroyed) {
|
|
52
|
-
!this.pixiText.destroyed && this.pixiText.destroy();
|
|
53
51
|
super.destroy();
|
|
52
|
+
!this._pixiText.destroyed && this._pixiText.destroy();
|
|
54
53
|
}
|
|
55
54
|
}
|
|
56
55
|
setAnchor(value) {
|
|
@@ -58,14 +57,14 @@ class Text extends container_1.Container {
|
|
|
58
57
|
return this;
|
|
59
58
|
}
|
|
60
59
|
get anchor() {
|
|
61
|
-
return new helpers_lib_1.Vector(this.
|
|
60
|
+
return new helpers_lib_1.Vector(this._pixiText.anchor.x, this._pixiText.anchor.y);
|
|
62
61
|
}
|
|
63
62
|
set anchor(value) {
|
|
64
|
-
this.
|
|
63
|
+
this._pixiText.anchor.set(value.x, value.y);
|
|
65
64
|
}
|
|
66
65
|
setPosition(value, options) {
|
|
67
66
|
if (options?.holdFrom) {
|
|
68
|
-
let blurDistance = this.
|
|
67
|
+
let blurDistance = this._pixiTextStyle.dropShadowDistance ?? 0;
|
|
69
68
|
let shadowOffset = new helpers_lib_1.Vector(options.holdFrom.x * blurDistance, options.holdFrom.y * blurDistance);
|
|
70
69
|
value = value.add(shadowOffset);
|
|
71
70
|
}
|
|
@@ -73,43 +72,43 @@ class Text extends container_1.Container {
|
|
|
73
72
|
return this;
|
|
74
73
|
}
|
|
75
74
|
setText(text) {
|
|
76
|
-
if (this.
|
|
77
|
-
this.
|
|
78
|
-
this.
|
|
75
|
+
if (this._text !== text) {
|
|
76
|
+
this._text = text;
|
|
77
|
+
this._regeneratePixiText();
|
|
79
78
|
}
|
|
80
79
|
return this;
|
|
81
80
|
}
|
|
82
81
|
setColor(color) {
|
|
83
82
|
let colorHex = helpers_lib_1.ColorHelper.rgbToHex(color);
|
|
84
|
-
if (this.
|
|
85
|
-
this.
|
|
86
|
-
this.
|
|
83
|
+
if (this._pixiTextStyle.fill !== colorHex) {
|
|
84
|
+
this._pixiTextStyle.fill = colorHex;
|
|
85
|
+
this._regeneratePixiText();
|
|
87
86
|
}
|
|
88
87
|
return this;
|
|
89
88
|
}
|
|
90
|
-
|
|
91
|
-
this.
|
|
92
|
-
this.
|
|
93
|
-
this.
|
|
94
|
-
this.
|
|
95
|
-
let pixiTextStyle = new
|
|
96
|
-
this.
|
|
97
|
-
this.
|
|
98
|
-
this.pixiContainer.addChild(this.
|
|
99
|
-
if (this.
|
|
100
|
-
this.
|
|
101
|
-
this.pixiContainer.addChild(this.
|
|
89
|
+
_regeneratePixiText() {
|
|
90
|
+
this._pixiText?.destroy();
|
|
91
|
+
this._strikethroughGraphics?.destroy();
|
|
92
|
+
this._strikethroughGraphics = undefined;
|
|
93
|
+
this._textMetricsVar = undefined;
|
|
94
|
+
let pixiTextStyle = new Pixi.TextStyle(this._pixiTextStyle);
|
|
95
|
+
this._pixiText = new Pixi.Text(this._text, pixiTextStyle);
|
|
96
|
+
this._pixiText.scale.set(FONT_SIZE_MULTIPLIER_INVERSE, FONT_SIZE_MULTIPLIER_INVERSE);
|
|
97
|
+
this.pixiContainer.addChild(this._pixiText);
|
|
98
|
+
if (this._pixiTextStyle.lineThrough) {
|
|
99
|
+
this._strikethroughGraphics = this._addStrikethroughToText(this._pixiText, this._pixiTextStyle.fill);
|
|
100
|
+
this.pixiContainer.addChild(this._strikethroughGraphics);
|
|
102
101
|
}
|
|
103
102
|
}
|
|
104
|
-
|
|
105
|
-
let textMetrics =
|
|
103
|
+
_addStrikethroughToText(pixiText, lineColor) {
|
|
104
|
+
let textMetrics = Pixi.TextMetrics.measureText(pixiText.text, pixiText.style);
|
|
106
105
|
let lineThickness = Math.max(1, Math.round(textMetrics.lineHeight * 0.07));
|
|
107
106
|
let lineOffset = (lineThickness % 2) * 0.5;
|
|
108
|
-
let strikethroughGraphics = new
|
|
107
|
+
let strikethroughGraphics = new Pixi.Graphics();
|
|
109
108
|
strikethroughGraphics.lineStyle(lineThickness, lineColor);
|
|
110
109
|
let currentY = 0;
|
|
111
110
|
textMetrics.lines.forEach((line, index) => {
|
|
112
|
-
let lineMetrics =
|
|
111
|
+
let lineMetrics = Pixi.TextMetrics.measureText(line, pixiText.style);
|
|
113
112
|
let lineY = Math.round(currentY +
|
|
114
113
|
(lineMetrics.fontProperties.ascent - lineMetrics.fontProperties.descent) * 0.6 +
|
|
115
114
|
lineMetrics.fontProperties.descent) + lineOffset;
|
package/dist/pixi/game.d.ts
CHANGED
|
@@ -1,16 +1,20 @@
|
|
|
1
1
|
import { Reducer, Variable } from 'actions-lib';
|
|
2
2
|
import { RGBColor, Vector } from 'helpers-lib';
|
|
3
|
-
import * as
|
|
4
|
-
import {
|
|
3
|
+
import * as Pixi from 'pixi.js';
|
|
4
|
+
import { Container } from './display-object/container';
|
|
5
5
|
import { Camera } from './modules/CAMERA/camera';
|
|
6
|
-
|
|
6
|
+
import { AssetDefinition, SpriteDefinition } from './pixi-definitions';
|
|
7
7
|
export interface GameConfiguration {
|
|
8
|
-
screenResolution?: {
|
|
9
|
-
width: number;
|
|
10
|
-
height: number;
|
|
8
|
+
readonly screenResolution?: {
|
|
9
|
+
readonly width: number;
|
|
10
|
+
readonly height: number;
|
|
11
11
|
};
|
|
12
|
-
devMode
|
|
13
|
-
backgroundColor
|
|
12
|
+
readonly devMode: boolean;
|
|
13
|
+
readonly backgroundColor: RGBColor;
|
|
14
|
+
}
|
|
15
|
+
export interface GameSetupOptions {
|
|
16
|
+
readonly assetDefinitions: readonly AssetDefinition<string>[];
|
|
17
|
+
readonly spriteDefinitions: Readonly<Record<string, SpriteDefinition>>;
|
|
14
18
|
}
|
|
15
19
|
export declare class Game {
|
|
16
20
|
private static _instance;
|
|
@@ -19,8 +23,9 @@ export declare class Game {
|
|
|
19
23
|
private static _camera;
|
|
20
24
|
static get camera(): Camera;
|
|
21
25
|
static get time(): number;
|
|
26
|
+
private static _setupOptions;
|
|
22
27
|
readonly stage: Container;
|
|
23
|
-
readonly renderer:
|
|
28
|
+
readonly renderer: Pixi.Renderer;
|
|
24
29
|
readonly _screenSize: Variable<Vector>;
|
|
25
30
|
readonly screenSize: import("actions-lib").Notifier<Vector>;
|
|
26
31
|
getScreenSize(): Vector;
|
|
@@ -28,15 +33,15 @@ export declare class Game {
|
|
|
28
33
|
readonly screenSizeCenter: import("actions-lib").Notifier<Vector>;
|
|
29
34
|
getScreenSizeCenter(): Vector;
|
|
30
35
|
readonly devMode: boolean;
|
|
31
|
-
private readonly
|
|
32
|
-
private readonly
|
|
33
|
-
private
|
|
36
|
+
private readonly _pixiApp;
|
|
37
|
+
private readonly _configuration;
|
|
38
|
+
private _screenPositionToStagePositionConverter;
|
|
34
39
|
constructor(partialConfiguration?: Partial<GameConfiguration>);
|
|
35
|
-
setup(
|
|
40
|
+
setup(setupOptions: GameSetupOptions): Promise<void>;
|
|
36
41
|
setResolution(resolution: number): void;
|
|
37
42
|
screenPositonToStagePosition(screenPosition: Vector): Vector;
|
|
38
43
|
setScreenPositionToStagePositionFunction(converterFunction: (screenPosition: Vector) => Vector): void;
|
|
39
44
|
resetScreenPositionToStagePositionFunction(): void;
|
|
40
|
-
destroyAsset(
|
|
41
|
-
private
|
|
45
|
+
destroyAsset(assetID: string): void;
|
|
46
|
+
private _setScreenSize;
|
|
42
47
|
}
|
package/dist/pixi/game.js
CHANGED
|
@@ -23,16 +23,16 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
23
23
|
return result;
|
|
24
24
|
};
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.Game =
|
|
26
|
+
exports.Game = void 0;
|
|
27
27
|
const actions_lib_1 = require("actions-lib");
|
|
28
28
|
const helpers_lib_1 = require("helpers-lib");
|
|
29
|
-
const
|
|
29
|
+
const Pixi = __importStar(require("pixi.js"));
|
|
30
30
|
const update_cycle_1 = require("../game-entities/update-cycle");
|
|
31
|
-
const
|
|
31
|
+
const container_1 = require("./display-object/container");
|
|
32
32
|
const game_assets_1 = require("./helpers/game-assets");
|
|
33
33
|
const position_conversion_helper_1 = require("./helpers/position-conversion.helper");
|
|
34
34
|
const camera_1 = require("./modules/CAMERA/camera");
|
|
35
|
-
|
|
35
|
+
const pixi_definitions_1 = require("./pixi-definitions");
|
|
36
36
|
class Game {
|
|
37
37
|
static get instance() {
|
|
38
38
|
return this._instance;
|
|
@@ -42,7 +42,11 @@ class Game {
|
|
|
42
42
|
return this._camera;
|
|
43
43
|
}
|
|
44
44
|
static get time() {
|
|
45
|
-
return update_cycle_1.UpdateCycle
|
|
45
|
+
return update_cycle_1.UpdateCycle._time;
|
|
46
|
+
}
|
|
47
|
+
/** @internal */
|
|
48
|
+
static get setupOptions() {
|
|
49
|
+
return this._setupOptions;
|
|
46
50
|
}
|
|
47
51
|
getScreenSize() {
|
|
48
52
|
return this._screenSize.value;
|
|
@@ -61,69 +65,70 @@ class Game {
|
|
|
61
65
|
throw new Error('There can be only one Game instance!');
|
|
62
66
|
}
|
|
63
67
|
else {
|
|
64
|
-
this.
|
|
68
|
+
this._configuration = {
|
|
65
69
|
screenResolution: undefined,
|
|
66
70
|
devMode: false,
|
|
67
71
|
backgroundColor: helpers_lib_1.ColorHelper.black,
|
|
68
72
|
...partialConfiguration
|
|
69
73
|
};
|
|
70
|
-
this.devMode = this.
|
|
71
|
-
this.
|
|
72
|
-
backgroundColor: this.
|
|
74
|
+
this.devMode = this._configuration.devMode || false;
|
|
75
|
+
this._pixiApp = new Pixi.Application({
|
|
76
|
+
backgroundColor: this._configuration.backgroundColor,
|
|
73
77
|
autoStart: false,
|
|
74
|
-
antialias:
|
|
75
|
-
resolution:
|
|
76
|
-
width: this.
|
|
77
|
-
height: this.
|
|
78
|
-
resizeTo: this.
|
|
78
|
+
antialias: pixi_definitions_1.DEFAULT_RESOLUTION < 1.5,
|
|
79
|
+
resolution: pixi_definitions_1.DEFAULT_RESOLUTION,
|
|
80
|
+
width: this._configuration.screenResolution?.width,
|
|
81
|
+
height: this._configuration.screenResolution?.height,
|
|
82
|
+
resizeTo: this._configuration.screenResolution === undefined ? window : undefined
|
|
79
83
|
});
|
|
80
84
|
}
|
|
81
85
|
}
|
|
82
|
-
async setup(
|
|
83
|
-
|
|
84
|
-
|
|
86
|
+
async setup(setupOptions) {
|
|
87
|
+
Game._setupOptions = setupOptions;
|
|
88
|
+
document.body.appendChild(this._pixiApp.view);
|
|
89
|
+
await Promise.all([game_assets_1.GameAssets.loadGameAssets(setupOptions.assetDefinitions)]);
|
|
85
90
|
Game._instance = this;
|
|
86
91
|
// @ts-ignore
|
|
87
|
-
this.stage = new
|
|
92
|
+
this.stage = new container_1.Container().attachToRoot();
|
|
88
93
|
// @ts-ignore
|
|
89
|
-
this.stage.pixiContainer = this.
|
|
94
|
+
this.stage.pixiContainer = this._pixiApp.stage;
|
|
90
95
|
// @ts-ignore
|
|
91
|
-
this.renderer = this.
|
|
92
|
-
this.
|
|
96
|
+
this.renderer = this._pixiApp.renderer;
|
|
97
|
+
this._setScreenSize();
|
|
93
98
|
this.stage.sortableChildren = true;
|
|
94
99
|
// pixi devtools configuration
|
|
95
100
|
// @ts-ignore
|
|
96
|
-
globalThis.__PIXI_APP__ = this.
|
|
101
|
+
globalThis.__PIXI_APP__ = this._pixiApp;
|
|
97
102
|
window.addEventListener('resize', _ => {
|
|
98
103
|
// Wait until pixijs adjusts the screen size
|
|
99
|
-
setTimeout(() => this.
|
|
104
|
+
setTimeout(() => this._setScreenSize());
|
|
100
105
|
});
|
|
101
106
|
Game._camera = new camera_1.Camera();
|
|
102
107
|
// Reminder: If the game should be paused or destroyed, all promises has to be resolved, that relies on update cycle
|
|
103
|
-
this.
|
|
104
|
-
this.
|
|
105
|
-
update_cycle_1.UpdateCycle.triggerUpdateTick(this.
|
|
108
|
+
this._pixiApp.start();
|
|
109
|
+
this._pixiApp.ticker.add(() => {
|
|
110
|
+
update_cycle_1.UpdateCycle.triggerUpdateTick(this._pixiApp.ticker.deltaMS);
|
|
106
111
|
});
|
|
107
112
|
}
|
|
108
113
|
setResolution(resolution) {
|
|
109
|
-
this.
|
|
110
|
-
this.
|
|
114
|
+
this._pixiApp.renderer.resolution = resolution;
|
|
115
|
+
this._pixiApp.renderer.resize(this._pixiApp.screen.width, this._pixiApp.screen.height);
|
|
111
116
|
}
|
|
112
117
|
screenPositonToStagePosition(screenPosition) {
|
|
113
118
|
let adjustedScreenPositionWithScale = position_conversion_helper_1.PositionConversionHelper.includeScaleInScreenPosition(screenPosition, Game.instance.stage.scale, Game.instance.getScreenSizeCenter());
|
|
114
|
-
return this.
|
|
119
|
+
return this._screenPositionToStagePositionConverter(adjustedScreenPositionWithScale);
|
|
115
120
|
}
|
|
116
121
|
setScreenPositionToStagePositionFunction(converterFunction) {
|
|
117
|
-
this.
|
|
122
|
+
this._screenPositionToStagePositionConverter = converterFunction;
|
|
118
123
|
}
|
|
119
124
|
resetScreenPositionToStagePositionFunction() {
|
|
120
|
-
this.
|
|
125
|
+
this._screenPositionToStagePositionConverter = (screenPosition) => screenPosition;
|
|
121
126
|
}
|
|
122
|
-
destroyAsset(
|
|
123
|
-
game_assets_1.GameAssets.destroyAsset(
|
|
127
|
+
destroyAsset(assetID) {
|
|
128
|
+
game_assets_1.GameAssets.destroyAsset(assetID);
|
|
124
129
|
}
|
|
125
|
-
|
|
126
|
-
let screenSize = new helpers_lib_1.Vector(this.
|
|
130
|
+
_setScreenSize() {
|
|
131
|
+
let screenSize = new helpers_lib_1.Vector(this._pixiApp.screen.width, this._pixiApp.screen.height);
|
|
127
132
|
this._screenSize.value = screenSize;
|
|
128
133
|
this._screenSizeCenter.value = screenSize.multiplyNumber(0.5).round();
|
|
129
134
|
}
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import * as
|
|
2
|
-
import { AssetDefinition } from '
|
|
1
|
+
import * as Pixi from 'pixi.js';
|
|
2
|
+
import { AssetDefinition } from '../pixi-definitions';
|
|
3
3
|
declare module 'pixi.js' {
|
|
4
4
|
interface Texture {
|
|
5
5
|
id: string;
|
|
6
6
|
}
|
|
7
7
|
}
|
|
8
8
|
export declare class GameAssets {
|
|
9
|
-
private static
|
|
10
|
-
private static
|
|
9
|
+
private static _resources;
|
|
10
|
+
private static _anonymouseAssetNameCounter;
|
|
11
11
|
static getAsset<T>(name: string): T;
|
|
12
|
-
static insertAsset(asset:
|
|
12
|
+
static insertAsset(asset: Pixi.Texture, name?: string): string;
|
|
13
13
|
static destroyAsset(name: string): void;
|
|
14
14
|
static loadGameAssets(assetDefinitions: readonly AssetDefinition[]): Promise<void>;
|
|
15
15
|
}
|
|
@@ -25,12 +25,12 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
26
|
exports.GameAssets = void 0;
|
|
27
27
|
const helpers_lib_1 = require("helpers-lib");
|
|
28
|
-
const
|
|
28
|
+
const Pixi = __importStar(require("pixi.js"));
|
|
29
29
|
class GameAssets {
|
|
30
|
-
static { this.
|
|
31
|
-
static { this.
|
|
30
|
+
static { this._resources = new Map(); }
|
|
31
|
+
static { this._anonymouseAssetNameCounter = 0; }
|
|
32
32
|
static getAsset(name) {
|
|
33
|
-
let resource = this.
|
|
33
|
+
let resource = this._resources.get(name);
|
|
34
34
|
if (resource) {
|
|
35
35
|
return resource;
|
|
36
36
|
}
|
|
@@ -40,14 +40,17 @@ class GameAssets {
|
|
|
40
40
|
}
|
|
41
41
|
static insertAsset(asset, name) {
|
|
42
42
|
if (!name) {
|
|
43
|
-
name = `
|
|
43
|
+
name = `a-${this._anonymouseAssetNameCounter++}`;
|
|
44
44
|
}
|
|
45
|
-
this.
|
|
45
|
+
this._resources.set(name, asset);
|
|
46
46
|
return name;
|
|
47
47
|
}
|
|
48
48
|
static destroyAsset(name) {
|
|
49
|
-
this.
|
|
50
|
-
|
|
49
|
+
let resource = this._resources.get(name);
|
|
50
|
+
if (resource) {
|
|
51
|
+
resource.destroy(true);
|
|
52
|
+
this._resources.delete(name);
|
|
53
|
+
}
|
|
51
54
|
}
|
|
52
55
|
static async loadGameAssets(assetDefinitions) {
|
|
53
56
|
let urlToNameGroup = new Map();
|
|
@@ -65,13 +68,13 @@ class GameAssets {
|
|
|
65
68
|
assetsToLoad.push({
|
|
66
69
|
url: definition.url,
|
|
67
70
|
callback: (asset) => {
|
|
68
|
-
if (asset instanceof
|
|
71
|
+
if (asset instanceof Pixi.Texture) {
|
|
69
72
|
asset.id = definition.id;
|
|
70
73
|
}
|
|
71
74
|
nameGroup = urlToNameGroup.get(definition.url);
|
|
72
75
|
if (nameGroup) {
|
|
73
76
|
nameGroup.forEach(name => {
|
|
74
|
-
this.
|
|
77
|
+
this._resources.set(name, asset);
|
|
75
78
|
});
|
|
76
79
|
}
|
|
77
80
|
else {
|
|
@@ -82,7 +85,7 @@ class GameAssets {
|
|
|
82
85
|
}
|
|
83
86
|
});
|
|
84
87
|
let timeStart = performance.now();
|
|
85
|
-
return Promise.all(assetsToLoad.map(asset =>
|
|
88
|
+
return Promise.all(assetsToLoad.map(asset => Pixi.Assets.load(asset.url)))
|
|
86
89
|
.then(resources => {
|
|
87
90
|
let timeEnd = performance.now();
|
|
88
91
|
console.info('Asset load completed in: ', Math.round(timeEnd - timeStart) / 1000, ' seconds');
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { Vector } from 'helpers-lib';
|
|
2
|
-
import * as
|
|
3
|
-
import { PolygonDefinition } from '
|
|
2
|
+
import * as Pixi from 'pixi.js';
|
|
3
|
+
import { PolygonDefinition } from '../pixi-definitions';
|
|
4
4
|
export declare class PositionConversionHelper {
|
|
5
5
|
static includeScaleInScreenPosition(screenPosition: Vector, gameInstanceScale: number, screenSizeCenter: Vector): Vector;
|
|
6
6
|
static normalizePolygonByAnchor(polygon: PolygonDefinition, frameSize: Vector, frameAnchor: Vector): PolygonDefinition;
|
|
7
7
|
}
|
|
8
|
-
export declare class CompositeHitArea implements
|
|
9
|
-
private
|
|
8
|
+
export declare class CompositeHitArea implements Pixi.IHitArea {
|
|
9
|
+
private _shapes;
|
|
10
10
|
constructor(polygonDefinition: PolygonDefinition, size: Vector, anchor: Vector);
|
|
11
11
|
contains(x: number, y: number): boolean;
|
|
12
12
|
}
|