Show progress bar when unpacking files.
This commit is contained in:
+149
-121
@@ -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,21 +150,23 @@ def unpack_cobjects():
|
|||||||
|
|
||||||
resources = load_cache_file('CObjects.cache')
|
resources = load_cache_file('CObjects.cache')
|
||||||
|
|
||||||
for res_id, data in resources:
|
with tqdm(total=len(resources)) as pBar:
|
||||||
in_stream = ResStream(data)
|
for res_id, data in resources:
|
||||||
magic = in_stream.read_dword()
|
in_stream = ResStream(data)
|
||||||
obj_type = in_stream.read_dword()
|
magic = in_stream.read_dword()
|
||||||
|
obj_type = in_stream.read_dword()
|
||||||
|
|
||||||
arc_in = COBJECTS_MAP[obj_type]()
|
arc_in = COBJECTS_MAP[obj_type]()
|
||||||
filepath = os.path.join(
|
filepath = os.path.join(
|
||||||
COBJECTS_DIRECTORY,
|
COBJECTS_DIRECTORY,
|
||||||
OBJECT_TYPE_TO_STRING[obj_type],
|
OBJECT_TYPE_TO_STRING[obj_type],
|
||||||
f'{res_id:d}.json'
|
f'{res_id:d}.json'
|
||||||
)
|
)
|
||||||
arc_in.load_binary(in_stream)
|
arc_in.load_binary(in_stream)
|
||||||
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,17 +225,19 @@ def unpack_czones():
|
|||||||
|
|
||||||
resources = load_cache_file('CZone.cache')
|
resources = load_cache_file('CZone.cache')
|
||||||
|
|
||||||
for res_id, data in resources:
|
with tqdm(total=len(resources)) as pBar:
|
||||||
arc_zone = ArcZone()
|
for res_id, data in resources:
|
||||||
in_stream = ResStream(data)
|
arc_zone = ArcZone()
|
||||||
filepath = os.path.join(
|
in_stream = ResStream(data)
|
||||||
CZONE_DIRECTORY,
|
filepath = os.path.join(
|
||||||
f'{res_id:d}.json'
|
CZONE_DIRECTORY,
|
||||||
)
|
f'{res_id:d}.json'
|
||||||
arc_zone.load_binary(in_stream)
|
)
|
||||||
parsed = arc_zone.save_json()
|
arc_zone.load_binary(in_stream)
|
||||||
with open(filepath, 'w') as fp:
|
parsed = arc_zone.save_json()
|
||||||
json.dump(parsed, fp, indent=2)
|
with open(filepath, 'w') as fp:
|
||||||
|
json.dump(parsed, fp, indent=2)
|
||||||
|
pBar.update(1)
|
||||||
|
|
||||||
|
|
||||||
def pack_czones():
|
def pack_czones():
|
||||||
@@ -278,19 +284,21 @@ def unpack_sound():
|
|||||||
|
|
||||||
resources = load_cache_file('Sound.cache')
|
resources = load_cache_file('Sound.cache')
|
||||||
|
|
||||||
for res_id, data in resources:
|
with tqdm(total=len(resources)) as pBar:
|
||||||
arc_sound = ArcSound()
|
for res_id, data in resources:
|
||||||
in_stream = ResStream(data)
|
arc_sound = ArcSound()
|
||||||
filepath = os.path.join(
|
in_stream = ResStream(data)
|
||||||
SOUND_DIRECTORY,
|
filepath = os.path.join(
|
||||||
f'{res_id:d}.wav'
|
SOUND_DIRECTORY,
|
||||||
)
|
f'{res_id:d}.wav'
|
||||||
|
)
|
||||||
|
|
||||||
arc_sound.load_binary(in_stream)
|
arc_sound.load_binary(in_stream)
|
||||||
with open(filepath, 'wb') as fp:
|
with open(filepath, 'wb') as fp:
|
||||||
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,17 +352,22 @@ 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')
|
||||||
for res_id, data in resources:
|
|
||||||
filepath = os.path.join(
|
|
||||||
TEXTURE_DIRECTORY,
|
|
||||||
f'{res_id:d}.tga'
|
|
||||||
)
|
|
||||||
|
|
||||||
arc_texture = ArcTexture()
|
print('Writing images')
|
||||||
in_stream = ResStream(data)
|
with tqdm(total=len(resources)) as pBar:
|
||||||
arc_texture.load_binary(in_stream)
|
for res_id, data in resources:
|
||||||
arc_texture.save_img(filepath)
|
filepath = os.path.join(
|
||||||
|
TEXTURE_DIRECTORY,
|
||||||
|
f'{res_id:d}.tga'
|
||||||
|
)
|
||||||
|
|
||||||
|
arc_texture = ArcTexture()
|
||||||
|
in_stream = ResStream(data)
|
||||||
|
arc_texture.load_binary(in_stream)
|
||||||
|
arc_texture.save_img(filepath)
|
||||||
|
pBar.update(1)
|
||||||
|
|
||||||
|
|
||||||
def pack_texture():
|
def pack_texture():
|
||||||
@@ -408,16 +421,19 @@ def unpack_terrain():
|
|||||||
init_terrain()
|
init_terrain()
|
||||||
|
|
||||||
resources = load_cache_file('TerrainAlpha.cache')
|
resources = load_cache_file('TerrainAlpha.cache')
|
||||||
for res_id, data in resources:
|
|
||||||
filepath = os.path.join(
|
|
||||||
TERRAIN_DIRECTORY,
|
|
||||||
f'{res_id:d}.tga'
|
|
||||||
)
|
|
||||||
|
|
||||||
arc_terrain = ArcTerrain()
|
with tqdm(total=len(resources)) as pBar:
|
||||||
in_stream = ResStream(data)
|
for res_id, data in resources:
|
||||||
arc_terrain.load_binary(in_stream)
|
filepath = os.path.join(
|
||||||
arc_terrain.save_img(filepath)
|
TERRAIN_DIRECTORY,
|
||||||
|
f'{res_id:d}.tga'
|
||||||
|
)
|
||||||
|
|
||||||
|
arc_terrain = ArcTerrain()
|
||||||
|
in_stream = ResStream(data)
|
||||||
|
arc_terrain.load_binary(in_stream)
|
||||||
|
arc_terrain.save_img(filepath)
|
||||||
|
pBar.update(1)
|
||||||
|
|
||||||
|
|
||||||
def pack_terrain():
|
def pack_terrain():
|
||||||
@@ -474,17 +490,19 @@ def unpack_mesh():
|
|||||||
|
|
||||||
resources = load_cache_file('Mesh.cache')
|
resources = load_cache_file('Mesh.cache')
|
||||||
|
|
||||||
for res_id, data in resources:
|
with tqdm(total=len(resources)) as pBar:
|
||||||
arc_mesh = ArcMesh()
|
for res_id, data in resources:
|
||||||
in_stream = ResStream(data)
|
arc_mesh = ArcMesh()
|
||||||
filepath = os.path.join(
|
in_stream = ResStream(data)
|
||||||
MESH_DIRECTORY,
|
filepath = os.path.join(
|
||||||
f'{res_id:d}.json'
|
MESH_DIRECTORY,
|
||||||
)
|
f'{res_id:d}.json'
|
||||||
arc_mesh.load_binary(in_stream)
|
)
|
||||||
parsed = arc_mesh.save_json()
|
arc_mesh.load_binary(in_stream)
|
||||||
with open(filepath, 'w') as fp:
|
parsed = arc_mesh.save_json()
|
||||||
json.dump(parsed, fp, indent=2)
|
with open(filepath, 'w') as fp:
|
||||||
|
json.dump(parsed, fp, indent=2)
|
||||||
|
pBar.update(1)
|
||||||
|
|
||||||
|
|
||||||
def pack_mesh():
|
def pack_mesh():
|
||||||
@@ -531,17 +549,19 @@ def unpack_visual():
|
|||||||
|
|
||||||
resources = load_cache_file('Visual.cache')
|
resources = load_cache_file('Visual.cache')
|
||||||
|
|
||||||
for res_id, data in resources:
|
with tqdm(total=len(resources)) as pBar:
|
||||||
arc_visual = ArcVisual()
|
for res_id, data in resources:
|
||||||
in_stream = ResStream(data)
|
arc_visual = ArcVisual()
|
||||||
filepath = os.path.join(
|
in_stream = ResStream(data)
|
||||||
VISUAL_DIRECTORY,
|
filepath = os.path.join(
|
||||||
f'{res_id:d}.json'
|
VISUAL_DIRECTORY,
|
||||||
)
|
f'{res_id:d}.json'
|
||||||
arc_visual.load_binary(in_stream)
|
)
|
||||||
parsed = arc_visual.save_json()
|
arc_visual.load_binary(in_stream)
|
||||||
with open(filepath, 'w') as fp:
|
parsed = arc_visual.save_json()
|
||||||
json.dump(parsed, fp, indent=2)
|
with open(filepath, 'w') as fp:
|
||||||
|
json.dump(parsed, fp, indent=2)
|
||||||
|
pBar.update(1)
|
||||||
|
|
||||||
|
|
||||||
def pack_visual():
|
def pack_visual():
|
||||||
@@ -588,17 +608,19 @@ def unpack_motion():
|
|||||||
|
|
||||||
resources = load_cache_file('Motion.cache')
|
resources = load_cache_file('Motion.cache')
|
||||||
|
|
||||||
for res_id, data in resources:
|
with tqdm(total=len(resources)) as pBar:
|
||||||
arc_motion = ArcMotion()
|
for res_id, data in resources:
|
||||||
in_stream = ResStream(data)
|
arc_motion = ArcMotion()
|
||||||
filepath = os.path.join(
|
in_stream = ResStream(data)
|
||||||
MOTION_DIRECTORY,
|
filepath = os.path.join(
|
||||||
f'{res_id:d}.json'
|
MOTION_DIRECTORY,
|
||||||
)
|
f'{res_id:d}.json'
|
||||||
arc_motion.load_binary(in_stream)
|
)
|
||||||
parsed = arc_motion.save_json()
|
arc_motion.load_binary(in_stream)
|
||||||
with open(filepath, 'w') as fp:
|
parsed = arc_motion.save_json()
|
||||||
json.dump(parsed, fp, indent=2)
|
with open(filepath, 'w') as fp:
|
||||||
|
json.dump(parsed, fp, indent=2)
|
||||||
|
pBar.update(1)
|
||||||
|
|
||||||
|
|
||||||
def pack_motion():
|
def pack_motion():
|
||||||
@@ -645,17 +667,19 @@ def unpack_tile():
|
|||||||
|
|
||||||
resources = load_cache_file('Tile.cache')
|
resources = load_cache_file('Tile.cache')
|
||||||
|
|
||||||
for res_id, data in resources:
|
with tqdm(total=len(resources)) as pBar:
|
||||||
arc_tile = ArcTileManager()
|
for res_id, data in resources:
|
||||||
in_stream = ResStream(data)
|
arc_tile = ArcTileManager()
|
||||||
filepath = os.path.join(
|
in_stream = ResStream(data)
|
||||||
TILE_DIRECTORY,
|
filepath = os.path.join(
|
||||||
f'{res_id:d}.json'
|
TILE_DIRECTORY,
|
||||||
)
|
f'{res_id:d}.json'
|
||||||
arc_tile.load_binary(in_stream)
|
)
|
||||||
parsed = arc_tile.save_json()
|
arc_tile.load_binary(in_stream)
|
||||||
with open(filepath, 'w') as fp:
|
parsed = arc_tile.save_json()
|
||||||
json.dump(parsed, fp, indent=2)
|
with open(filepath, 'w') as fp:
|
||||||
|
json.dump(parsed, fp, indent=2)
|
||||||
|
pBar.update(1)
|
||||||
|
|
||||||
|
|
||||||
def pack_tile():
|
def pack_tile():
|
||||||
@@ -702,18 +726,20 @@ def unpack_skeleton():
|
|||||||
|
|
||||||
resources = load_cache_file('Skeleton.cache')
|
resources = load_cache_file('Skeleton.cache')
|
||||||
|
|
||||||
for res_id, data in resources:
|
with tqdm(total=len(resources)) as pBar:
|
||||||
arc_skeleton = ArcSkeleton()
|
for res_id, data in resources:
|
||||||
in_stream = ResStream(data)
|
arc_skeleton = ArcSkeleton()
|
||||||
filepath = os.path.join(
|
in_stream = ResStream(data)
|
||||||
SKELETON_DIRECTORY,
|
filepath = os.path.join(
|
||||||
f'{res_id:d}.json'
|
SKELETON_DIRECTORY,
|
||||||
)
|
f'{res_id:d}.json'
|
||||||
arc_skeleton.load_binary(in_stream)
|
)
|
||||||
|
arc_skeleton.load_binary(in_stream)
|
||||||
|
|
||||||
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,18 +786,20 @@ def unpack_render():
|
|||||||
|
|
||||||
resources = load_cache_file('render.cache')
|
resources = load_cache_file('render.cache')
|
||||||
|
|
||||||
for res_id, data in resources:
|
with tqdm(total=len(resources)) as pBar:
|
||||||
arc_render = ArcRender()
|
for res_id, data in resources:
|
||||||
in_stream = ResStream(data)
|
arc_render = ArcRender()
|
||||||
filepath = os.path.join(
|
in_stream = ResStream(data)
|
||||||
RENDER_DIRECTORY,
|
filepath = os.path.join(
|
||||||
f'{res_id:d}.json'
|
RENDER_DIRECTORY,
|
||||||
)
|
f'{res_id:d}.json'
|
||||||
arc_render.load_binary(in_stream)
|
)
|
||||||
|
arc_render.load_binary(in_stream)
|
||||||
|
|
||||||
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():
|
||||||
|
|||||||
@@ -1 +1,4 @@
|
|||||||
pillow==9.3.0
|
pillow==9.3.0
|
||||||
|
|
||||||
|
|
||||||
|
tqdm~=4.64.1
|
||||||
|
|||||||
Reference in New Issue
Block a user