mirror of
https://github.com/OMGeeky/pytiled_parser.git
synced 2026-01-19 09:04:53 +01:00
First working TMX map parse at this point
This commit is contained in:
@@ -31,10 +31,10 @@ def parse(file: Path) -> TiledMap:
|
|||||||
# Is an external Tileset
|
# Is an external Tileset
|
||||||
tileset_path = Path(parent_dir / raw_tileset.attrib["source"])
|
tileset_path = Path(parent_dir / raw_tileset.attrib["source"])
|
||||||
with open(tileset_path) as tileset_file:
|
with open(tileset_path) as tileset_file:
|
||||||
raw_tileset = etree.parse(tileset_file).getroot()
|
raw_tileset_external = etree.parse(tileset_file).getroot()
|
||||||
|
|
||||||
tilesets[int(raw_tileset.attrib["firstgid"])] = parse_tileset(
|
tilesets[int(raw_tileset.attrib["firstgid"])] = parse_tileset(
|
||||||
raw_tileset,
|
raw_tileset_external,
|
||||||
int(raw_tileset.attrib["firstgid"]),
|
int(raw_tileset.attrib["firstgid"]),
|
||||||
external_path=tileset_path.parent,
|
external_path=tileset_path.parent,
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -134,8 +134,9 @@ def parse(
|
|||||||
if raw_tileset.attrib.get("backgroundcolor") is not None:
|
if raw_tileset.attrib.get("backgroundcolor") is not None:
|
||||||
tileset.background_color = parse_color(raw_tileset.attrib["backgroundcolor"])
|
tileset.background_color = parse_color(raw_tileset.attrib["backgroundcolor"])
|
||||||
|
|
||||||
image_element = raw_tileset.find("./image")
|
image_element = raw_tileset.find("image")
|
||||||
if image_element:
|
if image_element is not None:
|
||||||
|
print("here")
|
||||||
if external_path:
|
if external_path:
|
||||||
tileset.image = (
|
tileset.image = (
|
||||||
Path(external_path / image_element.attrib["source"])
|
Path(external_path / image_element.attrib["source"])
|
||||||
@@ -153,7 +154,6 @@ def parse(
|
|||||||
if my_string[0] != "#":
|
if my_string[0] != "#":
|
||||||
my_string = f"#{my_string}"
|
my_string = f"#{my_string}"
|
||||||
tileset.transparent_color = parse_color(my_string)
|
tileset.transparent_color = parse_color(my_string)
|
||||||
pass
|
|
||||||
|
|
||||||
tileoffset_element = raw_tileset.find("./tileoffset")
|
tileoffset_element = raw_tileset.find("./tileoffset")
|
||||||
if tileoffset_element:
|
if tileoffset_element:
|
||||||
|
|||||||
Reference in New Issue
Block a user