source: trunk/game/local_loaders/loaders.py @ 328

Revision 328, 2.2 KB checked in by Kaydeth_parpg, 10 years ago (diff)

Ticket #2: Patch by Kaydeth. Updated the classes in local_loaders and utilities directories to correct some obvious discrepancies with our coding standard. comment[s:trac, t:2] fixes[s:trac, t:2]

  • Property svn:eol-style set to native
Line 
1#!/usr/bin/python
2
3#   This program is free software: you can redistribute it and/or modify
4#   it under the terms of the GNU General Public License as published by
5#   the Free Software Foundation, either version 3 of the License, or
6#   (at your option) any later version.
7
8#   This program is distributed in the hope that it will be useful,
9#   but WITHOUT ANY WARRANTY; without even the implied warranty of
10#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11#   GNU General Public License for more details.
12
13#   You should have received a copy of the GNU General Public License
14#   along with this program.  If not, see <http://www.gnu.org/licenses/>.
15
16# Most of this code was copied from the FIFE file loaders.py
17# It is part of the local code base now so we customize what happens as
18# we read map files
19import fife
20
21from xmlmap import XMLMapLoader
22from serializers import WrongFileType, NameClash
23
24from serializers.xmlobject import XMLObjectLoader
25
26fileExtensions = ('xml',)
27
28def loadMapFile(path, engine, data, callback=None):
29    """     load map file and get (an optional) callback if major stuff
30            is done:
31    - map creation
32    - parsed impor0ts
33    - parsed layers
34    - parsed cameras
35    the callback will send both a string and a float (which shows
36    the overall process), callback(string, float)
37   
38    Inputs:
39        path = filename for map
40        engine = FIFE engine
41        data = Engine object for PARPG data
42       
43    @return    map    : map object
44    """
45    map_loader = XMLMapLoader(engine, data, callback)
46    map = map_loader.loadResource(fife.ResourceLocation(path))
47    print "--- Loading map took: ", map_loader.time_to_load, " seconds."
48    return map
49
50def loadImportFile(path, engine):
51    object_loader = XMLObjectLoader(engine.getImagePool(), \
52                                    engine.getAnimationPool(), \
53                                    engine.getModel(), engine.getVFS())
54    res = None
55    try:
56        res = object_loader.loadResource(fife.ResourceLocation(path))
57        print 'imported object file ' + path
58    except WrongFileType:
59        pass
60#        print 'ignored non-object file ' + path
61    except NameClash:
62        pass
63#        print 'ignored already loaded file ' + path
64    return res
Note: See TracBrowser for help on using the repository browser.