feature: Re-implemented properties casting to support casting properties for things outside of TiledObjects

This commit is contained in:
Darren Eberly
2020-06-01 20:51:05 -04:00
parent cf243729eb
commit 0a3bb8b51a
2 changed files with 18 additions and 9 deletions

View File

@@ -5,7 +5,7 @@ from typing import Callable, Dict, List, Mapping, Optional, Union
import attr
from typing_extensions import TypedDict
from . import properties
from . import properties as properties_
from .common_types import Color, OrderedPair, Size
from .template import Template
@@ -43,7 +43,7 @@ class TiledObject:
name: Optional[str] = None
type: Optional[str] = None
properties: properties.Properties = {}
properties: properties_.Properties = {}
template: Optional[Template] = None
@@ -163,7 +163,7 @@ class RawTiledObject(TypedDict):
visible: bool
name: str
type: str
properties: properties.RawProperties
properties: properties_.RawProperties
template: Template
ellipse: bool
point: bool
@@ -224,10 +224,7 @@ def _get_common_attributes(raw_tiled_object: RawTiledObject) -> TiledObject:
common_attributes.type = raw_tiled_object["type"]
if raw_tiled_object.get("properties"):
for prop in raw_tiled_object["properties"]:
name = str(prop["name"])
value = prop["value"]
common_attributes.properties[name] = prop["value"]
common_attributes.properties = properties_.cast(raw_tiled_object["properties"])
if raw_tiled_object.get("template"):
raise NotImplementedError