Skip to content

feat: Inherit template values, translate template gids and copy external tileset version - #98

Merged
spydon merged 2 commits into
mainfrom
spydon/missing-template-changes
Aug 31, 2026
Merged

spydon merged 2 commits into
mainfrom
spydon/missing-template-changes

Conversation

@spydon

@spydon spydon commented Aug 31, 2026 •

Copy link
Copy Markdown
Member

Description

#96 and #97 were merged into spydon/tsx-provider instead of main, and #72 was squash-merged before they landed on that branch, so their changes never reached main. This PR cherry-picks both commits on top of main.

Included:

Checklist

  • The title of my PR starts with a Conventional Commit prefix (fix:, feat:, docs: etc).
  • I have read the Contributor Guide and followed the process outlined for submitting PRs.
  • I have updated/added tests for ALL new/updated/fixed functionality.
  • I have updated/added relevant documentation in docs and added dartdoc comments with ///.
  • I have updated/added relevant examples in examples.

Breaking Change

  • Yes, this is a breaking change.
  • No, this is not a breaking change.

Related Issues

Re-lands #96 and #97 on main.

spydon added 2 commits August 31, 2026 15:16
# Description

When an external tileset is merged into the tileset entry of the map,
`version` and `type` were the only attributes that were not copied over,
so a map tileset backed by a `.tsx` file always reported the default
version `1.0`.

Stacked on #72 (base branch `spydon/tsx-provider` mirrors its head).
Once #72 is merged this PR will be rebased onto `main`.

## Checklist

- [x] The title of my PR starts with a [Conventional Commit] prefix
(`fix:`, `feat:`, `docs:` etc).
- [x] I have read the [Contributor Guide] and followed the process
outlined for submitting PRs.
- [x] I have updated/added tests for ALL new/updated/fixed
functionality.
- [x] I have updated/added relevant documentation in `docs` and added
dartdoc comments with `///`.
- [ ] I have updated/added relevant examples in `examples`.

## Breaking Change

- [ ] Yes, this is a breaking change.
- [x] No, this is *not* a breaking change.

## Related Issues

Follow-up to #72.

<!-- Links -->
[Contributor Guide]:
https://github.com/flame-engine/flame/blob/main/CONTRIBUTING.md
[Conventional Commit]: https://conventionalcommits.org

https://claude.ai/code/session_01LxYRD4TGF9St5Cmj7h1GNe
…97)

# Description

Completes template support from #72. Until now an object that referenced
a template only carried the parsed `Template`, while its own values
stayed at their defaults and the gid of the template was unusable since
it refers to the tileset of the template file, not to the tilesets of
the map.

- `TiledObject.parse` inherits every value the object does not specify
itself (`name`, `type`, `width`, `height`, `rotation`, `visible`,
`text`, shape, polygon and polyline) from the object of the template,
and merges the properties of the template with the ones of the object,
where the object wins. This is what Tiled writes: an instance only
contains what differs from its template.
- `TiledMap.parse` translates inherited gids to the tilesets of the map
afterwards, keeping the flip flags. When the map does not contain the
tileset of the template it is added to `TiledMap.tilesets` with the next
free `firstgid`, like Tiled does when loading such a map. An object that
specifies its own `gid` keeps it. `TiledObject.gid` stays null for an
inherited gid until the map translates it, so parsing a layer on its own
never produces a gid that points into the wrong tileset.
- Tilesets are matched by `source`, which is now always stored relative
to the map, also for tilesets referenced from template files in other
directories. `TiledObject.templatePath` follows the same rule. Added
`Parser.resolvePath` for that.
- Adds `Gid.flagMask`.

Stacked on #96 (which is stacked on #72). Once those are merged this PR
will be rebased onto `main`.

## Checklist

- [x] The title of my PR starts with a [Conventional Commit] prefix
(`fix:`, `feat:`, `docs:` etc).
- [x] I have read the [Contributor Guide] and followed the process
outlined for submitting PRs.
- [x] I have updated/added tests for ALL new/updated/fixed
functionality.
- [x] I have updated/added relevant documentation in `docs` and added
dartdoc comments with `///`.
- [ ] I have updated/added relevant examples in `examples`.

## Breaking Change

- [ ] Yes, this is a breaking change.
- [x] No, this is *not* a breaking change.

`Tileset.source` of tilesets referenced from template files changes from
the path as written in the template to the path relative to the map,
which is what #72 already documents for provider paths and what nobody
could rely on before, since those tilesets were never resolved.

## Related Issues

Follow-up to #72 and #73.

<!-- Links -->
[Contributor Guide]:
https://github.com/flame-engine/flame/blob/main/CONTRIBUTING.md
[Conventional Commit]: https://conventionalcommits.org

https://claude.ai/code/session_01LxYRD4TGF9St5Cmj7h1GNe
@spydon
spydon merged commit 47850e3 into main Aug 31, 2026
5 checks passed
@spydon
spydon deleted the spydon/missing-template-changes branch August 31, 2026 13:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants