comparison pytouhou/resource/loader.py @ 231:c417bb6c98bf

Search for 102h.exe in the game directory instead of the current directory.
author Thibaut Girka <thib@sitedethib.com>
date Fri, 30 Dec 2011 19:17:55 +0100
parents 5afc75f71fed
children 8fa660da5f0c
comparison
equal deleted inserted replaced
230:1c24a6d93c1b 231:c417bb6c98bf
1 import os
1 from io import BytesIO 2 from io import BytesIO
2 3
3 from pytouhou.formats.pbg3 import PBG3 4 from pytouhou.formats.pbg3 import PBG3
4 from pytouhou.formats.std import Stage 5 from pytouhou.formats.std import Stage
5 from pytouhou.formats.ecl import ECL 6 from pytouhou.formats.ecl import ECL
38 return cls(path, format_class, file_list) 39 return cls(path, format_class, file_list)
39 40
40 41
41 42
42 class Loader(object): 43 class Loader(object):
43 def __init__(self): 44 def __init__(self, game_dir=None):
45 self.game_dir = game_dir
44 self.known_files = {} 46 self.known_files = {}
45 self.instanced_ecls = {} 47 self.instanced_ecls = {}
46 self.instanced_anms = {} 48 self.instanced_anms = {}
47 self.instanced_stages = {} 49 self.instanced_stages = {}
48 self.instanced_msgs = {} 50 self.instanced_msgs = {}
49 self.instanced_shts = {} 51 self.instanced_shts = {}
50 52
51 53
52 def scan_archives(self, paths): 54 def scan_archives(self, paths):
53 for path in paths: 55 for path in paths:
56 if self.game_dir and not os.path.isabs(path):
57 path = os.path.join(self.game_dir, path)
54 archive_description = ArchiveDescription.get_from_path(path) 58 archive_description = ArchiveDescription.get_from_path(path)
55 for name in archive_description.file_list: 59 for name in archive_description.file_list:
56 self.known_files[name] = archive_description 60 self.known_files[name] = archive_description
57 61
58 62
101 file = self.get_file(name) 105 file = self.get_file(name)
102 self.instanced_shts[name] = SHT.read(file) #TODO: modular 106 self.instanced_shts[name] = SHT.read(file) #TODO: modular
103 return self.instanced_shts[name] 107 return self.instanced_shts[name]
104 108
105 109
106 def get_eosd_characters(self, name): 110 def get_eosd_characters(self, path):
107 with open(name, 'rb') as file: 111 #TODO: Move to pytouhou.games.eosd?
112 if self.game_dir and not os.path.isabs(path):
113 path = os.path.join(self.game_dir, path)
114 with open(path, 'rb') as file:
108 characters = EoSDSHT.read(file) #TODO: modular 115 characters = EoSDSHT.read(file) #TODO: modular
109 return characters 116 return characters
110 117
111 118
112 def get_anm_wrapper(self, names): 119 def get_anm_wrapper(self, names):