294 Commits

Author SHA1 Message Date
10fb65f66c feat: Add TextElementComponent (#2694)
Add TextElementComponent
2023-09-02 19:36:58 +00:00
4b420b7952 refactor!: Rename (Text) Elements, Nodes and Styles for clarity, add docs (#2700)
This occurred to me after a discussion on the [new FCS component
PR](https://github.com/flame-engine/flame/pull/2694#discussion_r1312450113).
As per usual, @spydon has opened my eyes to the ultimate truth:

We should rename loads of files, and it shall affect almost no one.

The idea is to (1) add a "Text" prefix to all text-rendering-related
classes and (2) rename the existing `Text*` to `InlineText*` (which is
what they are).

This PR is a bit big, but the changes should hopefully be simple to
review, and can be broken down into:

* Add a proper base class for the node inheritance chain, call it
TextNode (while working on Flame Markdown I realized the value this will
have to me)
* Rename the old TextNode to InlineTextNode
* Rename DocumentNode to DocumentRoot because it is not a node
* Rename Element to TextElement
* Rename the old TextElement to InlineTextElement
* Rename Style to FlameTextStyle (note: we could consider dropping the
Flame here)
* Rename the old FlameTextStyle to InlineTextStyle
* Update the docs accordingly
* Add some more diagrams and explanations to the docs, following the new
nomenclature
* I also updated our "internal" imports to use the text module to make
life so much easier (this could arguably be done in a separate PR, but I
honestly think it's easier to review together, please lmk if you prefer
me to split).

These are all breaking changes but likely won't actually affect most
users (see below).

While this is breaking, it should hopefully not affect most users,
because these are all infrastructure classes that most people aren't
using directly. If you are using the FCS components, or the renderers
`TextPaint` or `SpriteFontRenderer` directly, this should have zero
effect to you.

If you are using the Nodes, Stlyes or Elements directly, or have a
custom TextRenderer, see below.

Migrating should be a simple matter of renaming your type references:

* from TextNode to InlineTextNode
* from TextElement to InlineTextElement
* from Element to TextElement
* from FlameTextStyle to InlineTextStyle
* from Style to FlameTextStyle

Make sure to do it in the appropriate order not to cause any
double-replace issues.

If you are importing via the module `package:flame/text.dart`, which we
highly encourage, you should not have to change any import statements
whatsoever.
2023-09-02 12:59:59 -04:00
a1cb9a06ad refactor!: Kill TextRenderer, Long Live TextRenderer (#2683)
This will:

    kill the TextRenderer inheritance chain
    incorporate the functionality of the base TextRenderer in the base TextFormatter
    rename TextFormatter to TextRenderer and appropriate references

That is because both essentially do the same job; encompass the style (or "how") information about how to render text, but using two slightly different interfaces. While that could allow for more flexibility, it is a faux choice that needlessly complicates the pipeline. By having a single interface to comply with, we still allow for custom renders while at the same time making all the code downstream simpler to use and understand.
2023-08-27 21:47:01 +02:00
1a64443cca refactor!: Make TextElement more usable on its own (#2679)
This is part of my ongoing effort to simplify the text rendering
pipeline.
My ultimate goal is to:
* get rid of renders
* rename formatters to renderers
* make the interface complies to both
All details are specified here:
https://github.com/flame-engine/flame/pull/2663

As a first step to break down that huge PR, this makes a small change to
TextElements to make them more useful

This PR will:
### rename render -> draw

draw becomes the "internal", underlying impl, raw method, that just
draws the element w/ any custom options

### add a new render method that takes in more options

this does not need to be extended by every impl.
this is for end users and accepts parameters like position and anchor to
be more in line with the renderer interface

This is technically a breaking change but should have no effect for
users, unless you are creating your own custom `TextElement`s. In that
case, to migrate:

* rename your `render` method to `draw`
2023-08-26 12:10:03 -04:00
76405daf48 feat: Component visibility (HasVisibility mixin) (#2681)
This PR introduces a new HasVisibility mixin on Component. It prevents the renderTree method from progressing if the isVisible property is false. It therefore prevents the component and all it's children from rendering.

The purpose of this mixin is to allow showing and hiding a component without removing it from the tree.

An important note is that the component (and all it's children) will still be on the tree. They will continue to receive update events, and all other lifecycle events. If the user has implemented input such as tap events, or collision detection, or any other interactivity, this will continue to operate without affect (unless it relies on the render step - such as per-pixel collision detection).

This is expected behaviour. If it is not desired, the user needs to account for it (by checking isVisible in their code) or someone needs to create another mixin for HasEnabled or HasActive which would prevent these other actions 😁

I am very happy to make changes, take suggestions, etc!
2023-08-26 14:26:22 +02:00
10e4109c81 refactor: Fix lint issues across the codebase - Part 2 (#2677)
Fix a handful of lint issues across the codebase, identified using DCM.
Nothing controversial, I expect; slowly getting these out of the way so
we can focus on discussing bigger things.
2023-08-25 18:15:17 +00:00
27a8fd61cb refactor: Enable DCM linting (#2667)
This is a first step towards enabling DCM for Flame. Though I have tested with all rules, and am working on selecting, assessing, and fixing violations, as a first step, we can merge the infrastructural changes to flame_lint to and GitHub actions.
As a proof of concept, I am enabling two rules for which we have no violations.
I will followup with enabling more rules, adding discussions for controversial changes, and fixing non-controversial violations.
2023-08-24 13:09:26 +02:00
9887892493 chore: Update to Flutter 3.13 (#2656)
Updates the pipeline to use Flutter 3.13 and does all the analyze fixes.
2023-08-18 20:13:17 +02:00
09f09c6f4c docs: Update README.md of rogue_shooter (#2646)
This updates the rogue shooter readme since there was some confusion in
#2640.
2023-08-09 20:02:47 +02:00
b26700df7e chore(release): Publish Flame 1.8.2 (#2643)
- flame@1.8.2
 - flame_lint@1.1.0
 - flame_rive@1.9.1
 - flame_tiled@1.13.0
 - flame_isolate@0.4.0+2
 - flame_audio@2.0.5
 - flame_spine@0.1.1+1
 - flame_svg@1.8.1
 - flame_test@1.12.1
 - flame_oxygen@0.1.8+5
 - flame_bloc@1.10.1
 - flame_fire_atlas@1.3.8
 - flame_forge2d@0.14.1+1
 - flame_noise@0.1.1+4
 - flame_network_assets@0.2.0+4
 - flame_lottie@0.2.1+1
2023-08-08 22:17:03 +02:00
e852064e49 fix: Viewport should recieve events before the world (#2630)
The viewport should receive events before the world, otherwise all huds will get the events after the world components, if there are any world components underneath them.
2023-08-07 11:57:21 +00:00
e430b6cdf2 perf!: Pool CollisionProspects and remove some list creations from the collision detection (#2625)
This change introduces a very simple pool for `CollisionProspect`s so
that those objects don't have to be re-created each tick.
It means that the `CollisionProspect` needs to be mutable though, so the
code becomes a little bit harder to read since sets can't be used
anymore.
2023-07-28 22:59:24 +02:00
c11fdb9940 chore(release): Publish flame v1.8.1 et. al (#2599)
- flame@1.8.1
 - flame_test@1.12.0
 - flame_audio@2.0.4
 - flame_bloc@1.10.0
 - flame_fire_atlas@1.3.7
 - flame_forge2d@0.14.1
 - flame_isolate@0.4.0+1
 - flame_lottie@0.2.1
 - flame_noise@0.1.1+3
 - flame_oxygen@0.1.8+4
 - flame_rive@1.9.0
 - flame_spine@0.1.1
 - flame_svg@1.8.0
 - flame_tiled@1.12.0
 - jenny@1.0.4
 - flame_network_assets@0.2.0+3
2023-07-02 13:40:15 +00:00
ff3d91075c feat: Adding filterQuality arguments to Parallax load methods (#2596)
The Parallax already supported filter quality, but the loader methods were missing parameters for it to be passed to the loaded instances, making it impossible (unless manually loading) to set a filter quality in a parallax.

By setting a filter quality to none (which on flutter means that the next neighbour algorithm will be user) on pixel art sprites we can keep the crisp look that that style of art demands.
2023-06-30 06:03:00 +02:00
b3efb612cb feat: ComponentKey API (#2566)
Adds a new key api on FCS, which will allow users to get a component from the tree, without needing to iterate over all the children or a parent descendants.
2023-06-20 09:36:15 -03:00
3cdef9532d chore(release): Publish flame_tiled 1.11.0 (#2570)
- flame_tiled@1.11.0

Co-authored-by: Lukas Klingsbo <lukasklingsbo@Lukass-MacBook-Pro.local>
2023-06-09 10:54:07 -03:00
973b5808dd chore(publish): Publish Flame v1.8.0 and bridge packages (#2557)
flame@1.8.0
flame_rive@1.8.0
flame_test@1.11.0
flame_audio@2.0.3
flame_bloc@1.9.0
flame_fire_atlas@1.3.6
flame_forge2d@0.14.0
flame_isolate@0.4.0
flame_lint@1.0.0
flame_lottie@0.2.0+3
flame_network_assets@0.2.0+2
flame_noise@0.1.1+2
flame_oxygen@0.1.8+3
flame_spine@0.1.0+1
flame_svg@1.7.4
flame_tiled@1.10.2
jenny@1.0.3
2023-05-28 18:55:47 +00:00
a54f19a405 chore(release): Publish packages (#2555)
- flame@1.8.0
 - flame_rive@1.8.0
 - flame_test@1.11.0
 - flame_audio@2.0.3
 - flame_bloc@1.9.0
 - flame_fire_atlas@1.3.6
 - flame_forge2d@0.14.0
 - flame_isolate@0.4.0
 - flame_lint@0.2.0+3
 - flame_lottie@0.2.0+3
 - flame_network_assets@0.2.0+2
 - flame_noise@0.1.1+2
 - flame_oxygen@0.1.8+3
 - flame_spine@0.1.0+1
 - flame_svg@1.7.4
 - flame_tiled@1.10.2
 - jenny@1.0.3
2023-05-28 18:24:36 +00:00
2f71e06eb8 fix: Update sdk constraints to >=3.0.0 (#2554)
Update the SDK constraint to use >= 3.0.0
2023-05-28 20:09:45 +02:00
2d45d2be39 chore: Remove 1.8.0 deprecations (#2538)
Removes all the deprecated methods before 1.8.0 release.
2023-05-22 19:01:55 +02:00
b41622db8f fix: Solve warnings from 3.10.0 analyzer (#2532)
Just solves the warnings that the new Flutter version complains about (which makes us lose 10 points on pub).
2023-05-14 16:25:23 +02:00
19d1e72e4b chore(release): Publish flame_spine 0.1.0 (#2531)
- flame_spine@0.1.0
2023-05-10 13:33:18 +01:00
5d1a6fd167 feat: Spine bridge package (#2530)
This PR introduces a bridge package for Spine.

https://user-images.githubusercontent.com/744771/236058480-75c8212b-98e6-4e3b-834a-c1a9d4de31a8.mp4
2023-05-05 23:17:15 +02:00
472356df31 docs: WeldJoint docs and example (#2525)
WeldJoint docs and example
2023-05-01 20:22:28 +02:00
0991c3bf67 docs: RopeJoint documentation and example (#2520)
RopeJoint documentation and example
2023-04-25 10:37:31 +02:00
1ed2c5a297 feat: Add stepEngine to Game (#2516)
This PR adds a new method to Game which allows advancing the game loop by a certain amount of time while the engine is paused. By default it assumes one frame to be ~16 ms, but it can be controlled while calling stepEngine

The idea is to allow easy frame by frame inspection of the game. It can even be added to FlameStudio as part of the start/pause buttons on the toolbar.

https://user-images.githubusercontent.com/33748002/233453501-b9f90d49-1834-4f0f-9536-77629cfcadbc.mp4
2023-04-23 21:28:37 +02:00
9ab1adec1b chore(release): Publish flame_audio 2.0.2 (#2514)
- flame_audio@2.0.2
2023-04-19 20:29:16 +00:00
a25b0a03a5 feat: Customise grid of NineTileBox (#2495)
The previous implementation of the NineTileBox calculates identically sized tiles in a 3x3 grid and does not allow the user to customise this. For example, a 60x60 pixel sprite will be cut into 20x20 pixel tiles. This MR allows the user to specify the sizes of the fixed-width and fixed-height rows and columns so that a completely custom grid is possible.

Example with the following sprite and custom grid sizes.
Note that the stretchable row and column are only 1 pixel wide/high in this example.
2023-04-19 08:04:09 +00:00
87b8a067f3 refactor!: Move CameraComponent and events out of experimental (#2505)
This moves the CameraComponent and the new event system out of experimental since this now is the recommended way of handling things.
2023-04-19 09:55:32 +02:00
89926227c5 feat: Accept CollisionType in hitbox constructor (#2509)
With this PR we accept the `CollisionType` directly in the constructor.
2023-04-18 13:57:16 +00:00
9591e28541 chore(release): Publish packages (#2504)
- flame@1.7.3
 - flame_audio@2.0.1
 - flame_bloc@1.8.4
 - flame_fire_atlas@1.3.5
 - flame_flare@1.5.4
 - flame_forge2d@0.13.0+1
 - flame_isolate@0.3.0+1
 - flame_lint@0.2.0+2
 - flame_oxygen@0.1.8+2
 - flame_rive@1.7.1
 - flame_svg@1.7.3
 - flame_test@1.10.1
 - flame_tiled@1.10.1
 - jenny@1.0.2
 - flame_noise@0.1.1+1
 - flame_network_assets@0.2.0+1
 - flame_lottie@0.2.0+2
2023-04-16 01:18:03 +02:00
dbda37b81a refactor: Add new lint rules (#2477)
This PR adds the following lint rules to our list:

```
always_put_required_named_parameters_first
avoid_multiple_declarations_per_line
avoid_positional_boolean_parameters
avoid_returning_null_for_void
avoid_returning_this
avoid_unnecessary_containers
enable_null_safety
library_private_types_in_public_api
no_leading_underscores_for_library_prefixes
no_leading_underscores_for_local_identifiers
prefer_null_aware_method_calls
tighten_type_of_initializing_formals
unnecessary_late
use_setters_to_change_properties
```

And these rules were considered, and some changes were made according to
them as a clean-up, but in many places they didn't make sense
(`prefer_asserts_with_message` I would have included, but there were too
many places that needed to be changes):

```
collection_methods_unrelated_type
prefer_asserts_with_message
avoid_renaming_method_parameters
```
2023-04-13 19:42:00 +00:00
78b585fe8e docs: Added GearJoint docs and example (#2487)
GearJoint docs and example
2023-04-13 21:09:26 +02:00
95e34515df chore(release): Publish flame_audio 2.0.0 (#2484)
Release flame_audio@2.0.0 which uses audioplayers 4.0.0
2023-04-11 20:59:58 +00:00
47372087f2 feat!: Update AudioPlayers to ^4.0.0 (#2482)
This updates flame_audio to use the recently released audioplayers 4.0.0

Migration instructions:

AudioPool has moved to AudioPlayers, but we still export it from
flame_audio, so the only thing you have to do if you import AudioPool
directly is to change the import to:
import 'package:flame_audio/flame_audio.dart';
2023-04-11 21:51:43 +02:00
bd3e788612 feat: Deprecate Component.changeParent (#2478)
Since we now have a setter directly for parent, changeParent is no longer needed.
2023-04-11 16:55:27 +02:00
e4f741ef23 docs: PrismaticJoint docs and example (#2470)
PrismaticJoint example and documentation
2023-04-07 12:17:05 +00:00
de630a1c3a feat: Add isDragged in DragCallbacks mixin (#2472)
Adding a isDragged state for DragCallbacks mixin. This was available in the Draggable mixin.
2023-04-07 13:39:28 +02:00
ac878d8edf chore(release): Publish packages (#2462) 2023-04-02 20:06:47 +02:00
b5bdf4ec17 feat!: The HasTappableComponents mixin is no longer needed (#2450)
This PR is the second in a series of refactors that aim to simplify event handling in Flame. The approach is as follows:

    Added the MultiTapDispatcher component, which contains the logic that used to be within the HasTappableComponents mixin. This component is internal; it mounts to a FlameGame directly, and ensures that it is a singleton.
    Whenever any TapCallbacks component is added to a game, it automatically adds the MultiTapDispatcher component (unless there is already one), which in turn registers a tap gesture detector with GestureDetectorBuilder and rebuilds the game widget.

The end result is that now in order to make a component tappable you only need to add the TapCallbacks mixin to that component, everything else will be handled by the framework.

Consequently, the HasTappableComponents mixin is now empty and marked as deprecated.
2023-04-02 16:52:57 +00:00
b83c50737c docs: Added RevoluteJoint documentation (#2451)
Added RevoluteJoint documentation section
Moved the related example to the joints subfolder, and renamed the second example to avoid confusion.
2023-03-31 21:23:31 +02:00
a3f1601db8 feat: Adding ImageExtension.resize (#2418)
Adds a helper method to ImageExtension to make it easier to resize an image.
2023-03-31 11:39:08 +00:00
83c718fd50 docs: Update source code urls of forge2d joints in Flame Examples (#2437)
Update source code urls of forge2d joints in Flame Examples
2023-03-29 15:55:52 +00:00
d2a8fe01fa feat: Add HasTimeScale mixin (#2431)
This PR adds a new mixin on Component. When attached to a component, it allows scaling the delta time of that component as well as all its children by a non-negative factor. The idea is to allows slowing down or speeding up the gameplay by change the scaling factor.

Note: This approach works only for framerate independent game logic. Code in update() that is not dependent on delta time will remain unaffected by time scale.
2023-03-27 22:01:42 +02:00
e1049470fa docs: PulleyJoint documentation and example (#2425)
PulleyJoint documentation and example
2023-03-24 16:50:34 +01:00
277bd5d55c docs: MouseJoint documentation (#2417)
MouseJoint documentation, mostly copied from box2d docs. Moved the
existing example to joints subfolder
2023-03-18 15:21:30 +01:00
a9c198c727 fix: Fix key input to work after restart (#2415)
The map with active keymaps should be cleared and not the maps in the
map.
This made the game not taking input properly after restart.
2023-03-16 19:29:15 -03:00
11e329d665 docs: Fix non-web examples (#2411)
Fix build for non-web platforms, by hiding dart:html into platform-specific import.
2023-03-16 07:20:02 +01:00
de8f379021 chore: Update version of flutter_svg on flame_svg (#2408)
The flutter_svg version used on flame_svg was outdated, which causes us to lose precious pub points:

This updates the library by migrating a bit of the code (it was def a breaking change on their side, but shouldn't be on ours).
2023-03-15 14:33:28 +01:00
637c258b25 feat: Change HasCollisionDetection to be on Component (#2404)
This change makes it possible to have the collision detection system further down in the tree than on the FlameGame, this enables you to have collision detection on the World component for example.
Today it doesn't work if you have several worlds where the components are overlapping across the worlds, since the hitboxes live on top level.

So now you can use a World like this:

class CollisionDetectionWorld extends World with HasCollisionDetection {}
and all hitboxes added in there will only react with other hitboxes added to that world.
2023-03-15 13:11:23 +01:00