Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion pytiled_parser/parsers/tmx/properties.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import xml.etree.ElementTree as etree
from pathlib import Path

from pytiled_parser.properties import Properties, Property
from pytiled_parser.properties import Properties, Property, ClassProperty
from pytiled_parser.util import parse_color


Expand All @@ -11,6 +11,12 @@ def parse(raw_properties: etree.Element) -> Properties:

for raw_property in raw_properties.findall("property"):
type_ = raw_property.attrib.get("type")
if type_ == "class":
children_nodes = raw_property.find("./properties")
x = ClassProperty(
raw_property.attrib["propertytype"], parse(children_nodes) if children_nodes is not None else {})
final[raw_property.attrib["name"]] = x
continue

value_ = raw_property.attrib.get("value", raw_property.text)
if value_ is None:
Expand Down
7 changes: 6 additions & 1 deletion pytiled_parser/properties.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@

from .common_types import Color

Property = Union[int, float, Path, str, bool, Color]
class ClassProperty(dict):
def __init__(self, propertytype:str, *args, **kwargs):
self.propertytype = propertytype or ''
dict.__init__(self, *args, **kwargs)

Property = Union[int, float, Path, str, bool, Color, ClassProperty]

Properties = Dict[str, Property]
Loading