comparison pytouhou/ui/anmrenderer.pyx @ 430:c9433188ffdb

Remove AnmWrapper, since ANMs are lists of entries now.
author Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
date Sat, 03 Aug 2013 15:49:04 +0200
parents 5d7bb2fd74f7
children 6864a38b2413
comparison
equal deleted inserted replaced
429:40d5f3083ebc 430:c9433188ffdb
29 29
30 logger = get_logger(__name__) 30 logger = get_logger(__name__)
31 31
32 32
33 class ANMRenderer(Renderer): 33 class ANMRenderer(Renderer):
34 def __init__(self, window, resource_loader, anm_wrapper, index=0, sprites=False): 34 def __init__(self, window, resource_loader, anm, index=0, sprites=False):
35 self.use_fixed_pipeline = window.use_fixed_pipeline #XXX 35 self.use_fixed_pipeline = window.use_fixed_pipeline #XXX
36 36
37 Renderer.__init__(self, resource_loader) 37 Renderer.__init__(self, resource_loader)
38 38
39 self.window = window 39 self.window = window
40 self.texture_manager.load(resource_loader.instanced_anms.values()) 40 self.texture_manager.load(resource_loader.instanced_anms.values())
41 41
42 self._anm_wrapper = anm_wrapper 42 self._anm = anm
43 self.sprites = sprites 43 self.sprites = sprites
44 self.clear_color = (0., 0., 0., 1.) 44 self.clear_color = (0., 0., 0., 1.)
45 self.force_allow_dest_offset = False 45 self.force_allow_dest_offset = False
46 self.index_items() 46 self.index_items()
47 self.load(index) 47 self.load(index)
72 def load(self, index=None): 72 def load(self, index=None):
73 if index is None: 73 if index is None:
74 index = self.num 74 index = self.num
75 self.sprite = Sprite() 75 self.sprite = Sprite()
76 if self.sprites: 76 if self.sprites:
77 self.sprite.anm, self.sprite.texcoords = self._anm_wrapper.get_sprite(index) 77 self.sprite.anm = self._anm
78 self.sprite.texcoords = self._anm.sprites[index]
78 print('Loaded sprite %d' % index) 79 print('Loaded sprite %d' % index)
79 else: 80 else:
80 self.anmrunner = ANMRunner(self._anm_wrapper, index, self.sprite) 81 self.anmrunner = ANMRunner(self._anm, index, self.sprite)
81 print('Loading anim %d, handled events: %r' % (index, self.anmrunner.script.interrupts.keys())) 82 print('Loading anim %d, handled events: %r' % (index, self.anmrunner.script.interrupts.keys()))
82 self.num = index 83 self.num = index
83 84
84 85
85 def change(self, diff): 86 def change(self, diff):
91 92
92 93
93 def index_items(self): 94 def index_items(self):
94 self.items = {} 95 self.items = {}
95 if self.sprites: 96 if self.sprites:
96 self.items = self._anm_wrapper.sprites 97 self.items = self._anm.sprites
97 else: 98 else:
98 self.items = self._anm_wrapper.scripts 99 self.items = self._anm.scripts
99 100
100 101
101 def toggle_sprites(self): 102 def toggle_sprites(self):
102 self.sprites = not(self.sprites) 103 self.sprites = not(self.sprites)
103 self.index_items() 104 self.index_items()