|
47 | 47 | "type": str, |
48 | 48 | "properties": List[RawProperty], |
49 | 49 | "objectgroup": RawLayer, |
| 50 | + "x": int, |
| 51 | + "y": int, |
| 52 | + "width": int, |
| 53 | + "height": int |
50 | 54 | }, |
51 | 55 | ) |
52 | 56 | RawTile.__doc__ = """ |
@@ -191,18 +195,36 @@ def _parse_tile(raw_tile: RawTile, external_path: Optional[Path] = None) -> Tile |
191 | 195 | # image is set, but these aren't, so the branches will never fully be hit. |
192 | 196 | # However, leaving these checks in place is nice to prevent fatal errors on |
193 | 197 | # a manually edited map that has an "incorrect" but not "unusable" structure |
| 198 | + # |
| 199 | + # We also set the width and height attributes here as the values for these in |
| 200 | + # Tiled defaults to the same value as imagewidth and imageheight if no custom value |
| 201 | + # is set. We then later load in the custom value if it exists. |
194 | 202 | if raw_tile.get("imagewidth") is not None: # pragma: no cover |
195 | 203 | tile.image_width = raw_tile["imagewidth"] |
| 204 | + tile.width = tile.image_width |
196 | 205 |
|
197 | 206 | if raw_tile.get("imageheight") is not None: # pragma: no cover |
198 | 207 | tile.image_height = raw_tile["imageheight"] |
| 208 | + tile.height = tile.image_height |
199 | 209 |
|
200 | 210 | if raw_tile.get("type") is not None: |
201 | 211 | tile.class_ = raw_tile["type"] |
202 | 212 |
|
203 | 213 | if raw_tile.get("class") is not None: |
204 | 214 | tile.class_ = raw_tile["class"] |
205 | 215 |
|
| 216 | + if raw_tile.get("x") is not None: |
| 217 | + tile.x = raw_tile["x"] |
| 218 | + |
| 219 | + if raw_tile.get("y") is not None: |
| 220 | + tile.y = raw_tile["y"] |
| 221 | + |
| 222 | + if raw_tile.get("width") is not None: |
| 223 | + tile.width = raw_tile["width"] |
| 224 | + |
| 225 | + if raw_tile.get("height") is not None: |
| 226 | + tile.height = raw_tile["height"] |
| 227 | + |
206 | 228 | return tile |
207 | 229 |
|
208 | 230 |
|
|
0 commit comments