diff --git a/.github/ISSUE_TEMPLATE/bug_report.yml b/.github/ISSUE_TEMPLATE/bug_report.yml new file mode 100644 index 00000000000..588ee83f674 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug_report.yml @@ -0,0 +1,96 @@ +name: Bug Report +description: You are creating a Game with Flame but you are noticing some strange behavior, that it throws an unexpected exception, or that it is not working according to the specifications. +title: " " +labels: ["bug"] +assignees: "" +body: + - type: markdown + attributes: + value: | + When reporting a bug, please read this complete template and fill in all the questions in order to get a better response! + - type: textarea + id: what-happened + attributes: + label: What happened? + description: Tell us, what happened? + validations: + required: true + + - type: textarea + id: expectation + attributes: + label: What do you expect? + description: Also tell us, what behavior did you expect? + validations: + required: true + +# Steps to reproduce + +- type: textarea + id: expectation + attributes: + label: How can we reproduce this? + description: This one is very important, please be very precise in how we can reproduce this bug + validations: + required: false + +- type: textarea + id: expectation + attributes: + label: What steps should take to fix this? + description: If possible please report steps based on the example from this plugin! + validations: + required: false + +- type: textarea + id: expectation + attributes: + label: Do have an example of what change you want? + description: If you can make a minimal reproducible example it is incredibly helpful, the simplest way is to share a link from https://zapp.run, you can start from https://zapp.run/edit/flame where all dependencies are already set up. + validations: + required: false + + - type: textarea + id: logs + attributes: + label: Relevant log output + description: If you have any debug / error logging, please fill it here within the code block below + render: shell + + +- type: markdown + attributes: + label: Execute in a terminal and put output into the code block below + value: ``` +Output of: flutter doctor -v +``` + +# More environment information + +- type: markdown + attributes: + label: Create a list of more environment information, like: + value: Flame version: 1.0.0 + value: Platform affected: android, ios, web + value: Platform version affected: android 9, ios 13 + +# More information + +- type: textarea + id: expectation + attributes: + label: What do you expect? + description: Do you have any other useful information about this bug report? Please write it down here + validations: + required: false + + +- type: checkboxes + id: terms + attributes: + label: Are you interested in working on a PR for this? + options: + - label: I want to work on this + required: false + +## Possible helpful information: references to other sites/repositories diff --git a/CHANGELOG.md b/CHANGELOG.md index 62280343ee2..34b5900bdc3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,27 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +## 2023-10-17 + +### Changes + +--- + +Packages with breaking changes: + + - There are no breaking changes in this release. + +Packages with other changes: + + - [`jenny` - `v1.2.0`](#jenny---v120) + +--- + +#### `jenny` - `v1.2.0` + + - **FEAT**: Added lastline before choice ([#2822](https://github.com/flame-engine/flame/issues/2822)). ([3ef52524](https://github.com/flame-engine/flame/commit/3ef525246a0d3b1d02c470b5696164e677cdb6c4)) + + ## 2023-10-12 ### Changes diff --git a/doc/tutorials/klondike/app/lib/step2/klondike_game.dart b/doc/tutorials/klondike/app/lib/step2/klondike_game.dart index 888cbe079db..49a4c663bad 100644 --- a/doc/tutorials/klondike/app/lib/step2/klondike_game.dart +++ b/doc/tutorials/klondike/app/lib/step2/klondike_game.dart @@ -41,19 +41,15 @@ class KlondikeGame extends FlameGame { ), ); - final world = World() - ..add(stock) - ..add(waste) - ..addAll(foundations) - ..addAll(piles); - add(world); + world.add(stock); + world.add(waste); + world.addAll(foundations); + world.addAll(piles); - final camera = CameraComponent(world: world) - ..viewfinder.visibleGameSize = - Vector2(cardWidth * 7 + cardGap * 8, 4 * cardHeight + 3 * cardGap) - ..viewfinder.position = Vector2(cardWidth * 3.5 + cardGap * 4, 0) - ..viewfinder.anchor = Anchor.topCenter; - add(camera); + camera.viewfinder.visibleGameSize = + Vector2(cardWidth * 7 + cardGap * 8, 4 * cardHeight + 3 * cardGap); + camera.viewfinder.position = Vector2(cardWidth * 3.5 + cardGap * 4, 0); + camera.viewfinder.anchor = Anchor.topCenter; } } diff --git a/doc/tutorials/klondike/app/lib/step3/klondike_game.dart b/doc/tutorials/klondike/app/lib/step3/klondike_game.dart index a886cfdf0b5..6ed71ab44bf 100644 --- a/doc/tutorials/klondike/app/lib/step3/klondike_game.dart +++ b/doc/tutorials/klondike/app/lib/step3/klondike_game.dart @@ -44,19 +44,15 @@ class KlondikeGame extends FlameGame { ), ); - final world = World() - ..add(stock) - ..add(waste) - ..addAll(foundations) - ..addAll(piles); - add(world); + world.add(stock); + world.add(waste); + world.addAll(foundations); + world.addAll(piles); - final camera = CameraComponent(world: world) - ..viewfinder.visibleGameSize = - Vector2(cardWidth * 7 + cardGap * 8, 4 * cardHeight + 3 * cardGap) - ..viewfinder.position = Vector2(cardWidth * 3.5 + cardGap * 4, 0) - ..viewfinder.anchor = Anchor.topCenter; - add(camera); + camera.viewfinder.visibleGameSize = + Vector2(cardWidth * 7 + cardGap * 8, 4 * cardHeight + 3 * cardGap); + camera.viewfinder.position = Vector2(cardWidth * 3.5 + cardGap * 4, 0); + camera.viewfinder.anchor = Anchor.topCenter; final random = Random(); for (var i = 0; i < 7; i++) { diff --git a/packages/flame/lib/src/collisions/collision_passthrough.dart b/packages/flame/lib/src/collisions/collision_passthrough.dart index 278de56130a..cd62acd8dc2 100644 --- a/packages/flame/lib/src/collisions/collision_passthrough.dart +++ b/packages/flame/lib/src/collisions/collision_passthrough.dart @@ -1,3 +1,4 @@ +import 'package:collection/collection.dart'; import 'package:flame/collisions.dart'; import 'package:flame/components.dart'; import 'package:meta/meta.dart'; @@ -14,9 +15,9 @@ mixin CollisionPassthrough on CollisionCallbacks { @mustCallSuper void onMount() { super.onMount(); - passthroughParent = ancestors().firstWhere( + passthroughParent = ancestors().firstWhereOrNull( (c) => c is CollisionCallbacks, - ) as CollisionCallbacks; + ) as CollisionCallbacks?; } @override diff --git a/packages/flame/test/collisions/collision_passthrough_test.dart b/packages/flame/test/collisions/collision_passthrough_test.dart index cd2acc2db48..8dfea96065c 100644 --- a/packages/flame/test/collisions/collision_passthrough_test.dart +++ b/packages/flame/test/collisions/collision_passthrough_test.dart @@ -1,5 +1,6 @@ +import 'package:flame/collisions.dart'; import 'package:flame/components.dart'; -import 'package:flame/src/collisions/collision_passthrough.dart'; +import 'package:flame_test/flame_test.dart'; import 'package:test/test.dart'; import 'collision_test_helpers.dart'; @@ -40,5 +41,22 @@ void main() { expect(hitboxParent.onCollisionCounter, 1); }, }); + + testWithFlameGame('Null passthrough', (game) async { + final hitbox = CompositeHitbox(children: [RectangleHitbox()]); + final component = PositionComponent(children: [hitbox]); + final testBlock = TestBlock(Vector2.zero(), Vector2.all(10)); + + await game.addAll([component, testBlock]); + await game.ready(); + + expect(hitbox.passthroughParent, isNull); + + hitbox.removeFromParent(); + testBlock.add(hitbox); + await game.ready(); + + expect(hitbox.passthroughParent, testBlock); + }); }); } diff --git a/packages/flame_jenny/jenny/CHANGELOG.md b/packages/flame_jenny/jenny/CHANGELOG.md index e5597c5b1ee..6c5646e33c9 100644 --- a/packages/flame_jenny/jenny/CHANGELOG.md +++ b/packages/flame_jenny/jenny/CHANGELOG.md @@ -1,3 +1,7 @@ +## 1.2.0 + + - **FEAT**: Added lastline before choice ([#2822](https://github.com/flame-engine/flame/issues/2822)). ([3ef52524](https://github.com/flame-engine/flame/commit/3ef525246a0d3b1d02c470b5696164e677cdb6c4)) + ## 1.1.1 - **REFACTOR**: Remove unnecessary 'async' keyword across the codebase [DCM] ([#2803](https://github.com/flame-engine/flame/issues/2803)). ([2dfe0e5a](https://github.com/flame-engine/flame/commit/2dfe0e5a431213c7148ab6389e3e8c8dc49fbf3d)) diff --git a/packages/flame_jenny/jenny/lib/src/parse/parse.dart b/packages/flame_jenny/jenny/lib/src/parse/parse.dart index ec499639282..8830525b569 100644 --- a/packages/flame_jenny/jenny/lib/src/parse/parse.dart +++ b/packages/flame_jenny/jenny/lib/src/parse/parse.dart @@ -134,6 +134,16 @@ class _Parser { if (lines.isNotEmpty && lines.last is DialogueChoice) { (lines.last as DialogueChoice).options.add(option); } else { + if (lines.isNotEmpty && lines.last is DialogueLine) { + final lastLine = lines.removeLast() as DialogueLine; + lines.add( + DialogueLine( + content: lastLine.content!, + character: lastLine.character, + tags: [...lastLine.tags, '#lastline'], + ), + ); + } lines.add(DialogueChoice([option])); } } else if (nextToken == Token.startCommand) { @@ -912,8 +922,11 @@ class _Parser { } bool takeId() => takeTokenType(TokenType.id); + bool takeText() => takeTokenType(TokenType.text); + bool takePerson() => takeTokenType(TokenType.person); + bool takeNewline() { if (position >= tokens.length) { return true; @@ -967,6 +980,7 @@ class _Parser { class _NodeHeader { _NodeHeader(this.title, this.tags); + String? title; Map? tags; } diff --git a/packages/flame_jenny/jenny/lib/src/structure/dialogue_line.dart b/packages/flame_jenny/jenny/lib/src/structure/dialogue_line.dart index 145d5996c2a..f7ba148599e 100644 --- a/packages/flame_jenny/jenny/lib/src/structure/dialogue_line.dart +++ b/packages/flame_jenny/jenny/lib/src/structure/dialogue_line.dart @@ -56,6 +56,9 @@ class DialogueLine extends DialogueEntry { final LineContent _content; String? _value; + /// The content of this Line. + LineContent? get content => _content; + /// The character who is speaking the line. This can be null if the line does /// not contain a speaker. Character? get character => _character; diff --git a/packages/flame_jenny/jenny/pubspec.yaml b/packages/flame_jenny/jenny/pubspec.yaml index 2320ec77d69..a0164e949a5 100644 --- a/packages/flame_jenny/jenny/pubspec.yaml +++ b/packages/flame_jenny/jenny/pubspec.yaml @@ -1,6 +1,6 @@ name: jenny description: YarnSpinner equivalent for Dart. -version: 1.1.1 +version: 1.2.0 homepage: https://github.com/flame-engine/flame/tree/main/packages/flame_jenny/jenny funding: - https://opencollective.com/blue-fire diff --git a/packages/flame_jenny/jenny/test/dialogue_runner_test.dart b/packages/flame_jenny/jenny/test/dialogue_runner_test.dart index 8228321f1a4..45de437dfdb 100644 --- a/packages/flame_jenny/jenny/test/dialogue_runner_test.dart +++ b/packages/flame_jenny/jenny/test/dialogue_runner_test.dart @@ -124,6 +124,7 @@ void main() { test('dialogue with choices', () async { final yarn = YarnProject() ..parse('title: X\n---\n' + 'Question?\n' '-> Hi there\n' '-> Howdy\n' ' Greetings to you too\n' @@ -138,6 +139,8 @@ void main() { [ '[*] onDialogueStart()', '[*] onNodeStart(Node(X))', + '[*] onLineStart(DialogueLine(Question?)[#lastline])', + '[*] onLineFinish(DialogueLine(Question?))', '[*] onChoiceStart(DialogueChoice([Option(Hi there), ' + 'Option(Howdy), Option(Yo! #disabled)])) -> 1', '[*] onChoiceFinish(Option(Howdy))', @@ -157,6 +160,8 @@ void main() { [ '[*] onDialogueStart()', '[*] onNodeStart(Node(X))', + '[*] onLineStart(DialogueLine(Question?)[#lastline])', + '[*] onLineFinish(DialogueLine(Question?))', '[*] onChoiceStart(DialogueChoice([Option(Hi there), ' + 'Option(Howdy), Option(Yo! #disabled)])) -> 0', '[*] onChoiceFinish(Option(Hi there))', @@ -373,7 +378,7 @@ class _RecordingDialogueView extends DialogueView { @override FutureOr onLineStart(DialogueLine line) => - _record('onLineStart($line)'); + _record('onLineStart($line${line.tags.isNotEmpty ? line.tags : ""})'); @override void onLineFinish(DialogueLine line) => _record('onLineFinish($line)'); diff --git a/packages/flame_jenny/pubspec.yaml b/packages/flame_jenny/pubspec.yaml index e3388d0f63c..8da85f41b33 100644 --- a/packages/flame_jenny/pubspec.yaml +++ b/packages/flame_jenny/pubspec.yaml @@ -17,7 +17,7 @@ dependencies: flame: ^1.10.0 flutter: sdk: flutter - jenny: ^1.1.1 + jenny: ^1.2.0 meta: ^1.9.1 dev_dependencies: