annotate engine/python/fife/extensions/loaders.py @ 651:2851e232a113

* Modified the sound manager to better take care of sound clips. (Hope this fixes the crash at the end of the shooter demo)
author prock@33b003aa-7bff-0310-803a-e67f0ece8222
date Thu, 14 Oct 2010 15:52:43 +0000
parents b84dbc4665b0
children e3140f01749d
rev   line source
378
64738befdf3b bringing in the changes from the build_system_rework branch in preparation for the 0.3.0 release. This commit will require the Jan2010 devkit. Clients will also need to be modified to the new way to import fife.
vtchill@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
1 # -*- coding: utf-8 -*-
64738befdf3b bringing in the changes from the build_system_rework branch in preparation for the 0.3.0 release. This commit will require the Jan2010 devkit. Clients will also need to be modified to the new way to import fife.
vtchill@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
2
64738befdf3b bringing in the changes from the build_system_rework branch in preparation for the 0.3.0 release. This commit will require the Jan2010 devkit. Clients will also need to be modified to the new way to import fife.
vtchill@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
3 # ####################################################################
64738befdf3b bringing in the changes from the build_system_rework branch in preparation for the 0.3.0 release. This commit will require the Jan2010 devkit. Clients will also need to be modified to the new way to import fife.
vtchill@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
4 # Copyright (C) 2005-2009 by the FIFE team
64738befdf3b bringing in the changes from the build_system_rework branch in preparation for the 0.3.0 release. This commit will require the Jan2010 devkit. Clients will also need to be modified to the new way to import fife.
vtchill@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
5 # http://www.fifengine.de
64738befdf3b bringing in the changes from the build_system_rework branch in preparation for the 0.3.0 release. This commit will require the Jan2010 devkit. Clients will also need to be modified to the new way to import fife.
vtchill@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
6 # This file is part of FIFE.
64738befdf3b bringing in the changes from the build_system_rework branch in preparation for the 0.3.0 release. This commit will require the Jan2010 devkit. Clients will also need to be modified to the new way to import fife.
vtchill@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
7 #
64738befdf3b bringing in the changes from the build_system_rework branch in preparation for the 0.3.0 release. This commit will require the Jan2010 devkit. Clients will also need to be modified to the new way to import fife.
vtchill@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
8 # FIFE is free software; you can redistribute it and/or
64738befdf3b bringing in the changes from the build_system_rework branch in preparation for the 0.3.0 release. This commit will require the Jan2010 devkit. Clients will also need to be modified to the new way to import fife.
vtchill@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
9 # modify it under the terms of the GNU Lesser General Public
64738befdf3b bringing in the changes from the build_system_rework branch in preparation for the 0.3.0 release. This commit will require the Jan2010 devkit. Clients will also need to be modified to the new way to import fife.
vtchill@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
10 # License as published by the Free Software Foundation; either
64738befdf3b bringing in the changes from the build_system_rework branch in preparation for the 0.3.0 release. This commit will require the Jan2010 devkit. Clients will also need to be modified to the new way to import fife.
vtchill@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
11 # version 2.1 of the License, or (at your option) any later version.
64738befdf3b bringing in the changes from the build_system_rework branch in preparation for the 0.3.0 release. This commit will require the Jan2010 devkit. Clients will also need to be modified to the new way to import fife.
vtchill@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
12 #
64738befdf3b bringing in the changes from the build_system_rework branch in preparation for the 0.3.0 release. This commit will require the Jan2010 devkit. Clients will also need to be modified to the new way to import fife.
vtchill@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
13 # This library is distributed in the hope that it will be useful,
64738befdf3b bringing in the changes from the build_system_rework branch in preparation for the 0.3.0 release. This commit will require the Jan2010 devkit. Clients will also need to be modified to the new way to import fife.
vtchill@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
64738befdf3b bringing in the changes from the build_system_rework branch in preparation for the 0.3.0 release. This commit will require the Jan2010 devkit. Clients will also need to be modified to the new way to import fife.
vtchill@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
64738befdf3b bringing in the changes from the build_system_rework branch in preparation for the 0.3.0 release. This commit will require the Jan2010 devkit. Clients will also need to be modified to the new way to import fife.
vtchill@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
16 # Lesser General Public License for more details.
64738befdf3b bringing in the changes from the build_system_rework branch in preparation for the 0.3.0 release. This commit will require the Jan2010 devkit. Clients will also need to be modified to the new way to import fife.
vtchill@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
17 #
64738befdf3b bringing in the changes from the build_system_rework branch in preparation for the 0.3.0 release. This commit will require the Jan2010 devkit. Clients will also need to be modified to the new way to import fife.
vtchill@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
18 # You should have received a copy of the GNU Lesser General Public
64738befdf3b bringing in the changes from the build_system_rework branch in preparation for the 0.3.0 release. This commit will require the Jan2010 devkit. Clients will also need to be modified to the new way to import fife.
vtchill@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
19 # License along with this library; if not, write to the
64738befdf3b bringing in the changes from the build_system_rework branch in preparation for the 0.3.0 release. This commit will require the Jan2010 devkit. Clients will also need to be modified to the new way to import fife.
vtchill@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
20 # Free Software Foundation, Inc.,
64738befdf3b bringing in the changes from the build_system_rework branch in preparation for the 0.3.0 release. This commit will require the Jan2010 devkit. Clients will also need to be modified to the new way to import fife.
vtchill@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
21 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
64738befdf3b bringing in the changes from the build_system_rework branch in preparation for the 0.3.0 release. This commit will require the Jan2010 devkit. Clients will also need to be modified to the new way to import fife.
vtchill@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
22 # ####################################################################
64738befdf3b bringing in the changes from the build_system_rework branch in preparation for the 0.3.0 release. This commit will require the Jan2010 devkit. Clients will also need to be modified to the new way to import fife.
vtchill@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
23
64738befdf3b bringing in the changes from the build_system_rework branch in preparation for the 0.3.0 release. This commit will require the Jan2010 devkit. Clients will also need to be modified to the new way to import fife.
vtchill@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
24 # Loader interface for FIFE's native xml format.
64738befdf3b bringing in the changes from the build_system_rework branch in preparation for the 0.3.0 release. This commit will require the Jan2010 devkit. Clients will also need to be modified to the new way to import fife.
vtchill@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
25
644
b84dbc4665b0 loaders extension can now handle multiple loaders for different filetypes. A difference between map and object files is now being made!
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 585
diff changeset
26 import os.path
b84dbc4665b0 loaders extension can now handle multiple loaders for different filetypes. A difference between map and object files is now being made!
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 585
diff changeset
27
378
64738befdf3b bringing in the changes from the build_system_rework branch in preparation for the 0.3.0 release. This commit will require the Jan2010 devkit. Clients will also need to be modified to the new way to import fife.
vtchill@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
28 from fife import fife
64738befdf3b bringing in the changes from the build_system_rework branch in preparation for the 0.3.0 release. This commit will require the Jan2010 devkit. Clients will also need to be modified to the new way to import fife.
vtchill@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
29
64738befdf3b bringing in the changes from the build_system_rework branch in preparation for the 0.3.0 release. This commit will require the Jan2010 devkit. Clients will also need to be modified to the new way to import fife.
vtchill@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
30 from fife.extensions.serializers.xmlmap import XMLMapLoader
64738befdf3b bringing in the changes from the build_system_rework branch in preparation for the 0.3.0 release. This commit will require the Jan2010 devkit. Clients will also need to be modified to the new way to import fife.
vtchill@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
31 from fife.extensions.serializers import WrongFileType, NameClash
64738befdf3b bringing in the changes from the build_system_rework branch in preparation for the 0.3.0 release. This commit will require the Jan2010 devkit. Clients will also need to be modified to the new way to import fife.
vtchill@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
32
64738befdf3b bringing in the changes from the build_system_rework branch in preparation for the 0.3.0 release. This commit will require the Jan2010 devkit. Clients will also need to be modified to the new way to import fife.
vtchill@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
33 from fife.extensions.serializers.xmlobject import XMLObjectLoader
64738befdf3b bringing in the changes from the build_system_rework branch in preparation for the 0.3.0 release. This commit will require the Jan2010 devkit. Clients will also need to be modified to the new way to import fife.
vtchill@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
34
644
b84dbc4665b0 loaders extension can now handle multiple loaders for different filetypes. A difference between map and object files is now being made!
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 585
diff changeset
35 objectFileMapping = { 'xml' : XMLObjectLoader }
b84dbc4665b0 loaders extension can now handle multiple loaders for different filetypes. A difference between map and object files is now being made!
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 585
diff changeset
36 mapFileMapping = { 'xml' : XMLMapLoader}
378
64738befdf3b bringing in the changes from the build_system_rework branch in preparation for the 0.3.0 release. This commit will require the Jan2010 devkit. Clients will also need to be modified to the new way to import fife.
vtchill@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
37 fileExtensions = ('xml',)
644
b84dbc4665b0 loaders extension can now handle multiple loaders for different filetypes. A difference between map and object files is now being made!
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 585
diff changeset
38 mapFileExtensions = ('xml',)
378
64738befdf3b bringing in the changes from the build_system_rework branch in preparation for the 0.3.0 release. This commit will require the Jan2010 devkit. Clients will also need to be modified to the new way to import fife.
vtchill@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
39
585
c2de5aafe788 - added debug flag to loaders to enable/disable annoying print spam on maploading
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 378
diff changeset
40 def loadMapFile(path, engine, callback=None, debug=True):
378
64738befdf3b bringing in the changes from the build_system_rework branch in preparation for the 0.3.0 release. This commit will require the Jan2010 devkit. Clients will also need to be modified to the new way to import fife.
vtchill@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
41 """ load map file and get (an optional) callback if major stuff is done:
64738befdf3b bringing in the changes from the build_system_rework branch in preparation for the 0.3.0 release. This commit will require the Jan2010 devkit. Clients will also need to be modified to the new way to import fife.
vtchill@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
42 - map creation
64738befdf3b bringing in the changes from the build_system_rework branch in preparation for the 0.3.0 release. This commit will require the Jan2010 devkit. Clients will also need to be modified to the new way to import fife.
vtchill@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
43 - parsed imports
644
b84dbc4665b0 loaders extension can now handle multiple loaders for different filetypes. A difference between map and object files is now being made!
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 585
diff changeset
44 - parsed layers
378
64738befdf3b bringing in the changes from the build_system_rework branch in preparation for the 0.3.0 release. This commit will require the Jan2010 devkit. Clients will also need to be modified to the new way to import fife.
vtchill@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
45 - parsed cameras
64738befdf3b bringing in the changes from the build_system_rework branch in preparation for the 0.3.0 release. This commit will require the Jan2010 devkit. Clients will also need to be modified to the new way to import fife.
vtchill@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
46 the callback will send both a string and a float (which shows
64738befdf3b bringing in the changes from the build_system_rework branch in preparation for the 0.3.0 release. This commit will require the Jan2010 devkit. Clients will also need to be modified to the new way to import fife.
vtchill@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
47 the overall process), callback(string, float)
644
b84dbc4665b0 loaders extension can now handle multiple loaders for different filetypes. A difference between map and object files is now being made!
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 585
diff changeset
48
585
c2de5aafe788 - added debug flag to loaders to enable/disable annoying print spam on maploading
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 378
diff changeset
49 @type engine: object
c2de5aafe788 - added debug flag to loaders to enable/disable annoying print spam on maploading
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 378
diff changeset
50 @param engine: FIFE engine instance
c2de5aafe788 - added debug flag to loaders to enable/disable annoying print spam on maploading
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 378
diff changeset
51 @type callback: function
c2de5aafe788 - added debug flag to loaders to enable/disable annoying print spam on maploading
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 378
diff changeset
52 @param callback: callback for maploading progress
c2de5aafe788 - added debug flag to loaders to enable/disable annoying print spam on maploading
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 378
diff changeset
53 @type debug: bool
c2de5aafe788 - added debug flag to loaders to enable/disable annoying print spam on maploading
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 378
diff changeset
54 @param debug: flag to activate / deactivate print statements
644
b84dbc4665b0 loaders extension can now handle multiple loaders for different filetypes. A difference between map and object files is now being made!
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 585
diff changeset
55
585
c2de5aafe788 - added debug flag to loaders to enable/disable annoying print spam on maploading
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 378
diff changeset
56 @type map: object
c2de5aafe788 - added debug flag to loaders to enable/disable annoying print spam on maploading
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 378
diff changeset
57 @return map: FIFE map object
378
64738befdf3b bringing in the changes from the build_system_rework branch in preparation for the 0.3.0 release. This commit will require the Jan2010 devkit. Clients will also need to be modified to the new way to import fife.
vtchill@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
58 """
644
b84dbc4665b0 loaders extension can now handle multiple loaders for different filetypes. A difference between map and object files is now being made!
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 585
diff changeset
59 (filename, extension) = os.path.splitext(path)
b84dbc4665b0 loaders extension can now handle multiple loaders for different filetypes. A difference between map and object files is now being made!
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 585
diff changeset
60 map_loader = mapFileMapping[extension[1:]](engine, callback, debug)
378
64738befdf3b bringing in the changes from the build_system_rework branch in preparation for the 0.3.0 release. This commit will require the Jan2010 devkit. Clients will also need to be modified to the new way to import fife.
vtchill@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
61 map = map_loader.loadResource(fife.ResourceLocation(path))
585
c2de5aafe788 - added debug flag to loaders to enable/disable annoying print spam on maploading
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 378
diff changeset
62 if debug: print "--- Loading map took: ", map_loader.time_to_load, " seconds."
378
64738befdf3b bringing in the changes from the build_system_rework branch in preparation for the 0.3.0 release. This commit will require the Jan2010 devkit. Clients will also need to be modified to the new way to import fife.
vtchill@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
63 return map
64738befdf3b bringing in the changes from the build_system_rework branch in preparation for the 0.3.0 release. This commit will require the Jan2010 devkit. Clients will also need to be modified to the new way to import fife.
vtchill@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
64
64738befdf3b bringing in the changes from the build_system_rework branch in preparation for the 0.3.0 release. This commit will require the Jan2010 devkit. Clients will also need to be modified to the new way to import fife.
vtchill@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
65
585
c2de5aafe788 - added debug flag to loaders to enable/disable annoying print spam on maploading
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 378
diff changeset
66 def loadImportFile(path, engine, debug=False):
c2de5aafe788 - added debug flag to loaders to enable/disable annoying print spam on maploading
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 378
diff changeset
67 """ uses XMLObjectLoader to load import files from path
644
b84dbc4665b0 loaders extension can now handle multiple loaders for different filetypes. A difference between map and object files is now being made!
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 585
diff changeset
68
585
c2de5aafe788 - added debug flag to loaders to enable/disable annoying print spam on maploading
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 378
diff changeset
69 @type path: string
c2de5aafe788 - added debug flag to loaders to enable/disable annoying print spam on maploading
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 378
diff changeset
70 @param path: path to import file
c2de5aafe788 - added debug flag to loaders to enable/disable annoying print spam on maploading
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 378
diff changeset
71 @type engine: object
c2de5aafe788 - added debug flag to loaders to enable/disable annoying print spam on maploading
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 378
diff changeset
72 @param engine: FIFE engine instance
c2de5aafe788 - added debug flag to loaders to enable/disable annoying print spam on maploading
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 378
diff changeset
73 @type debug: bool
c2de5aafe788 - added debug flag to loaders to enable/disable annoying print spam on maploading
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 378
diff changeset
74 @param debug: flag to activate / deactivate print statements
c2de5aafe788 - added debug flag to loaders to enable/disable annoying print spam on maploading
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 378
diff changeset
75 """
644
b84dbc4665b0 loaders extension can now handle multiple loaders for different filetypes. A difference between map and object files is now being made!
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 585
diff changeset
76 (filename, extension) = os.path.splitext(path)
b84dbc4665b0 loaders extension can now handle multiple loaders for different filetypes. A difference between map and object files is now being made!
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 585
diff changeset
77 object_loader = objectFileMapping[extension[1:]](engine.getImagePool(), engine.getAnimationPool(), engine.getModel(), engine.getVFS())
378
64738befdf3b bringing in the changes from the build_system_rework branch in preparation for the 0.3.0 release. This commit will require the Jan2010 devkit. Clients will also need to be modified to the new way to import fife.
vtchill@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
78 res = None
64738befdf3b bringing in the changes from the build_system_rework branch in preparation for the 0.3.0 release. This commit will require the Jan2010 devkit. Clients will also need to be modified to the new way to import fife.
vtchill@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
79 try:
64738befdf3b bringing in the changes from the build_system_rework branch in preparation for the 0.3.0 release. This commit will require the Jan2010 devkit. Clients will also need to be modified to the new way to import fife.
vtchill@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
80 res = object_loader.loadResource(fife.ResourceLocation(path))
585
c2de5aafe788 - added debug flag to loaders to enable/disable annoying print spam on maploading
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 378
diff changeset
81 if debug: print 'imported object file ' + path
378
64738befdf3b bringing in the changes from the build_system_rework branch in preparation for the 0.3.0 release. This commit will require the Jan2010 devkit. Clients will also need to be modified to the new way to import fife.
vtchill@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
82 except WrongFileType:
64738befdf3b bringing in the changes from the build_system_rework branch in preparation for the 0.3.0 release. This commit will require the Jan2010 devkit. Clients will also need to be modified to the new way to import fife.
vtchill@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
83 pass
64738befdf3b bringing in the changes from the build_system_rework branch in preparation for the 0.3.0 release. This commit will require the Jan2010 devkit. Clients will also need to be modified to the new way to import fife.
vtchill@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
84 # print 'ignored non-object file ' + path
64738befdf3b bringing in the changes from the build_system_rework branch in preparation for the 0.3.0 release. This commit will require the Jan2010 devkit. Clients will also need to be modified to the new way to import fife.
vtchill@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
85 except NameClash:
64738befdf3b bringing in the changes from the build_system_rework branch in preparation for the 0.3.0 release. This commit will require the Jan2010 devkit. Clients will also need to be modified to the new way to import fife.
vtchill@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
86 pass
64738befdf3b bringing in the changes from the build_system_rework branch in preparation for the 0.3.0 release. This commit will require the Jan2010 devkit. Clients will also need to be modified to the new way to import fife.
vtchill@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
87 # print 'ignored already loaded file ' + path
64738befdf3b bringing in the changes from the build_system_rework branch in preparation for the 0.3.0 release. This commit will require the Jan2010 devkit. Clients will also need to be modified to the new way to import fife.
vtchill@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
88 return res
64738befdf3b bringing in the changes from the build_system_rework branch in preparation for the 0.3.0 release. This commit will require the Jan2010 devkit. Clients will also need to be modified to the new way to import fife.
vtchill@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
89
585
c2de5aafe788 - added debug flag to loaders to enable/disable annoying print spam on maploading
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 378
diff changeset
90 def loadImportDir(path, engine, debug=False):
c2de5aafe788 - added debug flag to loaders to enable/disable annoying print spam on maploading
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 378
diff changeset
91 """ helper function to call loadImportFile on a directory
644
b84dbc4665b0 loaders extension can now handle multiple loaders for different filetypes. A difference between map and object files is now being made!
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 585
diff changeset
92
585
c2de5aafe788 - added debug flag to loaders to enable/disable annoying print spam on maploading
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 378
diff changeset
93 @type path: string
c2de5aafe788 - added debug flag to loaders to enable/disable annoying print spam on maploading
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 378
diff changeset
94 @param path: path to import directory
c2de5aafe788 - added debug flag to loaders to enable/disable annoying print spam on maploading
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 378
diff changeset
95 @type engine: object
c2de5aafe788 - added debug flag to loaders to enable/disable annoying print spam on maploading
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 378
diff changeset
96 @param engine: FIFE engine instance
c2de5aafe788 - added debug flag to loaders to enable/disable annoying print spam on maploading
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 378
diff changeset
97 @type debug: bool
c2de5aafe788 - added debug flag to loaders to enable/disable annoying print spam on maploading
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 378
diff changeset
98 @param debug: flag to activate / deactivate print statements
c2de5aafe788 - added debug flag to loaders to enable/disable annoying print spam on maploading
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 378
diff changeset
99 """
378
64738befdf3b bringing in the changes from the build_system_rework branch in preparation for the 0.3.0 release. This commit will require the Jan2010 devkit. Clients will also need to be modified to the new way to import fife.
vtchill@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
100 for file in filter(lambda f: f.split('.')[-1] == 'xml', engine.getVFS().listFiles(path)):
585
c2de5aafe788 - added debug flag to loaders to enable/disable annoying print spam on maploading
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 378
diff changeset
101 loadImportFile('/'.join([path, file]), engine, debug)
c2de5aafe788 - added debug flag to loaders to enable/disable annoying print spam on maploading
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 378
diff changeset
102
c2de5aafe788 - added debug flag to loaders to enable/disable annoying print spam on maploading
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 378
diff changeset
103 def loadImportDirRec(path, engine, debug=False):
c2de5aafe788 - added debug flag to loaders to enable/disable annoying print spam on maploading
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 378
diff changeset
104 """ helper function to call loadImportFile recursive on a directory
378
64738befdf3b bringing in the changes from the build_system_rework branch in preparation for the 0.3.0 release. This commit will require the Jan2010 devkit. Clients will also need to be modified to the new way to import fife.
vtchill@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
105
585
c2de5aafe788 - added debug flag to loaders to enable/disable annoying print spam on maploading
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 378
diff changeset
106 @type path: string
c2de5aafe788 - added debug flag to loaders to enable/disable annoying print spam on maploading
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 378
diff changeset
107 @param path: path to import directory
c2de5aafe788 - added debug flag to loaders to enable/disable annoying print spam on maploading
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 378
diff changeset
108 @type engine: object
c2de5aafe788 - added debug flag to loaders to enable/disable annoying print spam on maploading
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 378
diff changeset
109 @param engine: FIFE engine instance
c2de5aafe788 - added debug flag to loaders to enable/disable annoying print spam on maploading
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 378
diff changeset
110 @type debug: bool
644
b84dbc4665b0 loaders extension can now handle multiple loaders for different filetypes. A difference between map and object files is now being made!
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 585
diff changeset
111 @param debug: flag to activate / deactivate print statements
585
c2de5aafe788 - added debug flag to loaders to enable/disable annoying print spam on maploading
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 378
diff changeset
112 """
c2de5aafe788 - added debug flag to loaders to enable/disable annoying print spam on maploading
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 378
diff changeset
113 loadImportDir(path, engine, debug)
378
64738befdf3b bringing in the changes from the build_system_rework branch in preparation for the 0.3.0 release. This commit will require the Jan2010 devkit. Clients will also need to be modified to the new way to import fife.
vtchill@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
114
64738befdf3b bringing in the changes from the build_system_rework branch in preparation for the 0.3.0 release. This commit will require the Jan2010 devkit. Clients will also need to be modified to the new way to import fife.
vtchill@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
115 for dir in filter(lambda d: not d.startswith('.'), engine.getVFS().listDirectories(path)):
585
c2de5aafe788 - added debug flag to loaders to enable/disable annoying print spam on maploading
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 378
diff changeset
116 loadImportDirRec('/'.join([path, dir]), engine, debug)
644
b84dbc4665b0 loaders extension can now handle multiple loaders for different filetypes. A difference between map and object files is now being made!
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 585
diff changeset
117
b84dbc4665b0 loaders extension can now handle multiple loaders for different filetypes. A difference between map and object files is now being made!
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 585
diff changeset
118
b84dbc4665b0 loaders extension can now handle multiple loaders for different filetypes. A difference between map and object files is now being made!
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 585
diff changeset
119 def addObjectFileLoader(fileExtension, loaderClass):
b84dbc4665b0 loaders extension can now handle multiple loaders for different filetypes. A difference between map and object files is now being made!
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 585
diff changeset
120 """Add a new loader for fileextension
b84dbc4665b0 loaders extension can now handle multiple loaders for different filetypes. A difference between map and object files is now being made!
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 585
diff changeset
121 @type fileExtension: string
b84dbc4665b0 loaders extension can now handle multiple loaders for different filetypes. A difference between map and object files is now being made!
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 585
diff changeset
122 @param fileExtension: The file extension the loader is registered for
b84dbc4665b0 loaders extension can now handle multiple loaders for different filetypes. A difference between map and object files is now being made!
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 585
diff changeset
123 @type loaderClass: object
b84dbc4665b0 loaders extension can now handle multiple loaders for different filetypes. A difference between map and object files is now being made!
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 585
diff changeset
124 @param loaderClass: A fife.ResourceLoader implementation that loads objects
b84dbc4665b0 loaders extension can now handle multiple loaders for different filetypes. A difference between map and object files is now being made!
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 585
diff changeset
125 from files with the given fileExtension
b84dbc4665b0 loaders extension can now handle multiple loaders for different filetypes. A difference between map and object files is now being made!
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 585
diff changeset
126 """
b84dbc4665b0 loaders extension can now handle multiple loaders for different filetypes. A difference between map and object files is now being made!
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 585
diff changeset
127 objectFileMapping[fileExtension] = loaderClass
b84dbc4665b0 loaders extension can now handle multiple loaders for different filetypes. A difference between map and object files is now being made!
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 585
diff changeset
128 _updateFileExtenions()
b84dbc4665b0 loaders extension can now handle multiple loaders for different filetypes. A difference between map and object files is now being made!
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 585
diff changeset
129
b84dbc4665b0 loaders extension can now handle multiple loaders for different filetypes. A difference between map and object files is now being made!
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 585
diff changeset
130
b84dbc4665b0 loaders extension can now handle multiple loaders for different filetypes. A difference between map and object files is now being made!
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 585
diff changeset
131 def addMapLoader(fileExtension, loaderClass):
b84dbc4665b0 loaders extension can now handle multiple loaders for different filetypes. A difference between map and object files is now being made!
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 585
diff changeset
132 """Add a new loader for fileextension
b84dbc4665b0 loaders extension can now handle multiple loaders for different filetypes. A difference between map and object files is now being made!
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 585
diff changeset
133 @type fileExtension: string
b84dbc4665b0 loaders extension can now handle multiple loaders for different filetypes. A difference between map and object files is now being made!
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 585
diff changeset
134 @param fileExtension: The file extension the loader is registered for
b84dbc4665b0 loaders extension can now handle multiple loaders for different filetypes. A difference between map and object files is now being made!
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 585
diff changeset
135 @type loaderClass: object
b84dbc4665b0 loaders extension can now handle multiple loaders for different filetypes. A difference between map and object files is now being made!
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 585
diff changeset
136 @param loaderClass: A fife.ResourceLoader implementation that loads maps
b84dbc4665b0 loaders extension can now handle multiple loaders for different filetypes. A difference between map and object files is now being made!
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 585
diff changeset
137 from files with the given fileExtension
b84dbc4665b0 loaders extension can now handle multiple loaders for different filetypes. A difference between map and object files is now being made!
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 585
diff changeset
138 """
b84dbc4665b0 loaders extension can now handle multiple loaders for different filetypes. A difference between map and object files is now being made!
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 585
diff changeset
139 mapFileMapping[fileExtension] = loaderClass
b84dbc4665b0 loaders extension can now handle multiple loaders for different filetypes. A difference between map and object files is now being made!
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 585
diff changeset
140 _updateMapFileExtensions()
b84dbc4665b0 loaders extension can now handle multiple loaders for different filetypes. A difference between map and object files is now being made!
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 585
diff changeset
141
b84dbc4665b0 loaders extension can now handle multiple loaders for different filetypes. A difference between map and object files is now being made!
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 585
diff changeset
142 def _updateFileExtensions():
b84dbc4665b0 loaders extension can now handle multiple loaders for different filetypes. A difference between map and object files is now being made!
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 585
diff changeset
143 fileExtensions = set(objectFileMapping.keys())
b84dbc4665b0 loaders extension can now handle multiple loaders for different filetypes. A difference between map and object files is now being made!
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 585
diff changeset
144
b84dbc4665b0 loaders extension can now handle multiple loaders for different filetypes. A difference between map and object files is now being made!
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 585
diff changeset
145 def _updateMapFileExtensions():
b84dbc4665b0 loaders extension can now handle multiple loaders for different filetypes. A difference between map and object files is now being made!
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 585
diff changeset
146 mapFileExtensions = set(mapFileMapping.keys())