# HG changeset patch # User Thibaut Girka # Date 1325526415 -3600 # Node ID d3ba32a9096e77da031cf3b6e0f42f74716ff3d3 # Parent 2b7f69ad9ccd9e03c0a2c757040c907f35661e98 Implement ANM0 instruction 29 and fix 24 diff --git a/pytouhou/formats/anm0.py b/pytouhou/formats/anm0.py --- a/pytouhou/formats/anm0.py +++ b/pytouhou/formats/anm0.py @@ -64,6 +64,7 @@ class Animations(object): 26: ('i', 'set_automatic_orientation'), 27: ('f', 'shift_texture_x'), 28: ('f', 'shift_texture_y'), + 29: ('i', 'set_visible'), 30: ('ffi', 'scale_in'), 31: ('i', None)} diff --git a/pytouhou/game/sprite.py b/pytouhou/game/sprite.py --- a/pytouhou/game/sprite.py +++ b/pytouhou/game/sprite.py @@ -23,11 +23,12 @@ class Sprite(object): 'texcoords', 'dest_offset', 'allow_dest_offset', 'texoffsets', 'mirrored', 'rescale', 'scale_speed', 'rotations_3d', 'rotations_speed_3d', 'corner_relative_placement', 'frame', - 'color', 'alpha', '_rendering_data') + 'color', 'alpha', 'visible', '_rendering_data') def __init__(self, width_override=0, height_override=0): self.anm = None self._removed = False self._changed = True + self.visible = True self.width_override = width_override self.height_override = height_override diff --git a/pytouhou/ui/renderer.pyx b/pytouhou/ui/renderer.pyx --- a/pytouhou/ui/renderer.pyx +++ b/pytouhou/ui/renderer.pyx @@ -48,7 +48,7 @@ cdef class Renderer: for element in elements: sprite = element._sprite - if sprite: + if sprite and sprite.visible: ox, oy = element.x, element.y key, (vertices, uvs, colors) = get_sprite_rendering_data(sprite) rec = indices_by_texture.setdefault(key, []) diff --git a/pytouhou/vm/anmrunner.py b/pytouhou/vm/anmrunner.py --- a/pytouhou/vm/anmrunner.py +++ b/pytouhou/vm/anmrunner.py @@ -51,6 +51,7 @@ class ANMRunner(object): self.instruction_pointer = new_ip self.frame, opcode, args = self.script[self.instruction_pointer] self.waiting = False + self._sprite.visible = True return True @@ -231,9 +232,9 @@ class ANMRunner(object): @instruction(24) def wait_ex(self): - """Hide/delete the sprite and wait for an interrupt. + """Hide the sprite and wait for an interrupt. """ - #TODO: Hide/delete the sprite and figure what happens exactly + self._sprite.visible = False self.waiting = True @@ -261,6 +262,11 @@ class ANMRunner(object): self._sprite.texoffsets = tox, toy + dy + @instruction(29) + def set_visible(self, visible): + self._sprite.visible = bool(visible & 1) + + @instruction(30) def scale_in(self, sx, sy, duration): self._sprite.scale_in(duration, sx, sy, lambda x: x) #TODO: formula