Skip to content

Commit 4bc7c8c

Browse files
refactor(rendering): movie clip rendering is disabled by default now
1 parent 0303531 commit 4bc7c8c

File tree

2 files changed

+26
-22
lines changed

2 files changed

+26
-22
lines changed

system/lib/config.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ def __init__(self):
1616
"has_update",
1717
"last_update",
1818
"auto_update",
19+
"should_render_movie_clips",
1920
)
2021

2122
self.initialized: bool = False
@@ -24,6 +25,7 @@ def __init__(self):
2425
self.has_update: bool = False
2526
self.last_update: int = -1
2627
self.auto_update: bool = False
28+
self.should_render_movie_clips: bool = False
2729

2830
self.load()
2931

system/lib/features/cut_sprites.py

Lines changed: 24 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import os
22
from pathlib import Path
33

4+
from system.lib.config import config
45
from system.lib.console import Console
56
from system.lib.matrices import Matrix2x3
67
from system.lib.objects.renderable.renderable_factory import (
@@ -53,25 +54,26 @@ def render_objects(swf: SupercellSWF, output_folder: Path):
5354
rendered_region = region.get_image()
5455
rendered_region.save(f"{output_folder}/shape_{shape.id}_{region_index}.png")
5556

56-
movie_clips_skipped = 0
57-
movie_clip_count = len(swf.movie_clips)
58-
for movie_clip_index in range(movie_clip_count):
59-
movie_clip = swf.movie_clips[movie_clip_index]
60-
61-
rendered_movie_clip = create_renderable_from_plain(swf, movie_clip).render(
62-
Matrix2x3()
63-
)
64-
if sum(rendered_movie_clip.size) >= 2:
65-
clip_name = movie_clip.export_name or movie_clip.id
66-
rendered_movie_clip.save(f"{output_folder}/movie_clips/{clip_name}.png")
67-
else:
68-
# For debug:
69-
# logger.warning(f'MovieClip {movie_clip.id} cannot be rendered.')
70-
movie_clips_skipped += 1
71-
72-
Console.progress_bar(
73-
"Rendering movie clips (%d/%d). Skipped count: %d"
74-
% (movie_clip_index + 1, movie_clip_count, movie_clips_skipped),
75-
movie_clip_index,
76-
movie_clip_count,
77-
)
57+
if config.should_render_movie_clips:
58+
movie_clips_skipped = 0
59+
movie_clip_count = len(swf.movie_clips)
60+
for movie_clip_index in range(movie_clip_count):
61+
movie_clip = swf.movie_clips[movie_clip_index]
62+
63+
rendered_movie_clip = create_renderable_from_plain(swf, movie_clip).render(
64+
Matrix2x3()
65+
)
66+
if sum(rendered_movie_clip.size) >= 2:
67+
clip_name = movie_clip.export_name or movie_clip.id
68+
rendered_movie_clip.save(f"{output_folder}/movie_clips/{clip_name}.png")
69+
else:
70+
# For debug:
71+
# logger.warning(f'MovieClip {movie_clip.id} cannot be rendered.')
72+
movie_clips_skipped += 1
73+
74+
Console.progress_bar(
75+
"Rendering movie clips (%d/%d). Skipped count: %d"
76+
% (movie_clip_index + 1, movie_clip_count, movie_clips_skipped),
77+
movie_clip_index,
78+
movie_clip_count,
79+
)

0 commit comments

Comments
 (0)