comparison engine/extensions/loaders.py @ 141:5e85737281bc

- some modification to loaders and serializers/xmlmap, now you can set a callback which informs you about finished parts of the maploading process - this can be used to prepare other parts of your client (e. g. load ingame gui) or to show a maploading progress bar USAGE (example): - map = loadMapFile(mapfile, engine, my_callback) - def mycallback(msg, percent): print msg; print percent
author chewie@33b003aa-7bff-0310-803a-e67f0ece8222
date Fri, 03 Oct 2008 12:14:39 +0000
parents ab09325f901e
children e7a431577c95
comparison
equal deleted inserted replaced
140:3fddb45c0304 141:5e85737281bc
4 import fife 4 import fife
5 5
6 from serializers.xmlmap import XMLMapLoader 6 from serializers.xmlmap import XMLMapLoader
7 from serializers import WrongFileType, NameClash 7 from serializers import WrongFileType, NameClash
8 8
9 from serializers.xmlobject import XMLObjectLoader
10
9 fileExtensions = ('xml',) 11 fileExtensions = ('xml',)
10 12
11 def loadMapFile(path, engine, content = ''): 13 def loadMapFile(path, engine, callback=None):
12 map_loader = XMLMapLoader(engine) 14 """ load map file and get (an optional) callback if major stuff is done:
15 - map creation
16 - parsed imports
17 - parsed layers
18 - parsed cameras
19 the callback will send both a string and a float (which shows
20 the overall process), callback(string, float)
21
22 @return map : map object
23 """
24 map_loader = XMLMapLoader(engine, callback)
13 return map_loader.loadResource(fife.ResourceLocation(path)) 25 return map_loader.loadResource(fife.ResourceLocation(path))
14
15 from serializers.xmlobject import XMLObjectLoader
16 26
17 def loadImportFile(path, engine): 27 def loadImportFile(path, engine):
18 object_loader = XMLObjectLoader(engine.getImagePool(), engine.getAnimationPool(), engine.getModel(), engine.getVFS()) 28 object_loader = XMLObjectLoader(engine.getImagePool(), engine.getAnimationPool(), engine.getModel(), engine.getVFS())
19 res = None 29 res = None
20 try: 30 try: