From 874d9b3819faac2aa0a4dd921fd9a20892131b46 Mon Sep 17 00:00:00 2001 From: ElnuDev Date: Thu, 10 Mar 2022 16:10:05 -0800 Subject: [PATCH] Improve packer formatting --- build/packer.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/build/packer.py b/build/packer.py index 5f59e20..2515818 100644 --- a/build/packer.py +++ b/build/packer.py @@ -7,11 +7,15 @@ resources = os.fsencode(RES_DIR) res = "" for resource in os.listdir(resources): - encoded = f"const unsigned char {os.path.splitext(resource)[0].decode().upper()}[] = {'{'} " + encoded = f"const unsigned char {os.path.splitext(resource)[0].decode().upper()}[] = {'{'}" file = open(RES_DIR + resource.decode(), "rb") # read binary + bytes_processed = 0 for byte in file.read(): + if bytes_processed % 16 == 0: + encoded += "\n\t" encoded += f"0x{byte.to_bytes(1, byteorder='little').hex()}, " - encoded = encoded[:-2] + " };" + bytes_processed += 1 + encoded = encoded[:-2] + "\n};" res += encoded + "\n" res_file = open(RES_FILE, "w")