feat(stdlib): Tiled P0.5 — TMX/TSX reader over the XML reader (#68)
All checks were successful
bootstrap / cfree-fixpoint (push) Successful in 20s
ci / build-and-test (push) Successful in 1m45s
commit-lint / conventional-commits (push) Successful in 3s
docs / build-and-deploy (push) Successful in 28s

Tiled.read / Tiled.read_tsx (runtime/native/tiled.ludic): map the native
XML formats (TMX/TSX/TX) onto the SAME intermediate the JSON path produces
— a Value tree in Tiled's JSON schema — so one format-independent core
(P1) consumes either reader.

- tmx_to_value walks a <map> into {orientation, width/height, tilewidth/
  height, tilesets[], layers[]}; every tile layer's <data> is decoded to a
  dense GID int list (CSV split, or base64 -> zlib/gzip inflate ->
  little-endian u32s), so a CSV .tmx and a base64 .tmj of the same map read
  structurally identically.
- External tilesets keep the {firstgid, source} reference (as TMJ does);
  embedded tilesets and standalone .tsx (tsx_to_value) inline full geometry
  + per-tile metadata (animation frames, collision objectgroup, class,
  properties) for later phases.
- Object layers, shapes (rect/ellipse/point/polygon/polyline/text),
  image/group layers and custom properties are parsed into the tree now so
  P2/P4/P5 just read it.
- tmj_normalize decodes base64 `data` strings in a parsed .tmj so the JSON
  path matches the XML path.

Proven by library/tiled_p05.ludic (30 assertions) incl. the in-repo Kenney
sampleMap.tmx + external sampleSheet.tsx and TMX-vs-TMJ structural
identity. Docs + inventory added; x test: 91 passed.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
Orkun ÇAKILKAYA 2026-09-01 14:15:41 +03:00
parent 79776d1f6a
commit 071c268de7
11 changed files with 5721 additions and 4986 deletions

View file

@ -0,0 +1,65 @@
{
"type": "map",
"version": "1.10",
"tiledversion": "1.10.2",
"orientation": "orthogonal",
"renderorder": "right-down",
"width": 4,
"height": 4,
"tilewidth": 16,
"tileheight": 16,
"infinite": false,
"nextlayerid": 3,
"nextobjectid": 1,
"tilesets": [
{
"firstgid": 1,
"source": "handmade.tsx"
}
],
"layers": [
{
"type": "tilelayer",
"id": 1,
"name": "csv",
"width": 4,
"height": 4,
"x": 0,
"y": 0,
"opacity": 1,
"visible": true,
"data": [
1,
2,
3,
4,
5,
6,
7,
8,
9,
10,
11,
12,
13,
14,
15,
2147483649
]
},
{
"type": "tilelayer",
"id": 2,
"name": "zlib",
"width": 4,
"height": 4,
"x": 0,
"y": 0,
"opacity": 1,
"visible": true,
"encoding": "base64",
"compression": "zlib",
"data": "eJwNw4cNACAMBLEPvYaVGT1nySYpMbOwsrFzcHJx8/DS+WjSDw1EAPo="
}
]
}