Laufende Version

This commit is contained in:
Robert 2021-12-26 15:49:55 +01:00
parent 78176b1b6d
commit a7450f2c8b
2 changed files with 103 additions and 4 deletions

View File

@ -1,8 +1,33 @@
import json
import sys
# bildname in lizenztext wandeln, daten ist rechte-json
def img2liz(image, daten):
for cpr in daten:
if cpr["name"] in image:
return cpr["copytxt"]
return False
# lizenz-property einbauen, falls nicht vorhanden
def addLiz(ts, lizTxt):
prop = json.loads('{"name":"tilesetCopyright", "type":"string"}')
prop["value"] = lizTxt
if "properties" in ts:
p = ts["properties"]
# altes falls enthalten entfernen, neues hinzu
for i in range(len(p)):
if p[i]["name"] == "tilesetCopyright":
del p[i]
break
p.append(prop)
else:
ts["properties"] = [ prop ]
print("Tiled-Editor Copyright-Info nach rc3.world-Vorgaben hinzufügen")
print("Datei rechte.json passend befüllen, dann Aufruf")
print("{$0} <tiledmapdatei.json>")
print(sys.argv[0] + "{$0} <tiledmapdatei.json>")
print("Die <tiledmapdatei.json> wird modifiziert! Vorher eigene Änderungen committen!")
print("")
@ -11,6 +36,36 @@ with open("rechte.json", "r") as rechte_file:
print("Folgende Rechte wurden zugeordnet:")
for recht in rechte:
print(recht["name"] + " zu -> " + recht["copytxt"])
#json.dump(rechte, rechte_file, indent=2)
with open()
if len(sys.argv) <= 1:
print("Du hast vergessen die Tiled-Datei (Json) als Arument anzugeben. Ende.")
exit(1)
tiledfile = sys.argv[1]
print("Überschreibe jetzt die Datei mit geändertem Inhalt: " + tiledfile)
mapjson = []
with open(tiledfile, "r") as map_file:
mapjson = json.load(map_file)
try:
tilesets = mapjson["tilesets"]
for ts in tilesets:
print("Bearbeite tileset " + ts["name"])
image = ts["image"]
lizTxt = img2liz(image, rechte)
if lizTxt:
print("--> verwende Lizenz " + lizTxt)
addLiz(ts, lizTxt)
else:
print("--> keine Lizenz zu " + image + " gefunden")
except:
print("fail")
exit(1)
with open("zz" + tiledfile, "w") as map_out_file:
json.dump(mapjson, map_out_file, indent=8)
print("geschrieben")

View File

@ -1,7 +1,51 @@
[
{
"name": "fantasy.png",
"copytxt": "CC0"
},
{
"name": "chaos_zone_shared.png",
"copytxt": "CC0BY ChaosZ0ne Ost"
},
{
"name": "c3gelb.png",
"copytxt": "CC0"
},
{
"name": "campfire.png",
"copytxt": "CC0"
},
{
"name": "tilesets_deviant_milkian_1.png",
"copytxt": "CC0"
},
{
"name": "tilesets_deviant_milkian_2.png",
"copytxt": "CC0"
},
{
"name": "tilesets_deviant_milkian_3.png",
"copytxt": "CC0"
},
{
"name": "bagger.png",
"copytxt": "CC0BY Chaostreff Chemnitz https://chch.it"
},
{
"name": "WinterCollection.png",
"copytxt": "CC0"
},
{
"name": "Waschbecken.png",
"copytxt": "CC0BY Chaostreff Chemnitz https://chch.it"
},
{
"name": "PinguineAntarktis.png",
"copytxt": "CC0BY Chaostreff Chemnitz https://chch.it"
},
{
"name": "floortileset.png",
"copytxt": "CC0BY blatut"
"copytxt": "CC0BY unbekannt"
},
{
"name": "chemnitz_al.png",