diff --git a/pyproject.toml b/pyproject.toml index 633039c3..58b0a10a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -30,7 +30,7 @@ dependencies = [ "Pillow >= 6.1.0", "appdirs >= 1.4.0", "explorerscript >= 0.2.2, < 0.3.0", - "skytemple-rust >= 1.8.4, < 1.9.0", + "skytemple-rust >= 1.8.5, < 1.9.0", 'pyobjc==10.3.2; sys_platform == "darwin"', "dungeon-eos==0.0.5", ] diff --git a/skytemple_files/graphics/bpl/_model.py b/skytemple_files/graphics/bpl/_model.py index f3a3f842..ccdf31b7 100644 --- a/skytemple_files/graphics/bpl/_model.py +++ b/skytemple_files/graphics/bpl/_model.py @@ -16,6 +16,7 @@ # along with SkyTemple. If not, see . from __future__ import annotations +import logging from range_typed_integers import u16_checked, u16 @@ -30,6 +31,8 @@ ) from skytemple_files.graphics.bpl.protocol import BplAnimationSpecProtocol, BplProtocol +logger = logging.getLogger(__name__) + class BplAnimationSpec(BplAnimationSpecProtocol): def __init__(self, duration_per_frame: u16, number_of_frames: u16) -> None: @@ -138,10 +141,16 @@ def apply_palette_animations(self, frame: int) -> list[list[int]]: """ # TODO: First frame is missing: No change! f_palettes = [] + already_used_colors = 0 for i, spec in enumerate(self.animation_specs): if spec.number_of_frames > 0: - actual_frame_for_pal = frame % spec.number_of_frames - pal_for_frame = self.animation_palette[actual_frame_for_pal] + actual_frame_for_pal = already_used_colors + (frame % spec.number_of_frames) + already_used_colors += spec.number_of_frames + if actual_frame_for_pal >= len(self.animation_palette): + logger.warning("palette animation frame out of bounds, using black") + pal_for_frame = [0] * 3 * 15 + else: + pal_for_frame = self.animation_palette[actual_frame_for_pal] f_palettes.append([0, 0, 0] + pal_for_frame) else: f_palettes.append(self.palettes[i])