diff --git a/.github/.cspell/flame_dictionary.txt b/.github/.cspell/flame_dictionary.txt index 81814197d92..d8a47f00a83 100644 --- a/.github/.cspell/flame_dictionary.txt +++ b/.github/.cspell/flame_dictionary.txt @@ -27,3 +27,4 @@ vantablack # brand name for a famous super-black ink known as the darkest ever m Weasley # Ron Weasley, a character from the book Harry Potter Wyrmsun # An open-source real-time strategy game https://www.indiedb.com/games/wyrmsun yarnspinner # A tool for building branching narrative and dialogue in games # https://yarnspinner.dev/ +terminui # A terminal UI library for Flutter diff --git a/.github/.cspell/words_dictionary.txt b/.github/.cspell/words_dictionary.txt index 71efd07cd0f..c83a7d75a1a 100644 --- a/.github/.cspell/words_dictionary.txt +++ b/.github/.cspell/words_dictionary.txt @@ -27,6 +27,7 @@ rebalance refreshable renderable rescan +strikethrough # of a text with a horizontal line across tappable tappables toolset diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml new file mode 100644 index 00000000000..25302769b70 --- /dev/null +++ b/.github/workflows/benchmark.yml @@ -0,0 +1,20 @@ +name: Benchmark + +on: [pull_request] + +jobs: + benchmark: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - uses: subosito/flutter-action@v2 + - uses: bluefireteam/melos-action@v3 + + - uses: luanpotter/dart-benchmark-action@v0.1.13 + with: + paths: "packages/flame/" + ignore-tag: "no-benchmark" + is-flutter: true + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/CHANGELOG.md b/CHANGELOG.md index 92e8dc24513..b4c11ff7e11 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,162 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +## 2025-01-02 + +### Changes + +--- + +Packages with breaking changes: + + - [`flame_3d` - `v0.1.0-dev.4`](#flame_3d---v010-dev4) + +Packages with other changes: + + - [`flame` - `v1.23.0`](#flame---v1230) + - [`flame_console` - `v0.1.2`](#flame_console---v012) + - [`flame_forge2d` - `v0.18.2+4`](#flame_forge2d---v01824) + - [`flame_isolate` - `v0.6.2+4`](#flame_isolate---v0624) + - [`flame_markdown` - `v0.2.3`](#flame_markdown---v023) + - [`flame_oxygen` - `v0.2.3+4`](#flame_oxygen---v0234) + - [`flame_sprite_fusion` - `v0.1.3+4`](#flame_sprite_fusion---v0134) + - [`flame_svg` - `v1.11.4`](#flame_svg---v1114) + - [`flame_test` - `v1.17.4`](#flame_test---v1174) + - [`flame_tiled` - `v1.21.2`](#flame_tiled---v1212) + - [`flame_behavior_tree` - `v0.1.3+4`](#flame_behavior_tree---v0134) + - [`flame_texturepacker` - `v4.1.4`](#flame_texturepacker---v414) + - [`flame_fire_atlas` - `v1.7.1`](#flame_fire_atlas---v171) + - [`flame_audio` - `v2.10.7`](#flame_audio---v2107) + - [`flame_spine` - `v0.2.2+4`](#flame_spine---v0224) + - [`flame_bloc` - `v1.12.5`](#flame_bloc---v1125) + - [`flame_kenney_xml` - `v0.1.1+4`](#flame_kenney_xml---v0114) + - [`flame_lottie` - `v0.4.2+4`](#flame_lottie---v0424) + - [`flame_rive` - `v1.10.7`](#flame_rive---v1107) + - [`flame_noise` - `v0.3.2+4`](#flame_noise---v0324) + - [`flame_riverpod` - `v5.4.7`](#flame_riverpod---v547) + - [`flame_network_assets` - `v0.3.3+4`](#flame_network_assets---v0334) + +Packages with dependency updates only: + +> Packages listed below depend on other packages in this workspace that have had changes. Their versions have been incremented to bump the minimum dependency versions of the packages they depend upon in this project. + + - `flame_behavior_tree` - `v0.1.3+4` + - `flame_texturepacker` - `v4.1.4` + - `flame_fire_atlas` - `v1.7.1` + - `flame_audio` - `v2.10.7` + - `flame_spine` - `v0.2.2+4` + - `flame_bloc` - `v1.12.5` + - `flame_kenney_xml` - `v0.1.1+4` + - `flame_lottie` - `v0.4.2+4` + - `flame_rive` - `v1.10.7` + - `flame_noise` - `v0.3.2+4` + - `flame_riverpod` - `v5.4.7` + - `flame_network_assets` - `v0.3.3+4` + +--- + +#### `flame_3d` - `v0.1.0-dev.4` + + - **REFACTOR**: Fix lint issues from latest flutter release ([#3390](https://github.com/flame-engine/flame/issues/3390)). ([978ad31b](https://github.com/flame-engine/flame/commit/978ad31b429d1801097b0db385a600c85a157867)) + - **FIX**: Use saner default value for camera's target ([#3238](https://github.com/flame-engine/flame/issues/3238)). ([78522c62](https://github.com/flame-engine/flame/commit/78522c624d846c827a1c0d7377837e04a30ba4e7)) + - **FIX**: Use saner default value for camera's target ([#3238](https://github.com/flame-engine/flame/issues/3238)). ([99ca355b](https://github.com/flame-engine/flame/commit/99ca355b3d4a3e9c7677454dc9bc2c874ee2e4a9)) + - **FIX**: Fix albedo texture binding on shader ([#3400](https://github.com/flame-engine/flame/issues/3400)). ([c380c91f](https://github.com/flame-engine/flame/commit/c380c91f7a7e22ab71c3617c0386159861a64abc)) + - **FIX**: Make build_shaders script compatible with other platforms [flame_3d] ([#3395](https://github.com/flame-engine/flame/issues/3395)). ([38331309](https://github.com/flame-engine/flame/commit/38331309ca5ee609e85422ee9d740569a35e5e9e)) + - **FIX**: Make `flame_3d` work with latest stable ([#3387](https://github.com/flame-engine/flame/issues/3387)). ([f940d3f9](https://github.com/flame-engine/flame/commit/f940d3f9420d3ce001f47a9155c582b8b4cd1dcb)) + - **FIX**: MeshComponent.bind should bind to the provided device ([#3278](https://github.com/flame-engine/flame/issues/3278)). ([d06b4ce6](https://github.com/flame-engine/flame/commit/d06b4ce6935987705447772f912719c405d39c9e)) + - **FIX**: Improve behavior of Quaternion.slerp function [flame_3d] ([#3306](https://github.com/flame-engine/flame/issues/3306)). ([8872a45a](https://github.com/flame-engine/flame/commit/8872a45a1b49d7ba7688d62ca25b2a8d31c495cb)) + - **FIX**: Improve quaternion slerp logic to avoid NaN edge cases ([#3303](https://github.com/flame-engine/flame/issues/3303)). ([712b03fb](https://github.com/flame-engine/flame/commit/712b03fbe176cf238a3780aee641254436520366)) + - **FIX**: Make the `build_shader` script work for windows ([#3402](https://github.com/flame-engine/flame/issues/3402)). ([ce7822a0](https://github.com/flame-engine/flame/commit/ce7822a0d0c5ac1c766635a5cf2c242d5e5f98ec)) + - **FIX**: MeshComponent.bind should bind to the provided device ([#3278](https://github.com/flame-engine/flame/issues/3278)). ([3ae3ef54](https://github.com/flame-engine/flame/commit/3ae3ef5476fa5f9ead7069efeee35cc31c0e9dd2)) + - **FIX**: Fix typo on loadTexture ([#3253](https://github.com/flame-engine/flame/issues/3253)). ([3a20a8cd](https://github.com/flame-engine/flame/commit/3a20a8cd61543aad21c1015de5c31ec1cbe71aed)) + - **FIX**: Improve behavior of Quaternion.slerp function [flame_3d] ([#3306](https://github.com/flame-engine/flame/issues/3306)). ([b9d6a0f1](https://github.com/flame-engine/flame/commit/b9d6a0f1d34e009cd91ae9d2ab0eed09b546d110)) + - **FIX**: Improve quaternion slerp logic to avoid NaN edge cases ([#3303](https://github.com/flame-engine/flame/issues/3303)). ([565b68b9](https://github.com/flame-engine/flame/commit/565b68b9da52d44281e93f9ae8617f9dbe9551f3)) + - **FIX**: Fix typo on loadTexture ([#3253](https://github.com/flame-engine/flame/issues/3253)). ([3d1f1437](https://github.com/flame-engine/flame/commit/3d1f143700506467798e030450227d8029b74ef2)) + - **FIX**: Add missing export for CylinderMesh [flame_3d] ([#3256](https://github.com/flame-engine/flame/issues/3256)). ([d8fb65c1](https://github.com/flame-engine/flame/commit/d8fb65c158a3cce442972fb24f55fb522729085f)) + - **FIX**: Add missing export for CylinderMesh [flame_3d] ([#3256](https://github.com/flame-engine/flame/issues/3256)). ([d517c169](https://github.com/flame-engine/flame/commit/d517c169ed9b4d4457df6ac1ae363277577597fa)) + - **FEAT**: More Lights! [flame_3d] ([#3250](https://github.com/flame-engine/flame/issues/3250)). ([5c508e81](https://github.com/flame-engine/flame/commit/5c508e81bddfb17857355da80e57f1ac77ab368d)) + - **FEAT**(flame_3d): Add helpful extension functions to Vector ([#3141](https://github.com/flame-engine/flame/issues/3141)). ([92195989](https://github.com/flame-engine/flame/commit/9219598904131d8fceba8d1ad980bea2805e3515)) + - **FEAT**: Add CylinderMesh [flame_3d] ([#3239](https://github.com/flame-engine/flame/issues/3239)). ([d5de1733](https://github.com/flame-engine/flame/commit/d5de1733c64c4fbaeee83089a3b0f9a3fbb3355d)) + - **FEAT**: Refactor shader uniform binding to support shader arrays [flame_3d] ([#3282](https://github.com/flame-engine/flame/issues/3282)). ([edae1662](https://github.com/flame-engine/flame/commit/edae166252a519d38496bb6bf7c84fe9f401b8d4)) + - **FEAT**(flame_3d): Make shader api more useful ([#3085](https://github.com/flame-engine/flame/issues/3085)). ([fe2e4f20](https://github.com/flame-engine/flame/commit/fe2e4f20195b453268b34e589616343fdce6201a)) + - **FEAT**(flame_3d): Make shader api more useful ([#3085](https://github.com/flame-engine/flame/issues/3085)). ([4042d300](https://github.com/flame-engine/flame/commit/4042d3002ce619bf6b8597aa7dc17a803bc57c69)) + - **FEAT**: Add more useful extensions to VectorN and Quaternion [flame_3d] ([#3296](https://github.com/flame-engine/flame/issues/3296)). ([f5f03e5e](https://github.com/flame-engine/flame/commit/f5f03e5ed7095ede713727d6bbab39db0505e7bf)) + - **FEAT**: Expose vector classes on core file [flame_3d] ([#3211](https://github.com/flame-engine/flame/issues/3211)). ([8f403ac2](https://github.com/flame-engine/flame/commit/8f403ac23ae7cdf5343652c30f9c0ee71d627b0a)) + - **FEAT**(flame_3d): Add helpful extension functions to Vector ([#3141](https://github.com/flame-engine/flame/issues/3141)). ([39e15fb3](https://github.com/flame-engine/flame/commit/39e15fb30256cbfaa86f4d7b8e3453c52942d1a5)) + - **FEAT**: Add CylinderMesh [flame_3d] ([#3239](https://github.com/flame-engine/flame/issues/3239)). ([01872fb6](https://github.com/flame-engine/flame/commit/01872fb6e45e10dc380fee7a176a8b37eeaef880)) + - **FEAT**(flame_3d): initial implementation of 3D support ([#3012](https://github.com/flame-engine/flame/issues/3012)). ([acb8e6fc](https://github.com/flame-engine/flame/commit/acb8e6fc07592a7df041512ed9e033b33eda8799)) + - **FEAT**: Support skeletal animation basics [flame_3d] ([#3291](https://github.com/flame-engine/flame/issues/3291)). ([9c0d1500](https://github.com/flame-engine/flame/commit/9c0d15006047597097dc0e054c1e03a04491cff9)) + - **FEAT**: Add normals to surfaces when not specified ([#3257](https://github.com/flame-engine/flame/issues/3257)). ([1dd21d7d](https://github.com/flame-engine/flame/commit/1dd21d7d6d4f58c9ac54a38363ee2fd0978a9d0c)) + - **FEAT**(flame_3d): initial implementation of 3D support ([#3012](https://github.com/flame-engine/flame/issues/3012)). ([0242e1dd](https://github.com/flame-engine/flame/commit/0242e1dd12a9b50a411d895b662f9df33536f6d9)) + - **FEAT**: Support skeletal animation basics [flame_3d] ([#3291](https://github.com/flame-engine/flame/issues/3291)). ([12927e41](https://github.com/flame-engine/flame/commit/12927e4100a7b4b46e4218db6792d25be1623f88)) + - **FEAT**: Add more useful extensions to VectorN and Quaternion [flame_3d] ([#3296](https://github.com/flame-engine/flame/issues/3296)). ([9cb95279](https://github.com/flame-engine/flame/commit/9cb9527909a4faa38609d25ebd7463f1e2e1a1ab)) + - **FEAT**: Make it easier work with the Mesh class [flame_3d] ([#3212](https://github.com/flame-engine/flame/issues/3212)). ([ebf2ee62](https://github.com/flame-engine/flame/commit/ebf2ee62e535fd1d0f499112b314e1d88e59bbc1)) + - **FEAT**: More Lights! [flame_3d] ([#3250](https://github.com/flame-engine/flame/issues/3250)). ([1780630e](https://github.com/flame-engine/flame/commit/1780630e7fcb386a331ba1219c15cb1ae8b139e6)) + - **FEAT**: Add normals to surfaces when not specified ([#3257](https://github.com/flame-engine/flame/issues/3257)). ([844c1d72](https://github.com/flame-engine/flame/commit/844c1d726e04e9c3c5739214720cf26fc62d3f9f)) + - **FEAT**(flame_3d): Fix minor nits on flame_3d ([#3140](https://github.com/flame-engine/flame/issues/3140)). ([11cdfb5e](https://github.com/flame-engine/flame/commit/11cdfb5ebeb62dd1aec2d51fd7fadfbfb17c6da5)) + - **FEAT**: Expose vector classes on core file [flame_3d] ([#3211](https://github.com/flame-engine/flame/issues/3211)). ([c3e68dff](https://github.com/flame-engine/flame/commit/c3e68dffd2e53a8dc8d4d3804c47e956dfc0ebb4)) + - **FEAT**(flame_3d): Fix minor nits on flame_3d ([#3140](https://github.com/flame-engine/flame/issues/3140)). ([b537d20a](https://github.com/flame-engine/flame/commit/b537d20ab65ce0312e9c05ba9156d794234d93e0)) + - **FEAT**: Make it easier work with the Mesh class [flame_3d] ([#3212](https://github.com/flame-engine/flame/issues/3212)). ([7f80b530](https://github.com/flame-engine/flame/commit/7f80b53078c037f81d386a44fa9b749cf7835ffa)) + - **DOCS**: Update docs and comments (flame_3d) ([#3057](https://github.com/flame-engine/flame/issues/3057)). ([14047879](https://github.com/flame-engine/flame/commit/14047879a13e1f13e51ce3411feb7c7962d6d7ee)) + - **DOCS**: Update docs and comments (flame_3d) ([#3057](https://github.com/flame-engine/flame/issues/3057)). ([b5fd457a](https://github.com/flame-engine/flame/commit/b5fd457a6b6bcad73006fc77a538c7e8521178a5)) + - **DOCS**: Update README.md docs to reflect current state of affairs ([#3305](https://github.com/flame-engine/flame/issues/3305)). ([ac3f48ff](https://github.com/flame-engine/flame/commit/ac3f48ffa6527c595035e8a9cc24307343dacb31)) + - **DOCS**: Update wording on README to match newer instructions [flame_3d] ([#3399](https://github.com/flame-engine/flame/issues/3399)). ([9c416cbf](https://github.com/flame-engine/flame/commit/9c416cbfcb4106ab7b1ad14324ca9cb89593b80d)) + - **DOCS**: Update README.md docs to reflect current state of affairs ([#3305](https://github.com/flame-engine/flame/issues/3305)). ([be72daee](https://github.com/flame-engine/flame/commit/be72daee6b92bcef2af3af78c1f64abe94c49d18)) + - **BREAKING** **FEAT**: Allow for custom shaders and materials ([#3384](https://github.com/flame-engine/flame/issues/3384)). ([ae731814](https://github.com/flame-engine/flame/commit/ae73181466c7e32b0e5e9e814f5170310c20f263)) + - **BREAKING** **FEAT**: Refactor the `CameraComponent3D` ([#3394](https://github.com/flame-engine/flame/issues/3394)). ([4a61718d](https://github.com/flame-engine/flame/commit/4a61718d3b8d45d18a74f662f1bf1eb8e6069983)) + +#### `flame` - `v1.23.0` + + - **REFACTOR**: Fix lint issues from latest flutter release ([#3390](https://github.com/flame-engine/flame/issues/3390)). ([978ad31b](https://github.com/flame-engine/flame/commit/978ad31b429d1801097b0db385a600c85a157867)) + - **FIX**: Take into consideration when child is added to parent that is removed in the same tick ([#3428](https://github.com/flame-engine/flame/issues/3428)). ([9a5c54be](https://github.com/flame-engine/flame/commit/9a5c54bea858fc8e9e84878f3ac0a0f7bc190b46)) + - **FIX**: Add missing export of GroupTextElement to text.dart ([#3424](https://github.com/flame-engine/flame/issues/3424)). ([c9c0f691](https://github.com/flame-engine/flame/commit/c9c0f691412bb026c1d766ec7b424a468f8929f7)) + - **FIX**: Add missing export of GroupElement to text.dart ([#3423](https://github.com/flame-engine/flame/issues/3423)). ([c0c4bb02](https://github.com/flame-engine/flame/commit/c0c4bb02a32306120a8770122116631f55c1c700)) + - **FIX**: Fix brighten and darken alpha issue ([#3414](https://github.com/flame-engine/flame/issues/3414)). ([de8e3bce](https://github.com/flame-engine/flame/commit/de8e3bcea2c2c2fa5e01dd288176c8f5623d21fb)) + - **FIX**: Set button size in onMount if not set ([#3413](https://github.com/flame-engine/flame/issues/3413)). ([916aa5ce](https://github.com/flame-engine/flame/commit/916aa5ce2ad3851b3044e043d2be7cbe923f2c40)) + - **FIX**: Fix bug preventing removeAll(children) from be called before mount ([#3408](https://github.com/flame-engine/flame/issues/3408)). ([726cb8b6](https://github.com/flame-engine/flame/commit/726cb8b6390c839f9cbab959b2268a7b45fa691c)) + - **FEAT**: Add support for strike-through text for flame_markdown ([#3426](https://github.com/flame-engine/flame/issues/3426)). ([1f9b0ea9](https://github.com/flame-engine/flame/commit/1f9b0ea9f35a7180725ec7f8f79a561c5f544bb7)) + - **FEAT**: Warning and docs about fullscreen methods outside the mobile platforms ([#3419](https://github.com/flame-engine/flame/issues/3419)). ([994e098b](https://github.com/flame-engine/flame/commit/994e098bd699a30aa13aed65f2bd0ab7254ad779)) + - **FEAT**: Add baseColor to Shadow3DDecorator ([#3375](https://github.com/flame-engine/flame/issues/3375)). ([b5d7ee07](https://github.com/flame-engine/flame/commit/b5d7ee0752ee1f2dddf1da4ac817f138296e1c96)) + +#### `flame_console` - `v0.1.2` + + - **REFACTOR**: Fix lint issues from latest flutter release ([#3390](https://github.com/flame-engine/flame/issues/3390)). ([978ad31b](https://github.com/flame-engine/flame/commit/978ad31b429d1801097b0db385a600c85a157867)) + - **FEAT**: Refactoring flame_console to use terminui ([#3388](https://github.com/flame-engine/flame/issues/3388)). ([de74a93b](https://github.com/flame-engine/flame/commit/de74a93b44f442341f816a2988c854f40902ff7e)) + +#### `flame_forge2d` - `v0.18.2+4` + + - **REFACTOR**: Fix lint issues from latest flutter release ([#3390](https://github.com/flame-engine/flame/issues/3390)). ([978ad31b](https://github.com/flame-engine/flame/commit/978ad31b429d1801097b0db385a600c85a157867)) + +#### `flame_isolate` - `v0.6.2+4` + + - **REFACTOR**: Fix lint issues from latest flutter release ([#3390](https://github.com/flame-engine/flame/issues/3390)). ([978ad31b](https://github.com/flame-engine/flame/commit/978ad31b429d1801097b0db385a600c85a157867)) + +#### `flame_markdown` - `v0.2.3` + + - **FIX**: Do not encode HTML by default when parsing markdown [flame_markdown] ([#3425](https://github.com/flame-engine/flame/issues/3425)). ([3067da94](https://github.com/flame-engine/flame/commit/3067da94fbc6df2da5197771cb9617588006a9b9)) + - **FEAT**: Add support for strike-through text for flame_markdown ([#3426](https://github.com/flame-engine/flame/issues/3426)). ([1f9b0ea9](https://github.com/flame-engine/flame/commit/1f9b0ea9f35a7180725ec7f8f79a561c5f544bb7)) + +#### `flame_oxygen` - `v0.2.3+4` + + - **REFACTOR**: Fix lint issues from latest flutter release ([#3390](https://github.com/flame-engine/flame/issues/3390)). ([978ad31b](https://github.com/flame-engine/flame/commit/978ad31b429d1801097b0db385a600c85a157867)) + +#### `flame_sprite_fusion` - `v0.1.3+4` + + - **REFACTOR**: Fix lint issues from latest flutter release ([#3390](https://github.com/flame-engine/flame/issues/3390)). ([978ad31b](https://github.com/flame-engine/flame/commit/978ad31b429d1801097b0db385a600c85a157867)) + +#### `flame_svg` - `v1.11.4` + + - **REFACTOR**: Fix lint issues from latest flutter release ([#3390](https://github.com/flame-engine/flame/issues/3390)). ([978ad31b](https://github.com/flame-engine/flame/commit/978ad31b429d1801097b0db385a600c85a157867)) + +#### `flame_test` - `v1.17.4` + + - **REFACTOR**: Fix lint issues from latest flutter release ([#3390](https://github.com/flame-engine/flame/issues/3390)). ([978ad31b](https://github.com/flame-engine/flame/commit/978ad31b429d1801097b0db385a600c85a157867)) + +#### `flame_tiled` - `v1.21.2` + + - **REFACTOR**: Fix lint issues from latest flutter release ([#3390](https://github.com/flame-engine/flame/issues/3390)). ([978ad31b](https://github.com/flame-engine/flame/commit/978ad31b429d1801097b0db385a600c85a157867)) + + ## 2024-12-10 ### Changes diff --git a/doc/flame/examples/pubspec.yaml b/doc/flame/examples/pubspec.yaml index 78e1c42b987..b67b6fff139 100644 --- a/doc/flame/examples/pubspec.yaml +++ b/doc/flame/examples/pubspec.yaml @@ -8,8 +8,8 @@ environment: flutter: ">=3.24.0" dependencies: - flame: ^1.22.0 - flame_rive: ^1.10.6 + flame: ^1.23.0 + flame_rive: ^1.10.7 flutter: sdk: flutter diff --git a/doc/flame/other/other.md b/doc/flame/other/other.md index d6671778f0a..c77a37efed1 100644 --- a/doc/flame/other/other.md +++ b/doc/flame/other/other.md @@ -7,7 +7,7 @@ ```{toctree} :hidden: - + Debugging Utils Widgets diff --git a/doc/flame/other/util.md b/doc/flame/other/util.md index e9f730d9ae1..6a626f5773d 100644 --- a/doc/flame/other/util.md +++ b/doc/flame/other/util.md @@ -5,6 +5,13 @@ On this page you can find documentation for some utility classes and methods. ## Device Class +```{warning} +Many methods in this class only work on mobile platforms (Android and iOS). + +Using these methods on other platforms will not have any effect and you will +get a warning printed on your console when running in debug mode. +``` + This class can be accessed from `Flame.device` and it has some methods that can be used to control the state of the device, for instance you can change the screen orientation and set whether the application should be fullscreen or not. diff --git a/doc/tutorials/klondike/app/pubspec.yaml b/doc/tutorials/klondike/app/pubspec.yaml index 3e7a4271f45..078d56e9839 100644 --- a/doc/tutorials/klondike/app/pubspec.yaml +++ b/doc/tutorials/klondike/app/pubspec.yaml @@ -7,7 +7,7 @@ environment: sdk: ">=3.4.0 <4.0.0" dependencies: - flame: ^1.22.0 + flame: ^1.23.0 flutter: sdk: flutter diff --git a/doc/tutorials/platformer/app/pubspec.yaml b/doc/tutorials/platformer/app/pubspec.yaml index 44149f4e8d0..a83d0273a34 100644 --- a/doc/tutorials/platformer/app/pubspec.yaml +++ b/doc/tutorials/platformer/app/pubspec.yaml @@ -8,7 +8,7 @@ environment: flutter: ">=3.24.0" dependencies: - flame: ^1.22.0 + flame: ^1.23.0 flutter: sdk: flutter diff --git a/doc/tutorials/space_shooter/app/pubspec.yaml b/doc/tutorials/space_shooter/app/pubspec.yaml index b2226b22ea0..5a7e6b755b9 100644 --- a/doc/tutorials/space_shooter/app/pubspec.yaml +++ b/doc/tutorials/space_shooter/app/pubspec.yaml @@ -9,7 +9,7 @@ environment: sdk: ">=3.4.0 <4.0.0" dependencies: - flame: ^1.22.0 + flame: ^1.23.0 flutter: sdk: flutter diff --git a/examples/games/padracing/pubspec.yaml b/examples/games/padracing/pubspec.yaml index 1de38e91aed..d912d6ead72 100644 --- a/examples/games/padracing/pubspec.yaml +++ b/examples/games/padracing/pubspec.yaml @@ -8,8 +8,8 @@ environment: dependencies: collection: ^1.17.1 - flame: ^1.22.0 - flame_forge2d: ^0.18.2+3 + flame: ^1.23.0 + flame_forge2d: ^0.18.2+4 flutter: sdk: flutter google_fonts: ^4.0.4 diff --git a/examples/games/rogue_shooter/pubspec.yaml b/examples/games/rogue_shooter/pubspec.yaml index a0de3241157..2729cbffe51 100644 --- a/examples/games/rogue_shooter/pubspec.yaml +++ b/examples/games/rogue_shooter/pubspec.yaml @@ -10,7 +10,7 @@ environment: flutter: ">=3.24.0" dependencies: - flame: ^1.22.0 + flame: ^1.23.0 flutter: sdk: flutter diff --git a/examples/games/trex/pubspec.yaml b/examples/games/trex/pubspec.yaml index 59e38015037..00d5fa84ad5 100644 --- a/examples/games/trex/pubspec.yaml +++ b/examples/games/trex/pubspec.yaml @@ -11,7 +11,7 @@ environment: dependencies: collection: ^1.16.0 - flame: ^1.22.0 + flame: ^1.23.0 flutter: sdk: flutter diff --git a/examples/lib/stories/image/brighten.dart b/examples/lib/stories/image/brighten.dart new file mode 100644 index 00000000000..ed0b07f9bc9 --- /dev/null +++ b/examples/lib/stories/image/brighten.dart @@ -0,0 +1,40 @@ +import 'package:flame/components.dart'; +import 'package:flame/extensions.dart'; +import 'package:flame/game.dart'; + +class ImageBrightnessExample extends FlameGame { + ImageBrightnessExample({ + required this.brightness, + }); + + final double brightness; + + static const String description = ''' + Shows how a dart:ui `Image` can be brightened using Flame Image extensions. + Use the properties on the side to change the brightness of the image. + '''; + + @override + Future onLoad() async { + final image = await images.load('flame.png'); + final brightenedImage = await image.brighten(brightness / 100); + + add( + SpriteComponent( + sprite: Sprite(image), + position: (size / 2) - Vector2(0, image.height / 2), + size: image.size, + anchor: Anchor.center, + ), + ); + + add( + SpriteComponent( + sprite: Sprite(brightenedImage), + position: (size / 2) + Vector2(0, brightenedImage.height / 2), + size: image.size, + anchor: Anchor.center, + ), + ); + } +} diff --git a/examples/lib/stories/image/darken.dart b/examples/lib/stories/image/darken.dart new file mode 100644 index 00000000000..f3b8d25c777 --- /dev/null +++ b/examples/lib/stories/image/darken.dart @@ -0,0 +1,40 @@ +import 'package:flame/components.dart'; +import 'package:flame/extensions.dart'; +import 'package:flame/game.dart'; + +class ImageDarknessExample extends FlameGame { + ImageDarknessExample({ + required this.darkness, + }); + + final double darkness; + + static const String description = ''' + Shows how a dart:ui `Image` can be darkened using Flame Image extensions. + Use the properties on the side to change the darkness of the image. + '''; + + @override + Future onLoad() async { + final image = await images.load('flame.png'); + final darkenedImage = await image.darken(darkness / 100); + + add( + SpriteComponent( + sprite: Sprite(image), + position: (size / 2) - Vector2(0, image.height / 2), + size: image.size, + anchor: Anchor.center, + ), + ); + + add( + SpriteComponent( + sprite: Sprite(darkenedImage), + position: (size / 2) + Vector2(0, darkenedImage.height / 2), + size: image.size, + anchor: Anchor.center, + ), + ); + } +} diff --git a/examples/lib/stories/image/image.dart b/examples/lib/stories/image/image.dart index af4eae7bfbc..181c9862fda 100644 --- a/examples/lib/stories/image/image.dart +++ b/examples/lib/stories/image/image.dart @@ -1,6 +1,8 @@ import 'package:dashbook/dashbook.dart'; import 'package:examples/commons/commons.dart'; +import 'package:examples/stories/image/brighten.dart'; +import 'package:examples/stories/image/darken.dart'; import 'package:examples/stories/image/resize.dart'; import 'package:flame/game.dart'; @@ -19,5 +21,25 @@ void addImageStories(Dashbook dashbook) { ), codeLink: baseLink('image/resize.dart'), info: ImageResizeExample.description, + ) + ..add( + 'brightness', + (context) => GameWidget( + game: ImageBrightnessExample( + brightness: context.numberProperty('brightness', 50), + ), + ), + codeLink: baseLink('image/brighten.dart'), + info: ImageBrightnessExample.description, + ) + ..add( + 'darkness', + (context) => GameWidget( + game: ImageDarknessExample( + darkness: context.numberProperty('darkness', 50), + ), + ), + codeLink: baseLink('image/darkness.dart'), + info: ImageDarknessExample.description, ); } diff --git a/examples/pubspec.yaml b/examples/pubspec.yaml index 5238cc51bbf..5b2028c3983 100644 --- a/examples/pubspec.yaml +++ b/examples/pubspec.yaml @@ -11,15 +11,15 @@ environment: dependencies: dashbook: ^0.1.15 - flame: ^1.22.0 - flame_audio: ^2.10.6 - flame_forge2d: ^0.18.2+3 - flame_isolate: ^0.6.2+3 - flame_lottie: ^0.4.2+3 - flame_noise: ^0.3.2+3 - flame_spine: ^0.2.2+3 - flame_svg: ^1.11.3 - flame_tiled: ^1.21.1 + flame: ^1.23.0 + flame_audio: ^2.10.7 + flame_forge2d: ^0.18.2+4 + flame_isolate: ^0.6.2+4 + flame_lottie: ^0.4.2+4 + flame_noise: ^0.3.2+4 + flame_spine: ^0.2.2+4 + flame_svg: ^1.11.4 + flame_tiled: ^1.21.2 flutter: sdk: flutter google_fonts: ^4.0.4 diff --git a/melos.yaml b/melos.yaml index 36b46e6fc09..070d3a7450b 100644 --- a/melos.yaml +++ b/melos.yaml @@ -23,7 +23,7 @@ command: vector_math: ^2.1.4 dev_dependencies: dartdoc: ^8.0.8 - mocktail: ^1.0.3 + mocktail: ^1.0.4 test: any publish: diff --git a/packages/flame/CHANGELOG.md b/packages/flame/CHANGELOG.md index 3cb84e30e87..5765842eb2c 100644 --- a/packages/flame/CHANGELOG.md +++ b/packages/flame/CHANGELOG.md @@ -1,3 +1,16 @@ +## 1.23.0 + + - **REFACTOR**: Fix lint issues from latest flutter release ([#3390](https://github.com/flame-engine/flame/issues/3390)). ([978ad31b](https://github.com/flame-engine/flame/commit/978ad31b429d1801097b0db385a600c85a157867)) + - **FIX**: Take into consideration when child is added to parent that is removed in the same tick ([#3428](https://github.com/flame-engine/flame/issues/3428)). ([9a5c54be](https://github.com/flame-engine/flame/commit/9a5c54bea858fc8e9e84878f3ac0a0f7bc190b46)) + - **FIX**: Add missing export of GroupTextElement to text.dart ([#3424](https://github.com/flame-engine/flame/issues/3424)). ([c9c0f691](https://github.com/flame-engine/flame/commit/c9c0f691412bb026c1d766ec7b424a468f8929f7)) + - **FIX**: Add missing export of GroupElement to text.dart ([#3423](https://github.com/flame-engine/flame/issues/3423)). ([c0c4bb02](https://github.com/flame-engine/flame/commit/c0c4bb02a32306120a8770122116631f55c1c700)) + - **FIX**: Fix brighten and darken alpha issue ([#3414](https://github.com/flame-engine/flame/issues/3414)). ([de8e3bce](https://github.com/flame-engine/flame/commit/de8e3bcea2c2c2fa5e01dd288176c8f5623d21fb)) + - **FIX**: Set button size in onMount if not set ([#3413](https://github.com/flame-engine/flame/issues/3413)). ([916aa5ce](https://github.com/flame-engine/flame/commit/916aa5ce2ad3851b3044e043d2be7cbe923f2c40)) + - **FIX**: Fix bug preventing removeAll(children) from be called before mount ([#3408](https://github.com/flame-engine/flame/issues/3408)). ([726cb8b6](https://github.com/flame-engine/flame/commit/726cb8b6390c839f9cbab959b2268a7b45fa691c)) + - **FEAT**: Add support for strike-through text for flame_markdown ([#3426](https://github.com/flame-engine/flame/issues/3426)). ([1f9b0ea9](https://github.com/flame-engine/flame/commit/1f9b0ea9f35a7180725ec7f8f79a561c5f544bb7)) + - **FEAT**: Warning and docs about fullscreen methods outside the mobile platforms ([#3419](https://github.com/flame-engine/flame/issues/3419)). ([994e098b](https://github.com/flame-engine/flame/commit/994e098bd699a30aa13aed65f2bd0ab7254ad779)) + - **FEAT**: Add baseColor to Shadow3DDecorator ([#3375](https://github.com/flame-engine/flame/issues/3375)). ([b5d7ee07](https://github.com/flame-engine/flame/commit/b5d7ee0752ee1f2dddf1da4ac817f138296e1c96)) + ## 1.22.0 - **FIX**: Remove extra `implements SizeProvider`s ([#3358](https://github.com/flame-engine/flame/issues/3358)). ([47ba0d87](https://github.com/flame-engine/flame/commit/47ba0d8738b101ed59781f8ba384cf05a16d65f1)) diff --git a/packages/flame/benchmark/main.dart b/packages/flame/benchmark/main.dart new file mode 100644 index 00000000000..cc6d8f98da8 --- /dev/null +++ b/packages/flame/benchmark/main.dart @@ -0,0 +1,5 @@ +import 'update_components_benchmark.dart'; + +Future main() async { + await UpdateComponentsBenchmark.main(); +} diff --git a/packages/flame/benchmark/update_components_benchmark.dart b/packages/flame/benchmark/update_components_benchmark.dart new file mode 100644 index 00000000000..05667491d17 --- /dev/null +++ b/packages/flame/benchmark/update_components_benchmark.dart @@ -0,0 +1,96 @@ +import 'dart:math'; + +import 'package:benchmark_harness/benchmark_harness.dart'; +import 'package:flame/components.dart'; +import 'package:flame/game.dart'; + +const _amountComponents = 20; +const _amountTicks = 1000; +const _amountInputs = 100; + +class UpdateComponentsBenchmark extends AsyncBenchmarkBase { + final Random random; + + late final FlameGame _game; + late final List<_BenchmarkComponent> _components; + late final List _dts; + late final Set _inputTicks; + + UpdateComponentsBenchmark(this.random) + : super('Updating Components Benchmark'); + + static Future main() async { + final r = Random(69420); + await UpdateComponentsBenchmark(r).report(); + } + + @override + Future setup() async { + _game = FlameGame(); + await _game.addAll( + List.generate(_amountComponents, _BenchmarkComponent.new), + ); + + await _game.ready(); + + _components = + _game.children.whereType<_BenchmarkComponent>().toList(growable: false); + + _dts = List.generate(_amountTicks, (_) => random.nextDouble()); + _inputTicks = List.generate( + _amountInputs, + (_) => random.nextInt(_amountTicks), + ).toSet(); + } + + @override + Future exercise() async { + for (final (idx, dt) in _dts.indexed) { + if (_inputTicks.contains(idx)) { + _components[random.nextInt(_amountComponents)].input( + xDirection: random.nextInt(3) - 1, + doJump: random.nextBool(), + ); + } + _game.update(dt); + } + } +} + +class _BenchmarkComponent extends PositionComponent { + static const _groundY = -20.0; + + final int id; + final Vector2 velocity = Vector2.zero(); + + _BenchmarkComponent(this.id); + + void input({ + required int xDirection, + required bool doJump, + }) { + // move x + velocity.x = xDirection * 100; + + // jump + if (position.y == _groundY) { + velocity.y -= 100; + } + } + + @override + void update(double dt) { + super.update(dt); + + position.add(velocity * dt); + velocity.add(Vector2(0, 10 * dt)); + + if (position.y > _groundY) { + position.y = _groundY; + velocity.setValues(0, 0); + } + } + + @override + String toString() => '[Component $id]'; +} diff --git a/packages/flame/example/pubspec.yaml b/packages/flame/example/pubspec.yaml index dd80da314ab..17660d65653 100644 --- a/packages/flame/example/pubspec.yaml +++ b/packages/flame/example/pubspec.yaml @@ -8,7 +8,7 @@ environment: flutter: ">=3.24.0" dependencies: - flame: ^1.22.0 + flame: ^1.23.0 flutter: sdk: flutter diff --git a/packages/flame/lib/src/components/core/component.dart b/packages/flame/lib/src/components/core/component.dart index 022ecd1f304..6854bff4713 100644 --- a/packages/flame/lib/src/components/core/component.dart +++ b/packages/flame/lib/src/components/core/component.dart @@ -633,7 +633,7 @@ class Component { _clearRemovingBit(); } game.enqueueMove(child, this); - } else if (isMounted && !isRemoving && !child.isMounted) { + } else if (isMounted && !child.isMounted) { child._parent = this; game.enqueueAdd(child, this); } else { @@ -848,6 +848,12 @@ class Component { } else { if (parent.isMounted && !isLoading) { _startLoading(); + } else if (parent.isRemoved) { + // This case happens when the child is added to a parent that is being + // removed in the same tick. + _parent = parent; + parent.children.add(this); + return LifecycleEventStatus.done; } return LifecycleEventStatus.block; } diff --git a/packages/flame/lib/src/components/input/button_component.dart b/packages/flame/lib/src/components/input/button_component.dart index 3e96c15b5c8..81bf1930eca 100644 --- a/packages/flame/lib/src/components/input/button_component.dart +++ b/packages/flame/lib/src/components/input/button_component.dart @@ -45,6 +45,9 @@ class ButtonComponent extends PositionComponent with TapCallbacks { button != null, 'The button has to either be passed in as an argument or set in onLoad', ); + if (size.isZero()) { + size = button!.size; + } if (!contains(button!)) { add(button!); } diff --git a/packages/flame/lib/src/components/input/sprite_button_component.dart b/packages/flame/lib/src/components/input/sprite_button_component.dart index 721497c3b9c..97eba006f00 100644 --- a/packages/flame/lib/src/components/input/sprite_button_component.dart +++ b/packages/flame/lib/src/components/input/sprite_button_component.dart @@ -65,6 +65,9 @@ class SpriteButtonComponent extends SpriteGroupComponent _button != null, 'The button sprite has to be set either in onLoad or in the constructor', ); + if (size.isZero()) { + size = _button!.originalSize; + } sprites = { ButtonState.up: _button!, ButtonState.down: buttonDown, diff --git a/packages/flame/lib/src/device.dart b/packages/flame/lib/src/device.dart index 8be513ecd86..62e89796945 100644 --- a/packages/flame/lib/src/device.dart +++ b/packages/flame/lib/src/device.dart @@ -1,5 +1,7 @@ import 'dart:async'; +import 'dart:io'; +import 'package:flutter/foundation.dart'; import 'package:flutter/services.dart'; /// Provides methods for controlling the device (e.g. setting the screen to @@ -7,11 +9,32 @@ import 'package:flutter/services.dart'; /// /// To use this class, access it via Flame.device. class Device { + void _warnIfDesktop(String source) { + assert(() { + if (!kIsWeb && + (Platform.isMacOS || Platform.isWindows || Platform.isLinux)) { + // ignore: avoid_print + print( + 'Warning: $source is not supported on desktop platforms. ' + 'It will be a no-op.', + ); + } + return true; + }()); + } + /// Sets the app to be full-screen (no buttons, bar or notifications on top). Future fullScreen() { + _warnIfDesktop('fullScreen'); return SystemChrome.setEnabledSystemUIMode(SystemUiMode.immersiveSticky); } + /// Restore the UI mode to the default ([SystemUiMode.edgeToEdge). + Future restoreFullscreen() { + _warnIfDesktop('restoreFullscreen'); + return SystemChrome.setEnabledSystemUIMode(SystemUiMode.edgeToEdge); + } + /// Sets the preferred orientation (landscape or portrait) for the app. /// /// When it opens, it will automatically change orientation to the preferred diff --git a/packages/flame/lib/src/extensions/color.dart b/packages/flame/lib/src/extensions/color.dart index 2cfb16c2b8b..4c78ae28ed8 100644 --- a/packages/flame/lib/src/extensions/color.dart +++ b/packages/flame/lib/src/extensions/color.dart @@ -1,6 +1,8 @@ import 'dart:math'; import 'dart:ui'; +import 'package:flutter/painting.dart' show HSLColor; + export 'dart:ui' show Color; extension ColorExtension on Color { @@ -12,13 +14,12 @@ extension ColorExtension on Color { Color darken(double amount) { assert(amount >= 0 && amount <= 1); - final f = 1 - amount; - return Color.fromARGB( - a ~/ 255, - (r * f).round(), - (g * f).round(), - (b * f).round(), - ); + final hsl = HSLColor.fromColor(this); + return hsl + .withLightness( + clampDouble(hsl.lightness * amount, 0.0, 1.0), + ) + .toColor(); } /// Brighten the shade of the color by the [amount]. @@ -29,12 +30,12 @@ extension ColorExtension on Color { Color brighten(double amount) { assert(amount >= 0 && amount <= 1); - return Color.fromARGB( - a ~/ 255, - (r + ((1.0 - r) * amount)) ~/ 255, - (g + ((1.0 - g) * amount)) ~/ 255, - (b + ((1.0 - b) * amount)) ~/ 255, - ); + final hsl = HSLColor.fromColor(this); + return hsl + .withLightness( + clampDouble(hsl.lightness + (1 - hsl.lightness) * amount, 0.0, 1.0), + ) + .toColor(); } // used as an example hex color code on the documentation below diff --git a/packages/flame/lib/src/extensions/image.dart b/packages/flame/lib/src/extensions/image.dart index d6fe177f08d..20c345f8d66 100644 --- a/packages/flame/lib/src/extensions/image.dart +++ b/packages/flame/lib/src/extensions/image.dart @@ -37,6 +37,45 @@ extension ImageExtension on Image { return (await toByteData())!.buffer.asUint8List(); } + Future transformPixels( + Color Function(Color) transform, { + bool reversePremultipliedAlpha = true, + }) async { + final pixelData = await pixelsInUint8(); + final newPixelData = Uint8List(pixelData.length); + + for (var i = 0; i < pixelData.length; i += 4) { + final r = pixelData[i + 0] / 255; + final g = pixelData[i + 1] / 255; + final b = pixelData[i + 2] / 255; + final a = pixelData[i + 3] / 255; + + final d = a == 0 || !reversePremultipliedAlpha ? 1 : a; + + // Reverse the pre-multiplied alpha. + final color = Color.from( + alpha: a, + red: r / d, + green: g / d, + blue: b / d, + ); + + final newColor = a == 0 ? color : transform(color); + + final newR = newColor.r; + final newG = newColor.g; + final newB = newColor.b; + + // Pre-multiply the alpha back into the new color. + newPixelData[i + 0] = (newR * d * 255).round(); + newPixelData[i + 1] = (newG * d * 255).round(); + newPixelData[i + 2] = (newB * d * 255).round(); + newPixelData[i + 3] = pixelData[i + 3]; + } + + return fromPixels(newPixelData, width, height); + } + /// Returns the bounding [Rect] of the image. Rect getBoundingRect() => Vector2.zero() & size; @@ -46,51 +85,31 @@ extension ImageExtension on Image { /// Change each pixel's color to be darker and return a new [Image]. /// /// The [amount] is a double value between 0 and 1. - Future darken(double amount) async { + Future darken( + double amount, { + bool reversePremultipliedAlpha = true, + }) async { assert(amount >= 0 && amount <= 1); - final pixelData = await pixelsInUint8(); - final newPixelData = Uint8List(pixelData.length); - - for (var i = 0; i < pixelData.length; i += 4) { - final color = Color.fromARGB( - pixelData[i + 3], - pixelData[i + 0], - pixelData[i + 1], - pixelData[i + 2], - ).darken(amount); - - newPixelData[i] = color.r ~/ 255; - newPixelData[i + 1] = color.g ~/ 255; - newPixelData[i + 2] = color.b ~/ 255; - newPixelData[i + 3] = color.a ~/ 255; - } - return fromPixels(newPixelData, width, height); + return transformPixels( + (color) => color.darken(amount), + reversePremultipliedAlpha: reversePremultipliedAlpha, + ); } /// Change each pixel's color to be brighter and return a new [Image]. /// /// The [amount] is a double value between 0 and 1. - Future brighten(double amount) async { + Future brighten( + double amount, { + bool reversePremultipliedAlpha = false, + }) async { assert(amount >= 0 && amount <= 1); - final pixelData = await pixelsInUint8(); - final newPixelData = Uint8List(pixelData.length); - - for (var i = 0; i < pixelData.length; i += 4) { - final color = Color.fromARGB( - pixelData[i + 3], - pixelData[i + 0], - pixelData[i + 1], - pixelData[i + 2], - ).brighten(amount); - - newPixelData[i] = color.r ~/ 255; - newPixelData[i + 1] = color.g ~/ 255; - newPixelData[i + 2] = color.b ~/ 255; - newPixelData[i + 3] = color.a ~/ 255; - } - return fromPixels(newPixelData, width, height); + return transformPixels( + (color) => color.brighten(amount), + reversePremultipliedAlpha: reversePremultipliedAlpha, + ); } /// Resizes this image to the given [newSize]. diff --git a/packages/flame/lib/src/text/common/utils.dart b/packages/flame/lib/src/text/common/utils.dart index 03e6b0a2782..6f19cd2d109 100644 --- a/packages/flame/lib/src/text/common/utils.dart +++ b/packages/flame/lib/src/text/common/utils.dart @@ -1,6 +1,5 @@ import 'dart:math'; -import 'package:flame/src/text/elements/group_element.dart'; import 'package:flame/text.dart'; import 'package:meta/meta.dart'; diff --git a/packages/flame/lib/src/text/nodes/column_node.dart b/packages/flame/lib/src/text/nodes/column_node.dart index 91906a22a82..2185fb77ab2 100644 --- a/packages/flame/lib/src/text/nodes/column_node.dart +++ b/packages/flame/lib/src/text/nodes/column_node.dart @@ -1,5 +1,4 @@ import 'package:flame/src/text/common/utils.dart'; -import 'package:flame/src/text/elements/group_element.dart'; import 'package:flame/text.dart'; import 'package:meta/meta.dart'; diff --git a/packages/flame/lib/src/text/nodes/document_root.dart b/packages/flame/lib/src/text/nodes/document_root.dart index 569cbf0661c..b8e69338881 100644 --- a/packages/flame/lib/src/text/nodes/document_root.dart +++ b/packages/flame/lib/src/text/nodes/document_root.dart @@ -1,7 +1,6 @@ import 'dart:math'; import 'package:flame/src/text/common/utils.dart'; -import 'package:flame/src/text/elements/group_element.dart'; import 'package:flame/text.dart'; import 'package:flutter/painting.dart'; diff --git a/packages/flame/lib/src/text/nodes/group_text_node.dart b/packages/flame/lib/src/text/nodes/group_text_node.dart index 725c149349d..1cdfe97aaeb 100644 --- a/packages/flame/lib/src/text/nodes/group_text_node.dart +++ b/packages/flame/lib/src/text/nodes/group_text_node.dart @@ -1,4 +1,3 @@ -import 'package:flame/src/text/elements/group_text_element.dart'; import 'package:flame/src/text/nodes/inline_text_node.dart'; import 'package:flame/text.dart'; diff --git a/packages/flame/lib/src/text/nodes/strikethrough_text_node.dart b/packages/flame/lib/src/text/nodes/strikethrough_text_node.dart new file mode 100644 index 00000000000..5929a6b508c --- /dev/null +++ b/packages/flame/lib/src/text/nodes/strikethrough_text_node.dart @@ -0,0 +1,35 @@ +import 'dart:ui'; + +import 'package:flame/src/text/nodes/inline_text_node.dart'; +import 'package:flame/text.dart'; + +/// An [InlineTextNode] representing a text with a strikethrough line. +/// +/// The exact styling can be controlled by the `strikethroughText` property +/// on the document style. +class StrikethroughTextNode extends InlineTextNode { + StrikethroughTextNode(this.child); + + StrikethroughTextNode.simple(String text) : child = PlainTextNode(text); + + StrikethroughTextNode.group(List children) + : child = GroupTextNode(children); + + final InlineTextNode child; + + static final defaultStyle = InlineTextStyle( + decoration: TextDecoration.lineThrough, + ); + + @override + void fillStyles(DocumentStyle stylesheet, InlineTextStyle parentTextStyle) { + style = FlameTextStyle.merge( + parentTextStyle, + stylesheet.strikethroughText, + )!; + child.fillStyles(stylesheet, style); + } + + @override + TextNodeLayoutBuilder get layoutBuilder => child.layoutBuilder; +} diff --git a/packages/flame/lib/src/text/nodes/text_block_node.dart b/packages/flame/lib/src/text/nodes/text_block_node.dart index 3ea8dfe5e13..967a1369c1f 100644 --- a/packages/flame/lib/src/text/nodes/text_block_node.dart +++ b/packages/flame/lib/src/text/nodes/text_block_node.dart @@ -1,7 +1,6 @@ import 'dart:ui'; import 'package:flame/src/text/common/utils.dart'; -import 'package:flame/src/text/elements/group_element.dart'; import 'package:flame/text.dart'; import 'package:meta/meta.dart'; diff --git a/packages/flame/lib/src/text/styles/document_style.dart b/packages/flame/lib/src/text/styles/document_style.dart index bf0a274f1cc..d11e8e105fd 100644 --- a/packages/flame/lib/src/text/styles/document_style.dart +++ b/packages/flame/lib/src/text/styles/document_style.dart @@ -21,6 +21,7 @@ class DocumentStyle extends FlameTextStyle { InlineTextStyle? boldText, InlineTextStyle? italicText, InlineTextStyle? codeText, + InlineTextStyle? strikethroughText, BlockStyle? paragraph, BlockStyle? header1, BlockStyle? header2, @@ -33,6 +34,10 @@ class DocumentStyle extends FlameTextStyle { _italicText = FlameTextStyle.merge(ItalicTextNode.defaultStyle, italicText), _codeText = FlameTextStyle.merge(CodeTextNode.defaultStyle, codeText), + _strikethroughText = FlameTextStyle.merge( + StrikethroughTextNode.defaultStyle, + strikethroughText, + ), _paragraph = FlameTextStyle.merge(ParagraphNode.defaultStyle, paragraph), _header1 = FlameTextStyle.merge(HeaderNode.defaultStyleH1, header1), @@ -46,6 +51,7 @@ class DocumentStyle extends FlameTextStyle { final InlineTextStyle? _boldText; final InlineTextStyle? _italicText; final InlineTextStyle? _codeText; + final InlineTextStyle? _strikethroughText; final BlockStyle? _paragraph; final BlockStyle? _header1; final BlockStyle? _header2; @@ -98,6 +104,7 @@ class DocumentStyle extends FlameTextStyle { InlineTextStyle get boldText => _boldText!; InlineTextStyle get italicText => _italicText!; InlineTextStyle get codeText => _codeText!; + InlineTextStyle get strikethroughText => _strikethroughText!; /// Style for [ParagraphNode]s. BlockStyle get paragraph => _paragraph!; @@ -122,6 +129,10 @@ class DocumentStyle extends FlameTextStyle { boldText: FlameTextStyle.merge(_boldText, other.boldText), italicText: FlameTextStyle.merge(_italicText, other.italicText), codeText: FlameTextStyle.merge(_codeText, other.codeText), + strikethroughText: FlameTextStyle.merge( + _strikethroughText, + other.strikethroughText, + ), background: merge(background, other.background) as BackgroundStyle?, paragraph: merge(paragraph, other.paragraph) as BlockStyle?, header1: merge(header1, other.header1) as BlockStyle?, diff --git a/packages/flame/lib/text.dart b/packages/flame/lib/text.dart index ad08ebefde4..738f07ff718 100644 --- a/packages/flame/lib/text.dart +++ b/packages/flame/lib/text.dart @@ -4,6 +4,8 @@ export 'src/text/common/glyph.dart' show Glyph; export 'src/text/common/line_metrics.dart' show LineMetrics; export 'src/text/common/sprite_font.dart' show SpriteFont; export 'src/text/elements/block_element.dart' show BlockElement; +export 'src/text/elements/group_element.dart' show GroupElement; +export 'src/text/elements/group_text_element.dart' show GroupTextElement; export 'src/text/elements/inline_text_element.dart' show InlineTextElement; export 'src/text/elements/rect_element.dart' show RectElement; export 'src/text/elements/rrect_element.dart' show RRectElement; @@ -23,6 +25,7 @@ export 'src/text/nodes/inline_text_node.dart' show InlineTextNode; export 'src/text/nodes/italic_text_node.dart' show ItalicTextNode; export 'src/text/nodes/paragraph_node.dart' show ParagraphNode; export 'src/text/nodes/plain_text_node.dart' show PlainTextNode; +export 'src/text/nodes/strikethrough_text_node.dart' show StrikethroughTextNode; export 'src/text/nodes/text_block_node.dart' show TextBlockNode; export 'src/text/nodes/text_node.dart' show TextNode; export 'src/text/renderers/sprite_font_renderer.dart' show SpriteFontRenderer; diff --git a/packages/flame/pubspec.yaml b/packages/flame/pubspec.yaml index f942547caad..d20affb8990 100644 --- a/packages/flame/pubspec.yaml +++ b/packages/flame/pubspec.yaml @@ -1,6 +1,6 @@ name: flame description: A minimalist Flutter game engine, provides a nice set of somewhat independent modules you can choose from. -version: 1.22.0 +version: 1.23.0 homepage: https://github.com/flame-engine/flame funding: - https://opencollective.com/blue-fire @@ -25,13 +25,14 @@ dependencies: vector_math: ^2.1.4 dev_dependencies: + benchmark_harness: ^2.3.1 canvas_test: ^0.2.0 dartdoc: ^8.0.8 flame_lint: ^1.2.1 - flame_test: ^1.17.3 + flame_test: ^1.17.4 flutter_test: sdk: flutter - mocktail: ^1.0.3 + mocktail: ^1.0.4 test: any screenshots: diff --git a/packages/flame/test/components/component_test.dart b/packages/flame/test/components/component_test.dart index 3cc4f69e4c9..aede46b867b 100644 --- a/packages/flame/test/components/component_test.dart +++ b/packages/flame/test/components/component_test.dart @@ -646,7 +646,13 @@ void main() { // Timeout is added because processLifecycleEvents of ComponentTreeRoot // gets blocked in such cases. - expect(game.ready().timeout(const Duration(seconds: 2)), completes); + + // Expect the ready future to complete + await expectLater( + game.ready().timeout(const Duration(seconds: 2)), + completes, + ); + expect(game.hasLifecycleEvents, isFalse); // Adding the parent again should eventually mount the child as well. await game.add(parent); diff --git a/packages/flame/test/extensions/image_extension_test.dart b/packages/flame/test/extensions/image_extension_test.dart index e2f0cc5aee1..919866dd715 100644 --- a/packages/flame/test/extensions/image_extension_test.dart +++ b/packages/flame/test/extensions/image_extension_test.dart @@ -54,53 +54,66 @@ void main() { }); test('darken colors each pixel darker', () async { - const originalColor = Color.fromARGB(193, 135, 73, 73); + const transparentColor = Color.fromARGB(0, 255, 0, 255); + const originalColor = Color.fromARGB(255, 135, 73, 73); final pixels = Uint8List.fromList( List.generate( 100 * 4, - (index) => _colorBit(index, originalColor), + (index) => _colorBit( + index, + index < 200 ? transparentColor : originalColor, + ), ), ); final image = await ImageExtension.fromPixels(pixels, 10, 10); const darkenAmount = 0.5; - final originalDarkenImage = await image.darken(darkenAmount); - final originalDarkenPixelsList = - await originalDarkenImage.pixelsInUint8(); + final actualDarkenedImage = await image.darken(darkenAmount); + final actualDarkenedPixels = await actualDarkenedImage.pixelsInUint8(); - final darkenColor = originalColor.darken(darkenAmount); + final darkenedColor = originalColor.darken(darkenAmount); final expectedDarkenPixels = Uint8List.fromList( List.generate( 100 * 4, - (index) => _colorBit(index, darkenColor), + (index) => _colorBit( + index, + index < 200 ? transparentColor : darkenedColor, + ), ), ); - expect(originalDarkenPixelsList, expectedDarkenPixels); + expect(actualDarkenedPixels, expectedDarkenPixels); }); test('brighten colors each pixel brighter', () async { - const originalColor = Color.fromARGB(193, 135, 73, 73); + const transparentColor = Color.fromARGB(0, 255, 0, 255); + const originalColor = Color.fromARGB(255, 255, 0, 0); + final pixels = Uint8List.fromList( List.generate( 100 * 4, - (index) => _colorBit(index, originalColor), + (index) => _colorBit( + index, + index < 200 ? transparentColor : originalColor, + ), ), ); final image = await ImageExtension.fromPixels(pixels, 10, 10); const brightenAmount = 0.5; - final originalBrightenImage = await image.brighten(brightenAmount); - final originalBrightenPixelsList = - await originalBrightenImage.pixelsInUint8(); + final brightenedImage = await image.brighten(brightenAmount); + final actualBrightenedPixels = await brightenedImage.pixelsInUint8(); final brightenColor = originalColor.brighten(brightenAmount); final expectedBrightenPixels = Uint8List.fromList( List.generate( 100 * 4, - (index) => _colorBit(index, brightenColor), + (index) => _colorBit( + index, + index < 200 ? transparentColor : brightenColor, + ), ), ); - expect(originalBrightenPixelsList, expectedBrightenPixels); + expect(actualBrightenedPixels, expectedBrightenPixels); }); test('resize resizes the image', () async { @@ -121,10 +134,10 @@ void main() { int _colorBit(int index, Color color) { return switch (index % 4) { - 0 => color.r ~/ 255, - 1 => color.g ~/ 255, - 2 => color.b ~/ 255, - 3 => color.a ~/ 255, + 0 => (color.r * 255).round(), + 1 => (color.g * 255).round(), + 2 => (color.b * 255).round(), + 3 => (color.a * 255).round(), _ => throw UnimplementedError(), }; } diff --git a/packages/flame/test/extensions/paint_test.dart b/packages/flame/test/extensions/paint_test.dart index 8f735ecdb81..7f5ad8f0fc1 100644 --- a/packages/flame/test/extensions/paint_test.dart +++ b/packages/flame/test/extensions/paint_test.dart @@ -32,7 +32,7 @@ void main() { paint.brighten(brightenAmount); - expect( + expectColor( paint.color, brightenBaseColor, reason: "Paint's color does not match brighten color", diff --git a/packages/flame/test/text/text_element_test.dart b/packages/flame/test/text/text_element_test.dart index b3b842520a9..b8ccdeae484 100644 --- a/packages/flame/test/text/text_element_test.dart +++ b/packages/flame/test/text/text_element_test.dart @@ -1,4 +1,3 @@ -import 'package:flame/src/text/elements/group_element.dart'; import 'package:flame/text.dart'; import 'package:flutter/rendering.dart'; import 'package:test/test.dart'; diff --git a/packages/flame/test/text/text_style_test.dart b/packages/flame/test/text/text_style_test.dart index 8e90c10dbee..850eb50d1a3 100644 --- a/packages/flame/test/text/text_style_test.dart +++ b/packages/flame/test/text/text_style_test.dart @@ -1,5 +1,3 @@ -import 'package:flame/src/text/elements/group_element.dart'; -import 'package:flame/src/text/elements/group_text_element.dart'; import 'package:flame/text.dart'; import 'package:flutter/rendering.dart'; import 'package:test/test.dart'; diff --git a/packages/flame_3d/CHANGELOG.md b/packages/flame_3d/CHANGELOG.md index 956107fedd4..c90ddc22c47 100644 --- a/packages/flame_3d/CHANGELOG.md +++ b/packages/flame_3d/CHANGELOG.md @@ -1,3 +1,55 @@ +## 0.1.0-dev.4 + +> Note: This release has breaking changes. + + - **REFACTOR**: Fix lint issues from latest flutter release ([#3390](https://github.com/flame-engine/flame/issues/3390)). ([978ad31b](https://github.com/flame-engine/flame/commit/978ad31b429d1801097b0db385a600c85a157867)) + - **FIX**: Use saner default value for camera's target ([#3238](https://github.com/flame-engine/flame/issues/3238)). ([78522c62](https://github.com/flame-engine/flame/commit/78522c624d846c827a1c0d7377837e04a30ba4e7)) + - **FIX**: Use saner default value for camera's target ([#3238](https://github.com/flame-engine/flame/issues/3238)). ([99ca355b](https://github.com/flame-engine/flame/commit/99ca355b3d4a3e9c7677454dc9bc2c874ee2e4a9)) + - **FIX**: Fix albedo texture binding on shader ([#3400](https://github.com/flame-engine/flame/issues/3400)). ([c380c91f](https://github.com/flame-engine/flame/commit/c380c91f7a7e22ab71c3617c0386159861a64abc)) + - **FIX**: Make build_shaders script compatible with other platforms [flame_3d] ([#3395](https://github.com/flame-engine/flame/issues/3395)). ([38331309](https://github.com/flame-engine/flame/commit/38331309ca5ee609e85422ee9d740569a35e5e9e)) + - **FIX**: Make `flame_3d` work with latest stable ([#3387](https://github.com/flame-engine/flame/issues/3387)). ([f940d3f9](https://github.com/flame-engine/flame/commit/f940d3f9420d3ce001f47a9155c582b8b4cd1dcb)) + - **FIX**: MeshComponent.bind should bind to the provided device ([#3278](https://github.com/flame-engine/flame/issues/3278)). ([d06b4ce6](https://github.com/flame-engine/flame/commit/d06b4ce6935987705447772f912719c405d39c9e)) + - **FIX**: Improve behavior of Quaternion.slerp function [flame_3d] ([#3306](https://github.com/flame-engine/flame/issues/3306)). ([8872a45a](https://github.com/flame-engine/flame/commit/8872a45a1b49d7ba7688d62ca25b2a8d31c495cb)) + - **FIX**: Improve quaternion slerp logic to avoid NaN edge cases ([#3303](https://github.com/flame-engine/flame/issues/3303)). ([712b03fb](https://github.com/flame-engine/flame/commit/712b03fbe176cf238a3780aee641254436520366)) + - **FIX**: Make the `build_shader` script work for windows ([#3402](https://github.com/flame-engine/flame/issues/3402)). ([ce7822a0](https://github.com/flame-engine/flame/commit/ce7822a0d0c5ac1c766635a5cf2c242d5e5f98ec)) + - **FIX**: MeshComponent.bind should bind to the provided device ([#3278](https://github.com/flame-engine/flame/issues/3278)). ([3ae3ef54](https://github.com/flame-engine/flame/commit/3ae3ef5476fa5f9ead7069efeee35cc31c0e9dd2)) + - **FIX**: Fix typo on loadTexture ([#3253](https://github.com/flame-engine/flame/issues/3253)). ([3a20a8cd](https://github.com/flame-engine/flame/commit/3a20a8cd61543aad21c1015de5c31ec1cbe71aed)) + - **FIX**: Improve behavior of Quaternion.slerp function [flame_3d] ([#3306](https://github.com/flame-engine/flame/issues/3306)). ([b9d6a0f1](https://github.com/flame-engine/flame/commit/b9d6a0f1d34e009cd91ae9d2ab0eed09b546d110)) + - **FIX**: Improve quaternion slerp logic to avoid NaN edge cases ([#3303](https://github.com/flame-engine/flame/issues/3303)). ([565b68b9](https://github.com/flame-engine/flame/commit/565b68b9da52d44281e93f9ae8617f9dbe9551f3)) + - **FIX**: Fix typo on loadTexture ([#3253](https://github.com/flame-engine/flame/issues/3253)). ([3d1f1437](https://github.com/flame-engine/flame/commit/3d1f143700506467798e030450227d8029b74ef2)) + - **FIX**: Add missing export for CylinderMesh [flame_3d] ([#3256](https://github.com/flame-engine/flame/issues/3256)). ([d8fb65c1](https://github.com/flame-engine/flame/commit/d8fb65c158a3cce442972fb24f55fb522729085f)) + - **FIX**: Add missing export for CylinderMesh [flame_3d] ([#3256](https://github.com/flame-engine/flame/issues/3256)). ([d517c169](https://github.com/flame-engine/flame/commit/d517c169ed9b4d4457df6ac1ae363277577597fa)) + - **FEAT**: More Lights! [flame_3d] ([#3250](https://github.com/flame-engine/flame/issues/3250)). ([5c508e81](https://github.com/flame-engine/flame/commit/5c508e81bddfb17857355da80e57f1ac77ab368d)) + - **FEAT**(flame_3d): Add helpful extension functions to Vector ([#3141](https://github.com/flame-engine/flame/issues/3141)). ([92195989](https://github.com/flame-engine/flame/commit/9219598904131d8fceba8d1ad980bea2805e3515)) + - **FEAT**: Add CylinderMesh [flame_3d] ([#3239](https://github.com/flame-engine/flame/issues/3239)). ([d5de1733](https://github.com/flame-engine/flame/commit/d5de1733c64c4fbaeee83089a3b0f9a3fbb3355d)) + - **FEAT**: Refactor shader uniform binding to support shader arrays [flame_3d] ([#3282](https://github.com/flame-engine/flame/issues/3282)). ([edae1662](https://github.com/flame-engine/flame/commit/edae166252a519d38496bb6bf7c84fe9f401b8d4)) + - **FEAT**(flame_3d): Make shader api more useful ([#3085](https://github.com/flame-engine/flame/issues/3085)). ([fe2e4f20](https://github.com/flame-engine/flame/commit/fe2e4f20195b453268b34e589616343fdce6201a)) + - **FEAT**(flame_3d): Make shader api more useful ([#3085](https://github.com/flame-engine/flame/issues/3085)). ([4042d300](https://github.com/flame-engine/flame/commit/4042d3002ce619bf6b8597aa7dc17a803bc57c69)) + - **FEAT**: Add more useful extensions to VectorN and Quaternion [flame_3d] ([#3296](https://github.com/flame-engine/flame/issues/3296)). ([f5f03e5e](https://github.com/flame-engine/flame/commit/f5f03e5ed7095ede713727d6bbab39db0505e7bf)) + - **FEAT**: Expose vector classes on core file [flame_3d] ([#3211](https://github.com/flame-engine/flame/issues/3211)). ([8f403ac2](https://github.com/flame-engine/flame/commit/8f403ac23ae7cdf5343652c30f9c0ee71d627b0a)) + - **FEAT**(flame_3d): Add helpful extension functions to Vector ([#3141](https://github.com/flame-engine/flame/issues/3141)). ([39e15fb3](https://github.com/flame-engine/flame/commit/39e15fb30256cbfaa86f4d7b8e3453c52942d1a5)) + - **FEAT**: Add CylinderMesh [flame_3d] ([#3239](https://github.com/flame-engine/flame/issues/3239)). ([01872fb6](https://github.com/flame-engine/flame/commit/01872fb6e45e10dc380fee7a176a8b37eeaef880)) + - **FEAT**(flame_3d): initial implementation of 3D support ([#3012](https://github.com/flame-engine/flame/issues/3012)). ([acb8e6fc](https://github.com/flame-engine/flame/commit/acb8e6fc07592a7df041512ed9e033b33eda8799)) + - **FEAT**: Support skeletal animation basics [flame_3d] ([#3291](https://github.com/flame-engine/flame/issues/3291)). ([9c0d1500](https://github.com/flame-engine/flame/commit/9c0d15006047597097dc0e054c1e03a04491cff9)) + - **FEAT**: Add normals to surfaces when not specified ([#3257](https://github.com/flame-engine/flame/issues/3257)). ([1dd21d7d](https://github.com/flame-engine/flame/commit/1dd21d7d6d4f58c9ac54a38363ee2fd0978a9d0c)) + - **FEAT**(flame_3d): initial implementation of 3D support ([#3012](https://github.com/flame-engine/flame/issues/3012)). ([0242e1dd](https://github.com/flame-engine/flame/commit/0242e1dd12a9b50a411d895b662f9df33536f6d9)) + - **FEAT**: Support skeletal animation basics [flame_3d] ([#3291](https://github.com/flame-engine/flame/issues/3291)). ([12927e41](https://github.com/flame-engine/flame/commit/12927e4100a7b4b46e4218db6792d25be1623f88)) + - **FEAT**: Add more useful extensions to VectorN and Quaternion [flame_3d] ([#3296](https://github.com/flame-engine/flame/issues/3296)). ([9cb95279](https://github.com/flame-engine/flame/commit/9cb9527909a4faa38609d25ebd7463f1e2e1a1ab)) + - **FEAT**: Make it easier work with the Mesh class [flame_3d] ([#3212](https://github.com/flame-engine/flame/issues/3212)). ([ebf2ee62](https://github.com/flame-engine/flame/commit/ebf2ee62e535fd1d0f499112b314e1d88e59bbc1)) + - **FEAT**: More Lights! [flame_3d] ([#3250](https://github.com/flame-engine/flame/issues/3250)). ([1780630e](https://github.com/flame-engine/flame/commit/1780630e7fcb386a331ba1219c15cb1ae8b139e6)) + - **FEAT**: Add normals to surfaces when not specified ([#3257](https://github.com/flame-engine/flame/issues/3257)). ([844c1d72](https://github.com/flame-engine/flame/commit/844c1d726e04e9c3c5739214720cf26fc62d3f9f)) + - **FEAT**(flame_3d): Fix minor nits on flame_3d ([#3140](https://github.com/flame-engine/flame/issues/3140)). ([11cdfb5e](https://github.com/flame-engine/flame/commit/11cdfb5ebeb62dd1aec2d51fd7fadfbfb17c6da5)) + - **FEAT**: Expose vector classes on core file [flame_3d] ([#3211](https://github.com/flame-engine/flame/issues/3211)). ([c3e68dff](https://github.com/flame-engine/flame/commit/c3e68dffd2e53a8dc8d4d3804c47e956dfc0ebb4)) + - **FEAT**(flame_3d): Fix minor nits on flame_3d ([#3140](https://github.com/flame-engine/flame/issues/3140)). ([b537d20a](https://github.com/flame-engine/flame/commit/b537d20ab65ce0312e9c05ba9156d794234d93e0)) + - **FEAT**: Make it easier work with the Mesh class [flame_3d] ([#3212](https://github.com/flame-engine/flame/issues/3212)). ([7f80b530](https://github.com/flame-engine/flame/commit/7f80b53078c037f81d386a44fa9b749cf7835ffa)) + - **DOCS**: Update docs and comments (flame_3d) ([#3057](https://github.com/flame-engine/flame/issues/3057)). ([14047879](https://github.com/flame-engine/flame/commit/14047879a13e1f13e51ce3411feb7c7962d6d7ee)) + - **DOCS**: Update docs and comments (flame_3d) ([#3057](https://github.com/flame-engine/flame/issues/3057)). ([b5fd457a](https://github.com/flame-engine/flame/commit/b5fd457a6b6bcad73006fc77a538c7e8521178a5)) + - **DOCS**: Update README.md docs to reflect current state of affairs ([#3305](https://github.com/flame-engine/flame/issues/3305)). ([ac3f48ff](https://github.com/flame-engine/flame/commit/ac3f48ffa6527c595035e8a9cc24307343dacb31)) + - **DOCS**: Update wording on README to match newer instructions [flame_3d] ([#3399](https://github.com/flame-engine/flame/issues/3399)). ([9c416cbf](https://github.com/flame-engine/flame/commit/9c416cbfcb4106ab7b1ad14324ca9cb89593b80d)) + - **DOCS**: Update README.md docs to reflect current state of affairs ([#3305](https://github.com/flame-engine/flame/issues/3305)). ([be72daee](https://github.com/flame-engine/flame/commit/be72daee6b92bcef2af3af78c1f64abe94c49d18)) + - **BREAKING** **FEAT**: Allow for custom shaders and materials ([#3384](https://github.com/flame-engine/flame/issues/3384)). ([ae731814](https://github.com/flame-engine/flame/commit/ae73181466c7e32b0e5e9e814f5170310c20f263)) + - **BREAKING** **FEAT**: Refactor the `CameraComponent3D` ([#3394](https://github.com/flame-engine/flame/issues/3394)). ([4a61718d](https://github.com/flame-engine/flame/commit/4a61718d3b8d45d18a74f662f1bf1eb8e6069983)) + ## 0.1.0-dev.3 - **FIX**: Improve behavior of Quaternion.slerp function [flame_3d] ([#3306](https://github.com/flame-engine/flame/issues/3306)). ([b9d6a0f1](https://github.com/flame-engine/flame/commit/b9d6a0f1d34e009cd91ae9d2ab0eed09b546d110)) diff --git a/packages/flame_3d/example/pubspec.yaml b/packages/flame_3d/example/pubspec.yaml index 801cd8c41b7..72d87456f15 100644 --- a/packages/flame_3d/example/pubspec.yaml +++ b/packages/flame_3d/example/pubspec.yaml @@ -7,8 +7,8 @@ environment: sdk: ">=3.4.0 <4.0.0" dependencies: - flame: ^1.16.0 - flame_3d: ^0.1.0-dev.3 + flame: ^1.23.0 + flame_3d: ^0.1.0-dev.4 flutter: sdk: flutter diff --git a/packages/flame_3d/pubspec.yaml b/packages/flame_3d/pubspec.yaml index b0d10c7d56e..46150d80cab 100644 --- a/packages/flame_3d/pubspec.yaml +++ b/packages/flame_3d/pubspec.yaml @@ -1,6 +1,6 @@ name: flame_3d description: Experimental 3D support for the Flame Engine -version: 0.1.0-dev.3 +version: 0.1.0-dev.4 homepage: https://github.com/flame-engine/flame/tree/main/packages/flame_3d funding: - https://opencollective.com/blue-fire @@ -12,7 +12,7 @@ environment: flutter: ">=3.24.0" dependencies: - flame: ^1.16.0 + flame: ^1.23.0 flutter: sdk: flutter flutter_gpu: @@ -23,7 +23,7 @@ dependencies: dev_dependencies: flame_lint: ^1.2.0 - flame_test: ^1.15.3 + flame_test: ^1.17.4 flutter_test: sdk: flutter diff --git a/packages/flame_audio/CHANGELOG.md b/packages/flame_audio/CHANGELOG.md index 78378296628..53dca959b0f 100644 --- a/packages/flame_audio/CHANGELOG.md +++ b/packages/flame_audio/CHANGELOG.md @@ -1,3 +1,7 @@ +## 2.10.7 + + - Update a dependency to the latest release. + ## 2.10.6 - Update a dependency to the latest release. diff --git a/packages/flame_audio/example/pubspec.yaml b/packages/flame_audio/example/pubspec.yaml index 16e7414af81..336b84379b1 100644 --- a/packages/flame_audio/example/pubspec.yaml +++ b/packages/flame_audio/example/pubspec.yaml @@ -9,8 +9,8 @@ environment: sdk: ">=3.4.0 <4.0.0" dependencies: - flame: ^1.22.0 - flame_audio: ^2.10.6 + flame: ^1.23.0 + flame_audio: ^2.10.7 flutter: sdk: flutter diff --git a/packages/flame_audio/pubspec.yaml b/packages/flame_audio/pubspec.yaml index 2fecc8ef710..78d9dbc729d 100644 --- a/packages/flame_audio/pubspec.yaml +++ b/packages/flame_audio/pubspec.yaml @@ -1,7 +1,7 @@ name: flame_audio description: | Audio support for the Flame game engine, basically a thin wrapper around the audioplayers package. -version: 2.10.6 +version: 2.10.7 homepage: https://github.com/flame-engine/flame/tree/main/packages/flame_audio funding: - https://opencollective.com/blue-fire @@ -17,7 +17,7 @@ environment: dependencies: audioplayers: ^6.0.0 - flame: ^1.22.0 + flame: ^1.23.0 flutter: sdk: flutter synchronized: ^3.1.0 @@ -27,4 +27,4 @@ dev_dependencies: flame_lint: ^1.2.1 flutter_test: sdk: flutter - mocktail: ^1.0.3 + mocktail: ^1.0.4 diff --git a/packages/flame_behavior_tree/CHANGELOG.md b/packages/flame_behavior_tree/CHANGELOG.md index e8f91fd1a68..8dd7b13d7f1 100644 --- a/packages/flame_behavior_tree/CHANGELOG.md +++ b/packages/flame_behavior_tree/CHANGELOG.md @@ -1,3 +1,7 @@ +## 0.1.3+4 + + - Update a dependency to the latest release. + ## 0.1.3+3 - Update a dependency to the latest release. diff --git a/packages/flame_behavior_tree/behavior_tree/pubspec.yaml b/packages/flame_behavior_tree/behavior_tree/pubspec.yaml index 4fb1ae06301..f5be42a88e8 100644 --- a/packages/flame_behavior_tree/behavior_tree/pubspec.yaml +++ b/packages/flame_behavior_tree/behavior_tree/pubspec.yaml @@ -15,5 +15,5 @@ dependencies: dev_dependencies: flame_lint: ^1.2.1 - mocktail: ^1.0.3 + mocktail: ^1.0.4 test: any diff --git a/packages/flame_behavior_tree/example/pubspec.yaml b/packages/flame_behavior_tree/example/pubspec.yaml index e0d7e779c0d..f77773598ae 100644 --- a/packages/flame_behavior_tree/example/pubspec.yaml +++ b/packages/flame_behavior_tree/example/pubspec.yaml @@ -11,8 +11,8 @@ environment: sdk: ">=3.4.0 <4.0.0" dependencies: - flame: ^1.22.0 - flame_behavior_tree: ^0.1.3+3 + flame: ^1.23.0 + flame_behavior_tree: ^0.1.3+4 flutter: sdk: flutter diff --git a/packages/flame_behavior_tree/pubspec.yaml b/packages/flame_behavior_tree/pubspec.yaml index b4fbe53c29a..490300dd72a 100644 --- a/packages/flame_behavior_tree/pubspec.yaml +++ b/packages/flame_behavior_tree/pubspec.yaml @@ -1,6 +1,6 @@ name: flame_behavior_tree description: A bridge package that integrates behavior_tree package with flame. -version: 0.1.3+3 +version: 0.1.3+4 homepage: https://github.com/flame-engine/flame/tree/main/packages/flame_behavior_tree funding: - https://opencollective.com/blue-fire @@ -15,13 +15,13 @@ environment: dependencies: behavior_tree: ^0.1.3 - flame: ^1.22.0 + flame: ^1.23.0 flutter: sdk: flutter dev_dependencies: flame_lint: ^1.2.1 - flame_test: ^1.17.3 + flame_test: ^1.17.4 flutter_test: sdk: flutter - mocktail: ^1.0.3 + mocktail: ^1.0.4 diff --git a/packages/flame_bloc/CHANGELOG.md b/packages/flame_bloc/CHANGELOG.md index a2b5e49accd..a74d0a8cb21 100644 --- a/packages/flame_bloc/CHANGELOG.md +++ b/packages/flame_bloc/CHANGELOG.md @@ -1,3 +1,7 @@ +## 1.12.5 + + - Update a dependency to the latest release. + ## 1.12.4 - Update a dependency to the latest release. diff --git a/packages/flame_bloc/example/pubspec.yaml b/packages/flame_bloc/example/pubspec.yaml index 5810a588585..59c02118383 100644 --- a/packages/flame_bloc/example/pubspec.yaml +++ b/packages/flame_bloc/example/pubspec.yaml @@ -11,8 +11,8 @@ environment: dependencies: equatable: ^2.0.5 - flame: ^1.22.0 - flame_bloc: ^1.12.4 + flame: ^1.23.0 + flame_bloc: ^1.12.5 flutter: sdk: flutter flutter_bloc: ^8.1.2 diff --git a/packages/flame_bloc/pubspec.yaml b/packages/flame_bloc/pubspec.yaml index e8be470e5f8..b0c8ea4e872 100644 --- a/packages/flame_bloc/pubspec.yaml +++ b/packages/flame_bloc/pubspec.yaml @@ -1,6 +1,6 @@ name: flame_bloc description: Integration for the Bloc state management library to Flame games. -version: 1.12.4 +version: 1.12.5 homepage: https://github.com/flame-engine/flame/tree/main/packages/flame_bloc funding: - https://opencollective.com/blue-fire @@ -16,7 +16,7 @@ environment: dependencies: bloc: ^8.1.1 - flame: ^1.22.0 + flame: ^1.23.0 flutter: sdk: flutter flutter_bloc: ^8.1.2 @@ -25,7 +25,7 @@ dependencies: dev_dependencies: dartdoc: ^8.0.8 flame_lint: ^1.2.1 - flame_test: ^1.17.3 + flame_test: ^1.17.4 flutter_test: sdk: flutter - mocktail: ^1.0.3 + mocktail: ^1.0.4 diff --git a/packages/flame_console/CHANGELOG.md b/packages/flame_console/CHANGELOG.md index a0bc358fcf8..4e9a8271518 100644 --- a/packages/flame_console/CHANGELOG.md +++ b/packages/flame_console/CHANGELOG.md @@ -1,3 +1,8 @@ +## 0.1.2 + + - **REFACTOR**: Fix lint issues from latest flutter release ([#3390](https://github.com/flame-engine/flame/issues/3390)). ([978ad31b](https://github.com/flame-engine/flame/commit/978ad31b429d1801097b0db385a600c85a157867)) + - **FEAT**: Refactoring flame_console to use terminui ([#3388](https://github.com/flame-engine/flame/issues/3388)). ([de74a93b](https://github.com/flame-engine/flame/commit/de74a93b44f442341f816a2988c854f40902ff7e)) + ## 0.1.1 - **FIX**(flame_console): MemoryRepository can't be const ([#3362](https://github.com/flame-engine/flame/issues/3362)). ([e977bd49](https://github.com/flame-engine/flame/commit/e977bd495b196368582eda4e7d8019adc6c268f4)) diff --git a/packages/flame_console/example/lib/main.dart b/packages/flame_console/example/lib/main.dart index bfcf5bbe2b0..e4ff1d238ab 100644 --- a/packages/flame_console/example/lib/main.dart +++ b/packages/flame_console/example/lib/main.dart @@ -30,7 +30,7 @@ class _MyGameAppState extends State { body: GameWidget( game: _game, overlayBuilderMap: { - 'console': (BuildContext context, MyGame game) => ConsoleView( + 'console': (BuildContext context, MyGame game) => FlameConsoleView( game: game, onClose: () { _game.overlays.remove('console'); diff --git a/packages/flame_console/example/pubspec.yaml b/packages/flame_console/example/pubspec.yaml index 9a11f2736f4..a02a8b728f4 100644 --- a/packages/flame_console/example/pubspec.yaml +++ b/packages/flame_console/example/pubspec.yaml @@ -9,8 +9,8 @@ environment: sdk: ">=3.4.0 <4.0.0" dependencies: - flame: ^1.22.0 - flame_console: ^0.1.1 + flame: ^1.23.0 + flame_console: ^0.1.2 flutter: sdk: flutter diff --git a/packages/flame_console/lib/src/commands/commands.dart b/packages/flame_console/lib/src/commands/commands.dart index 82fbaa0ff3b..5731a0f4cee 100644 --- a/packages/flame_console/lib/src/commands/commands.dart +++ b/packages/flame_console/lib/src/commands/commands.dart @@ -4,16 +4,14 @@ import 'package:flame/game.dart'; import 'package:flame_console/src/commands/commands.dart'; import 'package:flame_console/src/commands/pause_command.dart'; import 'package:flame_console/src/commands/resume_command.dart'; +import 'package:terminui/terminui.dart'; export 'debug_command.dart'; export 'ls_command.dart'; export 'remove_command.dart'; -abstract class ConsoleCommand { - ArgParser get parser; - String get description; - String get name; - +abstract class FlameConsoleCommand + extends TerminuiCommand { List listAllChildren(Component component) { return [ for (final child in component.children) ...[ @@ -50,23 +48,10 @@ abstract class ConsoleCommand { } } } - - (String?, String) run(G game, List args) { - final results = parser.parse(args); - return execute(game, results); - } - - (String?, String) execute(G game, ArgResults results); - - int? optionalIntResult(String key, ArgResults results) { - if (results[key] != null) { - return int.tryParse(results[key] as String); - } - return null; - } } -abstract class QueryCommand extends ConsoleCommand { +abstract class QueryCommand + extends FlameConsoleCommand { (String?, String) processChildren(List children); @override @@ -100,8 +85,8 @@ abstract class QueryCommand extends ConsoleCommand { ); } -class ConsoleCommands { - static List commands = [ +class FlameConsoleCommands { + static List commands = [ LsConsoleCommand(), RemoveConsoleCommand(), DebugConsoleCommand(), diff --git a/packages/flame_console/lib/src/commands/pause_command.dart b/packages/flame_console/lib/src/commands/pause_command.dart index 0bea75b8e56..4184a7f3d4b 100644 --- a/packages/flame_console/lib/src/commands/pause_command.dart +++ b/packages/flame_console/lib/src/commands/pause_command.dart @@ -2,7 +2,7 @@ import 'package:args/args.dart'; import 'package:flame/game.dart'; import 'package:flame_console/flame_console.dart'; -class PauseConsoleCommand extends ConsoleCommand { +class PauseConsoleCommand extends FlameConsoleCommand { @override (String?, String) execute(G game, ArgResults results) { if (game.paused) { diff --git a/packages/flame_console/lib/src/commands/resume_command.dart b/packages/flame_console/lib/src/commands/resume_command.dart index 25db4595b39..fb87cd72a19 100644 --- a/packages/flame_console/lib/src/commands/resume_command.dart +++ b/packages/flame_console/lib/src/commands/resume_command.dart @@ -2,7 +2,7 @@ import 'package:args/args.dart'; import 'package:flame/game.dart'; import 'package:flame_console/flame_console.dart'; -class ResumeConsoleCommand extends ConsoleCommand { +class ResumeConsoleCommand extends FlameConsoleCommand { @override (String?, String) execute(G game, ArgResults results) { if (!game.paused) { diff --git a/packages/flame_console/lib/src/controller.dart b/packages/flame_console/lib/src/controller.dart deleted file mode 100644 index a29d51ef799..00000000000 --- a/packages/flame_console/lib/src/controller.dart +++ /dev/null @@ -1,172 +0,0 @@ -import 'package:flame/game.dart'; -import 'package:flame_console/flame_console.dart'; -import 'package:flutter/material.dart'; -import 'package:flutter/services.dart'; - -class ConsoleState { - const ConsoleState({ - this.showHistory = false, - this.commandHistoryIndex = 0, - this.commandHistory = const [], - this.history = const [], - this.cmd = '', - }); - - final bool showHistory; - final int commandHistoryIndex; - final List commandHistory; - final List history; - final String cmd; - - ConsoleState copyWith({ - bool? showHistory, - int? commandHistoryIndex, - List? commandHistory, - List? history, - String? cmd, - }) { - return ConsoleState( - showHistory: showHistory ?? this.showHistory, - commandHistoryIndex: commandHistoryIndex ?? this.commandHistoryIndex, - commandHistory: commandHistory ?? this.commandHistory, - history: history ?? this.history, - cmd: cmd ?? this.cmd, - ); - } -} - -class ConsoleController { - ConsoleController({ - required this.repository, - required this.game, - required this.scrollController, - required this.onClose, - required this.commands, - ConsoleState state = const ConsoleState(), - }) : state = ValueNotifier(state); - - final ValueNotifier state; - final ConsoleRepository repository; - final G game; - final VoidCallback onClose; - final ScrollController scrollController; - final Map> commands; - - Future init() async { - final history = await repository.listCommandHistory(); - state.value = state.value.copyWith(history: history); - } - - void handleKeyEvent(KeyEvent event) { - if (event is KeyUpEvent) { - return; - } - final char = event.character; - - if (event.logicalKey == LogicalKeyboardKey.escape && - !state.value.showHistory) { - onClose(); - } else if (event.logicalKey == LogicalKeyboardKey.arrowUp && - !state.value.showHistory) { - final newState = state.value.copyWith( - showHistory: true, - commandHistoryIndex: state.value.commandHistory.length - 1, - ); - state.value = newState; - } else if (event.logicalKey == LogicalKeyboardKey.enter && - state.value.showHistory) { - final newState = state.value.copyWith( - cmd: state.value.commandHistory[state.value.commandHistoryIndex], - showHistory: false, - ); - state.value = newState; - } else if ((event.logicalKey == LogicalKeyboardKey.arrowUp || - event.logicalKey == LogicalKeyboardKey.arrowDown) && - state.value.showHistory) { - final newState = state.value.copyWith( - commandHistoryIndex: event.logicalKey == LogicalKeyboardKey.arrowUp - ? (state.value.commandHistoryIndex - 1) - .clamp(0, state.value.commandHistory.length - 1) - : (state.value.commandHistoryIndex + 1) - .clamp(0, state.value.commandHistory.length - 1), - ); - state.value = newState; - } else if (event.logicalKey == LogicalKeyboardKey.escape && - state.value.showHistory) { - state.value = state.value.copyWith( - showHistory: false, - ); - } else if (event.logicalKey == LogicalKeyboardKey.enter && - !state.value.showHistory) { - final split = state.value.cmd.split(' '); - - if (split.isEmpty) { - return; - } - - if (split.first == 'clear') { - state.value = state.value.copyWith( - history: [], - cmd: '', - ); - return; - } - - if (split.first == 'help') { - final output = commands.entries.fold('', (previous, entry) { - final help = '${entry.key} - ${entry.value.description}\n\n' - '${entry.value.parser.usage}\n\n'; - - return '$previous\n$help'; - }); - - state.value = state.value.copyWith( - history: [...state.value.history, output], - ); - return; - } - - final originalCommand = state.value.cmd; - state.value = state.value.copyWith( - history: [...state.value.history, state.value.cmd], - cmd: '', - ); - - final command = commands[split.first]; - - if (command == null) { - state.value = state.value.copyWith( - history: [...state.value.history, 'Command not found'], - ); - } else { - repository.addToCommandHistory(originalCommand); - state.value = state.value.copyWith( - commandHistory: [...state.value.commandHistory, originalCommand], - ); - final result = command.run(game, split.skip(1).toList()); - - if (result.$1 != null) { - state.value = state.value.copyWith( - history: [...state.value.history, ...result.$1!.split('\n')], - ); - } else if (result.$2.isNotEmpty) { - state.value = state.value.copyWith( - history: [...state.value.history, ...result.$2.split('\n')], - ); - } - } - - WidgetsBinding.instance.addPostFrameCallback((_) { - scrollController.jumpTo(scrollController.position.maxScrollExtent); - }); - } else if (event.logicalKey == LogicalKeyboardKey.backspace) { - state.value = state.value.copyWith( - cmd: state.value.cmd.substring(0, state.value.cmd.length - 1), - ); - } else if (char != null) { - state.value = state.value.copyWith( - cmd: state.value.cmd + char, - ); - } - } -} diff --git a/packages/flame_console/lib/src/flame_console.dart b/packages/flame_console/lib/src/flame_console.dart index b07822b44a2..7ac05acec88 100644 --- a/packages/flame_console/lib/src/flame_console.dart +++ b/packages/flame_console/lib/src/flame_console.dart @@ -1,3 +1,2 @@ export 'commands/commands.dart'; -export 'repository/repository.dart'; export 'view/view.dart'; diff --git a/packages/flame_console/lib/src/repository/console_repository.dart b/packages/flame_console/lib/src/repository/console_repository.dart deleted file mode 100644 index a8f87d896ea..00000000000 --- a/packages/flame_console/lib/src/repository/console_repository.dart +++ /dev/null @@ -1,7 +0,0 @@ -/// A repository to persist and read history of commands. -abstract class ConsoleRepository { - const ConsoleRepository(); - - Future addToCommandHistory(String command); - Future> listCommandHistory(); -} diff --git a/packages/flame_console/lib/src/repository/memory_console_repository.dart b/packages/flame_console/lib/src/repository/memory_console_repository.dart deleted file mode 100644 index c2e59e5e9cc..00000000000 --- a/packages/flame_console/lib/src/repository/memory_console_repository.dart +++ /dev/null @@ -1,21 +0,0 @@ -import 'package:flame_console/flame_console.dart'; - -/// An implementation of a [ConsoleRepository] that stores the command history -/// in memory. -class MemoryConsoleRepository extends ConsoleRepository { - MemoryConsoleRepository({ - List? commands, - }) : _commands = commands ?? []; - - final List _commands; - - @override - Future addToCommandHistory(String command) async { - _commands.add(command); - } - - @override - Future> listCommandHistory() async { - return _commands; - } -} diff --git a/packages/flame_console/lib/src/repository/repository.dart b/packages/flame_console/lib/src/repository/repository.dart deleted file mode 100644 index 1d5fc5033cb..00000000000 --- a/packages/flame_console/lib/src/repository/repository.dart +++ /dev/null @@ -1,2 +0,0 @@ -export 'console_repository.dart'; -export 'memory_console_repository.dart'; diff --git a/packages/flame_console/lib/src/view/console_view.dart b/packages/flame_console/lib/src/view/console_view.dart index 2d153e90fdd..09c9a8ff065 100644 --- a/packages/flame_console/lib/src/view/console_view.dart +++ b/packages/flame_console/lib/src/view/console_view.dart @@ -1,23 +1,9 @@ import 'package:flame/components.dart'; import 'package:flame/game.dart'; import 'package:flame_console/flame_console.dart'; -import 'package:flame_console/src/controller.dart'; -import 'package:flame_console/src/view/container_builder.dart'; -import 'package:flame_console/src/view/cursor_builder.dart'; -import 'package:flame_console/src/view/history_builder.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; - -typedef HistoryBuilder = Widget Function( - BuildContext context, - ScrollController scrollController, - Widget child, -); - -typedef ContainerBuilder = Widget Function( - BuildContext context, - Widget child, -); +import 'package:terminui/terminui.dart'; /// A Console like view that can be used to interact with a game. /// @@ -38,8 +24,8 @@ typedef ContainerBuilder = Widget Function( /// ), /// }, /// ) -class ConsoleView extends StatefulWidget { - const ConsoleView({ +class FlameConsoleView extends StatefulWidget { + const FlameConsoleView({ required this.game, required this.onClose, this.customCommands, @@ -49,15 +35,13 @@ class ConsoleView extends StatefulWidget { this.cursorColor, this.historyBuilder, this.textStyle, - @visibleForTesting this.controller, super.key, }); final G game; - final List>? customCommands; + final List>? customCommands; final VoidCallback onClose; - final ConsoleRepository? repository; - final ConsoleController? controller; + final TerminuiRepository? repository; final ContainerBuilder? containerBuilder; final WidgetBuilder? cursorBuilder; @@ -67,7 +51,7 @@ class ConsoleView extends StatefulWidget { final TextStyle? textStyle; @override - State createState() => _ConsoleViewState(); + State createState() => _ConsoleViewState(); } class _ConsoleKeyboardHandler extends Component with KeyboardHandler { @@ -82,28 +66,16 @@ class _ConsoleKeyboardHandler extends Component with KeyboardHandler { } } -class _ConsoleViewState extends State { - late final List _commandList = [ - ...ConsoleCommands.commands, +class _ConsoleViewState extends State { + late final List _commandList = [ + ...FlameConsoleCommands.commands, if (widget.customCommands != null) ...widget.customCommands!, ]; - late final repository = widget.repository ?? MemoryConsoleRepository(); + late final repository = widget.repository ?? MemoryTerminuiRepository(); - late final Map _commandsMap = { - for (final command in _commandList) command.name: command, - }; + late final _keyboardEventEmitter = KeyboardEventEmitter(); - late final _controller = widget.controller ?? - ConsoleController( - repository: repository, - game: widget.game, - scrollController: _scrollController, - onClose: widget.onClose, - commands: _commandsMap, - ); - - late final _scrollController = ScrollController(); late final KeyboardHandler _keyboardHandler; @override @@ -112,126 +84,31 @@ class _ConsoleViewState extends State { widget.game.add( _keyboardHandler = _ConsoleKeyboardHandler( - _controller.handleKeyEvent, + _keyboardEventEmitter.emit, ), ); - - _controller.init(); } @override void dispose() { _keyboardHandler.removeFromParent(); - _scrollController.dispose(); + _keyboardEventEmitter.dispose(); super.dispose(); } @override Widget build(BuildContext context) { - final cursorColor = widget.cursorColor ?? Colors.white; - - final textStyle = widget.textStyle ?? - Theme.of(context).textTheme.bodySmall?.copyWith( - color: Colors.white, - ); - - final historyBuilder = widget.historyBuilder ?? defaultHistoryBuilder; - final containerBuilder = widget.containerBuilder ?? defaultContainerBuilder; - final cursorBuilder = widget.cursorBuilder ?? defaultCursorBuilder; - - return ValueListenableBuilder( - valueListenable: _controller.state, - builder: (context, state, _) { - return SizedBox( - height: 400, - width: double.infinity, - child: Stack( - children: [ - Positioned( - top: 0, - left: 0, - right: 0, - bottom: 48, - child: containerBuilder( - context, - historyBuilder( - context, - _scrollController, - Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - for (final line in state.history) - Padding( - padding: const EdgeInsets.only(top: 8.0), - child: Text(line, style: textStyle), - ), - ], - ), - ), - ), - ), - if (state.showHistory) - Positioned( - bottom: 48, - left: 0, - right: 0, - child: containerBuilder( - context, - SizedBox( - height: 168, - child: Column( - verticalDirection: VerticalDirection.up, - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - if (state.commandHistory.isEmpty) - Padding( - padding: const EdgeInsets.only(top: 8.0), - child: Text('No history', style: textStyle), - ), - for (var i = state.commandHistoryIndex; - i >= 0 && i >= state.commandHistoryIndex - 5; - i--) - Padding( - padding: const EdgeInsets.only(top: 8.0), - child: ColoredBox( - color: i == state.commandHistoryIndex - ? cursorColor.withValues(alpha: .5) - : Colors.transparent, - child: Text( - state.commandHistory[i], - style: textStyle?.copyWith( - color: i == state.commandHistoryIndex - ? cursorColor - : textStyle.color, - ), - ), - ), - ), - ], - ), - ), - ), - ), - Positioned( - left: 0, - right: 0, - bottom: 0, - child: containerBuilder( - context, - Row( - children: [ - Text(state.cmd, style: textStyle), - SizedBox(width: (textStyle?.fontSize ?? 12) / 4), - cursorBuilder(context), - ], - ), - ), - ), - ], - ), - ); - }, + return TerminuiView( + onClose: widget.onClose, + commands: _commandList, + subject: widget.game, + keyboardEventEmitter: _keyboardEventEmitter, + containerBuilder: widget.containerBuilder, + cursorBuilder: widget.cursorBuilder, + cursorColor: widget.cursorColor, + historyBuilder: widget.historyBuilder, + textStyle: widget.textStyle, ); } } diff --git a/packages/flame_console/lib/src/view/cursor_builder.dart b/packages/flame_console/lib/src/view/cursor_builder.dart deleted file mode 100644 index b7bb8f49680..00000000000 --- a/packages/flame_console/lib/src/view/cursor_builder.dart +++ /dev/null @@ -1,11 +0,0 @@ -import 'package:flutter/material.dart'; - -Widget defaultCursorBuilder(BuildContext context) { - return const ColoredBox( - color: Colors.white, - child: SizedBox( - width: 8, - height: 20, - ), - ); -} diff --git a/packages/flame_console/lib/src/view/history_builder.dart b/packages/flame_console/lib/src/view/history_builder.dart deleted file mode 100644 index d6f31e69c04..00000000000 --- a/packages/flame_console/lib/src/view/history_builder.dart +++ /dev/null @@ -1,12 +0,0 @@ -import 'package:flutter/material.dart'; - -Widget defaultHistoryBuilder( - BuildContext context, - ScrollController scrollController, - Widget child, -) { - return SingleChildScrollView( - controller: scrollController, - child: child, - ); -} diff --git a/packages/flame_console/pubspec.yaml b/packages/flame_console/pubspec.yaml index 72f5858b298..fdb21280e15 100644 --- a/packages/flame_console/pubspec.yaml +++ b/packages/flame_console/pubspec.yaml @@ -1,6 +1,6 @@ name: flame_console description: "An extensible and customizable console to help debug Flame games." -version: 0.1.1 +version: 0.1.2 homepage: environment: @@ -9,12 +9,13 @@ environment: dependencies: args: ^2.5.0 - flame: ^1.22.0 + flame: ^1.23.0 flutter: sdk: flutter + terminui: ^0.1.0 dev_dependencies: flame_lint: ^1.2.1 - flame_test: ^1.17.3 + flame_test: ^1.17.4 flutter_test: sdk: flutter diff --git a/packages/flame_console/test/src/commands_test.dart b/packages/flame_console/test/src/commands_test.dart index 73b92aa08b2..27cfc9e4b1c 100644 --- a/packages/flame_console/test/src/commands_test.dart +++ b/packages/flame_console/test/src/commands_test.dart @@ -6,7 +6,7 @@ import 'package:flame_console/flame_console.dart'; import 'package:flame_test/flame_test.dart'; import 'package:flutter_test/flutter_test.dart'; -class _NoopCommand extends ConsoleCommand { +class _NoopCommand extends FlameConsoleCommand { @override String get description => ''; diff --git a/packages/flame_devtools/pubspec.yaml b/packages/flame_devtools/pubspec.yaml index 6eba08a59b6..e8b5f8ea43f 100644 --- a/packages/flame_devtools/pubspec.yaml +++ b/packages/flame_devtools/pubspec.yaml @@ -10,7 +10,7 @@ dependencies: animated_tree_view: ^2.2.0 devtools_app_shared: ^0.1.1 devtools_extensions: ^0.1.1 - flame: ^1.22.0 + flame: ^1.23.0 flutter: sdk: flutter flutter_riverpod: ^2.5.1 diff --git a/packages/flame_fire_atlas/CHANGELOG.md b/packages/flame_fire_atlas/CHANGELOG.md index d7df29db950..d134614c037 100644 --- a/packages/flame_fire_atlas/CHANGELOG.md +++ b/packages/flame_fire_atlas/CHANGELOG.md @@ -1,3 +1,7 @@ +## 1.7.1 + + - Update a dependency to the latest release. + ## 1.7.0 - **FEAT**: Adding getters and methods for easier manipulation of selections ([#3350](https://github.com/flame-engine/flame/issues/3350)). ([291af57d](https://github.com/flame-engine/flame/commit/291af57deb7d742a73438b026ca2f4fd1c6a3454)) diff --git a/packages/flame_fire_atlas/example/pubspec.yaml b/packages/flame_fire_atlas/example/pubspec.yaml index ddba6251b58..840b0169ac7 100644 --- a/packages/flame_fire_atlas/example/pubspec.yaml +++ b/packages/flame_fire_atlas/example/pubspec.yaml @@ -9,8 +9,8 @@ environment: sdk: ">=3.4.0 <4.0.0" dependencies: - flame: ^1.22.0 - flame_fire_atlas: ^1.7.0 + flame: ^1.23.0 + flame_fire_atlas: ^1.7.1 flutter: sdk: flutter diff --git a/packages/flame_fire_atlas/pubspec.yaml b/packages/flame_fire_atlas/pubspec.yaml index ed3a1eb39f2..d518990ec5c 100644 --- a/packages/flame_fire_atlas/pubspec.yaml +++ b/packages/flame_fire_atlas/pubspec.yaml @@ -1,7 +1,7 @@ name: flame_fire_atlas description: Easy to use texture atlases for the flame engine created with the fire atlas editor -version: 1.7.0 +version: 1.7.1 homepage: https://github.com/flame-engine/flame/tree/main/packages/flame_fire_atlas funding: - https://opencollective.com/blue-fire @@ -17,7 +17,7 @@ environment: dependencies: archive: ^3.3.9 - flame: ^1.22.0 + flame: ^1.23.0 flutter: sdk: flutter @@ -26,4 +26,4 @@ dev_dependencies: flame_lint: ^1.2.1 flutter_test: sdk: flutter - mocktail: ^1.0.3 + mocktail: ^1.0.4 diff --git a/packages/flame_forge2d/CHANGELOG.md b/packages/flame_forge2d/CHANGELOG.md index b4b0c30957f..89166e228e0 100644 --- a/packages/flame_forge2d/CHANGELOG.md +++ b/packages/flame_forge2d/CHANGELOG.md @@ -1,3 +1,7 @@ +## 0.18.2+4 + + - **REFACTOR**: Fix lint issues from latest flutter release ([#3390](https://github.com/flame-engine/flame/issues/3390)). ([978ad31b](https://github.com/flame-engine/flame/commit/978ad31b429d1801097b0db385a600c85a157867)) + ## 0.18.2+3 - Update a dependency to the latest release. diff --git a/packages/flame_forge2d/example/pubspec.yaml b/packages/flame_forge2d/example/pubspec.yaml index fbaa0075bac..3c0a7a60a9a 100644 --- a/packages/flame_forge2d/example/pubspec.yaml +++ b/packages/flame_forge2d/example/pubspec.yaml @@ -10,8 +10,8 @@ environment: flutter: ">=3.24.0" dependencies: - flame: ^1.22.0 - flame_forge2d: ^0.18.2+3 + flame: ^1.23.0 + flame_forge2d: ^0.18.2+4 flutter: sdk: flutter diff --git a/packages/flame_forge2d/pubspec.yaml b/packages/flame_forge2d/pubspec.yaml index fe1af0b87bf..0b6d3ed9be9 100644 --- a/packages/flame_forge2d/pubspec.yaml +++ b/packages/flame_forge2d/pubspec.yaml @@ -1,6 +1,6 @@ name: flame_forge2d description: Forge2D (Box2D) support for the Flame game engine. This uses the forge2d package and provides wrappers and components to be used inside Flame. -version: 0.18.2+3 +version: 0.18.2+4 homepage: https://github.com/flame-engine/flame/tree/main/packages/flame_forge2d funding: - https://opencollective.com/blue-fire @@ -16,7 +16,7 @@ environment: flutter: ">=3.24.0" dependencies: - flame: ^1.22.0 + flame: ^1.23.0 flutter: sdk: flutter forge2d: ^0.13.1 @@ -24,8 +24,8 @@ dependencies: dev_dependencies: dartdoc: ^8.0.8 flame_lint: ^1.2.1 - flame_test: ^1.17.3 + flame_test: ^1.17.4 flutter_test: sdk: flutter - mocktail: ^1.0.3 + mocktail: ^1.0.4 test: any diff --git a/packages/flame_isolate/CHANGELOG.md b/packages/flame_isolate/CHANGELOG.md index 125cbae0ac0..f6fb835d0df 100644 --- a/packages/flame_isolate/CHANGELOG.md +++ b/packages/flame_isolate/CHANGELOG.md @@ -1,3 +1,7 @@ +## 0.6.2+4 + + - **REFACTOR**: Fix lint issues from latest flutter release ([#3390](https://github.com/flame-engine/flame/issues/3390)). ([978ad31b](https://github.com/flame-engine/flame/commit/978ad31b429d1801097b0db385a600c85a157867)) + ## 0.6.2+3 - Update a dependency to the latest release. diff --git a/packages/flame_isolate/example/pubspec.yaml b/packages/flame_isolate/example/pubspec.yaml index 2b041783a34..e14a2c173cc 100755 --- a/packages/flame_isolate/example/pubspec.yaml +++ b/packages/flame_isolate/example/pubspec.yaml @@ -11,8 +11,8 @@ environment: dependencies: collection: ^1.18.0 - flame: ^1.22.0 - flame_isolate: ^0.6.2+3 + flame: ^1.23.0 + flame_isolate: ^0.6.2+4 flutter: sdk: flutter quiver: ^3.2.1 diff --git a/packages/flame_isolate/pubspec.yaml b/packages/flame_isolate/pubspec.yaml index f14b99bf6e9..af891d0f5f4 100644 --- a/packages/flame_isolate/pubspec.yaml +++ b/packages/flame_isolate/pubspec.yaml @@ -1,6 +1,6 @@ name: flame_isolate description: Flame wrapper for integral_isolates making multi-threading easy in Flame -version: 0.6.2+3 +version: 0.6.2+4 repository: https://github.com/flame-engine/flame/blob/main/packages/flame_isolate topics: - flame @@ -11,14 +11,14 @@ environment: flutter: ">=3.24.0" dependencies: - flame: ^1.22.0 + flame: ^1.23.0 flutter: sdk: flutter integral_isolates: ^0.5.1 dev_dependencies: flame_lint: ^1.2.1 - flame_test: ^1.17.3 + flame_test: ^1.17.4 flutter_test: sdk: flutter test: any diff --git a/packages/flame_jenny/pubspec.yaml b/packages/flame_jenny/pubspec.yaml index 34e3da7baac..890e18030b8 100644 --- a/packages/flame_jenny/pubspec.yaml +++ b/packages/flame_jenny/pubspec.yaml @@ -16,7 +16,7 @@ environment: dependencies: collection: ^1.17.1 - flame: ^1.22.0 + flame: ^1.23.0 flutter: sdk: flutter jenny: ^1.3.2 diff --git a/packages/flame_kenney_xml/CHANGELOG.md b/packages/flame_kenney_xml/CHANGELOG.md index 34351a5d3da..0757e3aec78 100644 --- a/packages/flame_kenney_xml/CHANGELOG.md +++ b/packages/flame_kenney_xml/CHANGELOG.md @@ -1,3 +1,7 @@ +## 0.1.1+4 + + - Update a dependency to the latest release. + ## 0.1.1+3 - Update a dependency to the latest release. diff --git a/packages/flame_kenney_xml/example/pubspec.yaml b/packages/flame_kenney_xml/example/pubspec.yaml index 99514527383..efe899eafdc 100644 --- a/packages/flame_kenney_xml/example/pubspec.yaml +++ b/packages/flame_kenney_xml/example/pubspec.yaml @@ -9,8 +9,8 @@ environment: sdk: ">=3.4.0 <4.0.0" dependencies: - flame: ^1.22.0 - flame_kenney_xml: ^0.1.1+3 + flame: ^1.23.0 + flame_kenney_xml: ^0.1.1+4 flutter: sdk: flutter diff --git a/packages/flame_kenney_xml/pubspec.yaml b/packages/flame_kenney_xml/pubspec.yaml index a21b4d4eda9..d18b56fa6f9 100644 --- a/packages/flame_kenney_xml/pubspec.yaml +++ b/packages/flame_kenney_xml/pubspec.yaml @@ -1,6 +1,6 @@ name: flame_kenney_xml description: "Support for Kenney XML spritesheets for the Flame game engine. This package parses XML files produced by Kenney." -version: 0.1.1+3 +version: 0.1.1+4 homepage: https://github.com/flame-engine/flame/tree/main/packages/flame_kenney_xml funding: - https://opencollective.com/blue-fire @@ -17,7 +17,7 @@ environment: flutter: ">=3.24.0" dependencies: - flame: ^1.22.0 + flame: ^1.23.0 flutter: sdk: flutter xml: ^6.5.0 diff --git a/packages/flame_lottie/CHANGELOG.md b/packages/flame_lottie/CHANGELOG.md index 6e0ad984ff9..95e9e83b75c 100644 --- a/packages/flame_lottie/CHANGELOG.md +++ b/packages/flame_lottie/CHANGELOG.md @@ -1,3 +1,7 @@ +## 0.4.2+4 + + - Update a dependency to the latest release. + ## 0.4.2+3 - Update a dependency to the latest release. diff --git a/packages/flame_lottie/example/pubspec.yaml b/packages/flame_lottie/example/pubspec.yaml index 1ce2ae92239..4a31ab58f2e 100644 --- a/packages/flame_lottie/example/pubspec.yaml +++ b/packages/flame_lottie/example/pubspec.yaml @@ -7,8 +7,8 @@ environment: sdk: ">=3.4.0 <4.0.0" dependencies: - flame: ^1.22.0 - flame_lottie: ^0.4.2+3 + flame: ^1.23.0 + flame_lottie: ^0.4.2+4 flutter: sdk: flutter lottie: diff --git a/packages/flame_lottie/pubspec.yaml b/packages/flame_lottie/pubspec.yaml index 648575d4f2d..b6ab02356c5 100644 --- a/packages/flame_lottie/pubspec.yaml +++ b/packages/flame_lottie/pubspec.yaml @@ -1,6 +1,6 @@ name: flame_lottie description: Flame wrapper for Lottie by AirBnB. This package implements a bridge between Lottie and Flame, allowing to load and display Lottie animations. -version: 0.4.2+3 +version: 0.4.2+4 homepage: https://github.com/flame-engine/flame/tree/main/packages/flame_lottie funding: - https://opencollective.com/blue-fire @@ -16,13 +16,13 @@ environment: flutter: ">=3.24.0" dependencies: - flame: ^1.22.0 + flame: ^1.23.0 flutter: sdk: flutter lottie: ^3.1.2 dev_dependencies: flame_lint: ^1.2.1 - flame_test: ^1.17.3 + flame_test: ^1.17.4 flutter_test: sdk: flutter diff --git a/packages/flame_markdown/CHANGELOG.md b/packages/flame_markdown/CHANGELOG.md index 734fd896dd4..825953abade 100644 --- a/packages/flame_markdown/CHANGELOG.md +++ b/packages/flame_markdown/CHANGELOG.md @@ -1,3 +1,8 @@ +## 0.2.3 + + - **FIX**: Do not encode HTML by default when parsing markdown [flame_markdown] ([#3425](https://github.com/flame-engine/flame/issues/3425)). ([3067da94](https://github.com/flame-engine/flame/commit/3067da94fbc6df2da5197771cb9617588006a9b9)) + - **FEAT**: Add support for strike-through text for flame_markdown ([#3426](https://github.com/flame-engine/flame/issues/3426)). ([1f9b0ea9](https://github.com/flame-engine/flame/commit/1f9b0ea9f35a7180725ec7f8f79a561c5f544bb7)) + ## 0.2.2+3 - Update a dependency to the latest release. diff --git a/packages/flame_markdown/example/assets/fire_and_ice.md b/packages/flame_markdown/example/assets/fire_and_ice.md index dfb58e92dc2..bcf1b77199a 100644 --- a/packages/flame_markdown/example/assets/fire_and_ice.md +++ b/packages/flame_markdown/example/assets/fire_and_ice.md @@ -1,9 +1,9 @@ -# Fire and Ice +# Fire & Ice -Some say the world will end in **fire**, +Some say the world will ~~end~~ in **fire**, Some say in *ice*. -From what I've tasted of desire +From what I've tasted of >desire<, I hold with those who favor **fire**. diff --git a/packages/flame_markdown/example/lib/main.dart b/packages/flame_markdown/example/lib/main.dart index bd7381f662d..caf1c729169 100644 --- a/packages/flame_markdown/example/lib/main.dart +++ b/packages/flame_markdown/example/lib/main.dart @@ -6,6 +6,7 @@ import 'package:flame/game.dart'; import 'package:flame/text.dart'; import 'package:flame_markdown/flame_markdown.dart'; import 'package:flutter/widgets.dart' hide Animation; +import 'package:markdown/markdown.dart'; void main() { runApp(GameWidget(game: MarkdownGame())); @@ -19,7 +20,15 @@ class MarkdownGame extends FlameGame { final markdown = await Flame.assets.readFile('fire_and_ice.md'); await add( TextElementComponent.fromDocument( - document: FlameMarkdown.toDocument(markdown), + document: FlameMarkdown.toDocument( + markdown, + document: Document( + encodeHtml: false, + inlineSyntaxes: [ + StrikethroughSyntax(), + ], + ), + ), style: DocumentStyle( padding: const EdgeInsets.all(16), ), diff --git a/packages/flame_markdown/example/pubspec.yaml b/packages/flame_markdown/example/pubspec.yaml index a2929b8f12a..0c4a97257e5 100644 --- a/packages/flame_markdown/example/pubspec.yaml +++ b/packages/flame_markdown/example/pubspec.yaml @@ -7,10 +7,11 @@ environment: sdk: ">=3.4.0 <4.0.0" dependencies: - flame: ^1.22.0 - flame_markdown: ^0.2.2+3 + flame: ^1.23.0 + flame_markdown: ^0.2.3 flutter: sdk: flutter + markdown: ^7.1.1 dev_dependencies: flame_lint: ^1.2.1 diff --git a/packages/flame_markdown/lib/flame_markdown.dart b/packages/flame_markdown/lib/flame_markdown.dart index 426853faf37..3176b1371bf 100644 --- a/packages/flame_markdown/lib/flame_markdown.dart +++ b/packages/flame_markdown/lib/flame_markdown.dart @@ -26,7 +26,13 @@ class FlameMarkdown { } static List _parse(String markdown, {Document? document}) { - return (document ?? Document()).parse(markdown); + return (document ?? _defaultDocument()).parse(markdown); + } + + static Document _defaultDocument() { + return Document( + encodeHtml: false, + ); } static TextNode _convertNode(Node node) { @@ -56,6 +62,7 @@ class FlameMarkdown { 'em' || 'i' => ItalicTextNode(child), 'strong' || 'b' => BoldTextNode(child), 'code' => CodeTextNode(child), + 'del' => StrikethroughTextNode(child), _ => throw Exception('Unknown element tag: ${element.tag}'), } as TextNode; } diff --git a/packages/flame_markdown/pubspec.yaml b/packages/flame_markdown/pubspec.yaml index a58053398cf..b407c8a1bee 100644 --- a/packages/flame_markdown/pubspec.yaml +++ b/packages/flame_markdown/pubspec.yaml @@ -1,7 +1,7 @@ name: flame_markdown description: | Markdown support for the Flame game engine, bridging the markdown package into Flame's text rendering pipeline. -version: 0.2.2+3 +version: 0.2.3 homepage: https://github.com/flame-engine/flame/tree/main/packages/flame_markdown funding: - https://opencollective.com/blue-fire @@ -16,7 +16,7 @@ environment: flutter: ">=3.24.0" dependencies: - flame: ^1.22.0 + flame: ^1.23.0 flutter: sdk: flutter markdown: ^7.1.1 diff --git a/packages/flame_markdown/test/flame_markdown_test.dart b/packages/flame_markdown/test/flame_markdown_test.dart index 656bb5fdd82..875817a93f6 100644 --- a/packages/flame_markdown/test/flame_markdown_test.dart +++ b/packages/flame_markdown/test/flame_markdown_test.dart @@ -3,6 +3,7 @@ import 'dart:io'; import 'package:flame/text.dart'; import 'package:flame_markdown/flame_markdown.dart'; import 'package:flutter_test/flutter_test.dart'; +import 'package:markdown/markdown.dart'; void main() { group('FlameMarkdown#toDocument', () { @@ -68,10 +69,14 @@ void main() { final doc = FlameMarkdown.toDocument(markdown); _expectDocument(doc, [ - (node) => _expectHeader(node, 1, 'Fire and Ice'), + (node) => _expectHeader(node, 1, 'Fire & Ice'), (node) => _expectParagraph(node, (p) { _expectGroup(p, [ - (node) => _expectPlain(node, 'Some say the world will end in '), + (node) => _expectPlain( + node, + // note: strike-trough is only parsed if enabled + 'Some say the world will ~~end~~ in ', + ), (node) => _expectBold(node, 'fire'), (node) => _expectPlain(node, ','), ]); @@ -86,7 +91,7 @@ void main() { ), (node) => _expectSimpleParagraph( node, - "From what I've tasted of desire", + "From what I've tasted of >desire<,", ), (node) => _expectParagraph(node, (p) { _expectGroup(p, [ @@ -97,9 +102,39 @@ void main() { }), ]); }); + + test('strikethrough can be enabled', () { + const markdown = 'Flame ~~will be~~ is a great game engine!'; + final doc = FlameMarkdown.toDocument( + markdown, + document: Document( + encodeHtml: false, + inlineSyntaxes: [ + StrikethroughSyntax(), + ], + ), + ); + + _expectDocument(doc, [ + (node) => _expectParagraph(node, (p) { + _expectGroup(p, [ + (node) => _expectPlain(node, 'Flame '), + (node) => _expectStrikethrough(node, 'will be'), + (node) => _expectPlain(node, ' is a great game engine!'), + ]); + }), + ]); + }); }); } +void _expectStrikethrough(InlineTextNode node, String text) { + expect(node, isA()); + final content = (node as StrikethroughTextNode).child; + expect(content, isA()); + expect((content as PlainTextNode).text, text); +} + void _expectBold(InlineTextNode node, String text) { expect(node, isA()); final content = (node as BoldTextNode).child; diff --git a/packages/flame_network_assets/CHANGELOG.md b/packages/flame_network_assets/CHANGELOG.md index b6d3952327f..7b8460f8ec0 100644 --- a/packages/flame_network_assets/CHANGELOG.md +++ b/packages/flame_network_assets/CHANGELOG.md @@ -1,3 +1,7 @@ +## 0.3.3+4 + + - Update a dependency to the latest release. + ## 0.3.3+3 - Update a dependency to the latest release. diff --git a/packages/flame_network_assets/example/pubspec.yaml b/packages/flame_network_assets/example/pubspec.yaml index d8b7c22fbe8..cbcaa43383f 100644 --- a/packages/flame_network_assets/example/pubspec.yaml +++ b/packages/flame_network_assets/example/pubspec.yaml @@ -8,8 +8,8 @@ environment: sdk: ">=3.4.0 <4.0.0" dependencies: - flame: ^1.22.0 - flame_network_assets: ^0.3.3+3 + flame: ^1.23.0 + flame_network_assets: ^0.3.3+4 flutter: sdk: flutter diff --git a/packages/flame_network_assets/pubspec.yaml b/packages/flame_network_assets/pubspec.yaml index 5775b727067..ceb9f9a9cd5 100644 --- a/packages/flame_network_assets/pubspec.yaml +++ b/packages/flame_network_assets/pubspec.yaml @@ -1,6 +1,6 @@ name: flame_network_assets description: Network assets support for Flame. -version: 0.3.3+3 +version: 0.3.3+4 homepage: https://github.com/flame-engine/flame/tree/main/packages/flame_network_assets funding: - https://opencollective.com/blue-fire @@ -17,7 +17,7 @@ environment: dependencies: dev: ^1.0.0 - flame: ^1.22.0 + flame: ^1.23.0 flutter: sdk: flutter http: ^1.2.1 @@ -29,4 +29,4 @@ dev_dependencies: flame_lint: ^1.2.1 flutter_test: sdk: flutter - mocktail: ^1.0.3 + mocktail: ^1.0.4 diff --git a/packages/flame_noise/CHANGELOG.md b/packages/flame_noise/CHANGELOG.md index 1357692f0a0..efce97ed049 100644 --- a/packages/flame_noise/CHANGELOG.md +++ b/packages/flame_noise/CHANGELOG.md @@ -1,3 +1,7 @@ +## 0.3.2+4 + + - Update a dependency to the latest release. + ## 0.3.2+3 - Update a dependency to the latest release. diff --git a/packages/flame_noise/pubspec.yaml b/packages/flame_noise/pubspec.yaml index 0528fa8aabe..93db0751795 100644 --- a/packages/flame_noise/pubspec.yaml +++ b/packages/flame_noise/pubspec.yaml @@ -1,6 +1,6 @@ name: flame_noise description: Integrate the fast_noise package into Flame -version: 0.3.2+3 +version: 0.3.2+4 homepage: https://github.com/flame-engine/flame/tree/main/packages/flame_noise funding: - https://opencollective.com/blue-fire @@ -16,12 +16,12 @@ environment: dependencies: fast_noise: ^2.0.0 - flame: ^1.22.0 + flame: ^1.23.0 flutter: sdk: flutter dev_dependencies: dartdoc: ^8.0.8 flame_lint: ^1.2.1 - flame_test: ^1.17.3 + flame_test: ^1.17.4 test: any \ No newline at end of file diff --git a/packages/flame_oxygen/CHANGELOG.md b/packages/flame_oxygen/CHANGELOG.md index 8c273001aa0..c9e85544e4c 100644 --- a/packages/flame_oxygen/CHANGELOG.md +++ b/packages/flame_oxygen/CHANGELOG.md @@ -1,3 +1,7 @@ +## 0.2.3+4 + + - **REFACTOR**: Fix lint issues from latest flutter release ([#3390](https://github.com/flame-engine/flame/issues/3390)). ([978ad31b](https://github.com/flame-engine/flame/commit/978ad31b429d1801097b0db385a600c85a157867)) + ## 0.2.3+3 - Update a dependency to the latest release. diff --git a/packages/flame_oxygen/example/pubspec.yaml b/packages/flame_oxygen/example/pubspec.yaml index cd6885aae64..1ba038f6f62 100644 --- a/packages/flame_oxygen/example/pubspec.yaml +++ b/packages/flame_oxygen/example/pubspec.yaml @@ -9,8 +9,8 @@ environment: sdk: ">=3.4.0 <4.0.0" dependencies: - flame: ^1.22.0 - flame_oxygen: ^0.2.3+3 + flame: ^1.23.0 + flame_oxygen: ^0.2.3+4 flutter: sdk: flutter diff --git a/packages/flame_oxygen/pubspec.yaml b/packages/flame_oxygen/pubspec.yaml index 66ebc146b13..03a53df370b 100644 --- a/packages/flame_oxygen/pubspec.yaml +++ b/packages/flame_oxygen/pubspec.yaml @@ -1,6 +1,6 @@ name: flame_oxygen description: Integrate the Oxygen ECS with the Flame Engine. -version: 0.2.3+3 +version: 0.2.3+4 homepage: https://github.com/flame-engine/flame/tree/main/packages/flame_oxygen funding: - https://opencollective.com/blue-fire @@ -14,7 +14,7 @@ environment: flutter: ">=3.24.0" dependencies: - flame: ^1.22.0 + flame: ^1.23.0 flutter: sdk: flutter oxygen: ^0.3.1 diff --git a/packages/flame_rive/CHANGELOG.md b/packages/flame_rive/CHANGELOG.md index 4b0e05d5db3..67aa6cca417 100644 --- a/packages/flame_rive/CHANGELOG.md +++ b/packages/flame_rive/CHANGELOG.md @@ -1,3 +1,7 @@ +## 1.10.7 + + - Update a dependency to the latest release. + ## 1.10.6 - Update a dependency to the latest release. diff --git a/packages/flame_rive/example/pubspec.yaml b/packages/flame_rive/example/pubspec.yaml index 58da8e073ec..64309756694 100644 --- a/packages/flame_rive/example/pubspec.yaml +++ b/packages/flame_rive/example/pubspec.yaml @@ -7,8 +7,8 @@ environment: sdk: ">=3.4.0 <4.0.0" dependencies: - flame: ^1.22.0 - flame_rive: ^1.10.6 + flame: ^1.23.0 + flame_rive: ^1.10.7 flutter: sdk: flutter rive: ^0.12.3 diff --git a/packages/flame_rive/pubspec.yaml b/packages/flame_rive/pubspec.yaml index 18699d6c9d2..eab3ca81b2c 100644 --- a/packages/flame_rive/pubspec.yaml +++ b/packages/flame_rive/pubspec.yaml @@ -1,7 +1,7 @@ name: flame_rive description: Rive support for the Flame game engine. This uses the rive package and provides wrappers and components to be used inside Flame. homepage: https://github.com/flame-engine/flame -version: 1.10.6 +version: 1.10.7 funding: - https://opencollective.com/blue-fire - https://github.com/sponsors/bluefireteam @@ -16,7 +16,7 @@ environment: flutter: ">=3.24.0" dependencies: - flame: ^1.22.0 + flame: ^1.23.0 flutter: sdk: flutter rive: ^0.12.3 @@ -24,6 +24,6 @@ dependencies: dev_dependencies: dartdoc: ^8.0.8 flame_lint: ^1.2.1 - flame_test: ^1.17.3 + flame_test: ^1.17.4 flutter_test: sdk: flutter diff --git a/packages/flame_riverpod/CHANGELOG.md b/packages/flame_riverpod/CHANGELOG.md index 162ad4496a9..c37d41a42a3 100644 --- a/packages/flame_riverpod/CHANGELOG.md +++ b/packages/flame_riverpod/CHANGELOG.md @@ -1,3 +1,7 @@ +## 5.4.7 + + - Update a dependency to the latest release. + ## 5.4.6 - Update a dependency to the latest release. diff --git a/packages/flame_riverpod/example/pubspec.yaml b/packages/flame_riverpod/example/pubspec.yaml index c578e34675d..58c62fd4cfe 100644 --- a/packages/flame_riverpod/example/pubspec.yaml +++ b/packages/flame_riverpod/example/pubspec.yaml @@ -5,8 +5,8 @@ version: 1.0.0+1 environment: sdk: ">=3.4.0 <4.0.0" dependencies: - flame: ^1.22.0 - flame_riverpod: ^5.4.6 + flame: ^1.23.0 + flame_riverpod: ^5.4.7 flutter: sdk: flutter flutter_riverpod: ^2.5.1 diff --git a/packages/flame_riverpod/pubspec.yaml b/packages/flame_riverpod/pubspec.yaml index 5dcb254108c..ef756b27335 100644 --- a/packages/flame_riverpod/pubspec.yaml +++ b/packages/flame_riverpod/pubspec.yaml @@ -1,6 +1,6 @@ name: flame_riverpod description: Helpers for using Riverpod - a reactive caching and data-binding framework, in conjunction with Flame. -version: 5.4.6 +version: 5.4.7 homepage: https://github.com/flame-engine/flame/tree/main/packages/flame_riverpod funding: - https://opencollective.com/blue-fire @@ -15,7 +15,7 @@ environment: flutter: ">=3.24.0" dependencies: - flame: ^1.22.0 + flame: ^1.23.0 flutter: sdk: flutter flutter_riverpod: ^2.5.1 diff --git a/packages/flame_spine/CHANGELOG.md b/packages/flame_spine/CHANGELOG.md index 56e8f3339ca..31336f038ed 100644 --- a/packages/flame_spine/CHANGELOG.md +++ b/packages/flame_spine/CHANGELOG.md @@ -1,3 +1,7 @@ +## 0.2.2+4 + + - Update a dependency to the latest release. + ## 0.2.2+3 - Update a dependency to the latest release. diff --git a/packages/flame_spine/example/pubspec.yaml b/packages/flame_spine/example/pubspec.yaml index ecfcfbc0850..164d61cf5e6 100644 --- a/packages/flame_spine/example/pubspec.yaml +++ b/packages/flame_spine/example/pubspec.yaml @@ -7,8 +7,8 @@ environment: sdk: ">=3.4.0 <4.0.0" dependencies: - flame: ^1.22.0 - flame_spine: ^0.2.2+3 + flame: ^1.23.0 + flame_spine: ^0.2.2+4 flutter: sdk: flutter diff --git a/packages/flame_spine/pubspec.yaml b/packages/flame_spine/pubspec.yaml index d473c4af06f..767a243660c 100644 --- a/packages/flame_spine/pubspec.yaml +++ b/packages/flame_spine/pubspec.yaml @@ -1,6 +1,6 @@ name: flame_spine description: Spine support for the Flame game engine. This uses the spine_flutter package and provides wrappers and components to be used inside Flame. -version: 0.2.2+3 +version: 0.2.2+4 homepage: https://github.com/flame-engine/flame/tree/main/packages/flame_spine funding: - https://opencollective.com/blue-fire @@ -16,7 +16,7 @@ environment: dependencies: collection: ^1.17.1 - flame: ^1.22.0 + flame: ^1.23.0 flutter: sdk: flutter spine_flutter: ^4.2.29 diff --git a/packages/flame_sprite_fusion/CHANGELOG.md b/packages/flame_sprite_fusion/CHANGELOG.md index 5b93560c593..f2a6aafa389 100644 --- a/packages/flame_sprite_fusion/CHANGELOG.md +++ b/packages/flame_sprite_fusion/CHANGELOG.md @@ -1,3 +1,7 @@ +## 0.1.3+4 + + - **REFACTOR**: Fix lint issues from latest flutter release ([#3390](https://github.com/flame-engine/flame/issues/3390)). ([978ad31b](https://github.com/flame-engine/flame/commit/978ad31b429d1801097b0db385a600c85a157867)) + ## 0.1.3+3 - Update a dependency to the latest release. diff --git a/packages/flame_sprite_fusion/example/pubspec.yaml b/packages/flame_sprite_fusion/example/pubspec.yaml index 830467df34d..f1ee016ae70 100644 --- a/packages/flame_sprite_fusion/example/pubspec.yaml +++ b/packages/flame_sprite_fusion/example/pubspec.yaml @@ -9,8 +9,8 @@ environment: sdk: ">=3.4.0 <4.0.0" dependencies: - flame: ^1.22.0 - flame_sprite_fusion: ^0.1.3+3 + flame: ^1.23.0 + flame_sprite_fusion: ^0.1.3+4 flutter: sdk: flutter diff --git a/packages/flame_sprite_fusion/pubspec.yaml b/packages/flame_sprite_fusion/pubspec.yaml index b31511194d1..fa298a792d8 100644 --- a/packages/flame_sprite_fusion/pubspec.yaml +++ b/packages/flame_sprite_fusion/pubspec.yaml @@ -1,6 +1,6 @@ name: flame_sprite_fusion description: "Sprite Fusion support for the Flame game engine. This package parses and renders tilemaps exported from Sprite Fusion tool." -version: 0.1.3+3 +version: 0.1.3+4 homepage: https://github.com/flame-engine/flame/tree/main/packages/flame_sprite_fusion funding: - https://opencollective.com/blue-fire @@ -15,12 +15,12 @@ environment: flutter: ">=3.24.0" dependencies: - flame: ^1.22.0 + flame: ^1.23.0 flutter: sdk: flutter dev_dependencies: flame_lint: ^1.2.1 - flame_test: ^1.17.3 + flame_test: ^1.17.4 flutter_test: sdk: flutter diff --git a/packages/flame_studio/pubspec.yaml b/packages/flame_studio/pubspec.yaml index 41a9731e9be..2797357aafa 100644 --- a/packages/flame_studio/pubspec.yaml +++ b/packages/flame_studio/pubspec.yaml @@ -14,7 +14,7 @@ environment: dependencies: collection: ^1.17.1 - flame: ^1.22.0 + flame: ^1.23.0 flutter: sdk: flutter flutter_riverpod: ^2.3.6 diff --git a/packages/flame_svg/CHANGELOG.md b/packages/flame_svg/CHANGELOG.md index bb03fbd1fc1..57e87129d8d 100644 --- a/packages/flame_svg/CHANGELOG.md +++ b/packages/flame_svg/CHANGELOG.md @@ -1,3 +1,7 @@ +## 1.11.4 + + - **REFACTOR**: Fix lint issues from latest flutter release ([#3390](https://github.com/flame-engine/flame/issues/3390)). ([978ad31b](https://github.com/flame-engine/flame/commit/978ad31b429d1801097b0db385a600c85a157867)) + ## 1.11.3 - Update a dependency to the latest release. diff --git a/packages/flame_svg/example/pubspec.yaml b/packages/flame_svg/example/pubspec.yaml index 3b1685ff04f..2c5419a8502 100644 --- a/packages/flame_svg/example/pubspec.yaml +++ b/packages/flame_svg/example/pubspec.yaml @@ -9,8 +9,8 @@ environment: sdk: ">=3.4.0 <4.0.0" dependencies: - flame: ^1.22.0 - flame_svg: ^1.11.3 + flame: ^1.23.0 + flame_svg: ^1.11.4 flutter: sdk: flutter diff --git a/packages/flame_svg/pubspec.yaml b/packages/flame_svg/pubspec.yaml index ca48acb0486..73133f6b858 100644 --- a/packages/flame_svg/pubspec.yaml +++ b/packages/flame_svg/pubspec.yaml @@ -1,6 +1,6 @@ name: flame_svg description: Package to add SVG rendering support for the Flame game engine -version: 1.11.3 +version: 1.11.4 homepage: https://github.com/flame-engine/flame/tree/main/packages/flame_svg funding: - https://opencollective.com/blue-fire @@ -16,7 +16,7 @@ environment: flutter: ">=3.24.0" dependencies: - flame: ^1.22.0 + flame: ^1.23.0 flutter: sdk: flutter flutter_svg: ^2.0.5 @@ -26,5 +26,5 @@ dev_dependencies: flame_lint: ^1.2.1 flutter_test: sdk: flutter - mocktail: ^1.0.3 + mocktail: ^1.0.4 test: any diff --git a/packages/flame_test/CHANGELOG.md b/packages/flame_test/CHANGELOG.md index a8b1edc5d32..967de0faef6 100644 --- a/packages/flame_test/CHANGELOG.md +++ b/packages/flame_test/CHANGELOG.md @@ -1,3 +1,7 @@ +## 1.17.4 + + - **REFACTOR**: Fix lint issues from latest flutter release ([#3390](https://github.com/flame-engine/flame/issues/3390)). ([978ad31b](https://github.com/flame-engine/flame/commit/978ad31b429d1801097b0db385a600c85a157867)) + ## 1.17.3 - Update a dependency to the latest release. diff --git a/packages/flame_test/example/pubspec.yaml b/packages/flame_test/example/pubspec.yaml index d87cd1fbabc..553a303668f 100644 --- a/packages/flame_test/example/pubspec.yaml +++ b/packages/flame_test/example/pubspec.yaml @@ -8,13 +8,13 @@ environment: sdk: ">=3.4.0 <4.0.0" dependencies: - flame: ^1.22.0 + flame: ^1.23.0 flutter: sdk: flutter dev_dependencies: flame_lint: ^1.2.1 - flame_test: ^1.17.3 + flame_test: ^1.17.4 flutter_test: sdk: flutter test: any diff --git a/packages/flame_test/pubspec.yaml b/packages/flame_test/pubspec.yaml index d1f7a1114d6..6706cbcdfa6 100644 --- a/packages/flame_test/pubspec.yaml +++ b/packages/flame_test/pubspec.yaml @@ -1,6 +1,6 @@ name: flame_test description: A package with classes to help testing applications using Flame -version: 1.17.3 +version: 1.17.4 homepage: https://github.com/flame-engine/flame/tree/main/packages/flame_test funding: - https://opencollective.com/blue-fire @@ -16,7 +16,7 @@ environment: flutter: ">=3.24.0" dependencies: - flame: ^1.22.0 + flame: ^1.23.0 flutter: sdk: flutter flutter_test: diff --git a/packages/flame_texturepacker/CHANGELOG.md b/packages/flame_texturepacker/CHANGELOG.md index 636eb390955..731c5069c39 100644 --- a/packages/flame_texturepacker/CHANGELOG.md +++ b/packages/flame_texturepacker/CHANGELOG.md @@ -1,3 +1,7 @@ +## 4.1.4 + + - Update a dependency to the latest release. + ## 4.1.3 - Update a dependency to the latest release. diff --git a/packages/flame_texturepacker/example/pubspec.yaml b/packages/flame_texturepacker/example/pubspec.yaml index 22342021cae..3daa2002b6e 100644 --- a/packages/flame_texturepacker/example/pubspec.yaml +++ b/packages/flame_texturepacker/example/pubspec.yaml @@ -8,8 +8,8 @@ environment: flutter: ">=3.24.0" dependencies: - flame: ^1.22.0 - flame_texturepacker: ^4.1.3 + flame: ^1.23.0 + flame_texturepacker: ^4.1.4 flutter: sdk: flutter diff --git a/packages/flame_texturepacker/pubspec.yaml b/packages/flame_texturepacker/pubspec.yaml index ab772aeff75..eea2aa93a0b 100644 --- a/packages/flame_texturepacker/pubspec.yaml +++ b/packages/flame_texturepacker/pubspec.yaml @@ -1,6 +1,6 @@ name: flame_texturepacker description: A simple plugin for the Flame Engine to import spritesheets generated by the TexturePacker tool. -version: 4.1.3 +version: 4.1.4 homepage: https://github.com/flame-engine/flame/tree/main/packages/flame_texturepacker funding: - https://opencollective.com/blue-fire @@ -16,7 +16,7 @@ environment: dependencies: collection: ^1.17.1 - flame: ^1.22.0 + flame: ^1.23.0 flutter: sdk: flutter @@ -24,3 +24,4 @@ dev_dependencies: flame_lint: ^1.2.1 flutter_test: sdk: flutter + mocktail: ^1.0.4 diff --git a/packages/flame_texturepacker/test/flame_texturepacker_test.dart b/packages/flame_texturepacker/test/flame_texturepacker_test.dart new file mode 100644 index 00000000000..93e356b5bde --- /dev/null +++ b/packages/flame_texturepacker/test/flame_texturepacker_test.dart @@ -0,0 +1,69 @@ +import 'dart:io'; + +import 'package:flame/cache.dart'; +import 'package:flame/flame.dart'; +import 'package:flame/game.dart'; +import 'package:flame_texturepacker/flame_texturepacker.dart'; +import 'package:flutter/services.dart'; +import 'package:flutter_test/flutter_test.dart'; +import 'package:mocktail/mocktail.dart'; + +class _MockAssetBundle extends Mock implements AssetBundle {} + +void main() { + TestWidgetsFlutterBinding.ensureInitialized(); + + group('TexturepackerLoader', () { + const atlasPath = + 'test/assets/newFormat/multiplePages/MultiplePageAtlasMap.atlas'; + const atlasImage1 = + 'test/assets/newFormat/multiplePages/MultiplePageAtlasMap.png'; + + test('load atlas from storage', () async { + final flameGame = FlameGame(); + final atlas = await flameGame.atlasFromStorage(atlasPath); + + expect(atlas, isNotNull); + expect(atlas.sprites.length, equals(12)); + + final firstSprite = atlas.findSpriteByName('robot_walk'); + expect(firstSprite, isNotNull); + expect(firstSprite!.srcSize, isNotNull); + expect(firstSprite.srcPosition, isNotNull); + }); + + test('load atlas from assets', () async { + final bundle = _MockAssetBundle(); + when(() => bundle.loadString(any())) + .thenAnswer((_) async => File(atlasPath).readAsString()); + when(() => bundle.load(any())).thenAnswer( + (_) async => ByteData.sublistView( + File(atlasImage1).readAsBytesSync(), + ), + ); + + final flameGame = FlameGame(); + Flame.assets = AssetsCache(bundle: bundle, prefix: ''); + Flame.images = Images(bundle: bundle, prefix: ''); + + final atlas = await flameGame.atlasFromAssets(atlasPath); + + expect(atlas, isNotNull); + expect(atlas.sprites.length, equals(12)); + + final firstSprite = atlas.findSpriteByName('robot_walk'); + expect(firstSprite, isNotNull); + expect(firstSprite!.srcSize.x, greaterThan(0)); + expect(firstSprite.srcSize.y, greaterThan(0)); + expect(firstSprite.srcPosition, isNotNull); + }); + + test('throws exception for invalid atlas path', () async { + final flameGame = FlameGame(); + expect( + () => flameGame.atlasFromStorage('invalid_path.atlas'), + throwsException, + ); + }); + }); +} diff --git a/packages/flame_texturepacker/test/legacy_format_test.dart b/packages/flame_texturepacker/test/legacy_format_test.dart index 82d8cd11c97..050688f01ec 100644 --- a/packages/flame_texturepacker/test/legacy_format_test.dart +++ b/packages/flame_texturepacker/test/legacy_format_test.dart @@ -1,7 +1,12 @@ +import 'dart:math' as math; +import 'dart:ui'; + import 'package:flame/components.dart'; import 'package:flame_texturepacker/flame_texturepacker.dart'; -import 'package:flutter/services.dart'; import 'package:flutter_test/flutter_test.dart'; +import 'package:mocktail/mocktail.dart'; + +class _MockCanvas extends Mock implements Canvas {} void main() { TestWidgetsFlutterBinding.ensureInitialized(); @@ -59,6 +64,7 @@ void main() { expect(jumpSprite.srcSize, Vector2(192, 256)); expect(jumpSprite.originalSize, Vector2(192, 256)); expect(jumpSprite.offset, Vector2(0, 0)); + expect(jumpSprite.angle, math.pi / 2); final walkSprite = atlas.findSpriteByName('robot_walk')!; expect(walkSprite.rotate, false); @@ -75,6 +81,7 @@ void main() { expect(walkSprite.srcSize, Vector2(192, 256)); expect(walkSprite.originalSize, Vector2(192, 256)); expect(walkSprite.offset, Vector2(0, 0)); + expect(walkSprite.angle, 0); }); test('Trimmed sprite data is loaded correctly', () async { @@ -98,12 +105,14 @@ void main() { expect(idleSprite.srcSize, Vector2(192, 256)); expect(idleSprite.originalSize, Vector2(192, 256)); expect(idleSprite.offset, Vector2(31, 0)); + expect(idleSprite.angle, 0); final idleSpritePackedSize = idleSprite.clone(useOriginalSize: false); expect(idleSpritePackedSize.src, const Rect.fromLTWH(0, 310, 130, 182)); expect(idleSpritePackedSize.srcSize, Vector2(130, 182)); expect(idleSpritePackedSize.originalSize, Vector2(130, 182)); expect(idleSpritePackedSize.offset, Vector2(0, 0)); + expect(idleSpritePackedSize.angle, 0); final walkSprite = atlas.findSpriteByName('robot_walk')!; expect(walkSprite.rotate, true); @@ -120,12 +129,14 @@ void main() { expect(walkSprite.srcSize, Vector2(192, 256)); expect(walkSprite.originalSize, Vector2(192, 256)); expect(walkSprite.offset, Vector2(14, 2)); + expect(walkSprite.angle, math.pi / 2); final walkSpritePackedSize = walkSprite.clone(useOriginalSize: false); expect(walkSpritePackedSize.src, const Rect.fromLTWH(0, 0, 183, 150)); expect(walkSpritePackedSize.srcSize, Vector2(150, 183)); expect(walkSpritePackedSize.originalSize, Vector2(150, 183)); expect(walkSpritePackedSize.offset, Vector2(0, 0)); + expect(walkSpritePackedSize.angle, math.pi / 2); }); }); group('Single page atlas', () { @@ -159,6 +170,15 @@ void main() { expect(jumpSprite, isNotNull); }); + test('findSpriteByNameIndex will return 1 sprite', () async { + final atlas = await TexturePackerAtlas.load( + atlasPath, + fromStorage: true, + ); + final jumpSprite = atlas.findSpriteByNameIndex('robot_jump', -1); + expect(jumpSprite, isNotNull); + }); + test('Sprite data is loaded correctly', () async { final atlas = await TexturePackerAtlas.load( atlasPath, @@ -180,6 +200,7 @@ void main() { expect(jumpSprite.srcSize, Vector2(192, 256)); expect(jumpSprite.originalSize, Vector2(192, 256)); expect(jumpSprite.offset, Vector2(0, 0)); + expect(jumpSprite.angle, 0); final walkSprite = atlas.findSpriteByName('robot_walk')!; expect(walkSprite.rotate, false); @@ -196,6 +217,7 @@ void main() { expect(walkSprite.srcSize, Vector2(192, 256)); expect(walkSprite.originalSize, Vector2(192, 256)); expect(walkSprite.offset, Vector2(0, 0)); + expect(walkSprite.angle, 0); }); test('Trimmed sprite data is loaded correctly', () async { @@ -219,12 +241,14 @@ void main() { expect(idleSprite.srcSize, Vector2(192, 256)); expect(idleSprite.originalSize, Vector2(192, 256)); expect(idleSprite.offset, Vector2(31, 0)); + expect(idleSprite.angle, 0); final idleSpritePackedSize = idleSprite.clone(useOriginalSize: false); expect(idleSpritePackedSize.src, const Rect.fromLTWH(0, 160, 130, 182)); expect(idleSpritePackedSize.srcSize, Vector2(130, 182)); expect(idleSpritePackedSize.originalSize, Vector2(130, 182)); expect(idleSpritePackedSize.offset, Vector2(0, 0)); + expect(idleSpritePackedSize.angle, 0); final walkSprite = atlas.findSpriteByName('robot_walk')!; expect(walkSprite.rotate, true); @@ -241,12 +265,93 @@ void main() { expect(walkSprite.srcSize, Vector2(192, 256)); expect(walkSprite.originalSize, Vector2(192, 256)); expect(walkSprite.offset, Vector2(14, 2)); + expect(walkSprite.angle, math.pi / 2); final walkSpritePackedSize = walkSprite.clone(useOriginalSize: false); expect(walkSpritePackedSize.src, const Rect.fromLTWH(191, 367, 183, 150)); expect(walkSpritePackedSize.srcSize, Vector2(150, 183)); expect(walkSpritePackedSize.originalSize, Vector2(150, 183)); expect(walkSpritePackedSize.offset, Vector2(0, 0)); + expect(walkSpritePackedSize.angle, math.pi / 2); + }); + + test('Sprite renders correctly when not rotated', () async { + final atlas = await TexturePackerAtlas.load( + atlasPath, + fromStorage: true, + ); + + final sprite = atlas.findSpriteByName('robot_jump')!; + final canvas = _MockCanvas(); + + sprite.render( + canvas, + position: Vector2(100, 100), + size: Vector2(384, 512), + ); + + expect(sprite.rotate, false); + expect(sprite.offset, Vector2.zero()); + expect(sprite.originalSize, Vector2(192, 256)); + expect(sprite.srcSize, Vector2(192, 256)); + }); + + test('Sprite renders correctly when rotated', () async { + final atlas = await TexturePackerAtlas.load( + atlasTrimmedPath, + fromStorage: true, + ); + + final sprite = atlas.findSpriteByName('robot_walk')!; + final canvas = _MockCanvas(); + + sprite.render( + canvas, + position: Vector2(100, 100), + size: Vector2(384, 512), + ); + + expect(sprite.rotate, true); + expect(sprite.offset, Vector2(14, 2)); + expect(sprite.originalSize, Vector2(192, 256)); + expect(sprite.srcSize, Vector2(192, 256)); + expect(sprite.angle, math.pi / 2); + }); + + test('Sprite renders with correct anchor point', () async { + final atlas = await TexturePackerAtlas.load( + atlasPath, + fromStorage: true, + ); + + final sprite = atlas.findSpriteByName('robot_jump')!; + final canvas = _MockCanvas(); + + sprite.render( + canvas, + position: Vector2(100, 100), + size: Vector2(192, 256), + anchor: Anchor.center, + ); + + expect(sprite.originalSize, Vector2(192, 256)); + }); + + test('Sprite renders correctly with default position', () async { + final atlas = await TexturePackerAtlas.load( + atlasPath, + fromStorage: true, + ); + + final sprite = atlas.findSpriteByName('robot_jump')!; + final canvas = _MockCanvas(); + + sprite.render( + canvas, + size: Vector2(192, 256), + ); + + expect(sprite.originalSize, Vector2(192, 256)); }); }); } diff --git a/packages/flame_texturepacker/test/new_format_test.dart b/packages/flame_texturepacker/test/new_format_test.dart index 0785e6e768e..f77ae76aa3b 100644 --- a/packages/flame_texturepacker/test/new_format_test.dart +++ b/packages/flame_texturepacker/test/new_format_test.dart @@ -1,7 +1,12 @@ +import 'dart:math' as math; +import 'dart:ui'; + import 'package:flame/components.dart'; import 'package:flame_texturepacker/flame_texturepacker.dart'; -import 'package:flutter/services.dart'; import 'package:flutter_test/flutter_test.dart'; +import 'package:mocktail/mocktail.dart'; + +class _MockCanvas extends Mock implements Canvas {} void main() { TestWidgetsFlutterBinding.ensureInitialized(); @@ -37,6 +42,15 @@ void main() { expect(jumpSprite, isNotNull); }); + test('findSpriteByNameIndex will return 1 sprite', () async { + final atlas = await TexturePackerAtlas.load( + atlasPath, + fromStorage: true, + ); + final jumpSprite = atlas.findSpriteByNameIndex('robot_jump', -1); + expect(jumpSprite, isNotNull); + }); + test('Sprite data is loaded correctly', () async { final atlas = await TexturePackerAtlas.load( atlasPath, @@ -58,6 +72,7 @@ void main() { expect(jumpSprite.srcSize, Vector2(192, 256)); expect(jumpSprite.originalSize, Vector2(192, 256)); expect(jumpSprite.offset, Vector2(0, 0)); + expect(jumpSprite.angle, math.pi / 2); final walkSprite = atlas.findSpriteByName('robot_walk')!; expect(walkSprite.rotate, false); @@ -74,6 +89,7 @@ void main() { expect(walkSprite.srcSize, Vector2(192, 256)); expect(walkSprite.originalSize, Vector2(192, 256)); expect(walkSprite.offset, Vector2(0, 0)); + expect(walkSprite.angle, 0); }); test('Trimmed sprite data is loaded correctly', () async { final atlas = await TexturePackerAtlas.load( @@ -96,12 +112,14 @@ void main() { expect(idleSprite.srcSize, Vector2(192, 256)); expect(idleSprite.originalSize, Vector2(192, 256)); expect(idleSprite.offset, Vector2(31, 0)); + expect(idleSprite.angle, 0); final idleSpritePackedSize = idleSprite.clone(useOriginalSize: false); expect(idleSpritePackedSize.src, const Rect.fromLTWH(0, 310, 130, 182)); expect(idleSpritePackedSize.srcSize, Vector2(130, 182)); expect(idleSpritePackedSize.originalSize, Vector2(130, 182)); expect(idleSpritePackedSize.offset, Vector2(0, 0)); + expect(idleSpritePackedSize.angle, 0); final walkSprite = atlas.findSpriteByName('robot_walk')!; expect(walkSprite.rotate, true); @@ -118,12 +136,72 @@ void main() { expect(walkSprite.srcSize, Vector2(192, 256)); expect(walkSprite.originalSize, Vector2(192, 256)); expect(walkSprite.offset, Vector2(14, 2)); + expect(walkSprite.angle, math.pi / 2); final walkSpritePackedSize = walkSprite.clone(useOriginalSize: false); expect(walkSpritePackedSize.src, const Rect.fromLTWH(0, 0, 183, 150)); expect(walkSpritePackedSize.srcSize, Vector2(150, 183)); expect(walkSpritePackedSize.originalSize, Vector2(150, 183)); expect(walkSpritePackedSize.offset, Vector2(0, 0)); + expect(walkSpritePackedSize.angle, math.pi / 2); + }); + + test('Sprite renders correctly', () async { + final atlas = await TexturePackerAtlas.load( + atlasPath, + fromStorage: true, + ); + + final sprite = atlas.findSpriteByName('robot_jump')!; + final canvas = _MockCanvas(); + + sprite.render( + canvas, + position: Vector2(100, 100), + size: Vector2(384, 512), + ); + + expect(sprite.rotate, true); + expect(sprite.offset, Vector2.zero()); + expect(sprite.originalSize, Vector2(192, 256)); + expect(sprite.srcSize, Vector2(192, 256)); + expect(sprite.angle, math.pi / 2); + }); + + test('Sprite renders with correct anchor point', () async { + final atlas = await TexturePackerAtlas.load( + atlasPath, + fromStorage: true, + ); + + final sprite = atlas.findSpriteByName('robot_jump')!; + final canvas = _MockCanvas(); + + sprite.render( + canvas, + position: Vector2(100, 100), + size: Vector2(192, 256), + anchor: Anchor.center, + ); + + expect(sprite.originalSize, Vector2(192, 256)); + }); + + test('Sprite renders correctly with default position', () async { + final atlas = await TexturePackerAtlas.load( + atlasPath, + fromStorage: true, + ); + + final sprite = atlas.findSpriteByName('robot_jump')!; + final canvas = _MockCanvas(); + + sprite.render( + canvas, + size: Vector2(192, 256), + ); + + expect(sprite.originalSize, Vector2(192, 256)); }); }); @@ -180,6 +258,7 @@ void main() { expect(jumpSprite.srcSize, Vector2(192, 256)); expect(jumpSprite.originalSize, Vector2(192, 256)); expect(jumpSprite.offset, Vector2(0, 0)); + expect(jumpSprite.angle, 0); final walkSprite = atlas.findSpriteByName('robot_walk')!; expect(walkSprite.rotate, false); @@ -196,6 +275,7 @@ void main() { expect(walkSprite.srcSize, Vector2(192, 256)); expect(walkSprite.originalSize, Vector2(192, 256)); expect(walkSprite.offset, Vector2(0, 0)); + expect(walkSprite.angle, 0); }); test('Trimmed sprite data is loaded correctly', () async { final atlas = await TexturePackerAtlas.load( @@ -218,12 +298,14 @@ void main() { expect(idleSprite.srcSize, Vector2(192, 256)); expect(idleSprite.originalSize, Vector2(192, 256)); expect(idleSprite.offset, Vector2(31, 0)); + expect(idleSprite.angle, 0); final idleSpritePackedSize = idleSprite.clone(useOriginalSize: false); expect(idleSpritePackedSize.src, const Rect.fromLTWH(0, 160, 130, 182)); expect(idleSpritePackedSize.srcSize, Vector2(130, 182)); expect(idleSpritePackedSize.originalSize, Vector2(130, 182)); expect(idleSpritePackedSize.offset, Vector2(0, 0)); + expect(idleSpritePackedSize.angle, 0); final walkSprite = atlas.findSpriteByName('robot_walk')!; expect(walkSprite.rotate, true); @@ -240,12 +322,72 @@ void main() { expect(walkSprite.srcSize, Vector2(192, 256)); expect(walkSprite.originalSize, Vector2(192, 256)); expect(walkSprite.offset, Vector2(14, 2)); + expect(walkSprite.angle, math.pi / 2); final walkSpritePackedSize = walkSprite.clone(useOriginalSize: false); expect(walkSpritePackedSize.src, const Rect.fromLTWH(191, 367, 183, 150)); expect(walkSpritePackedSize.srcSize, Vector2(150, 183)); expect(walkSpritePackedSize.originalSize, Vector2(150, 183)); expect(walkSpritePackedSize.offset, Vector2(0, 0)); + expect(walkSpritePackedSize.angle, math.pi / 2); + }); + + test('Sprite renders correctly', () async { + final atlas = await TexturePackerAtlas.load( + atlasTrimmedPath, + fromStorage: true, + ); + + final sprite = atlas.findSpriteByName('robot_walk')!; + final canvas = _MockCanvas(); + + sprite.render( + canvas, + position: Vector2(100, 100), + size: Vector2(384, 512), + ); + + expect(sprite.rotate, true); + expect(sprite.offset, Vector2(14, 2)); + expect(sprite.originalSize, Vector2(192, 256)); + expect(sprite.srcSize, Vector2(192, 256)); + expect(sprite.angle, math.pi / 2); + }); + + test('Sprite renders with correct anchor point', () async { + final atlas = await TexturePackerAtlas.load( + atlasPath, + fromStorage: true, + ); + + final sprite = atlas.findSpriteByName('robot_jump')!; + final canvas = _MockCanvas(); + + sprite.render( + canvas, + position: Vector2(100, 100), + size: Vector2(192, 256), + anchor: Anchor.center, + ); + + expect(sprite.originalSize, Vector2(192, 256)); + }); + + test('Sprite renders correctly with default position', () async { + final atlas = await TexturePackerAtlas.load( + atlasPath, + fromStorage: true, + ); + + final sprite = atlas.findSpriteByName('robot_jump')!; + final canvas = _MockCanvas(); + + sprite.render( + canvas, + size: Vector2(192, 256), + ); + + expect(sprite.originalSize, Vector2(192, 256)); }); }); } diff --git a/packages/flame_tiled/CHANGELOG.md b/packages/flame_tiled/CHANGELOG.md index 8c7db04629d..4a732cbfc6f 100644 --- a/packages/flame_tiled/CHANGELOG.md +++ b/packages/flame_tiled/CHANGELOG.md @@ -1,3 +1,7 @@ +## 1.21.2 + + - **REFACTOR**: Fix lint issues from latest flutter release ([#3390](https://github.com/flame-engine/flame/issues/3390)). ([978ad31b](https://github.com/flame-engine/flame/commit/978ad31b429d1801097b0db385a600c85a157867)) + ## 1.21.1 - Update a dependency to the latest release. diff --git a/packages/flame_tiled/example/pubspec.yaml b/packages/flame_tiled/example/pubspec.yaml index dab70ac1dad..91ed8a473a8 100644 --- a/packages/flame_tiled/example/pubspec.yaml +++ b/packages/flame_tiled/example/pubspec.yaml @@ -7,8 +7,8 @@ environment: sdk: ">=3.4.0 <4.0.0" dependencies: - flame: ^1.22.0 - flame_tiled: ^1.21.1 + flame: ^1.23.0 + flame_tiled: ^1.21.2 flutter: sdk: flutter diff --git a/packages/flame_tiled/pubspec.yaml b/packages/flame_tiled/pubspec.yaml index 727e3a1b3c4..d2c165d38c0 100644 --- a/packages/flame_tiled/pubspec.yaml +++ b/packages/flame_tiled/pubspec.yaml @@ -1,6 +1,6 @@ name: flame_tiled description: Tiled support for the Flame game engine. This uses the tiled package and provides wrappers and components to be used inside Flame. -version: 1.21.1 +version: 1.21.2 homepage: https://github.com/flame-engine/flame/tree/main/packages/flame_tiled funding: - https://opencollective.com/blue-fire @@ -17,7 +17,7 @@ environment: dependencies: collection: ^1.17.1 - flame: ^1.22.0 + flame: ^1.23.0 flutter: sdk: flutter meta: ^1.12.0