This commit is contained in:
UnitedAirforce
2025-02-10 09:51:03 +08:00
parent 9633c3acf4
commit 6d5b40b45f
3 changed files with 42 additions and 1 deletions
+18
View File
@@ -0,0 +1,18 @@
def hex_to_json(hex_string):
hex_string = hex_string.replace(" ", "").replace("\n", "")
byte_data = bytes.fromhex(hex_string)
if len(byte_data) % 4 != 0:
raise ValueError("Hex data must contain a multiple of 4 bytes.")
coordinates = []
for i in range(0, len(byte_data), 4):
x = int.from_bytes(byte_data[i:i+2], byteorder='big', signed=False)
y = int.from_bytes(byte_data[i+2:i+4], byteorder='big', signed=False)
coordinates.append({"x": x, "y": y})
return coordinates
hex_data = input("Input the hex data (with header 8 bytes removed):")
json_output = hex_to_json(hex_data)
print(json_output)
+19
View File
@@ -0,0 +1,19 @@
import json
def json_to_hex(json_filename):
with open(json_filename, 'r') as f:
coordinates = json.load(f)
hex_data = bytearray()
for coord in coordinates:
x_bytes = coord["x"].to_bytes(2, byteorder='big', signed=False)
y_bytes = coord["y"].to_bytes(2, byteorder='big', signed=False)
hex_data.extend(x_bytes + y_bytes)
return hex_data.hex().upper()
file_name = input("input the json file name: ")
hex_output = json_to_hex(file_name)
print(hex_output)
+5 -1
View File
@@ -1,3 +1,7 @@
uvdata is like the plist for the sprite sheets. To edit their dimensions, this tool can be used.
Parse uvdata.dat to uvdata.xlsx, and write it back to out_uvdata.dat.
Parse uvdata.dat to uvdata.xlsx, and write it back to out_uvdata.dat.
Each row of uvdata is the dimension of that image.bin. 8 byte of header is included (file index, number of elements)
Use the encode/decode.py to convert the header-removed hex strings to/from json coordinates.