Releases: pythonarcade/pytiled_parser
Version 2.2.8
Add explicit support for 3.13, previous versions work on 3.13 but it was not explicitly labeled as supported or being tested by CI.
Converts all file loading to use UTF-8 encoding by default. In most cases, all Tiled files will be exported from Tiled in UTF-8 encoding, however the python open()
function uses the system default locale. The only case where Tiled would not have used UTF-8 is for JSON files when Tiled was compiled against Qt 5, which is only in some builds of Tiled from older systems. All XML files exported from Tiled will always be UTF-8. If someone happens to have a JSON file which was exported from Tiled on an encoding other than UTF-8, or for some other reason is in a different encoding. This can be switched using a new optional argument named encoding
in the various public API parse
functions such as parse_map()
. This value is handed down through the pipeline of file loading in pytiled-parser, and will apply to every file loaded during the chain from this. This means that every file in a chain(for example, Map, Tileset, and Template File) must share the same encoding. This new argument is a string which is ultimately passed to the Python open() function. This change does introduce breaking changes in the underlying API which is not intended to be public facing, but if you are going deeper than the top level parse functions, you may need to adjust for this, as many of the underlying internal functions now have a mandatory encoding argument.
Property values which are of type "int" in Tiled will now be loaded as Python ints. Previously these values were loaded as floats, which for most purposes is fine, but not exactly correct. If a float value happens to find it's way into an int type property, pytiled-parser will mimic Tiled's functionality and round it up/down to the nearest integer value. This may technically be a breaking change for some obscure runtime type checking use cases, but shouldn't really break too much.
Previously when loading object templates, if the template had a name
key defined, it would override the object instance name
value. This has been changed such that the object instance name
will be respected, and override any name provided by a template. This is in line with Tiled, and it does not appear to actually be possible to provide a name
value in an object template, but you can technically put the field into the template file manually, and with JSON, Tiled actually stores an empty string in the field(as opposed to it just not existing in the TMX file), so with JSON the fields were being overwritten to an empty string.
Previously with the TMX format, the order of layers within a Group Layer were not guaranteed, this has been fixed and all layers and group layers should be in their proper order.
Version 2.2.7
Fixes a bug when using the TMX format, where multi-line String properties would not be correctly parsed, as they are placed differently in the XML than single line strings. (#75)
The Tiled docs also state that this multi-line format may in the future be used for all property values, so this change will help to futureproof against that.
Version 2.2.6
Fixes a bug where properties did not load as expected on objects when using object templates. As of this release, the functionality is such that if properties are defined on both an object, and it's template, they will both end up on the resulting object, with the ones defined directly on the object overriding any properties that have the same name from the template. It does not compare types, so a String property with the name test
would override a number property with the name test
, as an example. Comparing types could be done in the future, but is likely more complicated than it's worth doing right now.
Fixes a bug where the TMX parser would report all layers as top level layers, ignoring the layer group nesting. This bug was not present in the JSON parser. (#74)
Also handles some small deprecation warnings related to true/false comparisons of etree.Element classes in the TMX parser.
Version 2.2.5
Adds a __all__
section to the main library __init__.py
file which fixes problems when running pyright in strict mode against this library, it would not be able to see the exported types.
Version 2.2.4
Small change to the default text color, in Tiled the text color defaults to black(0, 0, 0), previously in pytiled-parser if the color was not specified it would default to white(255, 255, 255). This has been changed to match Tiled's behavior #70
Added a py.typed file in order for type checkers to identify the library as being typed properly.
Version 2.2.3
Exposed tileset parsing more directly. This was possible by accessing the largely internal interfaces within pytiled_parser already, but this provides the same interface for parsing Tilesets as we have for parsing maps. You can parse a tileset by simply passing the filepath to pytiled_parser.parse_tileset(file)
where file
is a pathlib.Path
object.
We have also removed some unnecessary Optional
typing from some attributes. This does technically mean there are changes to the API, but they shouldn't really effect anything. The pytiled_parser.Tile.width
and pytiled_parser.Tile.height
attributes will now default to 0 if they are not set. Under normal circumstances there does not exist a scenario where they can not be set, the only use case that would cause this to happen would be if the map/tileset file does not follow the Tiled specification. The pytiled_parser.TiledMap.map_file
attribute is also no longer optional, but does not have a default. This does mean if you were using the constructor for this class directly instead of the parsing functions, you would need to fix your usage of it, however it is extremely unlikely that anyone is doing that.
Version 2.2.2
Switched to pyproject.toml
for project setup. This should have no impact on users unless you are on a very old version of pip. If pip fails to install pytiled-parser, please try updating pip.
Fixed a bug in the TMX format where overriding or adding extra elements/attributes to object templates would not be applied. Only the id and the x, y position would be used. Now any overriden values(including properties) should be applied to the template. This bug did not exist in the JSON format, however there was no test coverage for this scenario in either format, that has since been added.
Version 2.2.1
Added official support for Python 3.11. No changes were actually made to do this, and most all previous versions of pytiled-parser should work fine with 3.11. We are just now including 3.11 in the matrix of Python versions we run tests for.
Improved compatibility for pre-1.0 Tiled JSON formats(#65). This does not necessarily mean we guarantee support with older versions of Tiled, support for older versions will be on a best effort approach.
Version 2.2.0
Added support for the following features from Tiled which were added in either Tiled 1.8 or 1.9. If you would like some more info on some of these items, please refer to the release notes from Tiled for those versions:
-
Tilesets
Tileset.tile_render_size
has been added, which reflects thetilerendersize
attribute from Tiled. This is a string value which can be either "tile" or "grid". This is used to determine the size the tile will render at. This defaults totile
and is the only behavior prior to Tiled 1.9, meaning it will use the size specified by the Tile. If this is set togrid
it will scale the tiles to the size defined the grid in the map.Tileset.fill_mode
has been added, which reflects thefillmode
attribute from Tiled. This is a string value which can be either "stretch" or "preserve-aspect-ratio". This is used to define how the scaling will be done when a tile is not rendered at it's native size(Like when using thegrid
option fortilerendersize
).- The
Tile
class has four new attributes:x
,y
,width
, andheight
. By default,x
andy
will be zero, andwidth
andheight
will be the same asimage_width
andimage_height
. These values are only able to changed for tiles which use an individual image rather than a single image file for the whole tileset. These values are used to define a sub-rectangle of the image which the Tile should be loaded as. These are all separate attributes rather than using theOrderedPair
andSize
classes as this is somewhat of a developing feature in Tiled in an effort to support sprite atlasses, and so for now we are going to just stick as closely to the underlying format as possible for it, to make future changes easier.
-
Layers
- Added
repeat_x
andrepeat_y
attributes. These are derived from therepeatx
andrepeaty
attributes in Tiled. These are boolean values which are used to determine if a layer should be repeated on a given axis when drawn. As of writing in Tiled these values can only be applied to Image layers, however it is possible other types will support this in the future. To prepare for this, these values are available to all layer types in pytiled_parser, and they will default toFalse
.
- Added
-
Maps
- Added
parallax_origin
attribute. This is anOrderedPair
object which is derived from theparallaxoriginx
andparallaxoriginy
attributes in Tiled. This is used to define a map wide origin point that layers which have parallax scrolling will use.
- Added
Version 2.1.2
This version does not make any changes to the library. The project has moved to using Github Actions to publishing the distribution to PyPI. We have made this release to fully test the system and ensure it is functional for future releases.