Skip to content

Commit

Permalink
feat!: upgrade to LDtk types and examples to 1.4.1 (drop support for …
Browse files Browse the repository at this point in the history
…<1.4.1) (#256)

Closes #247 
LDtk 1.4.0 and 1.4.1 have been released and we should keep this project
up to date before the next release. This PR rebuilds the `ldtk/mod.rs`
file based off the steps in the documentation and the latest rust
quicktype-generated file from LDtk. Some of these steps have been
removed/adjusted since some of them are have actually been implemented
in the quicktype itself. All example projects have been updated to 1.4.1
as well.
  • Loading branch information
Trouv authored Oct 25, 2023
1 parent c00085d commit ab21e2c
Show file tree
Hide file tree
Showing 7 changed files with 699 additions and 785 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ for additional level-loading options.
### Compatibility
| bevy | bevy_ecs_tilemap | LDtk | bevy_ecs_ldtk |
| --- | --- | --- | --- |
| 0.11 | 0.11 | 1.3.3 | main |
| 0.11 | 0.11 | 1.4.1 | main |
| 0.11 | 0.11 | 1.3.3 | 0.8 |
| 0.10 | 0.10 | 1.1 | 0.7 |
| 0.10 | 0.10 | 1.1 | 0.6 |
Expand Down
116 changes: 80 additions & 36 deletions assets/Typical_2D_platformer_example.ldtk

Large diffs are not rendered by default.

193 changes: 145 additions & 48 deletions assets/WorldMap_Free_layout.ldtk

Large diffs are not rendered by default.

45 changes: 34 additions & 11 deletions assets/field_instances.ldtk
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@
"doc": "https://ldtk.io/json",
"schema": "https://ldtk.io/files/JSON_SCHEMA.json",
"appAuthor": "Sebastien 'deepnight' Benard",
"appVersion": "1.3.3",
"appVersion": "1.4.1",
"url": "https://ldtk.io"
},
"iid": "e5d71f40-c640-11ed-8b6c-3f97242aa928",
"jsonVersion": "1.3.3",
"appBuildId": 468555,
"jsonVersion": "1.4.1",
"appBuildId": 471698,
"nextUid": 96,
"identifierStyle": "Capitalize",
"toc": [],
Expand All @@ -22,6 +22,8 @@
"defaultPivotX": 0,
"defaultPivotY": 0,
"defaultGridSize": 16,
"defaultEntityWidth": 16,
"defaultEntityHeight": 16,
"bgColor": "#40465B",
"defaultLevelBgColor": "#696A79",
"minifyJson": false,
Expand Down Expand Up @@ -63,6 +65,7 @@
"requiredTags": [],
"excludedTags": [],
"intGridValues": [],
"intGridValuesGroups": [],
"autoRuleGroups": [],
"autoSourceLayerDefUid": null,
"tilesetDefUid": null,
Expand Down Expand Up @@ -92,8 +95,9 @@
"parallaxScaling": true,
"requiredTags": [],
"excludedTags": [],
"intGridValues": [{ "value": 1, "identifier": "Wall", "color": "#000000", "tile": null }],
"autoRuleGroups": [{ "uid": 80, "name": "Walls", "active": true, "isOptional": false, "rules": [
"intGridValues": [{ "value": 1, "identifier": "Wall", "color": "#000000", "tile": null, "groupUid": 0 }],
"intGridValuesGroups": [],
"autoRuleGroups": [{ "uid": 80, "name": "Walls", "color": null, "icon": null, "active": true, "isOptional": false, "rules": [
{
"uid": 82,
"active": true,
Expand Down Expand Up @@ -341,7 +345,8 @@
"requiredTags": [],
"excludedTags": [],
"intGridValues": [],
"autoRuleGroups": [{ "uid": 91, "name": "Background", "active": true, "isOptional": false, "rules": [
"intGridValuesGroups": [],
"autoRuleGroups": [{ "uid": 91, "name": "Background", "color": null, "icon": null, "active": true, "isOptional": false, "rules": [
{
"uid": 93,
"active": true,
Expand Down Expand Up @@ -436,6 +441,7 @@
"tilesetId": 31,
"tileRenderMode": "FitInside",
"tileRect": { "tilesetUid": 31, "x": 64, "y": 2720, "w": 32, "h": 32 },
"uiTileRect": null,
"nineSliceBorders": [],
"maxCount": 0,
"limitScope": "PerLevel",
Expand All @@ -457,6 +463,7 @@
"editorDisplayScale": 1,
"editorDisplayPos": "Above",
"editorLinkStyle": "StraightArrow",
"editorDisplayColor": null,
"editorAlwaysShow": false,
"editorShowInWorld": true,
"editorCutLongValues": true,
Expand Down Expand Up @@ -491,6 +498,7 @@
"editorDisplayScale": 1,
"editorDisplayPos": "Above",
"editorLinkStyle": "StraightArrow",
"editorDisplayColor": null,
"editorAlwaysShow": false,
"editorShowInWorld": true,
"editorCutLongValues": true,
Expand Down Expand Up @@ -525,6 +533,7 @@
"editorDisplayScale": 1,
"editorDisplayPos": "Above",
"editorLinkStyle": "StraightArrow",
"editorDisplayColor": null,
"editorAlwaysShow": false,
"editorShowInWorld": true,
"editorCutLongValues": true,
Expand Down Expand Up @@ -559,6 +568,7 @@
"editorDisplayScale": 1,
"editorDisplayPos": "Above",
"editorLinkStyle": "CurvedArrow",
"editorDisplayColor": null,
"editorAlwaysShow": false,
"editorShowInWorld": true,
"editorCutLongValues": true,
Expand Down Expand Up @@ -627,11 +637,11 @@
}
}
], "enums": [{ "identifier": "Equipment", "uid": 2, "values": [
{ "id": "Helmet", "tileRect": { "tilesetUid": 31, "x": 0, "y": 32, "w": 32, "h": 32 }, "tileId": -1, "color": 12496031, "__tileSrcRect": [0,32,32,32] },
{ "id": "Armor", "tileRect": { "tilesetUid": 31, "x": 32, "y": 32, "w": 32, "h": 32 }, "tileId": -1, "color": 10777205, "__tileSrcRect": [32,32,32,32] },
{ "id": "Boots", "tileRect": { "tilesetUid": 31, "x": 64, "y": 32, "w": 32, "h": 32 }, "tileId": -1, "color": 8869439, "__tileSrcRect": [64,32,32,32] },
{ "id": "Sword", "tileRect": { "tilesetUid": 31, "x": 96, "y": 32, "w": 32, "h": 32 }, "tileId": -1, "color": 12363427, "__tileSrcRect": [96,32,32,32] },
{ "id": "Shield", "tileRect": { "tilesetUid": 31, "x": 128, "y": 32, "w": 32, "h": 32 }, "tileId": -1, "color": 10662597, "__tileSrcRect": [128,32,32,32] }
{ "id": "Helmet", "tileRect": { "tilesetUid": 31, "x": 0, "y": 32, "w": 32, "h": 32 }, "color": 12496031 },
{ "id": "Armor", "tileRect": { "tilesetUid": 31, "x": 32, "y": 32, "w": 32, "h": 32 }, "color": 10777205 },
{ "id": "Boots", "tileRect": { "tilesetUid": 31, "x": 64, "y": 32, "w": 32, "h": 32 }, "color": 8869439 },
{ "id": "Sword", "tileRect": { "tilesetUid": 31, "x": 96, "y": 32, "w": 32, "h": 32 }, "color": 12363427 },
{ "id": "Shield", "tileRect": { "tilesetUid": 31, "x": 128, "y": 32, "w": 32, "h": 32 }, "color": 10662597 }
], "iconTilesetUid": 31, "externalRelPath": null, "externalFileChecksum": null, "tags": [] }], "externalEnums": [], "levelFields": [
{
"identifier": "title",
Expand All @@ -647,6 +657,7 @@
"editorDisplayScale": 1,
"editorDisplayPos": "Above",
"editorLinkStyle": "StraightArrow",
"editorDisplayColor": null,
"editorAlwaysShow": false,
"editorShowInWorld": true,
"editorCutLongValues": true,
Expand Down Expand Up @@ -724,6 +735,8 @@
"__tags": [],
"__tile": { "tilesetUid": 31, "x": 64, "y": 2720, "w": 32, "h": 32 },
"__smartColor": "#FF0000",
"__worldX": 64,
"__worldY": 112,
"iid": "69b312b0-c640-11ed-8b6c-8f6519e0d2b4",
"width": 32,
"height": 32,
Expand Down Expand Up @@ -767,6 +780,8 @@
"__tags": [],
"__tile": { "tilesetUid": 31, "x": 64, "y": 2720, "w": 32, "h": 32 },
"__smartColor": "#FF0000",
"__worldX": 96,
"__worldY": 160,
"iid": "1a554610-c640-11ed-8b6c-15b1960faff2",
"width": 16,
"height": 16,
Expand Down Expand Up @@ -803,6 +818,8 @@
"__tags": [],
"__tile": { "tilesetUid": 31, "x": 64, "y": 2720, "w": 32, "h": 32 },
"__smartColor": "#FF0000",
"__worldX": 144,
"__worldY": 144,
"iid": "1ac45b90-c640-11ed-8b6c-a59b01c5c306",
"width": 16,
"height": 16,
Expand Down Expand Up @@ -839,6 +856,8 @@
"__tags": [],
"__tile": { "tilesetUid": 31, "x": 64, "y": 2720, "w": 32, "h": 32 },
"__smartColor": "#FF0000",
"__worldX": 112,
"__worldY": 96,
"iid": "1b396480-c640-11ed-8b6c-f56e35f68eb2",
"width": 16,
"height": 16,
Expand Down Expand Up @@ -872,6 +891,8 @@
"__tags": [],
"__tile": { "tilesetUid": 31, "x": 64, "y": 2720, "w": 32, "h": 32 },
"__smartColor": "#FF0000",
"__worldX": 192,
"__worldY": 128,
"iid": "1b9232e0-c640-11ed-8b6c-ab2c2d42f439",
"width": 16,
"height": 16,
Expand Down Expand Up @@ -905,6 +926,8 @@
"__tags": [],
"__tile": { "tilesetUid": 31, "x": 64, "y": 2720, "w": 32, "h": 32 },
"__smartColor": "#FF0000",
"__worldX": 160,
"__worldY": 80,
"iid": "240e2280-c640-11ed-8b6c-ad0787b6f408",
"width": 16,
"height": 16,
Expand Down
15 changes: 12 additions & 3 deletions assets/my_project.ldtk
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@
"doc": "https://ldtk.io/json",
"schema": "https://ldtk.io/files/JSON_SCHEMA.json",
"appAuthor": "Sebastien 'deepnight' Benard",
"appVersion": "1.3.3",
"appVersion": "1.4.1",
"url": "https://ldtk.io"
},
"iid": "369ed9c0-c640-11ed-bac6-cfa00fd378d5",
"jsonVersion": "1.3.3",
"appBuildId": 468555,
"jsonVersion": "1.4.1",
"appBuildId": 471698,
"nextUid": 6,
"identifierStyle": "Capitalize",
"toc": [],
Expand All @@ -22,6 +22,8 @@
"defaultPivotX": 0,
"defaultPivotY": 0,
"defaultGridSize": 16,
"defaultEntityWidth": 16,
"defaultEntityHeight": 16,
"bgColor": "#40465B",
"defaultLevelBgColor": "#696A79",
"minifyJson": false,
Expand Down Expand Up @@ -63,6 +65,7 @@
"requiredTags": [],
"excludedTags": [],
"intGridValues": [],
"intGridValuesGroups": [],
"autoRuleGroups": [],
"autoSourceLayerDefUid": null,
"tilesetDefUid": null,
Expand Down Expand Up @@ -93,6 +96,7 @@
"requiredTags": [],
"excludedTags": [],
"intGridValues": [],
"intGridValuesGroups": [],
"autoRuleGroups": [],
"autoSourceLayerDefUid": null,
"tilesetDefUid": 1,
Expand Down Expand Up @@ -125,6 +129,7 @@
"tilesetId": 5,
"tileRenderMode": "FitInside",
"tileRect": { "tilesetUid": 5, "x": 160, "y": 192, "w": 32, "h": 32 },
"uiTileRect": null,
"nineSliceBorders": [],
"maxCount": 0,
"limitScope": "PerLevel",
Expand Down Expand Up @@ -232,6 +237,8 @@
"__tags": [],
"__tile": { "tilesetUid": 5, "x": 160, "y": 192, "w": 32, "h": 32 },
"__smartColor": "#94D9B3",
"__worldX": 128,
"__worldY": 112,
"iid": "cbcc78c0-8dc0-11ec-9045-d14d83e99362",
"width": 64,
"height": 64,
Expand All @@ -246,6 +253,8 @@
"__tags": [],
"__tile": { "tilesetUid": 5, "x": 160, "y": 192, "w": 32, "h": 32 },
"__smartColor": "#94D9B3",
"__worldX": 80,
"__worldY": 128,
"iid": "cbcc78c1-8dc0-11ec-9045-3f386f00e6d6",
"width": 32,
"height": 32,
Expand Down
5 changes: 2 additions & 3 deletions src/ldtk/field_instance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ use regex::Regex;

use crate::ldtk::color;

#[derive(PartialEq, Debug, Clone, Serialize, Reflect)]
#[derive(Debug, Clone, Serialize, PartialEq, Reflect)]
#[serde(rename_all = "camelCase")]
pub struct FieldInstance {
/// Field definition identifier
#[serde(rename = "__identifier")]
Expand Down Expand Up @@ -37,12 +38,10 @@ pub struct FieldInstance {
pub value: FieldValue,

/// Reference of the **Field definition** UID
#[serde(rename = "defUid")]
pub def_uid: i32,

/// Editor internal raw values
#[reflect(ignore)]
#[serde(rename = "realEditorValues")]
pub real_editor_values: Vec<Option<serde_json::Value>>,
}

Expand Down
Loading

0 comments on commit ab21e2c

Please sign in to comment.