diff --git a/.github/workflows/build-and-publish.yml b/.github/workflows/build-and-publish.yml index 734e607..24d30ba 100644 --- a/.github/workflows/build-and-publish.yml +++ b/.github/workflows/build-and-publish.yml @@ -1,7 +1,7 @@ name: Build and Publish env: - FINGERPRINT: b8cb4e1c4ee7485bafc34123e4cb2b5b869b4f93 + FINGERPRINT: c4e8c2976dcf42530d68dcb1fdfb61d071085abf GAME_ASSET_URL: https://game-assets.clashofclans.com GCP_BUCKET_NAME: game-assets-clashofclans.appspot.com diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml index 2d74efb..636c89a 100644 --- a/.github/workflows/build-and-test.yml +++ b/.github/workflows/build-and-test.yml @@ -6,7 +6,7 @@ on: env: GCP_BUCKET_NAME: game-assets-clashofclans.appspot.com - FINGERPRINT: b8cb4e1c4ee7485bafc34123e4cb2b5b869b4f93 + FINGERPRINT: c4e8c2976dcf42530d68dcb1fdfb61d071085abf GAME_ASSET_URL: https://game-assets.clashofclans.com SC_FILE_NAME: ui_cc.sc SC_TEX_FILE_NAME: ui_cc_tex.sc diff --git a/Main.py b/Main.py index e9dde44..b1daf83 100644 --- a/Main.py +++ b/Main.py @@ -42,8 +42,9 @@ def extract_images(): with open(f"{input_folder}/{file}", "rb") as f: print('') Console.info(f"Processing {file}") + texturePath = os.path.dirname(file) # extracting texture - images = process_sc(f"{sc_file_name}_tex", f.read(), f"{sc_output_dir}/texture/", True) + images = process_sc(texturePath, f"{sc_file_name}_tex", f.read(), f"{sc_output_dir}/texture/", True) if sc_file not in files: Console.warn(f"{sc_file} not found! Will skip cutting images") diff --git a/System/Dumpsc.py b/System/Dumpsc.py index 7829009..fa129e4 100644 --- a/System/Dumpsc.py +++ b/System/Dumpsc.py @@ -11,52 +11,7 @@ import astc_decomp import liblzfse -def load_ktx(data): - header = data[:64] - ktx_data = data[64:] - - if header[12:16] == bytes.fromhex('01020304'): - endianness = '<' - - else: - endianness = '>' - - if header[0:7] != b'\xabKTX 11': - raise TypeError('Unsupported or unknown KTX version: {}'.format(header[0:7])) - - glInternalFormat, = struct.unpack(endianness + 'I', header[28:32]) - pixelWidth, pixelHeight = struct.unpack(endianness + '2I', header[36:44]) - bytesOfKeyValueData, = struct.unpack(endianness + 'I', header[60:64]) - - if glInternalFormat not in (0x93B0, 0x93B4, 0x93B7): - raise TypeError('Unsupported texture format: {}'.format(hex(glInternalFormat))) - - if glInternalFormat == 0x93B0: - block_width, block_height = 4, 4 - - elif glInternalFormat == 0x93B4: - block_width, block_height = 6, 6 - - else: - block_width, block_height = 8, 8 - - key_value_data = ktx_data[:bytesOfKeyValueData] - ktx_data = ktx_data[bytesOfKeyValueData:] - - if b'Compression_APPLE' in key_value_data: - if ktx_data[12:15] == b'bvx': - image_data = liblzfse.decompress(ktx_data[12:]) - - else: - raise ValueError('Unsupported compression type: {}'.format( - ktx_data[12:15]) - ) - - else: - image_data = ktx_data[4:] - - return Image.frombytes('RGBA', (pixelWidth, pixelHeight), image_data, 'astc', (block_width, block_height, False)) - +from System.Ktx import load_ktx def convert_pixel(pixel, type): if type in (0, 1): @@ -141,7 +96,7 @@ def decompress_data(data, baseName="Unknown"): return decompressed -def process_sc(baseName, data, path, decompress): +def process_sc(texturePath, baseName, data, path, decompress): if decompress: decompressed = decompress_data(data, baseName) @@ -160,12 +115,21 @@ def process_sc(baseName, data, path, decompress): i += 4 # Ignore this uint32, it's basically the fileSize + the size of subType + width + height (9 bytes) fileSize, = struct.unpack('