Mercurial > fife-parpg
diff 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 |
line wrap: on
line diff
--- a/engine/extensions/loaders.py Sun Sep 28 11:12:36 2008 +0000 +++ b/engine/extensions/loaders.py Fri Oct 03 12:14:39 2008 +0000 @@ -6,14 +6,24 @@ from serializers.xmlmap import XMLMapLoader from serializers import WrongFileType, NameClash +from serializers.xmlobject import XMLObjectLoader + fileExtensions = ('xml',) -def loadMapFile(path, engine, content = ''): - map_loader = XMLMapLoader(engine) +def loadMapFile(path, engine, callback=None): + """ load map file and get (an optional) callback if major stuff is done: + - map creation + - parsed imports + - parsed layers + - parsed cameras + the callback will send both a string and a float (which shows + the overall process), callback(string, float) + + @return map : map object + """ + map_loader = XMLMapLoader(engine, callback) return map_loader.loadResource(fife.ResourceLocation(path)) -from serializers.xmlobject import XMLObjectLoader - def loadImportFile(path, engine): object_loader = XMLObjectLoader(engine.getImagePool(), engine.getAnimationPool(), engine.getModel(), engine.getVFS()) res = None