Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for merging tilesets #171

Open
stefanbeller opened this issue Mar 19, 2012 · 5 comments
Open

Add support for merging tilesets #171

stefanbeller opened this issue Mar 19, 2012 · 5 comments
Labels
feature It's a feature, not a bug.

Comments

@stefanbeller
Copy link
Contributor

It would be great if we could merge tilesets (remove unused tiles from all tilesets, store the remaining tiles into a single tileset and apply that to the map).

This project aims at doing that (or something very similar):
https://github.com/falanxia/tileset_baker/wiki

(creating this to close the issue at the old bugtracker
https://sourceforge.net/apps/mantisbt/tiled/view.php?id=36 )

@ghost
Copy link

ghost commented Feb 19, 2013

I have created a java tool to merge map tilesets: http://devnewton.bci.im/projects/tiledmerge/home

I made it for my own usage, but if someone need to use it, I can improve it.

@rmarku
Copy link

rmarku commented Jan 21, 2015

This would be great, some kind of "save as"/"export" that allow to save the TMX file and only one optimized tileset image.
Or it can be other application like tmxrasterizer that optimize all tilesets and generate a new tmx and png image.

Not like tileset_baker but more like tmxOptimizer

@gdm85
Copy link

gdm85 commented Nov 12, 2016

Given that there is now support of external tilesets, my requirement for this feature is to merge the embedded <tileset>s of multiple maps into an external one.

I am going to make some a for this, the logic will basically go like:

  • load in memory all embedded tilesets of the map files + the rotated/flipped version of each tile (hashes)
  • de-duplicate and create a list of replacements <old id> -> <new id> (with needed flags etc)
  • update the maps by running them the list of replacements
  • remove the embedded <tileset>s from the maps and replace with the new compact external one

@bjorn bjorn moved this to Future in Roadmap Feb 3, 2023
@bjorn bjorn added this to Roadmap Feb 3, 2023
@TomONeill
Copy link

TomONeill commented Aug 23, 2023

My problem is that by copying tiles from another .tmx file, Tiled creates a copy of the tileset into the tmx file you're copying to, even if the exact same tileset was already there. I think the reason for this is because the tileset has another image source.

I created a console app to deduplicate tilesets to fix the above scenario:
https://github.com/TomONeill/tmx-tileset-deduplicator/releases

Sorry, I'm a lazy developer, don't know C++ and felt it was too hard to add this into Tiled itself. But feel free to take inspiration from my project to add it to Tiled.

@bjorn
Copy link
Member

bjorn commented Aug 23, 2023

@TomONeill Thanks for sharing your tool!

I think the reason for this is because the tileset has another image source.

Hmm, if they do then it's not the same tileset, which is why it gets duplicated. Tiled does not do a deep comparison of the tileset image to see if it is the same image.

I think in general for this scenario the fix would be to use external tilesets (.tsx files). Use the "Export Tileset" action to turn an embedded tileset into an external one or the "Replace Tileset" action (either of which you can find below the tileset view) to replace each duplicated tileset with the external one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature It's a feature, not a bug.
Projects
Status: No status
Development

No branches or pull requests

5 participants