Updates to use the new color method `withValues`.
---------
Co-authored-by: Lukas Klingsbo <lukas.klingsbo@gmail.com>
Co-authored-by: Jochum van der Ploeg <jochum@vdploeg.net>
Update cicd.yml file on flame_3d to match main.
Since we finally updated main, we should require no difference
whatsoever on this file anymore.
This will require downgrading all the color changes, which is fine. This
should never have been a part of flame_3d to begin with.
Files were "untouched" by checking out the exact version as they are in
main right now (will need to rebase flame_3d to main later). I had to
add a couple more files because the files on main had dependencies on
changes that are not yet rebased on flame_3d. These extra diffs should
disappear when I do the final rebase.
Enable DCM rule double-literal-format.
More details
[here](https://dcm.dev/docs/rules/common/double-literal-format/). This
both forbids trailing zeroes and mandates leading zeroes.
If we would prefer a different style (e.g. prefer no leading zero
instead), just lmk :)
Update IsometricTileMapComponent to have better defined position and
size.
Before, the isometric component "zero" would be the center of the 0,0
block.
However, that does not play nicely with our component system if you want
to know the size (i.e. bounding box) of a component.
This changes so that the 0,0 of the component is the 0,0 of the AABB
around the isometric tiles. Then, it also computes the size of the
component accordingly.
This also changes the example to allow toggling between half and full
size more easily.
In our example, this is what it looks like:

The example still shows how to compute the previous origin (the purple
dot) if you want to.
With full size blocks:

This is a minor breaking change as you might need to "reposition" your
tile components, essentially remove the "compensation" for its location
that you probably did yourself. If you were centering the tile component
based on the available methods such as `map.getBlockCenterPosition`,
then just make sure you are adding the `map.position` to that and it
should work as before.
This PR introduces a new ScrollTextBoxComponent, enhancing the existing
text box functionalities with scrollable text capabilities. This
component, built on top of the existing TextBoxComponent, is designed to
handle scrollable text, thereby providing a better user interface for
games that require displaying longer text content.
Added docs and and an example.
---------
Co-authored-by: Lukas Klingsbo <lukas.klingsbo@gmail.com>
Co-authored-by: Lukas Klingsbo <me@lukas.fyi>
I was playing around with the rule avoid-global-state
While I don't think we should enable it, because we do have several totally legitimate cases of what the rule considers global state, it did help me find any current cases where the things just should be final constants.
So this PR will mark semantically final variables as final (or const) proper, exclusively on examples (no violations on actual src code are legit).
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.
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.
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`
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.
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
```
This PR continues the work for enabling rich text support within Flame.
Here I add support for different text fragments having different TextStyles, and allow those styles to be inheritable within the text node tree.
This PR introduces the notions of structured text, and text styles, to support rendering of rich text bodies.
Specifically, we recognize that sometimes in games one needs to render pieces of text that are larger than a single word or even a single paragraph. These pieces may include: books, quest descriptions, mission objectives, tutorials, in-game help system, dialogues, etc. Rendering such a piece of text is non-trivial, however. In order to tackle this problem, I break into the following parts:
Text structure, represented as a tree of Nodes. The nodes describe the logical structure of the text, for example the document may contain a header, and then several paragraphs, and a list, where the list contains some list items, some of which having possibly several paragraphs, etc. This structure is similar to how in HTML the text is marked up with HTML tags.
Text styles are struct-like classes that contain properties describing how the text is to be styled: font size, font renderer, borders, backgrounds, margins, padding, etc. This representation is also tree-like, so that for example text inside paragraphs can have different style than text within headers, and paragraphs within lists can have different margins. A text style is similar to a stylesheet in HTML.
Text elements are the result of applying the document style to a document node: they are the "prepared" and laid out pieces, ready to be rendered. Elements are a bit like mini-components, or perhaps text "particles" in a particle system.
- Added option align in the TextBoxComponent which controls the alignment of text.
- Added option for the TextBoxComponent to have a fixed size (before the only mode was for the textbox to automatically expand/shrink to fit the text).
* Added Component.childrenFactory
* fix some of the lint warnings
* more lint warnings
* remove changelog entry
* more analyzer warnings
* one more warning
* one more warning
* remove more unused imports
* fix more warnings
* another warning
* one more warning
* a lot more warnings
* some more warnings
* fix warnings in flame_svg
* fix warnings in flame_bloc
* Remove OrderedSet override feature
* Remove testRandom change
* Remove unnecessary type checks
* Re-remove deprecated argument in random_test
Co-authored-by: Pasha Stetsenko <stpasha@google.com>
* Animations, CameraAndViewport, CollisionDetection and Components unified
* Added descriptions to effects
* Rename input games
* Unify input stories
* Add info to parallax section
* Added descriptions to the rendering examples
* Add descriptions to the sprites directory
* Fix utils and rendering section
* Add descriptions to the widgets section
* Delete directory that rebase brought back
* Unify game names
* Added some styleguide docs for examples
* Fix analyze issues
* All files should have _example as suffix
* Made the FollowComponentExample a bit easier to understand
* Change priority of ember
* Game as a component
* Fix component stories
* Effects are now components
* Update effects docs
* Handle swap of parent
* Fix reAddChildren
* Wait for children to be added
* BaseComponent and PositionComponent to be non-abstract
* Simplify HasGameRef
* Revert so that onLoad can be null
* Fix example description
* Effects as components
* Remove gameRef from addChildren
* Fix hasGameRef
* Start migrating effects
* Updated comments of effect fields
* Fix comments
* Continue to fix sequence and combined effects
* Upgrade ordered_set
* Fix position_component_test
* BaseComponent -> Component
* Fix combined and sequence effects
* Await components to be added in tests
* Remove unnecessary game.update in tests
* Fix some tests related to composition
* BaseGame should be used in examples
* Fix CombinedEffect test
* Keyboard code to be based on Component
* Fix keyboard tests
* Fix analyze problems
* Fix sequence_effect
* Fix combined_effect_test
* Store peak state instead of end state
* Fix sequence_effect tests
* Update tutorial
* Fix tutorial 1
* Remove SimplePositionComponentEffect
* Remove unused test variable
* Update docs
* Removed onMount
* Remove onMount
* Add missing dartdoc
* Fix dart docs
* Add super.update where needed
* Move reAddChildren to component
* Reorganize method order in game widget
* preOffset -> initialDelay, postOffset -> peakDelay
* Introduce component.onParentChange
* Remove tests in wrong file
* Fix composed component test
* Add game lifecycle test
* Use BaseGame for mouse cursor test
* Oxygen should (?) not call super.update
* Use BaseGame in keyboard_test
* Fix onLoad to be properly cached
* Re-add unintentionally removed override
* Fix info for collision detection tests
* Add test for correct lifecycle on parent change
* Fix particles example
* Add component lifecycle diagram to the docs
* Add docs for the game lifecycle
* onRemove should be called when a game is removed from the widget
* Fix analyze errors
* prepare should be called from the component itself, not its parent
* Fix dartdoc
* onParentChange -> onMount
* onMount should have void as return type
* Simplify the loaderFuture in GameWidget
* Fix mock_canvas
* Fix rebase problem
* Remove asComponent
* Less complex _loaderFuture
* Add super.update to no_fcs parallax example
* Fix async tests
* Revert _loaderFuture
* Fix analyze issues
* await gameWithCollidables
* Keep epsilon small where it can be
* tappable methods should return bool
* Game lifecycle is now the same as for Component
* Remove mustCallSuper from component.update
* Make onLoadCache protected
* @internal on onLoadCache
* Cache/Memoize debugPaint and debugTextPaint
* Fix imports
* Fix comments
* Always call super.onLoad so that mixins can override it
* Add forgotten super.onLoad
* Bump coverage percentage
* HasCollidables should override update
* Fix Game comments
* Fix some dartdoc
* Apply suggestions from code review
Co-authored-by: Erick <erickzanardoo@gmail.com>
* Game + Loadable as mixins
* Update packages/flame/lib/src/game/game_widget/game_widget.dart
Co-authored-by: Luan Nico <luanpotter27@gmail.com>
* Update loadable docs
* Fix comments
* Move fps_counter
* Fix keyboard example
* Fix dartdoc
* Remove tutorials temporarily
* Fix game lowlevel graph
* Fix resize issue
Co-authored-by: Erick <erickzanardoo@gmail.com>
Co-authored-by: Luan Nico <luanpotter27@gmail.com>
* No setter for position and size
* Use setter for position and size
* Add onPositionUpdate and snapTo to Camera
* Fix formatting
* Fix size in test
* Update packages/flame/CHANGELOG.md
Co-authored-by: Jochum van der Ploeg <jochum@vdploeg.net>
* Update packages/flame/CHANGELOG.md
Co-authored-by: Jochum van der Ploeg <jochum@vdploeg.net>
* Better naming for internal position state
* Anchor and angle defaults on effect test utils
* No setter for position and size
* Fix scale effect
* Fix formatting
Co-authored-by: Jochum van der Ploeg <jochum@vdploeg.net>
Co-authored-by: Erick Zanardo <erickzanardoo@gmail.com>