Skip to content

Commit

Permalink
refactor(rendering): movie clip rendering is disabled by default now
Browse files Browse the repository at this point in the history
  • Loading branch information
danila-schelkov committed Aug 20, 2024
1 parent 0303531 commit 4bc7c8c
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 22 deletions.
2 changes: 2 additions & 0 deletions system/lib/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ def __init__(self):
"has_update",
"last_update",
"auto_update",
"should_render_movie_clips",
)

self.initialized: bool = False
Expand All @@ -24,6 +25,7 @@ def __init__(self):
self.has_update: bool = False
self.last_update: int = -1
self.auto_update: bool = False
self.should_render_movie_clips: bool = False

self.load()

Expand Down
46 changes: 24 additions & 22 deletions system/lib/features/cut_sprites.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import os
from pathlib import Path

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

movie_clips_skipped = 0
movie_clip_count = len(swf.movie_clips)
for movie_clip_index in range(movie_clip_count):
movie_clip = swf.movie_clips[movie_clip_index]

rendered_movie_clip = create_renderable_from_plain(swf, movie_clip).render(
Matrix2x3()
)
if sum(rendered_movie_clip.size) >= 2:
clip_name = movie_clip.export_name or movie_clip.id
rendered_movie_clip.save(f"{output_folder}/movie_clips/{clip_name}.png")
else:
# For debug:
# logger.warning(f'MovieClip {movie_clip.id} cannot be rendered.')
movie_clips_skipped += 1

Console.progress_bar(
"Rendering movie clips (%d/%d). Skipped count: %d"
% (movie_clip_index + 1, movie_clip_count, movie_clips_skipped),
movie_clip_index,
movie_clip_count,
)
if config.should_render_movie_clips:
movie_clips_skipped = 0
movie_clip_count = len(swf.movie_clips)
for movie_clip_index in range(movie_clip_count):
movie_clip = swf.movie_clips[movie_clip_index]

rendered_movie_clip = create_renderable_from_plain(swf, movie_clip).render(
Matrix2x3()
)
if sum(rendered_movie_clip.size) >= 2:
clip_name = movie_clip.export_name or movie_clip.id
rendered_movie_clip.save(f"{output_folder}/movie_clips/{clip_name}.png")
else:
# For debug:
# logger.warning(f'MovieClip {movie_clip.id} cannot be rendered.')
movie_clips_skipped += 1

Console.progress_bar(
"Rendering movie clips (%d/%d). Skipped count: %d"
% (movie_clip_index + 1, movie_clip_count, movie_clips_skipped),
movie_clip_index,
movie_clip_count,
)

0 comments on commit 4bc7c8c

Please sign in to comment.