Skip to content

Commit 3abc2c3

Browse files
committed
Improved pack graphicss composing
1 parent a8bb8f1 commit 3abc2c3

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

toolchain/toolchain/python/icmtoolchain/script_build.py

+9-7
Original file line numberDiff line numberDiff line change
@@ -331,28 +331,30 @@ def build_resources() -> int:
331331
return overall_result
332332

333333
def build_pack_graphics() -> int:
334-
graphics_groups = GLOBALS.MAKE_CONFIG.get_list("graphics.groups")
335-
if len(graphics_groups) == 0 or not GLOBALS.MAKE_CONFIG.has_value("manifest"):
334+
graphics_archive = join(GLOBALS.MOD_STRUCTURE.directory, "graphics.zip")
335+
if exists(graphics_archive):
336+
remove_tree(graphics_archive)
337+
graphics_groups = GLOBALS.MAKE_CONFIG.get_value("graphics.groups")
338+
if not isinstance(graphics_groups, dict):
336339
return 0
340+
337341
graphics_directory = GLOBALS.MAKE_CONFIG.get_build_path("graphics")
338342
remove_tree(graphics_directory)
339343
ensure_directory(graphics_directory)
340344

341-
graphics_archive = join(GLOBALS.MOD_STRUCTURE.directory, "graphics.zip")
342-
if exists(graphics_archive):
343-
remove_tree(graphics_archive)
344-
for name, images in graphics_groups:
345+
for name, images in graphics_groups.items():
345346
offset = 1
346347
if isinstance(images, str):
347348
images = [images]
348349
for image_directory in images:
349350
for image_path in GLOBALS.MAKE_CONFIG.get_paths(image_directory):
350351
if not isfile(image_path):
351-
warn(f"* Skipping graphics image file {basename(image_path)}, since it does not exists!")
352+
warn(f"* Skipping graphics image file {basename(image_path)}, cause it does not exists!")
352353
continue
353354
copy_file(image_path, join(graphics_directory, f"{name}@{offset}.png"))
354355
offset += 1
355356

356357
from shutil import make_archive
357358
make_archive(graphics_archive[:-4], "zip", graphics_directory)
359+
print(f"Composed a pack with graphics from {len(graphics_groups.keys())} groups!")
358360
return 0

0 commit comments

Comments
 (0)