diff --git a/basement.json b/basement.json index 8f8a476..c33ca3c 100644 --- a/basement.json +++ b/basement.json @@ -392,6 +392,12 @@ "nextlayerid":39, "nextobjectid":2, "orientation":"orthogonal", + "properties":[ + { + "name":"mapCopyright", + "type":"string", + "value":"CC0" + }], "renderorder":"right-down", "tiledversion":"1.3.1", "tileheight":32, @@ -7107,6 +7113,12 @@ "imagewidth":128, "margin":0, "name":"nopslide", + "properties":[ + { + "name":"tilesetCopyright", + "type":"string", + "value":"CC0" + }], "spacing":0, "tilecount":16, "tileheight":32, diff --git a/first-floor.json b/first-floor.json index 24b6902..bc450e1 100644 --- a/first-floor.json +++ b/first-floor.json @@ -388,6 +388,12 @@ "nextlayerid":37, "nextobjectid":1, "orientation":"orthogonal", + "properties":[ + { + "name":"mapCopyright", + "type":"string", + "value":"CC0" + }], "renderorder":"right-down", "tiledversion":"1.3.1", "tileheight":32, diff --git a/heizhaus-basement.tmx b/heizhaus-basement.tmx index e7db4c0..49e7541 100644 --- a/heizhaus-basement.tmx +++ b/heizhaus-basement.tmx @@ -3,6 +3,9 @@ + + + @@ -3671,6 +3674,9 @@ + + + diff --git a/heizhaus-first-floor.tmx b/heizhaus-first-floor.tmx index dcea7b2..2c1fb43 100644 --- a/heizhaus-first-floor.tmx +++ b/heizhaus-first-floor.tmx @@ -3,6 +3,9 @@ + + + diff --git a/heizhaus.tmx b/heizhaus.tmx index c8a62d1..50accad 100644 --- a/heizhaus.tmx +++ b/heizhaus.tmx @@ -3694,18 +3694,33 @@ + + + + + + + + + + + + + + + diff --git a/main.json b/main.json index b145228..961dab7 100644 --- a/main.json +++ b/main.json @@ -7518,6 +7518,12 @@ "imagewidth":64, "margin":0, "name":"worldExit", + "properties":[ + { + "name":"tilesetCopyright", + "type":"string", + "value":"CC0" + }], "spacing":0, "tilecount":4, "tileheight":32, @@ -7531,6 +7537,12 @@ "imagewidth":64, "margin":0, "name":"023_Fairydust", + "properties":[ + { + "name":"tilesetCopyright", + "type":"string", + "value":"CC0" + }], "spacing":0, "tilecount":8, "tileheight":32, @@ -7544,6 +7556,12 @@ "imagewidth":512, "margin":0, "name":"wintiles", + "properties":[ + { + "name":"tilesetCopyright", + "type":"string", + "value":"CC0" + }], "spacing":0, "tilecount":1024, "tileheight":32, @@ -7557,6 +7575,12 @@ "imagewidth":640, "margin":0, "name":"cija_32x32_basic_CC0", + "properties":[ + { + "name":"tilesetCopyright", + "type":"string", + "value":"CC0" + }], "spacing":0, "tilecount":600, "tileheight":32, @@ -7570,6 +7594,12 @@ "imagewidth":128, "margin":0, "name":"nopslide", + "properties":[ + { + "name":"tilesetCopyright", + "type":"string", + "value":"CC0" + }], "spacing":0, "tilecount":16, "tileheight":32, diff --git a/mapcleanup.py b/mapcleanup.py new file mode 100755 index 0000000..8dbeab9 --- /dev/null +++ b/mapcleanup.py @@ -0,0 +1,58 @@ +#!/usr/bin/env python3 + +import argparse +import sys +import xml.etree.ElementTree as ET + + +def main(): + parser = argparse.ArgumentParser(description="Cleanup rc3.world maps") + parser.add_argument("map", help="map in .tmx format") + parser.add_argument("-o", "--output", help="where to write modified map") + parser.add_argument( + "-i", + "--in-place", + help="replace map with modified version", + action="store_true", + ) + parser.add_argument( + "--fix-copyright", + help="add mapCopyright/tilesetCopyright properties", + action="store_true", + ) + args = parser.parse_args() + + if not args.output and not args.in_place: + print("Output unspecified.", file=sys.stderr) + sys.exit(1) + + tree = ET.parse(args.map) + map = tree.getroot() + if args.fix_copyright: + fix_copyright(map) + tree.write(args.output or args.map, xml_declaration=False) + + +def fix_copyright(map): + if map.find("properties/property[@name='mapCopyright']") is None: + license = input("Map license? [CC0] ") or "CC0" + properties = map.find("properties") + if properties is None: + properties = ET.SubElement(map, "properties") + ET.SubElement(properties, "property", name="mapCopyright", value=license) + + for tileset in map.findall("tileset"): + if tileset.find("properties/property[@name='tilesetCopyright']") is None: + license = ( + input("Tileset '%s' license? [CC0] " % tileset.attrib["name"]) or "CC0" + ) + properties = tileset.find("properties") + if properties is None: + properties = ET.SubElement(tileset, "properties") + ET.SubElement( + properties, "property", name="tilesetCopyright", value=license + ) + + +if __name__ == "__main__": + main()