Show progress bar when unpacking files.

This commit is contained in:
2022-12-31 11:49:00 -05:00
parent 2e62063c14
commit 6bc7e3ecd8
2 changed files with 152 additions and 121 deletions
+28
View File
@@ -13,6 +13,7 @@ import json
import os import os
import sys import sys
import wave import wave
from tqdm import tqdm
from arcane.ArcImage import * from arcane.ArcImage import *
from arcane.ArcMesh import * from arcane.ArcMesh import *
@@ -29,6 +30,7 @@ from arcane.objects import ArcObj, ArcDoorObject, ArcStaticObject, ArcStructureO
from arcane.util import * from arcane.util import *
from arcane.zones import * from arcane.zones import *
DUMP_DIRECTORY = 'ARCANE_DUMP' DUMP_DIRECTORY = 'ARCANE_DUMP'
WORKING_DIRECTORY = os.path.dirname(__file__) WORKING_DIRECTORY = os.path.dirname(__file__)
TARGET_DIRECTORY = os.path.join(WORKING_DIRECTORY, DUMP_DIRECTORY) TARGET_DIRECTORY = os.path.join(WORKING_DIRECTORY, DUMP_DIRECTORY)
@@ -148,6 +150,7 @@ def unpack_cobjects():
resources = load_cache_file('CObjects.cache') resources = load_cache_file('CObjects.cache')
with tqdm(total=len(resources)) as pBar:
for res_id, data in resources: for res_id, data in resources:
in_stream = ResStream(data) in_stream = ResStream(data)
magic = in_stream.read_dword() magic = in_stream.read_dword()
@@ -163,6 +166,7 @@ def unpack_cobjects():
parsed = arc_in.save_json() parsed = arc_in.save_json()
with open(filepath, 'w') as fp: with open(filepath, 'w') as fp:
json.dump(parsed, fp, indent=2) json.dump(parsed, fp, indent=2)
pBar.update(1)
def pack_cobjects(): def pack_cobjects():
@@ -221,6 +225,7 @@ def unpack_czones():
resources = load_cache_file('CZone.cache') resources = load_cache_file('CZone.cache')
with tqdm(total=len(resources)) as pBar:
for res_id, data in resources: for res_id, data in resources:
arc_zone = ArcZone() arc_zone = ArcZone()
in_stream = ResStream(data) in_stream = ResStream(data)
@@ -232,6 +237,7 @@ def unpack_czones():
parsed = arc_zone.save_json() parsed = arc_zone.save_json()
with open(filepath, 'w') as fp: with open(filepath, 'w') as fp:
json.dump(parsed, fp, indent=2) json.dump(parsed, fp, indent=2)
pBar.update(1)
def pack_czones(): def pack_czones():
@@ -278,6 +284,7 @@ def unpack_sound():
resources = load_cache_file('Sound.cache') resources = load_cache_file('Sound.cache')
with tqdm(total=len(resources)) as pBar:
for res_id, data in resources: for res_id, data in resources:
arc_sound = ArcSound() arc_sound = ArcSound()
in_stream = ResStream(data) in_stream = ResStream(data)
@@ -291,6 +298,7 @@ def unpack_sound():
wave_writer = wave.Wave_write(fp) wave_writer = wave.Wave_write(fp)
arc_sound.save_wav(wave_writer) arc_sound.save_wav(wave_writer)
wave_writer.close() wave_writer.close()
pBar.update(1)
def pack_sound(): def pack_sound():
@@ -344,7 +352,11 @@ def test_sound():
def unpack_texture(): def unpack_texture():
init_texture() init_texture()
print('Decompressing Texture Cache...')
resources = load_cache_file('Textures.cache') resources = load_cache_file('Textures.cache')
print('Writing images')
with tqdm(total=len(resources)) as pBar:
for res_id, data in resources: for res_id, data in resources:
filepath = os.path.join( filepath = os.path.join(
TEXTURE_DIRECTORY, TEXTURE_DIRECTORY,
@@ -355,6 +367,7 @@ def unpack_texture():
in_stream = ResStream(data) in_stream = ResStream(data)
arc_texture.load_binary(in_stream) arc_texture.load_binary(in_stream)
arc_texture.save_img(filepath) arc_texture.save_img(filepath)
pBar.update(1)
def pack_texture(): def pack_texture():
@@ -408,6 +421,8 @@ def unpack_terrain():
init_terrain() init_terrain()
resources = load_cache_file('TerrainAlpha.cache') resources = load_cache_file('TerrainAlpha.cache')
with tqdm(total=len(resources)) as pBar:
for res_id, data in resources: for res_id, data in resources:
filepath = os.path.join( filepath = os.path.join(
TERRAIN_DIRECTORY, TERRAIN_DIRECTORY,
@@ -418,6 +433,7 @@ def unpack_terrain():
in_stream = ResStream(data) in_stream = ResStream(data)
arc_terrain.load_binary(in_stream) arc_terrain.load_binary(in_stream)
arc_terrain.save_img(filepath) arc_terrain.save_img(filepath)
pBar.update(1)
def pack_terrain(): def pack_terrain():
@@ -474,6 +490,7 @@ def unpack_mesh():
resources = load_cache_file('Mesh.cache') resources = load_cache_file('Mesh.cache')
with tqdm(total=len(resources)) as pBar:
for res_id, data in resources: for res_id, data in resources:
arc_mesh = ArcMesh() arc_mesh = ArcMesh()
in_stream = ResStream(data) in_stream = ResStream(data)
@@ -485,6 +502,7 @@ def unpack_mesh():
parsed = arc_mesh.save_json() parsed = arc_mesh.save_json()
with open(filepath, 'w') as fp: with open(filepath, 'w') as fp:
json.dump(parsed, fp, indent=2) json.dump(parsed, fp, indent=2)
pBar.update(1)
def pack_mesh(): def pack_mesh():
@@ -531,6 +549,7 @@ def unpack_visual():
resources = load_cache_file('Visual.cache') resources = load_cache_file('Visual.cache')
with tqdm(total=len(resources)) as pBar:
for res_id, data in resources: for res_id, data in resources:
arc_visual = ArcVisual() arc_visual = ArcVisual()
in_stream = ResStream(data) in_stream = ResStream(data)
@@ -542,6 +561,7 @@ def unpack_visual():
parsed = arc_visual.save_json() parsed = arc_visual.save_json()
with open(filepath, 'w') as fp: with open(filepath, 'w') as fp:
json.dump(parsed, fp, indent=2) json.dump(parsed, fp, indent=2)
pBar.update(1)
def pack_visual(): def pack_visual():
@@ -588,6 +608,7 @@ def unpack_motion():
resources = load_cache_file('Motion.cache') resources = load_cache_file('Motion.cache')
with tqdm(total=len(resources)) as pBar:
for res_id, data in resources: for res_id, data in resources:
arc_motion = ArcMotion() arc_motion = ArcMotion()
in_stream = ResStream(data) in_stream = ResStream(data)
@@ -599,6 +620,7 @@ def unpack_motion():
parsed = arc_motion.save_json() parsed = arc_motion.save_json()
with open(filepath, 'w') as fp: with open(filepath, 'w') as fp:
json.dump(parsed, fp, indent=2) json.dump(parsed, fp, indent=2)
pBar.update(1)
def pack_motion(): def pack_motion():
@@ -645,6 +667,7 @@ def unpack_tile():
resources = load_cache_file('Tile.cache') resources = load_cache_file('Tile.cache')
with tqdm(total=len(resources)) as pBar:
for res_id, data in resources: for res_id, data in resources:
arc_tile = ArcTileManager() arc_tile = ArcTileManager()
in_stream = ResStream(data) in_stream = ResStream(data)
@@ -656,6 +679,7 @@ def unpack_tile():
parsed = arc_tile.save_json() parsed = arc_tile.save_json()
with open(filepath, 'w') as fp: with open(filepath, 'w') as fp:
json.dump(parsed, fp, indent=2) json.dump(parsed, fp, indent=2)
pBar.update(1)
def pack_tile(): def pack_tile():
@@ -702,6 +726,7 @@ def unpack_skeleton():
resources = load_cache_file('Skeleton.cache') resources = load_cache_file('Skeleton.cache')
with tqdm(total=len(resources)) as pBar:
for res_id, data in resources: for res_id, data in resources:
arc_skeleton = ArcSkeleton() arc_skeleton = ArcSkeleton()
in_stream = ResStream(data) in_stream = ResStream(data)
@@ -714,6 +739,7 @@ def unpack_skeleton():
parsed = arc_skeleton.save_json() parsed = arc_skeleton.save_json()
with open(filepath, 'w') as fp: with open(filepath, 'w') as fp:
json.dump(parsed, fp, indent=2) json.dump(parsed, fp, indent=2)
pBar.update(1)
def pack_skeleton(): def pack_skeleton():
@@ -760,6 +786,7 @@ def unpack_render():
resources = load_cache_file('render.cache') resources = load_cache_file('render.cache')
with tqdm(total=len(resources)) as pBar:
for res_id, data in resources: for res_id, data in resources:
arc_render = ArcRender() arc_render = ArcRender()
in_stream = ResStream(data) in_stream = ResStream(data)
@@ -772,6 +799,7 @@ def unpack_render():
parsed = arc_render.save_json() parsed = arc_render.save_json()
with open(filepath, 'w') as fp: with open(filepath, 'w') as fp:
json.dump(parsed, fp, indent=2) json.dump(parsed, fp, indent=2)
pBar.update(1)
def pack_render(): def pack_render():
+3
View File
@@ -1 +1,4 @@
pillow==9.3.0 pillow==9.3.0
tqdm~=4.64.1