comparison pytouhou/resource/loader.py @ 321:61adb5453e46

Implement music playback.
author Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
date Wed, 13 Jun 2012 15:29:43 +0200
parents 92a6fd2632f1
children cddfd3cb4797
comparison
equal deleted inserted replaced
320:1a4ffdda8735 321:61adb5453e46
22 from pytouhou.formats.ecl import ECL 22 from pytouhou.formats.ecl import ECL
23 from pytouhou.formats.anm0 import ANM0 23 from pytouhou.formats.anm0 import ANM0
24 from pytouhou.formats.msg import MSG 24 from pytouhou.formats.msg import MSG
25 from pytouhou.formats.sht import SHT 25 from pytouhou.formats.sht import SHT
26 from pytouhou.formats.exe import SHT as EoSDSHT, InvalidExeException 26 from pytouhou.formats.exe import SHT as EoSDSHT, InvalidExeException
27 from pytouhou.formats.music import Track
27 28
28 29
29 from pytouhou.resource.anmwrapper import AnmWrapper 30 from pytouhou.resource.anmwrapper import AnmWrapper
30 31
31 from pytouhou.utils.helpers import get_logger 32 from pytouhou.utils.helpers import get_logger
104 self.instanced_ecls = {} 105 self.instanced_ecls = {}
105 self.instanced_anms = {} 106 self.instanced_anms = {}
106 self.instanced_stages = {} 107 self.instanced_stages = {}
107 self.instanced_msgs = {} 108 self.instanced_msgs = {}
108 self.instanced_shts = {} 109 self.instanced_shts = {}
110 self.instanced_tracks = {}
109 111
110 112
111 def scan_archives(self, paths_lists): 113 def scan_archives(self, paths_lists):
112 for paths in paths_lists: 114 for paths in paths_lists:
113 def _expand_paths(): 115 def _expand_paths():
182 except InvalidExeException: 184 except InvalidExeException:
183 pass 185 pass
184 logger.error("Required game exe not found!") 186 logger.error("Required game exe not found!")
185 187
186 188
189 def get_track(self, name):
190 posname = name.replace('bgm/', '').replace('.mid', '.pos')
191 if name not in self.instanced_tracks:
192 file = self.get_file(posname)
193 self.instanced_tracks[name] = Track.read(file) #TODO: modular
194 return self.instanced_tracks[name]
195
196
187 def get_anm_wrapper(self, names, offsets=None): 197 def get_anm_wrapper(self, names, offsets=None):
188 """Create an AnmWrapper for ANM files “names”. 198 """Create an AnmWrapper for ANM files “names”.
189 199
190 If one of the files “names” does not exist or is not a valid ANM file, 200 If one of the files “names” does not exist or is not a valid ANM file,
191 raises an exception. 201 raises an exception.