diff --git a/pytiled_parser/layer.py b/pytiled_parser/layer.py index 9f86553..58bcc98 100644 --- a/pytiled_parser/layer.py +++ b/pytiled_parser/layer.py @@ -62,6 +62,7 @@ class Layer: size: Optional[Size] = None offset: Optional[OrderedPair] = None properties: Optional[properties_.Properties] = None + tint_color: Optional[Color] = None TileLayerGrid = List[List[int]] @@ -202,6 +203,7 @@ class RawLayer(TypedDict): properties: List[properties_.RawProperty] startx: int starty: int + tintcolor: str transparentcolor: str type: str visible: bool @@ -358,6 +360,9 @@ def _get_common_attributes(raw_layer: RawLayer) -> Layer: raw_layer["parallaxx"], raw_layer["parallaxy"] ) + if raw_layer.get("tintcolor") is not None: + common_attributes.tint_color = parse_color(raw_layer["tintcolor"]) + return common_attributes diff --git a/tests/test_data/layer_tests/all_layer_types/expected.py b/tests/test_data/layer_tests/all_layer_types/expected.py index 9756763..0279b32 100644 --- a/tests/test_data/layer_tests/all_layer_types/expected.py +++ b/tests/test_data/layer_tests/all_layer_types/expected.py @@ -14,6 +14,7 @@ EXPECTED = [ properties={ "test": "test property", }, + tint_color=common_types.Color(170, 255, 255, 255), data=[ [ 1, @@ -83,6 +84,7 @@ EXPECTED = [ visible=True, id=4, parallax_factor=common_types.OrderedPair(2.3, 1.2), + tint_color=common_types.Color(0, 0, 255, 255), layers=[ layer.ObjectLayer( name="Object Layer 1", @@ -111,6 +113,7 @@ EXPECTED = [ id=3, image=Path("../../images/tile_04.png"), transparent_color=common_types.Color(0, 0, 0, 255), + tint_color=common_types.Color(255, 0, 0, 255), ), layer.ImageLayer( name="Image Layer 2", diff --git a/tests/test_data/layer_tests/all_layer_types/map.json b/tests/test_data/layer_tests/all_layer_types/map.json index 6c459de..8d08251 100644 --- a/tests/test_data/layer_tests/all_layer_types/map.json +++ b/tests/test_data/layer_tests/all_layer_types/map.json @@ -18,6 +18,7 @@ "type":"string", "value":"test property" }], + "tintcolor":"#aaffff", "type":"tilelayer", "visible":true, "width":8, @@ -53,6 +54,7 @@ "opacity":1, "parallaxx":2.3, "parallaxy":1.2, + "tintcolor":"#0000ff", "type":"group", "visible":true, "x":0, @@ -63,6 +65,7 @@ "image":"..\/..\/images\/tile_04.png", "name":"Image Layer 1", "opacity":1, + "tintcolor":"#ff0000", "transparentcolor":"#000000", "type":"imagelayer", "visible":true,