split tilesets bigger than 4096x4096

This commit is contained in:
Thomas Lindner 2021-12-27 00:36:01 +01:00
parent 486a1f2683
commit fdaadcd9ae
10 changed files with 100 additions and 24 deletions

View file

@ -469,11 +469,11 @@
{
"columns":18,
"firstgid":321,
"image":"imgs\/cija_32x32_expansion for Pipoya_CC0.png",
"imageheight":4256,
"image":"imgs\/cija_32x32_expansion for Pipoya_CC0_0000.png",
"imageheight":4096,
"imagewidth":576,
"margin":0,
"name":"cija_32x32_expansion for Pipoya_CC0",
"name":"cija_32x32_expansion for Pipoya_CC0 (0, 0)",
"properties":[
{
"name":"tilesetCopyright",
@ -481,7 +481,26 @@
"value":"CC0"
}],
"spacing":0,
"tilecount":2394,
"tilecount":2304,
"tileheight":32,
"tilewidth":32
},
{
"columns":18,
"firstgid":2625,
"image":"imgs\/cija_32x32_expansion for Pipoya_CC0_0001.png",
"imageheight":160,
"imagewidth":576,
"margin":0,
"name":"cija_32x32_expansion for Pipoya_CC0 (0, 1)",
"properties":[
{
"name":"tilesetCopyright",
"type":"string",
"value":"CC0"
}],
"spacing":0,
"tilecount":90,
"tileheight":32,
"tilewidth":32
},

View file

@ -455,11 +455,11 @@
{
"columns":18,
"firstgid":321,
"image":"imgs\/cija_32x32_expansion for Pipoya_CC0.png",
"imageheight":4256,
"image":"imgs\/cija_32x32_expansion for Pipoya_CC0_0000.png",
"imageheight":4096,
"imagewidth":576,
"margin":0,
"name":"cija_32x32_expansion for Pipoya_CC0",
"name":"cija_32x32_expansion for Pipoya_CC0 (0, 0)",
"properties":[
{
"name":"tilesetCopyright",
@ -467,7 +467,26 @@
"value":"CC0"
}],
"spacing":0,
"tilecount":2394,
"tilecount":2304,
"tileheight":32,
"tilewidth":32
},
{
"columns":18,
"firstgid":2625,
"image":"imgs\/cija_32x32_expansion for Pipoya_CC0_0001.png",
"imageheight":160,
"imagewidth":576,
"margin":0,
"name":"cija_32x32_expansion for Pipoya_CC0 (0, 1)",
"properties":[
{
"name":"tilesetCopyright",
"type":"string",
"value":"CC0"
}],
"spacing":0,
"tilecount":90,
"tileheight":32,
"tilewidth":32
},

View file

@ -18,11 +18,17 @@
</properties>
<image source="imgs/tilesets_deviant_milkian_1.png" width="512" height="512"/>
</tileset>
<tileset firstgid="321" name="cija_32x32_expansion for Pipoya_CC0" tilewidth="32" tileheight="32" tilecount="2394" columns="18">
<tileset firstgid="321" name="cija_32x32_expansion for Pipoya_CC0 (0, 0)" tilewidth="32" tileheight="32" tilecount="2304" columns="18">
<properties>
<property name="tilesetCopyright" value="CC0"/>
</properties>
<image source="imgs/cija_32x32_expansion for Pipoya_CC0.png" width="576" height="4256"/>
<image source="imgs/cija_32x32_expansion for Pipoya_CC0_0000.png" width="576" height="4096"/>
</tileset>
<tileset firstgid="2625" name="cija_32x32_expansion for Pipoya_CC0 (0, 1)" tilewidth="32" tileheight="32" tilecount="90" columns="18">
<properties>
<property name="tilesetCopyright" value="CC0"/>
</properties>
<image source="imgs/cija_32x32_expansion for Pipoya_CC0_0001.png" width="576" height="160"/>
</tileset>
<tileset firstgid="2715" name="01_door" tilewidth="32" tileheight="32" tilecount="8" columns="4">
<properties>

View file

@ -18,11 +18,17 @@
</properties>
<image source="imgs/tilesets_deviant_milkian_1.png" width="512" height="512"/>
</tileset>
<tileset firstgid="321" name="cija_32x32_expansion for Pipoya_CC0" tilewidth="32" tileheight="32" tilecount="2394" columns="18">
<tileset firstgid="321" name="cija_32x32_expansion for Pipoya_CC0 (0, 0)" tilewidth="32" tileheight="32" tilecount="2304" columns="18">
<properties>
<property name="tilesetCopyright" value="CC0"/>
</properties>
<image source="imgs/cija_32x32_expansion for Pipoya_CC0.png" width="576" height="4256"/>
<image source="imgs/cija_32x32_expansion for Pipoya_CC0_0000.png" width="576" height="4096"/>
</tileset>
<tileset firstgid="2625" name="cija_32x32_expansion for Pipoya_CC0 (0, 1)" tilewidth="32" tileheight="32" tilecount="90" columns="18">
<properties>
<property name="tilesetCopyright" value="CC0"/>
</properties>
<image source="imgs/cija_32x32_expansion for Pipoya_CC0_0001.png" width="576" height="160"/>
</tileset>
<tileset firstgid="2715" name="01_door" tilewidth="32" tileheight="32" tilecount="8" columns="4">
<properties>

View file

@ -18,11 +18,17 @@
</properties>
<image source="imgs/tilesets_deviant_milkian_1.png" width="512" height="512"/>
</tileset>
<tileset firstgid="321" name="cija_32x32_expansion for Pipoya_CC0" tilewidth="32" tileheight="32" tilecount="2394" columns="18">
<tileset firstgid="321" name="cija_32x32_expansion for Pipoya_CC0 (0, 0)" tilewidth="32" tileheight="32" tilecount="2304" columns="18">
<properties>
<property name="tilesetCopyright" value="CC0"/>
</properties>
<image source="imgs/cija_32x32_expansion for Pipoya_CC0.png" width="576" height="4256"/>
<image source="imgs/cija_32x32_expansion for Pipoya_CC0_0000.png" width="576" height="4096"/>
</tileset>
<tileset firstgid="2625" name="cija_32x32_expansion for Pipoya_CC0 (0, 1)" tilewidth="32" tileheight="32" tilecount="90" columns="18">
<properties>
<property name="tilesetCopyright" value="CC0"/>
</properties>
<image source="imgs/cija_32x32_expansion for Pipoya_CC0_0001.png" width="576" height="160"/>
</tileset>
<tileset firstgid="2715" name="01_door" tilewidth="32" tileheight="32" tilecount="8" columns="4">
<properties>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 618 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 588 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 25 KiB

View file

@ -802,11 +802,11 @@
{
"columns":18,
"firstgid":321,
"image":"imgs\/cija_32x32_expansion for Pipoya_CC0.png",
"imageheight":4256,
"image":"imgs\/cija_32x32_expansion for Pipoya_CC0_0000.png",
"imageheight":4096,
"imagewidth":576,
"margin":0,
"name":"cija_32x32_expansion for Pipoya_CC0",
"name":"cija_32x32_expansion for Pipoya_CC0 (0, 0)",
"properties":[
{
"name":"tilesetCopyright",
@ -814,7 +814,26 @@
"value":"CC0"
}],
"spacing":0,
"tilecount":2394,
"tilecount":2304,
"tileheight":32,
"tilewidth":32
},
{
"columns":18,
"firstgid":2625,
"image":"imgs\/cija_32x32_expansion for Pipoya_CC0_0001.png",
"imageheight":160,
"imagewidth":576,
"margin":0,
"name":"cija_32x32_expansion for Pipoya_CC0 (0, 1)",
"properties":[
{
"name":"tilesetCopyright",
"type":"string",
"value":"CC0"
}],
"spacing":0,
"tilecount":90,
"tileheight":32,
"tilewidth":32
},

View file

@ -1,6 +1,7 @@
#!/usr/bin/env python3
from argparse import ArgumentParser
from copy import copy
from lxml import etree
from pathlib import Path
from PIL import Image
@ -164,13 +165,13 @@ def separate_collisions(map):
def split_tilesets(map):
# we need the offset of the tileset inside the map element to insert new tilesets correctly
for offset, tileset in enumerate(map):
if tileset.tag != "tileset":
continue
for tileset in map.findall("tileset"):
image = tileset.find("image")
if int(image.attrib["width"]) <= 4096 and int(image.attrib["height"]) <= 4096:
continue
if int(image.attrib["width"]) > 4096:
print("Can't split tileset '%s'. Spliting of width > 4096 not implemented." % tileset.attrib["name"])
continue
dosplit = input("Split tileset '%s'? [yN] " % tileset.attrib["name"])
if dosplit.lower() != "y":
continue
@ -201,10 +202,10 @@ def split_tilesets(map):
tilecount=str(tilecount),
columns=str(columns),
)
map.insert(offset + i + j, tileset_croped)
tileset.addprevious(tileset_croped)
firstgid += tilecount
if properties is not None:
tileset_croped.append(properties)
tileset_croped.append(copy(properties))
etree.SubElement(
tileset_croped,
"image",