summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--chickadee/render/tiled.scm16
1 files changed, 13 insertions, 3 deletions
diff --git a/chickadee/render/tiled.scm b/chickadee/render/tiled.scm
index cce0683..42b6793 100644
--- a/chickadee/render/tiled.scm
+++ b/chickadee/render/tiled.scm
@@ -259,9 +259,10 @@
(vector-set! tiles i tile))
(loop (+ i 1))))
tiles))
- (define (parse-tileset node)
- (let* ((first-gid (attr node 'firstgid string->number))
- (name (attr node 'name))
+ (define (first-gid node)
+ (attr node 'firstgid string->number))
+ (define (parse-internal-tileset node first-gid)
+ (let* ((name (attr node 'name))
(tile-width (attr node 'tilewidth string->number))
(tile-height (attr node 'tileheight string->number))
(margin (or (attr node 'margin string->number) 0))
@@ -276,6 +277,15 @@
((sxpath '(properties property)) node))))
(%make-tileset name first-gid size tile-width tile-height
atlas tiles properties)))
+ (define (parse-external-tileset node)
+ (let* ((first-gid (attr node 'firstgid string->number))
+ (source (scope (attr node 'source)))
+ (tree (call-with-input-file source xml->sxml)))
+ (parse-internal-tileset (car ((sxpath '(tileset)) tree)) first-gid)))
+ (define (parse-tileset node)
+ (if (attr node 'source)
+ (parse-external-tileset node)
+ (parse-internal-tileset node (first-gid node))))
(define (tile-gid->map-tile gid tilesets x y tile-width tile-height)
(let* ((tileset (find (lambda (t)
(and (>= gid (tileset-first-gid t))