mirror of
https://github.com/OMGeeky/pytiled_parser.git
synced 2026-02-13 21:18:20 +01:00
Support version key changes from Tiled 1.6
This commit is contained in:
@@ -60,7 +60,7 @@ class TiledMap:
|
|||||||
tiled_version: str
|
tiled_version: str
|
||||||
tile_size: Size
|
tile_size: Size
|
||||||
tilesets: TilesetDict
|
tilesets: TilesetDict
|
||||||
version: float
|
version: str
|
||||||
|
|
||||||
map_file: Optional[Path] = None
|
map_file: Optional[Path] = None
|
||||||
background_color: Optional[Color] = None
|
background_color: Optional[Color] = None
|
||||||
@@ -102,7 +102,7 @@ class _RawTiledMap(TypedDict):
|
|||||||
tilesets: List[_RawTilesetMapping]
|
tilesets: List[_RawTilesetMapping]
|
||||||
tilewidth: int
|
tilewidth: int
|
||||||
type: str
|
type: str
|
||||||
version: float
|
version: Union[str, float]
|
||||||
width: int
|
width: int
|
||||||
|
|
||||||
|
|
||||||
@@ -139,6 +139,11 @@ def parse_map(file: Path) -> TiledMap:
|
|||||||
raw_tileset = typing_cast(RawTileSet, raw_tileset)
|
raw_tileset = typing_cast(RawTileSet, raw_tileset)
|
||||||
tilesets[raw_tileset["firstgid"]] = tileset.cast(raw_tileset)
|
tilesets[raw_tileset["firstgid"]] = tileset.cast(raw_tileset)
|
||||||
|
|
||||||
|
if isinstance(raw_tiled_map["version"], float):
|
||||||
|
version = str(raw_tiled_map["version"])
|
||||||
|
else:
|
||||||
|
version = raw_tiled_map["version"]
|
||||||
|
|
||||||
# `map` is a built-in function
|
# `map` is a built-in function
|
||||||
map_ = TiledMap(
|
map_ = TiledMap(
|
||||||
map_file=file,
|
map_file=file,
|
||||||
@@ -152,7 +157,7 @@ def parse_map(file: Path) -> TiledMap:
|
|||||||
tiled_version=raw_tiled_map["tiledversion"],
|
tiled_version=raw_tiled_map["tiledversion"],
|
||||||
tile_size=Size(raw_tiled_map["tilewidth"], raw_tiled_map["tileheight"]),
|
tile_size=Size(raw_tiled_map["tilewidth"], raw_tiled_map["tileheight"]),
|
||||||
tilesets=tilesets,
|
tilesets=tilesets,
|
||||||
version=raw_tiled_map["version"],
|
version=version,
|
||||||
)
|
)
|
||||||
|
|
||||||
if raw_tiled_map.get("backgroundcolor") is not None:
|
if raw_tiled_map.get("backgroundcolor") is not None:
|
||||||
|
|||||||
Reference in New Issue
Block a user