1118 Commits

Author SHA1 Message Date
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
be31336da5 docs: Add sphinx copy button configurations in conf.py (#2466)
Add sphinx copy button configurations in conf.py
2023-04-05 16:13:24 +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
2bb894893c feat: Add copy button to code snippets (#2456)
Implement sphinix-copybutton in docs
2023-04-02 14:27:56 +02:00
564799adc9 docs: Remove unnecessary async from code snippets (#2454)
Removed unnecessary async from code snippets.
2023-04-02 01:59:53 +02: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
5b5ff30309 docs: Hidden toctree details for flame_audio & flame_forge2d (#2447)
Remove :hidden: from flame_audio.md & flame_forge2d.md files.
2023-03-30 17:29:49 +00:00
04babf347e docs: Some @overrides for the onLoad() function are missing (#2448)
missing @overrides are added in the corresponding code snippets.
2023-03-30 17:19:05 +00:00
72245bf903 docs: Update the side bar menu with the latest additions (#2440)
Add Hardware Keyboard Detector in Inputs
and
Align Component in Layout
2023-03-30 15:06:47 +00:00
bc8b51cb39 docs: Note about hiding other import exporting Route (#2438) 2023-03-29 22:49:45 +02:00
8e9a56da94 docs: Error in flame_svg code snippets in documentation (#2433)
Update code snippets for flame_svg docs
2023-03-28 18:09:51 +02: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
4ff25ffb1f feat: Add scroll to right side nav (#2428)
when overflow-y, the scroll will be enabled on hover that makes us
scroll through the contents and click what's below

# Description

Initially, the contents section (the right side nav) doesn't scroll when
overflow. This PR adds the functionality to scroll when it overflows
vertically.

Working video:


https://user-images.githubusercontent.com/40348358/227519288-805ae943-0c23-4220-8224-fec168bae599.mov

### a small case to consider

This commit had some complications like having to compromise with having
shrink width. It doesn't much shrink, but does slightly does.

Before this PR:
<img width="1237" alt="Screenshot 2023-03-24 at 17 43 18"
src="https://user-images.githubusercontent.com/40348358/227519653-84c503a2-8ab4-460a-96b7-17c31d60ce62.png">

After this PR:
<img width="1238" alt="Screenshot 2023-03-24 at 17 42 54"
src="https://user-images.githubusercontent.com/40348358/227519701-bce512d7-e6df-459b-a3a1-5762a05f2934.png">

But, I am thinking this can be considered as the readability isn't
effected much as this sidebar only is visible when there is enough space
(more width).

## 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 `///`.
- [-] I have updated/added relevant examples in `examples` or `docs`.


## Breaking Change?

- [-] Yes, this PR is a breaking change.
- [x] No, this PR is not a breaking change.


## Related Issues

Closes #2423
2023-03-24 09:36:53 -03:00
61d69656de feat: Add network assets package. (#2314)
# Description

Adds some documentation and a package that can be used to fetch assets
from the network.
2023-03-18 20:12:14 +00:00
b5af714c53 docs: Fix for missing jQuery (#2416)
As mentioned in discord, the current build of the docs loses jQuery
functionality. This is due to sphinx being upgraded to version 6 in
which they removed jQuery and created a stand-alone package for it.

Additionally, in the process of doing that, I noticed the previously
mentioned fix (in the comments) for the `melos doc-setup` about removing
the single quotes to keep it clean didn't make into the final code. I
have updated that as it was previously confirmed to work on all
platforms in: https://github.com/flame-engine/flame/pull/2401

I noticed that the copyright that was in the `conf.py` was locked at
2021 and so I made it go to 2023 as well. This can be removed if not
desired, but thought maybe this had just been overlooked.

Finally, there was an error regarding a duplicate instantiation of a
constant. This had to do with the fact the basic theme provided with
sphinx, the next version after which the docs were based, had a bug fix
implemented:
https://www.sphinx-doc.org/en/master/changes.html#release-5-1-0-released-jul-24-2022.
In their fix, it also broke the way the flames theme works. On a side
note, the docs are using a very outdated version of the basic theme and
should likely be overhauled, but that is outside the scope of this pr.
None the less, after I finally figured out how the basic theme is
inherited and where that lived on my machine, I was able to resolve the
discrepancies and eliminate the conflicting names between the two
themes.

In short, all errors have been resolved and I have confirmed that
mobile, web, search, highlighting, menus, etc. all work - at least on my
machine.
2023-03-18 19:27:44 +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
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
a72b0ff3ac docs: Do not use shell=True in dart_domain.py (#2405)
This fixes a problem that we accidentally introduced in a recent PR: the
`shell=True` setting requires that the arguments were passed as a single
string instead of a list. Passing as a string, in turn, is somewhat
problematic because the file names need to be escaped, and there is no
utility function to make this escaping cross-platform.

So, instead we'll use the standard `shell=False`, and invoke
`dartdoc_json.bat` on Windows instead of simply `dartdoc_json`. Hope
this would work.
2023-03-13 19:43:40 +01:00
4293343a2e docs: Fixed linked joints examples (#2400)
Embedded flutter-app joints examples didn't work, because flutter-app script expects the example page to be located in the lib folder of a module. Introduced a new subfolder param, to specify where to find the example page.

Verified joints examples apps and code button on the doc page work; Also verified the same for the effects page.
2023-03-13 11:25:49 +00:00
35d5533ded docs!: Adds doc-kill melos command and bumps requirements (#2397)
As mentioned in #2395, there are several lingering issues that can be solved by bumping the Python package requirements up. All packages need / can run on Python 3.8+, so the docs do not need to be updated regarding that.

This PR specifically fixes the following warnings:

flame\doc\bridge_packages\bridge_packages.md:4: WARNING: 'myst' reference target not found: ..\bridge_packages\flame_audio\flame_audio.md
....There were a lot of those....

`attrs_image` is deprecated.  Use `attrs_inline` instead.

Additionally, this PR adds a new command melos doc-kill which executes the kill-server.py script. This script relies on psutil which has been added to the requirements.txt, but allows a cross platform ability to isolate and kill process threads that are locking the port 8000. This commonly happens when you exit melos doc-serve and the internal web server doesn't die as well. This may not be an issue for Unix platforms, but for Windows users its extremely annoying.

The only alternative for Windows users is to manually do:

netstat -ano | findstr :8000
// Then run:
taskkill /PID XXXXX /F 

As I mentioned in the other PR, I split this out so it can be debated mainly for the bump in requirements; however, I feel the benefits are very worth it. I marked this as breaking just because it changes the base package requirements and adds a package which may not qualify as breaking, depending on how you look at it.

Edit: Forgot that this PR also fixes a typo in the melos doc-serve description and corrects the misspelling of everytime to every time.
2023-03-13 09:15:07 +00:00
cb52f5a58a docs: MotorJoint doc and example (#2394)
Documentation covering MotorJoint and a usage example.
2023-03-12 22:31:20 +00:00
63704c40ee docs: Added fix for building on Windows and resolved other build errors (#2395)
<!--
The title of your PR on the line above should start with a [Conventional
Commit] prefix
(`fix:`, `feat:`, `docs:`, `test:`, `chore:`, `refactor:`, `perf:`,
`build:`, `ci:`,
`style:`, `revert:`). This title will later become an entry in the
[CHANGELOG], so please
make sure that it summarizes the PR adequately.
-->

# Description
<!--
Provide a description of what this PR is doing.
If you're modifying existing behavior, describe the existing behavior,
how this PR is changing it,
and what motivated the change. If this is a breaking change, specify
explicitly which APIs were
changed.
-->

@eukleshnin identified issues with building the documents locally on a
Windows workstation. Namely, the following was occurring:

```
reading sources... [  2%] flame/layout/align_component
Exception occurred:

FileNotFoundError: [WinError 2]
```
This was determined to be a combination of several things.

1. In `dart_domain.py`, the `subprocess.run` calling dartdoc_json did
not have the shell parameter set to true. This solves the error about
the file not being found. This then generates errors that subsequent
references to the `temp_file` did not exist.
2. This was due to the default setting with Python `tempfile` where when
it determines the temp file has been closed, it deletes it; however, it
was still needed, so by setting the `delete=False` parameter, the file
would still remain.
3. Unfortunately, because it still remains, it needs to be deleted once
it is no longer needed. Trying to use `finally:` with the `try` block
failed to produce the results desired, so the temp file name was
registered with the class so it can be deleted in the original calling
function if it exists. This proved successful.
4. Although not critical, the same temp file uses a suffix of `json` so
it was creating files `xxxxjson`. By adding the "." in the suffix, it
creates valid file names now. This doesn't actually fix anything, it
just seemed wrong, so I fixed it to be valid files if ever needed down
the road.

Now that the docs built, there were several warnings that could be
resolved:
1. `Overlays.md` was not referenced in the TOC tree.
2. Since overlays were removed in
https://github.com/flame-engine/flame/pull/2384, the Platformer tutorial
had a link to the old path and it needed to be updated.

Finally and open for discussion, during this process of debugging, I
upgraded all packages to the most current to see what impacts there
were. The following is the old and new potential `requirements.txt`:

```
----Old
linkify-it-py==2.0.0
myst-parser==0.18.1
Pygments==2.12.0
Sphinx==5.0.2
sphinxcontrib-mermaid==0.8.1
sphinx-autobuild==2021.3.14
jinja2==3.1.2

----- New
linkify-it-py==2.0.0
myst-parser==1.0.0
Pygments==2.14.0
Sphinx==6.1.3
sphinxcontrib-mermaid==0.8.1
sphinx-autobuild==2021.3.14
Jinja2==3.1.2
```

The only byproduct of this upgrade was a deprecated package warning for
`attrs_image` in `conf.py` which was updated to `attrs_inline`. I made
that change initially for this PR, but backed it out as I didn't know if
there was a desire to update the `requirements.txt` and felt some
discussion may be warranted.

Regardless, with everything upgraded or left as is, the other fixes
resolve the issues on Windows.

## 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.
- [X] I have updated/added relevant documentation in `docs` and added
dartdoc comments with `///`.
- [ ] I have updated/added relevant examples in `examples` or `docs`.


## Breaking Change?
<!--
Would your PR require Flame users to update their apps following your
change?

If yes, then the title of the PR should include "!" (for example,
`feat!:`, `fix!:`). See
[Conventional Commit] for details. Also, for a breaking PR uncomment and
fill in the "Migration
instructions" section below.

### Migration instructions

If the PR is breaking, uncomment this header and add instructions for
how to migrate from the
currently released version to the new proposed way.
-->

- [ ] Yes, this PR is a breaking change.
- [X] No, this PR is not a breaking change.


## Related Issues
<!--
Indicate which issues this PR resolves, if any. For example:

Closes #1234
!-->

<!-- Links -->
[Contributor Guide]:
https://github.com/flame-engine/flame/blob/main/CONTRIBUTING.md
[Conventional Commit]: https://conventionalcommits.org
[CHANGELOG]:
https://github.com/flame-engine/flame/blob/main/CHANGELOG.md

---------

Co-authored-by: Lukas Klingsbo <me@lukas.fyi>
2023-03-12 20:54:48 +00:00
0ea612d73a docs: FrictionJoint documentation and example (#2383)
Added documentation and example for FrictionJoint.
Also modified main.dart to be able to run individual examples by providing page param.
2023-03-06 23:34:45 +01:00
4f5e56f05f feat: Added AlignComponent layout component (#2350)
This PR adds first layout component: AlignComponent, an equivalent of Align widget in Flutter.

AlignComponent sizes itself to its parent, and then keeps its child aligned to the specified anchor within its own bounding box.

Also adding onParentResize() lifecycle method, which is similar to onGameResize, but fires whenever the parent of the current component changes its size for any reason. (FlameGame is assumed to have the size canvasSize, and will invoke onParentResize whenever the canvas size changes).

Additional layout components are planned to be added in future PRs.
2023-03-02 22:51:02 +01:00
9d18248092 docs: Break out overlays docs (#2384)
The docs for overlays were a bit hard to find so I broke them out to its
own section.
They could need some some updating too with more examples and
instructions.
2023-03-02 14:49:18 +00:00
7de8fe9b6a chore: Standardize and unify SDK versions across packages (#2374)
# Description

This does two things:

## Use double quotes for SDK constraints

Standardize the usage of single or double quotes to specify sdk
constraints across pubspecs
I see no reason this should not be kept consistent
I also see no reason to prefer one over the other, so I searched the
code base and there are 7 instances of single quote vs 32 of double
quotes, so I favored the later

## Update all SDK constraints to 2.18

Let me know if there are any issues with it, but I believe we should
keep this consistent across all packages.
Also there is a pubspec on root which imply all should be on 2.18
anyway.

## 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`.

## Breaking Change?

- [ ] Yes, this PR is a breaking change.
- [x] No, this PR is not a breaking change.

<!-- Links -->
[Contributor Guide]:
https://github.com/flame-engine/flame/blob/main/CONTRIBUTING.md
[Conventional Commit]: https://conventionalcommits.org/
[CHANGELOG]:
https://github.com/flame-engine/flame/blob/main/CHANGELOG.md

Co-authored-by: Lukas Klingsbo <me@lukas.fyi>
2023-03-01 18:08:13 +00:00
181e0b59fd feat: Add position and anchor params for Sprite and SpriteAnimation Particles (#2370) 2023-02-28 12:34:58 +01:00
5b07bd58f3 docs: DistanceJoint documentation and example (#2369)
DistanceJoint documentation and example
2023-02-27 22:29:07 +01:00
79bfeee3fe docs: Fix invite link to Discord in docs top bar (#2371)
The link went directly to the Flame channel instead of being an invite link to the server, so it didn't work for people that weren't already on the server.
2023-02-27 18:02:14 +01:00
1ef518794c refactor: Component rebalancing is now performed via a global queue (#2352)
This PR ensures that all component rebalancing operations are resolved from a single location, after the update stage but before the render stage (thus, components may get reordered during the update, and these changes will go into effect during the rendering step on the same game tick).

This also fixes the problem where the child changing the priorities of its parent would cause a ConcurrentModificationError.

A number of methods that were used to handle rebalancing are now marked as deprecated. From the user's perspective, the only API they should be using is the .priority setter.
2023-02-27 00:45:27 +01:00
093a1abb07 docs: Update to latest sphinx-mermaid (#2368)
This fixes the regression with that the graphs aren't rendering.
Unfortunately they will forever be broken in the v1.6.0 release of the
docs now.

Fix comes from here:
2eaff4220a
2023-02-26 15:16:28 +01:00
957ad2402a docs: Added a page for Joints documentation + ConstantVolumeJoint doc and example (#2362)
Added a page for Forge2D joints documentation.
Added a `ConstantVolumeJoint` documentation and example.

Will add other joint types in the next PRs.
2023-02-26 13:33:22 +01:00
d1c94d9cfa docs: Fix typo in Step 3 of platformer tutorial (#2363)
The grid position variable is non-private: gridPosition in the PlatformBlock class definition but was used as private: _gridPosition in the onLoad method.

This PR updates the grid position variable in the onLoad to gridPosition.
2023-02-23 06:25:01 +01:00
c2ba1fc65f docs: Fixing components sub-directory path (#2359)
At the *Other classes* session, when it is mentioned that we need to
create the `components` sub-directory, the tutorial is guiding us to add
it in the root, but on the structure below, it is possible to see that
it should be created inside the `libs` folder instead.

It seems to be better to be more explicit in this paragraph.
2023-02-21 21:42:32 +01:00
ecea91661f docs: Small anchor confusion in the components doc (#2356)
Seems to have been some confusion about the anchor from the one that
wrote these docs, the sentence that described the code was wrong.
2023-02-21 11:19:21 -05:00
38e8758a85 docs: Indentation fix in gesture list (#2355)
Minor indentation fix in the list of gesture detectors.
2023-02-20 11:28:26 -05:00
655824fc00 docs: Refactor documentation for GameWidget (#2344)
Use the dartdoc directive for the GameWidget class, allowing us to keep the documentation in the code and on the site in sync.
2023-02-17 13:39:13 +01:00
7c7d2e8be2 docs: Fix typo in Step 3 of platformer tutorial (#2336)
The tutorial said to add a velocity variable and fill the update method in the EmberQuestGame class instead of the PlatformBlock class.
2023-02-12 15:01:26 +01:00
b5f79d1ce4 feat: Add DoubleTapCallbacks that receives double-tap events. (#2327)
As-is
As mentioned in #2321, the user needs to propagate double-tap events to the component tree using DoubleTapDetector & propagateToChildren until now.

To-be
Any components that are mixed into the DoubleTapCallbacks receive double-tap-related events.
Same as DragCallbacks, there is no need to add mixin to the game like HasDoubleTapCallbaks as before.
2023-02-10 19:29:36 +01:00
754461850f refactor!: Use ComponentTreeRoot for component removal (#2317)
Component removal is now handled via the ComponentTreeRoot class and its queue of lifecycle events.

    The onGameResize event now only fires before the component's onMount, but not before its onLoad.

Migration instructions

If you have components that rely on receiving onGameResize calls before they load, then
you can retrieve the game's size in onLoad manually via findGame()!.size.
2023-02-08 13:54:40 +01:00
34c3b6bdc4 feat: Add ability to opt-out flip (#2316)
As I mentioned on #2310 (comment),
it's inevitable to create an atlas that has 2x width from the original one to support flip, it could bring some limitations. So it would be great to opt out the flip.

Here's the reason why this is needed.
Flip may impact performance if the composed tileset(AKA texture) is big.
The software tiled has shortcuts to go back by cmd(ctrl)-z, rotating by z, and flipping horizontally by x. Imagine that you clicked a tile to the wrong place, you may press cmd-z and so on. In this situation, you can also accidentally press z or x, and as a result, the tile flips! It is fine with some complicated or flip(rotate)-consiousable tiles. But some things like the floor or sky are hard to recognize. I even made a program for my design team to pick out coordinates of where the flipped tiles exist but often there are flips. So, providing a way by simple boolean argument may prevent this.
2023-02-05 21:24:01 +01:00
90321658c4 docs: Fix old doc code (#2322)
Saw some old code references, fixed them up.
2023-02-05 16:31:16 +00:00
3faf114994 feat!: HasDraggableComponents mixin is no longer needed (#2312)
This PR is first in a series of refactors that aim to simplify event handling in Flame. The approach is as follows:

    Added class GestureDetectorBuilder, which encapsulates the logic of applyGestureDetectors() in a class. This class resides within the Game and initiates widget rebuild whenever any new gesture detectors are added or removed. Note: 

    [idea] Convert HasTappableComponents/HasDraggableComponents into classes #1733 suggests having a list of interfaces inside the Game class -- this is essentially that list, encapsulated in a class.
    Added the MultiDragDispatcher component, which contains the logic that used to be within the HasDraggableComponents mixin. This component is internal; it mounts to a FlameGame directly, and ensures that it is a singleton.
    Whenever any DragCallbacks component is added to a game, it automatically adds the MultiDragDispatcher component (unless there is already one), which in turn registers a drag gesture detector with GestureDetectorBuilder and rebuilds the game widget.

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

Consequently, the HasDraggableComponents mixin is now empty and marked as deprecated.
2023-02-05 13:09:58 +00:00
e5345e62d0 RemoveATypoInTheCodeOfTuto (#2309)
Co-authored-by: avieville <github.avieville@gmail.com>
2023-01-30 14:31:26 -03:00
343b84529d docs: Fix actual typos that made into our dictionary (#2305) 2023-01-28 16:58:27 -05:00
7662118d14 chore(release): Publish flame_lint 0.2.0 (#2301)
- flame_lint@0.2.0
2023-01-28 00:44:29 +00:00
95b1fc0fbc feat: Added HardwareKeyboardDetector (#2257)
This creates a new component HardwareKeyboardDetector, which is a more advanced version of the KeyboardEvents mixin:

    HardwareKeyboardDetector is a component instead of a mixin, which means it can be added/removed by the user at any point;
    multiple such detectors can be attached to a game - for example, in a 2-player game one component may be paying attention to arrow keys, while another to WASD keys;
    the new component uses Flutter's HardwareKeyboard interface, bypassing the need for a Focus widget;
    the component keeps the ordered list of keys that are currently being pressed, which is helpful for games where this order is important;
    there is the ability to temporarily pause the reception of key events using keyEventsPaused property.
2023-01-27 21:57:42 +00:00
3b87e838f6 docs: Create "dart" domain extension (#2278)
In Sphinx, there is a concept of a "domain", which enables documenting library object such as classes and functions, and then referencing them from any other place in the documentation. This PR adds such a domain for the Dart language.

With the new approach, a class/function can be documented using the following directive:

```{dartdoc}
📦 flame
:symbol: GameWidget
:file: src/game/game_widget/game_widget.dart
```

The documentation will then be automatically extracted from the referenced file using the dartdoc_json tool (published as a separate package), and then rendered inside the page. The screenshot below shows an example of how DialogueRunner class from Jenny would be rendered:

<image>

Once a symbol has been documented using the dartdoc directive, it can be referenced from other places in the documentation as

{ref}`DialogueRunner`
2023-01-25 21:17:25 +00:00