This PR addresses the concerns in
https://github.com/flame-engine/flame/issues/3488
For convenience, here is the relevant text.
> It is a fairly common feature for a game to "type out" dialogue within
a TextBoxComponent (as the behavior would be if timePerChar > 0, but
also allow the user to skip that type-out effect, and display the
dialogue in its entirety (as the behavior would be if timePerChar == 0).
This PR implements a setter for TextBoxComponent.boxConfig, allowing for
the TextBoxConfig to be changed after TextBoxComponent is instantiated.
The `_boxConfig` has been made non-final to allow this field to be
modifiable.
Additionally, a `skip` method is implemented which more explicitly
provides the intended skipping behavior.
---------
Co-authored-by: Lukas Klingsbo <me@lukas.fyi>
Add helper methods to create matrix4 with sensible defaults.
The provided `compose` function from `Matrix4` has two issues IMO:
* no sensible defaults, so all 3 parameters must be specified
* no named parameters, which can cause confusion when used
These new helpers make it much easier to create simpler matrixes,
especially for a single or couple of operations (but not all 3).
# Description
AudioPlayers used to mix their sounds with other audio on the device,
which is not the proposed experience on Mobile devices. So this behavior
was changed in AudioPlayers, but it wasn't enforced due to a bug.
Obviously this behavior is not wanted for Games as multiple sounds
should play simultaneously, so this recovers the old functionality
again.
## Checklist
<!--
Before you create this PR confirm that it meets all requirements listed
below by checking the
relevant checkboxes with `[x]`. If some checkbox is not applicable, mark
it as `[-]`.
-->
- [x] I have followed the [Contributor Guide] when preparing my PR.
- [ ] I have updated/added tests for ALL new/updated/fixed
functionality.
- [ ] I have updated/added relevant documentation in `docs` and added
dartdoc comments with `///`.
- [x] I have updated/added relevant examples in `examples` or `docs`.
Not sure, if I can test this properly, as it's on a system level. I
could ensure the values are set though (?)
## Breaking Change?
I'm actually not sure, if this is breaking, I think it's not, as
`audioplayers` used to work like `mixWithOthers` due to a bug, but is
not anymore.
- [ ] Yes, this PR is a breaking change.
- [x] No, this PR is not a breaking change.
<!--
### Migration instructions
If the PR is breaking, uncomment this header and add instructions for
how to migrate from the
currently released version in-between the two following tags:
-->
<!-- End of exclude from commit message -->
---------
Co-authored-by: Lukas Klingsbo <me@lukas.fyi>
This creates a generic `CloseToVector` class to be used to power the
existing `closeToVector2` and `closeToVector3` and brand-new
`closeToVector4` and `closeToQuaternion` matchers. This base class is
not exposed (for now; but we could reconsider if demand arises).
Simplify and unify syntax used for exports on flame_test.
The file in question only has one public class, which is exported.
This brings it in line with all other exports on the file - the only
exception being `test_golden.dart` which does indeed declare other
auxiliary public types.
# Description
CommandDash is shutting down and the AI Code assist isn't operational
anymore. This PR requests its removal from the all Readme.
We're thankful for being able to serve the community and apologise for
the interruption.
## Checklist
- [X] I have followed the [Contributor Guide] when preparing my PR.
- [X] I have updated/added tests for ALL new/updated/fixed
functionality.
- [X] I have updated/added relevant documentation in `docs` and added
dartdoc comments with `///`.
- [x] I have updated/added relevant examples in `examples` or `docs`.
This moves to the slightly breaking tiled 0.11.0 version (it moves away
from `Color` and uses its own `ColorData` class instead).
### Migration instructions
Use `colorData.toColor()` if you need a `Color` object from tiled.
Replaces uses of `.forEach()` with regular `for` loops. This has
significant impact on performance in hot paths such as
`Component.updateTree()` and `Component.renderTree()`.

In the graph above, you see 50 runs of
`benchmark/update_components_benchmark.dart`. The forEach results are
blue, the for-loop results are green. I could see this effect after just
replacing the `forEach` calls in `component.dart`. Data
[here](https://docs.google.com/spreadsheets/d/e/2PACX-1vRk_yGmLN6o0oqSUWDBh7ODx7B8EIToeahZcZBS3VKHX8AbEnmrgmEqDt98cZLoBjIKQX3MlOc0XwsP/pubhtml).
> Aside for posterity: `for i in {1..50}; do flutter test
benchmark/main.dart --no-pub -r silent 2>/dev/null >>
benchmarks_for_loop.txt; done`, then get the data from the text file.
I went ahead and replaced additional `forEach` calls elsewhere in the
engine codebase, but there was no additional effect on the benchmark.
Still, I kept those changes in. I only replaced `forEach` in places that
seemed relatively hot (e.g. `ComponentSet.reorder()`). There are more
`forEach` calls in the codebase but those seem fine to me as they aren't
likely to be called too often.
It should be noted that I needed to update the benchmark to add children
to the components. Every `_BenchmarkComponent` now has 10 children. This
feels a bit more realistic use of the framework than having a flat array
of components with no children. By changing the benchmark code in this
way, I made it a bit slower, so I'm not sure if the effect will be seen
in the CI/CD.
I also tried whether the change will have effect on my game's benchmark
(which is a lot more involved and uses `flutter driver` to test the
whole game in AOT mode). For the game, the effect is negligible but that
was kind of expected since my game spends a significant amount of its
CPU time on AI, raycasting, smoke simulation and drawVertices, none of
which really depend on the speed of the engine `update()` mechanism.
---------
Co-authored-by: Erick <erickzanardoo@gmail.com>
Make resource creation be on demand to enable testing.
Basically changes how the `Resource` class work:
* resources are lazily loaded
* the Resource class is responsible for re-creating resources when
needed
* children just provide the recreateResource boolean
This adds a possibility to override the paint in the `NineTileBox` class
which enables `NineTileBoxComponent` to have `HasPaint`, so that opacity
and color effects can be used on it.
Fixes: #3430
On https://docs.flame-engine.org/latest/ towards the bottom it says
`void onTapUp(TapUpInfo info)`
However, this causes the following error on the latest version of Flame
(1.23.0):
```
'Player.onTapUp' ('void Function(TapUpInfo)') isn't a valid override of 'TapCallbacks.onTapUp' ('void Function(TapUpEvent)').dartinvalid_override
tap_callbacks.dart(16, 8): The member being overridden.
```
Changing TapUpInfo to TapUpEvent fixes it.
This PR adds a debug navigation to the flame `devtools` extension,
allowing developers to quickly switch between `overlays`.
https://github.com/user-attachments/assets/00d5e2f8-d78b-4ba4-92cb-b0c295d76ba6
### Changes
1. added getter for `registeredOverlays` to `OverlayManager`
2. created `OverlayNavigationConnector` exposing `getOverlays` and
`navigateToOverlay` to the devtools
3. added `getOverlays` and `navigateToOverlay` to `Repository`
4. created `OverlayNavigation` holding a list of all
`registeredOverlays` which when an item is tapped shows this `overlay`
If you have any ideas/remarks/suggestions please let me know 🚀
---------
Co-authored-by: Lukas Klingsbo <me@lukas.fyi>
add multiFactory to SpawnComponent to be able to create a list of
components for each spawn tick. For backwards compatibility the single
component factory is still supported and wrapped internally.
This PR enhances the SpawnComponent to accept a multiFactory which adds
a list of components per tick instead of just one.
---------
Co-authored-by: Patrick Cornelißen <patrick.cornelissen@ars.de>
Co-authored-by: Luan Nico <luanpotter27@gmail.com>
Co-authored-by: Lukas Klingsbo <lukas.klingsbo@gmail.com>
Enhance tests for flame_markdown to ensure nested styles are propagated.
Specifically adds a second section to each test to assert the element
tree (after having asserted the node tree).
And then uses that to add a nested inline style test making sure the
"CSS" is propagated and merged correctly.
Bumps [jinja2](https://github.com/pallets/jinja) from 3.1.4 to 3.1.5.
<details>
<summary>Release notes</summary>
<p><em>Sourced from <a
href="https://github.com/pallets/jinja/releases">jinja2's
releases</a>.</em></p>
<blockquote>
<h2>3.1.5</h2>
<p>This is the Jinja 3.1.5 security fix release, which fixes security
issues and bugs but does not otherwise change behavior and should not
result in breaking changes compared to the latest feature release.</p>
<p>PyPI: <a
href="https://pypi.org/project/Jinja2/3.1.5/">https://pypi.org/project/Jinja2/3.1.5/</a>
Changes: <a
href="https://jinja.palletsprojects.com/changes/#version-3-1-5">https://jinja.palletsprojects.com/changes/#version-3-1-5</a>
Milestone: <a
href="https://github.com/pallets/jinja/milestone/16?closed=1">https://github.com/pallets/jinja/milestone/16?closed=1</a></p>
<ul>
<li>The sandboxed environment handles indirect calls to
<code>str.format</code>, such as by passing a stored reference to a
filter that calls its argument. <a
href="https://github.com/pallets/jinja/security/advisories/GHSA-q2x7-8rv6-6q7h">GHSA-q2x7-8rv6-6q7h</a></li>
<li>Escape template name before formatting it into error messages, to
avoid issues with names that contain f-string syntax. <a
href="https://redirect.github.com/pallets/jinja/issues/1792">#1792</a>,
<a
href="https://github.com/pallets/jinja/security/advisories/GHSA-gmj6-6f8f-6699">GHSA-gmj6-6f8f-6699</a></li>
<li>Sandbox does not allow <code>clear</code> and <code>pop</code> on
known mutable sequence types. <a
href="https://redirect.github.com/pallets/jinja/issues/2032">#2032</a></li>
<li>Calling sync <code>render</code> for an async template uses
<code>asyncio.run</code>. <a
href="https://redirect.github.com/pallets/jinja/issues/1952">#1952</a></li>
<li>Avoid unclosed <code>auto_aiter</code> warnings. <a
href="https://redirect.github.com/pallets/jinja/issues/1960">#1960</a></li>
<li>Return an <code>aclose</code>-able <code>AsyncGenerator</code> from
<code>Template.generate_async</code>. <a
href="https://redirect.github.com/pallets/jinja/issues/1960">#1960</a></li>
<li>Avoid leaving <code>root_render_func()</code> unclosed in
<code>Template.generate_async</code>. <a
href="https://redirect.github.com/pallets/jinja/issues/1960">#1960</a></li>
<li>Avoid leaving async generators unclosed in blocks, includes and
extends. <a
href="https://redirect.github.com/pallets/jinja/issues/1960">#1960</a></li>
<li>The runtime uses the correct <code>concat</code> function for the
current environment when calling block references. <a
href="https://redirect.github.com/pallets/jinja/issues/1701">#1701</a></li>
<li>Make <code>|unique</code> async-aware, allowing it to be used after
another async-aware filter. <a
href="https://redirect.github.com/pallets/jinja/issues/1781">#1781</a></li>
<li><code>|int</code> filter handles <code>OverflowError</code> from
scientific notation. <a
href="https://redirect.github.com/pallets/jinja/issues/1921">#1921</a></li>
<li>Make compiling deterministic for tuple unpacking in a <code>{% set
... %}</code> call. <a
href="https://redirect.github.com/pallets/jinja/issues/2021">#2021</a></li>
<li>Fix dunder protocol (<code>copy</code>/<code>pickle</code>/etc)
interaction with <code>Undefined</code> objects. <a
href="https://redirect.github.com/pallets/jinja/issues/2025">#2025</a></li>
<li>Fix <code>copy</code>/<code>pickle</code> support for the internal
<code>missing</code> object. <a
href="https://redirect.github.com/pallets/jinja/issues/2027">#2027</a></li>
<li><code>Environment.overlay(enable_async)</code> is applied correctly.
<a
href="https://redirect.github.com/pallets/jinja/issues/2061">#2061</a></li>
<li>The error message from <code>FileSystemLoader</code> includes the
paths that were searched. <a
href="https://redirect.github.com/pallets/jinja/issues/1661">#1661</a></li>
<li><code>PackageLoader</code> shows a clearer error message when the
package does not contain the templates directory. <a
href="https://redirect.github.com/pallets/jinja/issues/1705">#1705</a></li>
<li>Improve annotations for methods returning copies. <a
href="https://redirect.github.com/pallets/jinja/issues/1880">#1880</a></li>
<li><code>urlize</code> does not add <code>mailto:</code> to values like
<code>@a@b</code>. <a
href="https://redirect.github.com/pallets/jinja/issues/1870">#1870</a></li>
<li>Tests decorated with <code>@pass_context</code> can be used with the
<code>|select</code> filter. <a
href="https://redirect.github.com/pallets/jinja/issues/1624">#1624</a></li>
<li>Using <code>set</code> for multiple assignment (<code>a, b = 1,
2</code>) does not fail when the target is a namespace attribute. <a
href="https://redirect.github.com/pallets/jinja/issues/1413">#1413</a></li>
<li>Using <code>set</code> in all branches of <code>{% if %}{% elif %}{%
else %}</code> blocks does not cause the variable to be considered
initially undefined. <a
href="https://redirect.github.com/pallets/jinja/issues/1253">#1253</a></li>
</ul>
</blockquote>
</details>
<details>
<summary>Changelog</summary>
<p><em>Sourced from <a
href="https://github.com/pallets/jinja/blob/main/CHANGES.rst">jinja2's
changelog</a>.</em></p>
<blockquote>
<h2>Version 3.1.5</h2>
<p>Released 2024-12-21</p>
<ul>
<li>The sandboxed environment handles indirect calls to
<code>str.format</code>, such as
by passing a stored reference to a filter that calls its argument.
:ghsa:<code>q2x7-8rv6-6q7h</code></li>
<li>Escape template name before formatting it into error messages, to
avoid
issues with names that contain f-string syntax.
:issue:<code>1792</code>, :ghsa:<code>gmj6-6f8f-6699</code></li>
<li>Sandbox does not allow <code>clear</code> and <code>pop</code> on
known mutable sequence
types. :issue:<code>2032</code></li>
<li>Calling sync <code>render</code> for an async template uses
<code>asyncio.run</code>.
:pr:<code>1952</code></li>
<li>Avoid unclosed <code>auto_aiter</code> warnings.
:pr:<code>1960</code></li>
<li>Return an <code>aclose</code>-able <code>AsyncGenerator</code> from
<code>Template.generate_async</code>. :pr:<code>1960</code></li>
<li>Avoid leaving <code>root_render_func()</code> unclosed in
<code>Template.generate_async</code>. :pr:<code>1960</code></li>
<li>Avoid leaving async generators unclosed in blocks, includes and
extends.
:pr:<code>1960</code></li>
<li>The runtime uses the correct <code>concat</code> function for the
current environment
when calling block references. :issue:<code>1701</code></li>
<li>Make <code>|unique</code> async-aware, allowing it to be used after
another
async-aware filter. :issue:<code>1781</code></li>
<li><code>|int</code> filter handles <code>OverflowError</code> from
scientific notation.
:issue:<code>1921</code></li>
<li>Make compiling deterministic for tuple unpacking in a <code>{% set
... %}</code>
call. :issue:<code>2021</code></li>
<li>Fix dunder protocol (<code>copy</code>/<code>pickle</code>/etc)
interaction with <code>Undefined</code>
objects. :issue:<code>2025</code></li>
<li>Fix <code>copy</code>/<code>pickle</code> support for the internal
<code>missing</code> object.
:issue:<code>2027</code></li>
<li><code>Environment.overlay(enable_async)</code> is applied correctly.
:pr:<code>2061</code></li>
<li>The error message from <code>FileSystemLoader</code> includes the
paths that were
searched. :issue:<code>1661</code></li>
<li><code>PackageLoader</code> shows a clearer error message when the
package does not
contain the templates directory. :issue:<code>1705</code></li>
<li>Improve annotations for methods returning copies.
:pr:<code>1880</code></li>
<li><code>urlize</code> does not add <code>mailto:</code> to values like
<code>@a@b</code>. :pr:<code>1870</code></li>
<li>Tests decorated with <code>@pass_context`` can be used with the
``|select`` filter. :issue:</code>1624`</li>
<li>Using <code>set</code> for multiple assignment (<code>a, b = 1,
2</code>) does not fail when the
target is a namespace attribute. :issue:<code>1413</code></li>
<li>Using <code>set</code> in all branches of <code>{% if %}{% elif %}{%
else %}</code> blocks
does not cause the variable to be considered initially undefined.
:issue:<code>1253</code></li>
</ul>
</blockquote>
</details>
<details>
<summary>Commits</summary>
<ul>
<li><a
href="877f6e51be"><code>877f6e5</code></a>
release version 3.1.5</li>
<li><a
href="8d58859265"><code>8d58859</code></a>
remove test pypi</li>
<li><a
href="eda8fe86fd"><code>eda8fe8</code></a>
update dev dependencies</li>
<li><a
href="c8fdce1e03"><code>c8fdce1</code></a>
Fix bug involving calling set on a template parameter within all
branches of ...</li>
<li><a
href="66587ce989"><code>66587ce</code></a>
Fix bug where set would sometimes fail within if</li>
<li><a
href="fbc3a696c7"><code>fbc3a69</code></a>
Add support for namespaces in tuple parsing (<a
href="https://redirect.github.com/pallets/jinja/issues/1664">#1664</a>)</li>
<li><a
href="b8f4831d41"><code>b8f4831</code></a>
more comments about nsref assignment</li>
<li><a
href="ee832194cd"><code>ee83219</code></a>
Add support for namespaces in tuple assignment</li>
<li><a
href="1d55cddbb2"><code>1d55cdd</code></a>
Triple quotes in docs (<a
href="https://redirect.github.com/pallets/jinja/issues/2064">#2064</a>)</li>
<li><a
href="8a8eafc6b9"><code>8a8eafc</code></a>
edit block assignment section</li>
<li>Additional commits viewable in <a
href="https://github.com/pallets/jinja/compare/3.1.4...3.1.5">compare
view</a></li>
</ul>
</details>
<br />
[](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores)
Dependabot will resolve any conflicts with this PR as long as you don't
alter it yourself. You can also trigger a rebase manually by commenting
`@dependabot rebase`.
[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)
---
<details>
<summary>Dependabot commands and options</summary>
<br />
You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits
that have been made to it
- `@dependabot merge` will merge this PR after your CI passes on it
- `@dependabot squash and merge` will squash and merge this PR after
your CI passes on it
- `@dependabot cancel merge` will cancel a previously requested merge
and block automerging
- `@dependabot reopen` will reopen this PR if it is closed
- `@dependabot close` will close this PR and stop Dependabot recreating
it. You can achieve the same result by closing it manually
- `@dependabot show <dependency name> ignore conditions` will show all
of the ignore conditions of the specified dependency
- `@dependabot ignore this major version` will close this PR and stop
Dependabot creating any more for this major version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this minor version` will close this PR and stop
Dependabot creating any more for this minor version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop
Dependabot creating any more for this dependency (unless you reopen the
PR or upgrade to it yourself)
You can disable automated security fix PRs for this repo from the
[Security Alerts
page](https://github.com/flame-engine/flame/network/alerts).
</details>
Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Lukas Klingsbo <me@lukas.fyi>
Add very basic benchmark infrastructure, using the `examples` app as a
centralized benchmark playground and with first ever benchmark file just
testing some components and updates (more to come).
This also sets up the `dart-benchmark-action` to run, starting on this
very PR!
Currently we end up in a bad state if a child is added to a parent that
is removed in the same tick, this PR fixes that by adding the child
after the parent has been unmounted.
Closes: #3416
Add support for strike-through text for flame_markdown, if enabled by
the user.
Basically parses the `del` HTMl tag and maps it to a new inline text
renderer in Flame's text rendering pipeline.
The style can be controlled with a new property if desired.
In order to parse `~~`-wrapped text into the new node element, the
underlying markdown parser must have the strikethrough option enabled
(or an equivalent custom option), which can be controlled by the user if
providing their own document.