Skip to content

Commit

Permalink
Merge branch 'main' into flame-engine#69-dart-sdk
Browse files Browse the repository at this point in the history
# Conflicts:
#	packages/tiled/pubspec.yaml
#	packages/tiled/test/parser_test.dart
  • Loading branch information
benni-tec committed Dec 20, 2024
2 parents 82a2b34 + 581391c commit 8acf697
Show file tree
Hide file tree
Showing 33 changed files with 90 additions and 58 deletions.
35 changes: 20 additions & 15 deletions .github/workflows/cicd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,33 +18,38 @@ jobs:
channel: 'stable'
- uses: flame-engine/flame-dartdoc-action@v2

format:
analyze:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: subosito/flutter-action@v1
- uses: actions/checkout@v3
- uses: subosito/flutter-action@v2
- uses: bluefireteam/melos-action@v3
- name: "Analyze with latest stable"
uses: invertase/[email protected]
with:
channel: 'stable'
- uses: flame-engine/flame-format-action@v1
fatal-infos: true

analyze:
format:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: subosito/flutter-action@v1
- uses: actions/checkout@v3
- uses: subosito/flutter-action@v2
with:
channel: 'stable'
- uses: flame-engine/flame-analyze-action@v2
cache: true
- uses: bluefireteam/melos-action@v3
- name: Run format
run: melos format-check
# END LINTING STAGE

# BEGIN TESTING STAGE
test:
needs: [dartdoc, format, analyze]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: subosito/flutter-action@v1
- uses: actions/checkout@v3
- uses: subosito/flutter-action@v2
with:
channel: 'stable'
- uses: flame-engine/flame-test-action@v1
cache: true
- uses: bluefireteam/melos-action@v3
- name: Run tests
run: melos test
# END TESTING STAGE
8 changes: 4 additions & 4 deletions melos.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,12 @@ scripts:
description: Run `flutter analyze` for all packages.

format:
run: melos exec flutter format . --fix
description: Run `flutter format` for all packages.
run: melos exec dart format . --fix
description: Run `dart format` for all packages.

format-check:
run: melos exec flutter format . --set-exit-if-changed
description: Run `flutter format` checks for all packages.
run: melos exec dart format . --set-exit-if-changed
description: Run `dart format` checks for all packages.

dartdoc:
run: melos exec flutter pub run dartdoc
Expand Down
13 changes: 7 additions & 6 deletions packages/tiled/LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
The MIT License (MIT)
MIT License

Copyright (c) <year> <copyright holders>
Copyright (c) 2021 Blue Fire

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand All @@ -9,13 +9,14 @@ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

2 changes: 1 addition & 1 deletion packages/tiled/lib/src/chunk.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
part of tiled;
part of '../tiled.dart';

/// Below is Tiled's documentation about how this structure is represented
/// on XML files:
Expand Down
2 changes: 1 addition & 1 deletion packages/tiled/lib/src/common/enums.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
part of tiled;
part of '../../tiled.dart';

enum MapOrientation { orthogonal, isometric, staggered, hexagonal }

Expand Down
2 changes: 1 addition & 1 deletion packages/tiled/lib/src/common/flips.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
part of tiled;
part of '../../tiled.dart';

class Flips {
final bool horizontally;
Expand Down
2 changes: 1 addition & 1 deletion packages/tiled/lib/src/common/frame.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
part of tiled;
part of '../../tiled.dart';

/// Below is Tiled's documentation about how this structure is represented
/// on XML files:
Expand Down
2 changes: 1 addition & 1 deletion packages/tiled/lib/src/common/gid.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
part of tiled;
part of '../../tiled.dart';

/// A [Gid], Global Tile ID is a Tiled concept to represent the tiles inside
/// int matrices. This wrapper is used by [Layer] and [Chunk] to provide
Expand Down
2 changes: 1 addition & 1 deletion packages/tiled/lib/src/common/point.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
part of tiled;
part of '../../tiled.dart';

/// Below is Tiled's documentation about how this structure is represented
/// on XML files:
Expand Down
2 changes: 1 addition & 1 deletion packages/tiled/lib/src/common/property.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
part of tiled;
part of '../../tiled.dart';

/// Below is Tiled's documentation about how this structure is represented
/// on XML files:
Expand Down
2 changes: 1 addition & 1 deletion packages/tiled/lib/src/common/tiled_image.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
part of tiled;
part of '../../tiled.dart';

/// Below is Tiled's documentation about how this structure is represented
/// on XML files:
Expand Down
2 changes: 1 addition & 1 deletion packages/tiled/lib/src/editor_setting/chunk_size.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
part of tiled;
part of '../../tiled.dart';

/// Below is Tiled's documentation about how this structure is represented
/// on XML files:
Expand Down
2 changes: 1 addition & 1 deletion packages/tiled/lib/src/editor_setting/editor_setting.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
part of tiled;
part of '../../tiled.dart';

/// Below is Tiled's documentation about how this structure is represented
/// on XML files:
Expand Down
2 changes: 1 addition & 1 deletion packages/tiled/lib/src/editor_setting/export.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
part of tiled;
part of '../../tiled.dart';

/// Below is Tiled's documentation about how this structure is represented
/// on XML files:
Expand Down
4 changes: 2 additions & 2 deletions packages/tiled/lib/src/layer.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
part of tiled;
part of '../tiled.dart';

/// Below is Tiled's documentation about how this structure is represented
/// on XML files:
Expand Down Expand Up @@ -328,7 +328,7 @@ abstract class Layer {
decompressed = const ZLibDecoder().decodeBytes(decodedString);
break;
case Compression.gzip:
decompressed = GZipDecoder().decodeBytes(decodedString);
decompressed = const GZipDecoder().decodeBytes(decodedString);
break;
case Compression.zstd:
throw UnsupportedError('zstd is an unsupported compression');
Expand Down
5 changes: 3 additions & 2 deletions packages/tiled/lib/src/objects/text.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
part of tiled;
part of '../../tiled.dart';

/// Below is Tiled's documentation about how this structure is represented
/// on XML files:
Expand Down Expand Up @@ -74,7 +74,8 @@ class Text {
fontFamily: parser.getString('fontFamily', defaults: 'sans-serif'),
pixelSize: parser.getInt('pixelSize', defaults: 16),
color: parser.getString('color', defaults: '#000000'),
text: parser.getString('text', defaults: ''),
text: parser.getInnerTextOrNull() ??
parser.getString('text', defaults: ''),
hAlign: parser.getHAlign('hAlign', defaults: HAlign.left),
vAlign: parser.getVAlign('vAlign', defaults: VAlign.top),
bold: parser.getBool('bold', defaults: false),
Expand Down
2 changes: 1 addition & 1 deletion packages/tiled/lib/src/objects/tiled_object.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
part of tiled;
part of '../../tiled.dart';

/// Below is Tiled's documentation about how this structure is represented
/// on XML files:
Expand Down
11 changes: 10 additions & 1 deletion packages/tiled/lib/src/parser.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
part of tiled;
part of '../tiled.dart';

class ParsingException implements Exception {
final String name;
Expand All @@ -11,6 +11,10 @@ class XmlParser extends Parser {
final XmlElement element;
XmlParser(this.element);

@override
String? getInnerTextOrNull() =>
element.innerText.isEmpty ? null : element.innerText;

@override
String? getStringOrNull(String name, {String? defaults}) {
return element.getAttribute(name) ?? defaults;
Expand Down Expand Up @@ -46,6 +50,9 @@ class JsonParser extends Parser {
final Map<String, dynamic> json;
JsonParser(this.json);

@override
String? getInnerTextOrNull() => null;

@override
String? getStringOrNull(String name, {String? defaults}) {
return json[name]?.toString() ?? defaults;
Expand Down Expand Up @@ -75,6 +82,8 @@ class JsonParser extends Parser {
}

abstract class Parser {
String? getInnerTextOrNull();

String? getStringOrNull(String name, {String? defaults});

List<Parser> getChildren(String name);
Expand Down
2 changes: 1 addition & 1 deletion packages/tiled/lib/src/template.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
part of tiled;
part of '../tiled.dart';

/// Below is Tiled's documentation about how this structure is represented
/// on XML files:
Expand Down
2 changes: 1 addition & 1 deletion packages/tiled/lib/src/tile_map_parser.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
part of tiled;
part of '../tiled.dart';

class TileMapParser {
static TiledMap parseJson(String json) {
Expand Down
3 changes: 2 additions & 1 deletion packages/tiled/lib/src/tiled_map.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
part of tiled;
part of '../tiled.dart';

/// Below is Tiled's documentation about how this structure is represented
/// on XML files:
Expand Down Expand Up @@ -247,6 +247,7 @@ class TiledMap {
(tileset) =>
[tileset.image, ...tileset.tiles.map((tile) => tile.image)],
)
// ignore: deprecated_member_use
.whereNotNull()
.toList();
}
Expand Down
2 changes: 1 addition & 1 deletion packages/tiled/lib/src/tileset/grid.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
part of tiled;
part of '../../tiled.dart';

/// Below is Tiled's documentation about how this structure is represented
/// on XML files:
Expand Down
2 changes: 1 addition & 1 deletion packages/tiled/lib/src/tileset/terrain.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
part of tiled;
part of '../../tiled.dart';

/// Below is Tiled's documentation about how this structure is represented
/// on XML files:
Expand Down
2 changes: 1 addition & 1 deletion packages/tiled/lib/src/tileset/tile.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
part of tiled;
part of '../../tiled.dart';

/// Below is Tiled's documentation about how this structure is represented
/// on XML files:
Expand Down
2 changes: 1 addition & 1 deletion packages/tiled/lib/src/tileset/tile_offset.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
part of tiled;
part of '../../tiled.dart';

/// Below is Tiled's documentation about how this structure is represented
/// on XML files:
Expand Down
2 changes: 1 addition & 1 deletion packages/tiled/lib/src/tileset/tileset.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
part of tiled;
part of '../../tiled.dart';

/// Below is Tiled's documentation about how this structure is represented
/// on XML files:
Expand Down
2 changes: 1 addition & 1 deletion packages/tiled/lib/src/tileset/wang/wang_color.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
part of tiled;
part of '../../../tiled.dart';

/// Below is Tiled's documentation about how this structure is represented
/// on XML files:
Expand Down
2 changes: 1 addition & 1 deletion packages/tiled/lib/src/tileset/wang/wang_set.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
part of tiled;
part of '../../../tiled.dart';

/// Below is Tiled's documentation about how this structure is represented
/// on XML files:
Expand Down
2 changes: 1 addition & 1 deletion packages/tiled/lib/src/tileset/wang/wang_tile.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
part of tiled;
part of '../../../tiled.dart';

/// Below is Tiled's documentation about how this structure is represented
/// on XML files:
Expand Down
2 changes: 1 addition & 1 deletion packages/tiled/lib/src/tsx_provider.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
part of tiled;
part of '../tiled.dart';

/// abstract class to be implemented for an external tileset data provider.
abstract class TsxProvider {
Expand Down
7 changes: 4 additions & 3 deletions packages/tiled/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,14 @@ homepage: https://github.com/flame-engine/tiled.dart

environment:
sdk: ">=2.18.0 <3.0.0"

dependencies:
archive: ^3.3.0
archive: ">=3.3.0 <5.0.0"
collection: ^1.16.0
meta: ^1.7.0
xml: ^6.1.0

dev_dependencies:
dartdoc: ^6.0.1
flame_lint: ^1.1.1
dartdoc: ^8.3.1
flame_lint: ^1.1.2
test: ^1.24.8
14 changes: 14 additions & 0 deletions packages/tiled/test/parser_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import 'dart:io';
import 'dart:math' show Rectangle;

import 'package:test/test.dart';
import 'package:collection/collection.dart';
import 'package:tiled/tiled.dart';
import 'package:xml/xml.dart';

Expand Down Expand Up @@ -87,6 +88,10 @@ void main() {
equals('test_value'),
);
expect(
properties
.getValue<String>('multiline string')
?.replaceAll('\r\n', '\n'),
equals('Hello,\nWorld'),
properties.getValue<String>('multiline string'),
equals('Hello,\r\nWorld'),
);
Expand Down Expand Up @@ -234,6 +239,15 @@ void main() {
test('has the right class_', () {
expect(og.class_, equals('objectLayer1Class'));
});

test('has the right text object with ID 5', () {
final textObject = (og as ObjectGroup)
.objects
.firstWhereOrNull((element) => element.id == 5);
final text = textObject?.text;
expect(text?.wrap, equals(true));
expect(text?.text, equals('Hello World'));
});
});
});

Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ environment:
sdk: ">=3.0.0 <4.0.0"

dev_dependencies:
melos: ^3.0.0
melos: ^6.2.0

0 comments on commit 8acf697

Please sign in to comment.