Mercurial > fife-parpg
comparison engine/extensions/loaders.py @ 0:4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
author | mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222 |
---|---|
date | Sun, 29 Jun 2008 18:44:17 +0000 |
parents | |
children | ab09325f901e |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:4a0efb7baf70 |
---|---|
1 # coding: utf-8 | |
2 # Loader interface for FIFE's native xml format. | |
3 | |
4 import fife | |
5 | |
6 from serializers.xmlmap import XMLMapLoader | |
7 from serializers import WrongFileType, NameClash | |
8 | |
9 fileExtensions = ('xml',) | |
10 | |
11 def loadMapFile(path, engine, content = ''): | |
12 map_loader = XMLMapLoader(engine) | |
13 return map_loader.loadResource(fife.ResourceLocation(path)) | |
14 | |
15 from serializers.xmlobject import XMLObjectLoader | |
16 | |
17 def loadImportFile(path, engine): | |
18 object_loader = XMLObjectLoader(engine.getImagePool(), engine.getAnimationPool(), engine.getModel(), engine.getVFS()) | |
19 res = None | |
20 try: | |
21 res = object_loader.loadResource(fife.ResourceLocation(path)) | |
22 print 'imported object file ' + path | |
23 except WrongFileType: | |
24 print 'ignored non-object file ' + path | |
25 except NameClash: | |
26 print 'ignored already loaded file ' + path | |
27 return res | |
28 | |
29 def loadImportDir(path, engine): | |
30 for file in filter(lambda f: f.split('.')[-1] == 'xml', engine.getVFS().listFiles(path)): | |
31 loadImportFile('/'.join([path, file]), engine) | |
32 | |
33 def loadImportDirRec(path, engine): | |
34 loadImportDir(path, engine) | |
35 | |
36 for dir in filter(lambda d: not d.startswith('.'), engine.getVFS().listDirectories(path)): | |
37 loadImportDirRec('/'.join([path, dir]), engine) |