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
json support #18
json support #18
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did a quick review, few comments.
Sorry for the long delay @synchronisator I had some harsh weeks at work. But lets get back to this as I think json support is very useful. I will re-open and address any remaining comments myself. |
I have rewritten everything, but have not yet made a new pr. Look here: https://github.com/synchronisator/tiled.dart/tree/jsonsupport |
@synchronisator ah sounds good! I will wait for your PR then. lmk if I can help with anything :) |
Hi, "computeDrawRect": "can we just move it up the data hierarchy? if not ok to put on flame_tiled" We could add this to "tileset" like this:
Is this a solution you would like? |
"make sure we have fallbacks so the old TMX files still work" The old test.tmx failes with the current version of my code. This is because the tilecount is missing in the file. But the tilecount is important to create the tileMatrix.
But this is wrong. I could recreate this buggy behavior if the tileCount is not available but i dont think this is a good solution.... Edit: Hm...something is not right here... i will have a look at my tileset code again. no time now, but the code where i use tilecount is not for TileMatrix (thats in layer) but for tiles-List. I will have a deeper look later. Edit2: ok, i got it. Sorry i was a little bit confused.
is needed to add every "empty" tile to the tiles. SOLUTION:
That is a hack for very old maps (older than 5 years) |
So. we reach the last three questions:
isometric_grass_and_water.png is from Tiled And coins.png is from flutter_tiled If the images are ok, the only open task would be to make the tests clean and without uncommented code. I will work on that in the next time. |
Hi, i updated the tests.
Maybe you have an idea. |
@synchronisator after testing with the TiledMapEditor, rectangles have no certain property set and no polygon/ polyline but only width and height. The width and height could be zero, that would mean that the rectangle has the size of one tile (from what i can see). The question is if isRectangle should check the polygon if it has 4 points creating a rectangle (which could be done be some math) |
@Akida31 |
I just created a map with different shapes and looked into the Json-Export-file. Probably not the cleanest way. Would be nice if you could verify that my assumptions are true. |
@Akida31 Thanks for your testing. Something similar is happening with an ellipse without dragging. here is the height 20 again without a height in the json. Maybe its a tiled default. After a little bit of analysing. I think the rule is: If its NOT a polygon or polyline or ellipse or point it IS a rectangle. Question to all of you: Is it needed to calculate rectangles from polygons? |
I asked some people in the tiled discord and learned two things:
|
@synchronisator great work! How is it going, anything you need help with? :) Once this is in we will start migrating this package to null-safety. |
@spydon thanks If someone has any ideas on this, please comment. I have no idea what is going wrong here... |
Thanks for the quick reply! I'll have a look with the team. |
I am not at my pc right now. But I think there was a test for this method that fails now... But I am not 100% sure. Will have a look later |
@spydon Other things:
|
Haven't dug deep into what each one is, but my initial 2cents:
|
Since this PR is so useful and so big, I think we can be a bit lenient with missing features and followups, as long as they are well documented here :) |
Hi, |
expect( | ||
layer.tileIDMatrix[8], equals([0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0])); | ||
expect( | ||
layer.tileIDMatrix[9], equals([0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0])); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor comment, these should have a trailing comma since it is split on two lines.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we can do that as a followup
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let's merge this and address things as needed
This PR enables json support for tiled maps.
The compare-test shows, that the test.tmx and the same map as test.json have the same output.
A user jan load a json, but decide to use the tmx strusture instead by converting it.