ODE/assets-cg/converters.py

33 lines
756 B
Python

import fxconv
import json
def convert(input_name, output, params, target):
if params["custom-type"] == "map":
convert_map(input_name, output, params, target)
return 0
else:
return 1
def convert_map(input_name, output, params, target):
with open(input_name, "r") as file:
json_data = json.load(file)
data = fxconv.ObjectData()
data += fxconv.u32(json_data["width"]) + fxconv.u32(json_data["height"]) + fxconv.u32(len(json_data["layers"]))
for layer in json_data["layers"]:
layer_data = bytes()
for tile in layer["data"]:
layer_data += fxconv.u16(tile)
data += fxconv.ref(layer_data)
fxconv.elf(data, output, "_" + params["name"], **target)