Tiled: Exporting a file to map-0.0.1.json doesn't work

Created on 1 Jul 2019  路  6Comments  路  Source: mapeditor/tiled

It's a problem when parsing the file name for the extension I guess.
Exporting to map.json and then renaming it works.

bug

All 6 comments

I just tried to reproduce your problem but it exported fine. Could you please give me some more information, like:

  • Which version of Tiled are you using?
  • Which operating system are you on?
  • What does "doesn't work" mean? What is happening instead?
  • Using version 1.1.6
  • I'm on Linux Fedora

I go into file > export as...
I type a name with multiple dots in it :
Screenshot from 2019-07-10 11-13-27

When I click save I have this :
Screenshot from 2019-07-10 11-13-36

Could you make sure the appropriate plugin is installed for the JSON format to be available? I believe in Fedora the plugins are separate packages.

As said, exporting to map.json works. It's just map.xxxx.json that doesn't.
To me it's clear that the problem comes from the parsing of the extension in the file name.

Whoops, sorry, I had forgotten about that little detail.

Actually the reason I could not reproduce it before was probably because I had explicitly selected the JSON format in the file type dropdown. This is a workaround that you could use as well.

If you keep the file type dropdown on "All Files", then Tiled tries to determine the format by the file extension. But it does this by looking from the first dot rather than from the last dot, and then it can't find any format that matches a "0.0.0.test.json" extension. I don't remember why I made it use the "complete" suffix rather than just the last part, but right now Tiled has one plugin that uses the file extension ".room.gmx", so simply taking only the last part would break auto-detection of that format.

So I think a solution will be to first search for a matching format using the complete suffix, and when that fails to fall back to a search for only the last part. Actually one could take this even further and search for sub-suffixes as well otherwise you couldn't detect a file like ".test.room.gmx"... so a better fix would probably be to change the way the matching itself is done to support such cases as well.

This turned out to be not so hard to fix, since a helper method for doing the right check was already available. Thanks for the report! :-)

Was this page helpful?
0 / 5 - 0 ratings