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

Exporting a file to map-0.0.1.json doesn't work #2149

Closed
K-marad opened this issue Jul 1, 2019 · 6 comments
Labels
bug

Comments

@K-marad
Copy link

@K-marad K-marad commented Jul 1, 2019

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

@bjorn

This comment has been minimized.

Copy link
Owner

@bjorn bjorn commented Jul 1, 2019

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?
@K-marad

This comment has been minimized.

Copy link
Author

@K-marad K-marad commented Jul 10, 2019

  • 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

@bjorn

This comment has been minimized.

Copy link
Owner

@bjorn bjorn commented Jul 10, 2019

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.

@K-marad

This comment has been minimized.

Copy link
Author

@K-marad K-marad commented Jul 10, 2019

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.

@bjorn

This comment has been minimized.

Copy link
Owner

@bjorn bjorn commented Jul 10, 2019

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.

@bjorn bjorn added the bug label Jul 10, 2019
@bjorn bjorn closed this in e456a51 Jul 10, 2019
@bjorn

This comment has been minimized.

Copy link
Owner

@bjorn bjorn commented Jul 10, 2019

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! :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.