1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23 """ Loaders plugin manager """
24 from __future__ import print_function
25
26 import os.path
27
28 from fife import fife
29 from fife.extensions.serializers.xmlmap import XMLMapLoader
30
31 mapFileMapping = { 'xml' : XMLMapLoader}
32 fileExtensions = set(['xml'])
33
34 -def loadMapFile(path, engine, callback=None, debug=True, extensions={}):
35 """ load map file and get (an optional) callback if major stuff is done:
36
37 - map creation
38 - parsed imports
39 - parsed layers
40 - parsed cameras
41
42 the callback will send both a string and a float (which shows
43 the overall process), callback(string, float)
44
45 @type engine: object
46 @param engine: FIFE engine instance
47 @type callback: function
48 @param callback: callback for maploading progress
49 @type debug: bool
50 @param debug: flag to activate / deactivate print statements
51 @rtype object
52 @return FIFE map object
53 """
54 (filename, extension) = os.path.splitext(path)
55 map_loader = mapFileMapping[extension[1:]](engine, callback, debug, extensions)
56 map = map_loader.loadResource(path)
57 if debug: print("--- Loading map took: ", map_loader.time_to_load, " seconds.")
58 return map
59
61 """Add a new loader for fileextension
62 @type fileExtension: string
63 @param fileExtension: The file extension the loader is registered for
64 @type loaderClass: object
65 @param loaderClass: A fife.ResourceLoader implementation that loads maps
66 from files with the given fileExtension
67 """
68 mapFileMapping[fileExtension] = loaderClass
69 _updateMapFileExtensions()
70
74