Mercurial > touhou
annotate pytouhou/resource/loader.py @ 297:a09ac4650e0d
Fix relative path handling and os-specific path separators.
author | Thibaut Girka <thib@sitedethib.com> |
---|---|
date | Tue, 06 Mar 2012 17:45:14 +0100 |
parents | 2100276c289d |
children | 92a6fd2632f1 |
rev | line source |
---|---|
285
2100276c289d
Document some AnmWrapper related functions.
Thibaut Girka <thib@sitedethib.com>
parents:
282
diff
changeset
|
1 # -*- encoding: utf-8 -*- |
2100276c289d
Document some AnmWrapper related functions.
Thibaut Girka <thib@sitedethib.com>
parents:
282
diff
changeset
|
2 ## |
2100276c289d
Document some AnmWrapper related functions.
Thibaut Girka <thib@sitedethib.com>
parents:
282
diff
changeset
|
3 ## Copyright (C) 2012 Thibaut Girka <thib@sitedethib.com> |
2100276c289d
Document some AnmWrapper related functions.
Thibaut Girka <thib@sitedethib.com>
parents:
282
diff
changeset
|
4 ## |
2100276c289d
Document some AnmWrapper related functions.
Thibaut Girka <thib@sitedethib.com>
parents:
282
diff
changeset
|
5 ## This program is free software; you can redistribute it and/or modify |
2100276c289d
Document some AnmWrapper related functions.
Thibaut Girka <thib@sitedethib.com>
parents:
282
diff
changeset
|
6 ## it under the terms of the GNU General Public License as published |
2100276c289d
Document some AnmWrapper related functions.
Thibaut Girka <thib@sitedethib.com>
parents:
282
diff
changeset
|
7 ## by the Free Software Foundation; version 3 only. |
2100276c289d
Document some AnmWrapper related functions.
Thibaut Girka <thib@sitedethib.com>
parents:
282
diff
changeset
|
8 ## |
2100276c289d
Document some AnmWrapper related functions.
Thibaut Girka <thib@sitedethib.com>
parents:
282
diff
changeset
|
9 ## This program is distributed in the hope that it will be useful, |
2100276c289d
Document some AnmWrapper related functions.
Thibaut Girka <thib@sitedethib.com>
parents:
282
diff
changeset
|
10 ## but WITHOUT ANY WARRANTY; without even the implied warranty of |
2100276c289d
Document some AnmWrapper related functions.
Thibaut Girka <thib@sitedethib.com>
parents:
282
diff
changeset
|
11 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
2100276c289d
Document some AnmWrapper related functions.
Thibaut Girka <thib@sitedethib.com>
parents:
282
diff
changeset
|
12 ## GNU General Public License for more details. |
2100276c289d
Document some AnmWrapper related functions.
Thibaut Girka <thib@sitedethib.com>
parents:
282
diff
changeset
|
13 ## |
2100276c289d
Document some AnmWrapper related functions.
Thibaut Girka <thib@sitedethib.com>
parents:
282
diff
changeset
|
14 |
231
c417bb6c98bf
Search for 102h.exe in the game directory instead of the current directory.
Thibaut Girka <thib@sitedethib.com>
parents:
229
diff
changeset
|
15 import os |
262
8fa660da5f0c
Automatically search data files using different names.
Thibaut Girka <thib@sitedethib.com>
parents:
231
diff
changeset
|
16 from glob import glob |
8fa660da5f0c
Automatically search data files using different names.
Thibaut Girka <thib@sitedethib.com>
parents:
231
diff
changeset
|
17 from itertools import chain |
97 | 18 from io import BytesIO |
19 | |
20 from pytouhou.formats.pbg3 import PBG3 | |
21 from pytouhou.formats.std import Stage | |
22 from pytouhou.formats.ecl import ECL | |
282
dbb1a86c0235
Rename Animations to ANM0 and prepare AnmWrapper for dialogs and interface.
Thibaut Girka <thib@sitedethib.com>
parents:
263
diff
changeset
|
23 from pytouhou.formats.anm0 import ANM0 |
133
2cad2e84a49e
Add reading support for the MSG format.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
97
diff
changeset
|
24 from pytouhou.formats.msg import MSG |
220
0595315d3880
Fix SHT handling; change a few things to be closer to ZUN’s mind; and first stub of PCB support.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
133
diff
changeset
|
25 from pytouhou.formats.sht import SHT |
229
5afc75f71fed
Add “SHT” support to EoSD, and do a little cleanup.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
220
diff
changeset
|
26 from pytouhou.formats.exe import SHT as EoSDSHT |
97 | 27 |
28 | |
29 from pytouhou.resource.anmwrapper import AnmWrapper | |
30 | |
31 | |
263
ac677dd0ffe0
Add support for reading from a directory instead of a PBG3 (for debugging purposes).
Thibaut Girka <thib@sitedethib.com>
parents:
262
diff
changeset
|
32 class Directory(object): |
ac677dd0ffe0
Add support for reading from a directory instead of a PBG3 (for debugging purposes).
Thibaut Girka <thib@sitedethib.com>
parents:
262
diff
changeset
|
33 def __init__(self, path): |
ac677dd0ffe0
Add support for reading from a directory instead of a PBG3 (for debugging purposes).
Thibaut Girka <thib@sitedethib.com>
parents:
262
diff
changeset
|
34 self.path = path |
ac677dd0ffe0
Add support for reading from a directory instead of a PBG3 (for debugging purposes).
Thibaut Girka <thib@sitedethib.com>
parents:
262
diff
changeset
|
35 |
ac677dd0ffe0
Add support for reading from a directory instead of a PBG3 (for debugging purposes).
Thibaut Girka <thib@sitedethib.com>
parents:
262
diff
changeset
|
36 |
ac677dd0ffe0
Add support for reading from a directory instead of a PBG3 (for debugging purposes).
Thibaut Girka <thib@sitedethib.com>
parents:
262
diff
changeset
|
37 def __enter__(self): |
ac677dd0ffe0
Add support for reading from a directory instead of a PBG3 (for debugging purposes).
Thibaut Girka <thib@sitedethib.com>
parents:
262
diff
changeset
|
38 return self |
ac677dd0ffe0
Add support for reading from a directory instead of a PBG3 (for debugging purposes).
Thibaut Girka <thib@sitedethib.com>
parents:
262
diff
changeset
|
39 |
ac677dd0ffe0
Add support for reading from a directory instead of a PBG3 (for debugging purposes).
Thibaut Girka <thib@sitedethib.com>
parents:
262
diff
changeset
|
40 |
ac677dd0ffe0
Add support for reading from a directory instead of a PBG3 (for debugging purposes).
Thibaut Girka <thib@sitedethib.com>
parents:
262
diff
changeset
|
41 def __exit__(self, type, value, traceback): |
ac677dd0ffe0
Add support for reading from a directory instead of a PBG3 (for debugging purposes).
Thibaut Girka <thib@sitedethib.com>
parents:
262
diff
changeset
|
42 return False |
ac677dd0ffe0
Add support for reading from a directory instead of a PBG3 (for debugging purposes).
Thibaut Girka <thib@sitedethib.com>
parents:
262
diff
changeset
|
43 |
ac677dd0ffe0
Add support for reading from a directory instead of a PBG3 (for debugging purposes).
Thibaut Girka <thib@sitedethib.com>
parents:
262
diff
changeset
|
44 |
ac677dd0ffe0
Add support for reading from a directory instead of a PBG3 (for debugging purposes).
Thibaut Girka <thib@sitedethib.com>
parents:
262
diff
changeset
|
45 def list_files(self): |
ac677dd0ffe0
Add support for reading from a directory instead of a PBG3 (for debugging purposes).
Thibaut Girka <thib@sitedethib.com>
parents:
262
diff
changeset
|
46 file_list = [] |
ac677dd0ffe0
Add support for reading from a directory instead of a PBG3 (for debugging purposes).
Thibaut Girka <thib@sitedethib.com>
parents:
262
diff
changeset
|
47 for path in os.listdir(self.path): |
ac677dd0ffe0
Add support for reading from a directory instead of a PBG3 (for debugging purposes).
Thibaut Girka <thib@sitedethib.com>
parents:
262
diff
changeset
|
48 if os.path.isfile(os.path.join(self.path, path)): |
ac677dd0ffe0
Add support for reading from a directory instead of a PBG3 (for debugging purposes).
Thibaut Girka <thib@sitedethib.com>
parents:
262
diff
changeset
|
49 file_list.append(path) |
ac677dd0ffe0
Add support for reading from a directory instead of a PBG3 (for debugging purposes).
Thibaut Girka <thib@sitedethib.com>
parents:
262
diff
changeset
|
50 return file_list |
ac677dd0ffe0
Add support for reading from a directory instead of a PBG3 (for debugging purposes).
Thibaut Girka <thib@sitedethib.com>
parents:
262
diff
changeset
|
51 |
ac677dd0ffe0
Add support for reading from a directory instead of a PBG3 (for debugging purposes).
Thibaut Girka <thib@sitedethib.com>
parents:
262
diff
changeset
|
52 |
ac677dd0ffe0
Add support for reading from a directory instead of a PBG3 (for debugging purposes).
Thibaut Girka <thib@sitedethib.com>
parents:
262
diff
changeset
|
53 def extract(self, name): |
ac677dd0ffe0
Add support for reading from a directory instead of a PBG3 (for debugging purposes).
Thibaut Girka <thib@sitedethib.com>
parents:
262
diff
changeset
|
54 with open(os.path.join(self.path, str(name)), 'rb') as file: |
ac677dd0ffe0
Add support for reading from a directory instead of a PBG3 (for debugging purposes).
Thibaut Girka <thib@sitedethib.com>
parents:
262
diff
changeset
|
55 contents = file.read() |
ac677dd0ffe0
Add support for reading from a directory instead of a PBG3 (for debugging purposes).
Thibaut Girka <thib@sitedethib.com>
parents:
262
diff
changeset
|
56 return contents |
ac677dd0ffe0
Add support for reading from a directory instead of a PBG3 (for debugging purposes).
Thibaut Girka <thib@sitedethib.com>
parents:
262
diff
changeset
|
57 |
ac677dd0ffe0
Add support for reading from a directory instead of a PBG3 (for debugging purposes).
Thibaut Girka <thib@sitedethib.com>
parents:
262
diff
changeset
|
58 |
ac677dd0ffe0
Add support for reading from a directory instead of a PBG3 (for debugging purposes).
Thibaut Girka <thib@sitedethib.com>
parents:
262
diff
changeset
|
59 |
97 | 60 class ArchiveDescription(object): |
61 _formats = {'PBG3': PBG3} | |
62 | |
63 def __init__(self, path, format_class, file_list=None): | |
64 self.path = path | |
65 self.format_class = format_class | |
66 self.file_list = file_list or [] | |
67 | |
68 | |
69 def open(self): | |
263
ac677dd0ffe0
Add support for reading from a directory instead of a PBG3 (for debugging purposes).
Thibaut Girka <thib@sitedethib.com>
parents:
262
diff
changeset
|
70 if self.format_class is Directory: |
ac677dd0ffe0
Add support for reading from a directory instead of a PBG3 (for debugging purposes).
Thibaut Girka <thib@sitedethib.com>
parents:
262
diff
changeset
|
71 return self.format_class(self.path) |
ac677dd0ffe0
Add support for reading from a directory instead of a PBG3 (for debugging purposes).
Thibaut Girka <thib@sitedethib.com>
parents:
262
diff
changeset
|
72 |
97 | 73 file = open(self.path, 'rb') |
74 instance = self.format_class.read(file) | |
75 return instance | |
76 | |
77 | |
78 @classmethod | |
79 def get_from_path(cls, path): | |
263
ac677dd0ffe0
Add support for reading from a directory instead of a PBG3 (for debugging purposes).
Thibaut Girka <thib@sitedethib.com>
parents:
262
diff
changeset
|
80 if os.path.isdir(path): |
ac677dd0ffe0
Add support for reading from a directory instead of a PBG3 (for debugging purposes).
Thibaut Girka <thib@sitedethib.com>
parents:
262
diff
changeset
|
81 instance = Directory(path) |
ac677dd0ffe0
Add support for reading from a directory instead of a PBG3 (for debugging purposes).
Thibaut Girka <thib@sitedethib.com>
parents:
262
diff
changeset
|
82 file_list = instance.list_files() |
ac677dd0ffe0
Add support for reading from a directory instead of a PBG3 (for debugging purposes).
Thibaut Girka <thib@sitedethib.com>
parents:
262
diff
changeset
|
83 return cls(path, Directory, file_list) |
97 | 84 with open(path, 'rb') as file: |
85 magic = file.read(4) | |
86 file.seek(0) | |
87 format_class = cls._formats[magic] | |
88 instance = format_class.read(file) | |
89 file_list = instance.list_files() | |
90 return cls(path, format_class, file_list) | |
91 | |
92 | |
93 | |
94 class Loader(object): | |
231
c417bb6c98bf
Search for 102h.exe in the game directory instead of the current directory.
Thibaut Girka <thib@sitedethib.com>
parents:
229
diff
changeset
|
95 def __init__(self, game_dir=None): |
262
8fa660da5f0c
Automatically search data files using different names.
Thibaut Girka <thib@sitedethib.com>
parents:
231
diff
changeset
|
96 self.exe = None |
231
c417bb6c98bf
Search for 102h.exe in the game directory instead of the current directory.
Thibaut Girka <thib@sitedethib.com>
parents:
229
diff
changeset
|
97 self.game_dir = game_dir |
97 | 98 self.known_files = {} |
99 self.instanced_ecls = {} | |
100 self.instanced_anms = {} | |
101 self.instanced_stages = {} | |
133
2cad2e84a49e
Add reading support for the MSG format.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
97
diff
changeset
|
102 self.instanced_msgs = {} |
220
0595315d3880
Fix SHT handling; change a few things to be closer to ZUN’s mind; and first stub of PCB support.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
133
diff
changeset
|
103 self.instanced_shts = {} |
97 | 104 |
105 | |
262
8fa660da5f0c
Automatically search data files using different names.
Thibaut Girka <thib@sitedethib.com>
parents:
231
diff
changeset
|
106 def scan_archives(self, paths_lists): |
8fa660da5f0c
Automatically search data files using different names.
Thibaut Girka <thib@sitedethib.com>
parents:
231
diff
changeset
|
107 for paths in paths_lists: |
8fa660da5f0c
Automatically search data files using different names.
Thibaut Girka <thib@sitedethib.com>
parents:
231
diff
changeset
|
108 def _expand_paths(): |
297
a09ac4650e0d
Fix relative path handling and os-specific path separators.
Thibaut Girka <thib@sitedethib.com>
parents:
285
diff
changeset
|
109 for path in paths.split(os.path.pathsep): |
262
8fa660da5f0c
Automatically search data files using different names.
Thibaut Girka <thib@sitedethib.com>
parents:
231
diff
changeset
|
110 if self.game_dir and not os.path.isabs(path): |
8fa660da5f0c
Automatically search data files using different names.
Thibaut Girka <thib@sitedethib.com>
parents:
231
diff
changeset
|
111 path = os.path.join(self.game_dir, path) |
8fa660da5f0c
Automatically search data files using different names.
Thibaut Girka <thib@sitedethib.com>
parents:
231
diff
changeset
|
112 yield glob(path) |
8fa660da5f0c
Automatically search data files using different names.
Thibaut Girka <thib@sitedethib.com>
parents:
231
diff
changeset
|
113 paths = list(chain(*_expand_paths())) |
8fa660da5f0c
Automatically search data files using different names.
Thibaut Girka <thib@sitedethib.com>
parents:
231
diff
changeset
|
114 path = paths[0] |
8fa660da5f0c
Automatically search data files using different names.
Thibaut Girka <thib@sitedethib.com>
parents:
231
diff
changeset
|
115 if os.path.splitext(path)[1] == '.exe': |
8fa660da5f0c
Automatically search data files using different names.
Thibaut Girka <thib@sitedethib.com>
parents:
231
diff
changeset
|
116 self.exe = path |
8fa660da5f0c
Automatically search data files using different names.
Thibaut Girka <thib@sitedethib.com>
parents:
231
diff
changeset
|
117 else: |
8fa660da5f0c
Automatically search data files using different names.
Thibaut Girka <thib@sitedethib.com>
parents:
231
diff
changeset
|
118 archive_description = ArchiveDescription.get_from_path(path) |
8fa660da5f0c
Automatically search data files using different names.
Thibaut Girka <thib@sitedethib.com>
parents:
231
diff
changeset
|
119 for name in archive_description.file_list: |
8fa660da5f0c
Automatically search data files using different names.
Thibaut Girka <thib@sitedethib.com>
parents:
231
diff
changeset
|
120 self.known_files[name] = archive_description |
97 | 121 |
122 | |
123 def get_file_data(self, name): | |
124 with self.known_files[name].open() as archive: | |
125 content = archive.extract(name) | |
126 return content | |
127 | |
128 | |
129 def get_file(self, name): | |
130 with self.known_files[name].open() as archive: | |
131 content = archive.extract(name) | |
132 return BytesIO(content) | |
133 | |
134 | |
135 def get_anm(self, name): | |
136 if name not in self.instanced_anms: | |
137 file = self.get_file(name) | |
282
dbb1a86c0235
Rename Animations to ANM0 and prepare AnmWrapper for dialogs and interface.
Thibaut Girka <thib@sitedethib.com>
parents:
263
diff
changeset
|
138 self.instanced_anms[name] = ANM0.read(file) #TODO: modular |
97 | 139 return self.instanced_anms[name] |
140 | |
141 | |
142 def get_stage(self, name): | |
143 if name not in self.instanced_stages: | |
144 file = self.get_file(name) | |
145 self.instanced_stages[name] = Stage.read(file) #TODO: modular | |
146 return self.instanced_stages[name] | |
147 | |
148 | |
149 def get_ecl(self, name): | |
150 if name not in self.instanced_ecls: | |
151 file = self.get_file(name) | |
152 self.instanced_ecls[name] = ECL.read(file) #TODO: modular | |
153 return self.instanced_ecls[name] | |
154 | |
155 | |
133
2cad2e84a49e
Add reading support for the MSG format.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
97
diff
changeset
|
156 def get_msg(self, name): |
2cad2e84a49e
Add reading support for the MSG format.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
97
diff
changeset
|
157 if name not in self.instanced_msgs: |
2cad2e84a49e
Add reading support for the MSG format.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
97
diff
changeset
|
158 file = self.get_file(name) |
2cad2e84a49e
Add reading support for the MSG format.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
97
diff
changeset
|
159 self.instanced_msgs[name] = MSG.read(file) #TODO: modular |
2cad2e84a49e
Add reading support for the MSG format.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
97
diff
changeset
|
160 return self.instanced_msgs[name] |
2cad2e84a49e
Add reading support for the MSG format.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
97
diff
changeset
|
161 |
2cad2e84a49e
Add reading support for the MSG format.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
97
diff
changeset
|
162 |
220
0595315d3880
Fix SHT handling; change a few things to be closer to ZUN’s mind; and first stub of PCB support.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
133
diff
changeset
|
163 def get_sht(self, name): |
0595315d3880
Fix SHT handling; change a few things to be closer to ZUN’s mind; and first stub of PCB support.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
133
diff
changeset
|
164 if name not in self.instanced_shts: |
0595315d3880
Fix SHT handling; change a few things to be closer to ZUN’s mind; and first stub of PCB support.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
133
diff
changeset
|
165 file = self.get_file(name) |
0595315d3880
Fix SHT handling; change a few things to be closer to ZUN’s mind; and first stub of PCB support.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
133
diff
changeset
|
166 self.instanced_shts[name] = SHT.read(file) #TODO: modular |
0595315d3880
Fix SHT handling; change a few things to be closer to ZUN’s mind; and first stub of PCB support.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
133
diff
changeset
|
167 return self.instanced_shts[name] |
0595315d3880
Fix SHT handling; change a few things to be closer to ZUN’s mind; and first stub of PCB support.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
133
diff
changeset
|
168 |
0595315d3880
Fix SHT handling; change a few things to be closer to ZUN’s mind; and first stub of PCB support.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
133
diff
changeset
|
169 |
262
8fa660da5f0c
Automatically search data files using different names.
Thibaut Girka <thib@sitedethib.com>
parents:
231
diff
changeset
|
170 def get_eosd_characters(self): |
231
c417bb6c98bf
Search for 102h.exe in the game directory instead of the current directory.
Thibaut Girka <thib@sitedethib.com>
parents:
229
diff
changeset
|
171 #TODO: Move to pytouhou.games.eosd? |
262
8fa660da5f0c
Automatically search data files using different names.
Thibaut Girka <thib@sitedethib.com>
parents:
231
diff
changeset
|
172 path = self.exe |
231
c417bb6c98bf
Search for 102h.exe in the game directory instead of the current directory.
Thibaut Girka <thib@sitedethib.com>
parents:
229
diff
changeset
|
173 with open(path, 'rb') as file: |
229
5afc75f71fed
Add “SHT” support to EoSD, and do a little cleanup.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
220
diff
changeset
|
174 characters = EoSDSHT.read(file) #TODO: modular |
5afc75f71fed
Add “SHT” support to EoSD, and do a little cleanup.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
220
diff
changeset
|
175 return characters |
5afc75f71fed
Add “SHT” support to EoSD, and do a little cleanup.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
220
diff
changeset
|
176 |
5afc75f71fed
Add “SHT” support to EoSD, and do a little cleanup.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
220
diff
changeset
|
177 |
285
2100276c289d
Document some AnmWrapper related functions.
Thibaut Girka <thib@sitedethib.com>
parents:
282
diff
changeset
|
178 def get_anm_wrapper(self, names, offsets=None): |
2100276c289d
Document some AnmWrapper related functions.
Thibaut Girka <thib@sitedethib.com>
parents:
282
diff
changeset
|
179 """Create an AnmWrapper for ANM files “names”. |
2100276c289d
Document some AnmWrapper related functions.
Thibaut Girka <thib@sitedethib.com>
parents:
282
diff
changeset
|
180 |
2100276c289d
Document some AnmWrapper related functions.
Thibaut Girka <thib@sitedethib.com>
parents:
282
diff
changeset
|
181 If one of the files “names” does not exist or is not a valid ANM file, |
2100276c289d
Document some AnmWrapper related functions.
Thibaut Girka <thib@sitedethib.com>
parents:
282
diff
changeset
|
182 raises an exception. |
2100276c289d
Document some AnmWrapper related functions.
Thibaut Girka <thib@sitedethib.com>
parents:
282
diff
changeset
|
183 """ |
282
dbb1a86c0235
Rename Animations to ANM0 and prepare AnmWrapper for dialogs and interface.
Thibaut Girka <thib@sitedethib.com>
parents:
263
diff
changeset
|
184 return AnmWrapper((self.get_anm(name) for name in names), offsets) |
97 | 185 |
186 | |
285
2100276c289d
Document some AnmWrapper related functions.
Thibaut Girka <thib@sitedethib.com>
parents:
282
diff
changeset
|
187 def get_anm_wrapper2(self, names, offsets=None): |
2100276c289d
Document some AnmWrapper related functions.
Thibaut Girka <thib@sitedethib.com>
parents:
282
diff
changeset
|
188 """Create an AnmWrapper for ANM files “names”. |
2100276c289d
Document some AnmWrapper related functions.
Thibaut Girka <thib@sitedethib.com>
parents:
282
diff
changeset
|
189 |
2100276c289d
Document some AnmWrapper related functions.
Thibaut Girka <thib@sitedethib.com>
parents:
282
diff
changeset
|
190 Stop at the first non-existent or invalid ANM file if there is one, |
2100276c289d
Document some AnmWrapper related functions.
Thibaut Girka <thib@sitedethib.com>
parents:
282
diff
changeset
|
191 and return an AnmWrapper for all the previous correct files. |
2100276c289d
Document some AnmWrapper related functions.
Thibaut Girka <thib@sitedethib.com>
parents:
282
diff
changeset
|
192 """ |
282
dbb1a86c0235
Rename Animations to ANM0 and prepare AnmWrapper for dialogs and interface.
Thibaut Girka <thib@sitedethib.com>
parents:
263
diff
changeset
|
193 anms = [] |
dbb1a86c0235
Rename Animations to ANM0 and prepare AnmWrapper for dialogs and interface.
Thibaut Girka <thib@sitedethib.com>
parents:
263
diff
changeset
|
194 |
97 | 195 try: |
196 for name in names: | |
282
dbb1a86c0235
Rename Animations to ANM0 and prepare AnmWrapper for dialogs and interface.
Thibaut Girka <thib@sitedethib.com>
parents:
263
diff
changeset
|
197 anms.append(self.get_anm(name)) |
97 | 198 except KeyError: |
199 pass | |
200 | |
282
dbb1a86c0235
Rename Animations to ANM0 and prepare AnmWrapper for dialogs and interface.
Thibaut Girka <thib@sitedethib.com>
parents:
263
diff
changeset
|
201 return AnmWrapper(anms, offsets) |
97 | 202 |