From b07f30fd0d17e385817adefc258f99c65ee051b7 Mon Sep 17 00:00:00 2001 From: Darren Eberly Date: Sat, 6 Jun 2020 15:28:15 -0400 Subject: [PATCH] implemented RawLayer class --- pytiled_parser/layer.py | 45 ++++++++++++++++++++++++++++++++++++++--- 1 file changed, 42 insertions(+), 3 deletions(-) diff --git a/pytiled_parser/layer.py b/pytiled_parser/layer.py index ef0be1f..4cba0de 100644 --- a/pytiled_parser/layer.py +++ b/pytiled_parser/layer.py @@ -3,10 +3,11 @@ from typing import List, Optional, Union import attr +from typing_extensions import TypedDict +from . import properties as properties_ from .common_types import OrderedPair, Size -from .properties import Properties -from .tiled_object import TiledObject +from .tiled_object import RawTiledObject, TiledObject @attr.s(auto_attribs=True, kw_only=True) @@ -37,7 +38,7 @@ class Layer: offset: Optional[OrderedPair] opacity: Optional[float] - properties: Optional[Properties] + properties: Optional[properties_.Properties] TileLayerGrid = List[List[int]] @@ -122,3 +123,41 @@ class LayerGroup(Layer): """ layers: Optional[List[Union["LayerGroup", Layer, ObjectLayer]]] + + +class RawChunk(TypedDict): + """ The keys and their types that appear in a Chunk JSON Object.""" + + data: Union[List[int], str] + height: int + width: int + x: int + y: int + + +class RawLayer(TypedDict): + """ The keys and their types that appear in a Layer JSON Object.""" + + chunks: List[RawChunk] + compression: str + data: Union[List[int], str] + draworder: str + encoding: str + height: int + id: int + image: str + layers: List[RawLayer] + name: str + objects: List[RawTiledObject] + offsetx: float + offsety: float + opacity: float + properties: List[properties_.RawProperty] + startx: int + starty: int + transparentcolor: str + type: str + visible: bool + width: int + x: int + y: int