comparison pytouhou/resource/loader.py @ 282:dbb1a86c0235

Rename Animations to ANM0 and prepare AnmWrapper for dialogs and interface.
author Thibaut Girka <thib@sitedethib.com>
date Sat, 11 Feb 2012 16:43:54 +0100
parents ac677dd0ffe0
children 2100276c289d
comparison
equal deleted inserted replaced
281:13dcde917083 282:dbb1a86c0235
4 from io import BytesIO 4 from io import BytesIO
5 5
6 from pytouhou.formats.pbg3 import PBG3 6 from pytouhou.formats.pbg3 import PBG3
7 from pytouhou.formats.std import Stage 7 from pytouhou.formats.std import Stage
8 from pytouhou.formats.ecl import ECL 8 from pytouhou.formats.ecl import ECL
9 from pytouhou.formats.anm0 import Animations 9 from pytouhou.formats.anm0 import ANM0
10 from pytouhou.formats.msg import MSG 10 from pytouhou.formats.msg import MSG
11 from pytouhou.formats.sht import SHT 11 from pytouhou.formats.sht import SHT
12 from pytouhou.formats.exe import SHT as EoSDSHT 12 from pytouhou.formats.exe import SHT as EoSDSHT
13 13
14 14
119 119
120 120
121 def get_anm(self, name): 121 def get_anm(self, name):
122 if name not in self.instanced_anms: 122 if name not in self.instanced_anms:
123 file = self.get_file(name) 123 file = self.get_file(name)
124 self.instanced_anms[name] = Animations.read(file) #TODO: modular 124 self.instanced_anms[name] = ANM0.read(file) #TODO: modular
125 return self.instanced_anms[name] 125 return self.instanced_anms[name]
126 126
127 127
128 def get_stage(self, name): 128 def get_stage(self, name):
129 if name not in self.instanced_stages: 129 if name not in self.instanced_stages:
161 with open(path, 'rb') as file: 161 with open(path, 'rb') as file:
162 characters = EoSDSHT.read(file) #TODO: modular 162 characters = EoSDSHT.read(file) #TODO: modular
163 return characters 163 return characters
164 164
165 165
166 def get_anm_wrapper(self, names): 166 def get_anm_wrapper(self, names, offsets=()):
167 return AnmWrapper(self.get_anm(name) for name in names) 167 return AnmWrapper((self.get_anm(name) for name in names), offsets)
168 168
169 169
170 def get_anm_wrapper2(self, names): 170 def get_anm_wrapper2(self, names, offsets=()):
171 anims = [] 171 anms = []
172
172 try: 173 try:
173 for name in names: 174 for name in names:
174 anims.append(self.get_anm(name)) 175 anms.append(self.get_anm(name))
175 except KeyError: 176 except KeyError:
176 pass 177 pass
177 178
178 return AnmWrapper(anims) 179 return AnmWrapper(anms, offsets)
179 180