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

Revision 317, 2.1 KB checked in by barra_parpg, 10 years ago (diff)

Patch by sirren & mvbarracuda:

  • New player character animations
  • Changed PC object id to player for consistency reasons (agentxmlgen.py uses the folder name for the object id)
  • Renamed parpg-editor >> parpg_editor (use underscores as space characters!)
  • SVL eol-style >> native fixes
  • 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 is done:
30    - map creation
31    - parsed impor0ts
32    - parsed layers
33    - parsed cameras
34    the callback will send both a string and a float (which shows
35    the overall process), callback(string, float)
36   
37    Inputs:
38        path = filename for map
39        engine = FIFE engine
40        data = Engine object for PARPG data
41       
42    @return    map    : map object
43    """
44    map_loader = XMLMapLoader(engine, data, callback)
45    map = map_loader.loadResource(fife.ResourceLocation(path))
46    print "--- Loading map took: ", map_loader.time_to_load, " seconds."
47    return map
48
49def loadImportFile(path, engine):
50    object_loader = XMLObjectLoader(engine.getImagePool(), engine.getAnimationPool(), engine.getModel(), engine.getVFS())
51    res = None
52    try:
53        res = object_loader.loadResource(fife.ResourceLocation(path))
54        print 'imported object file ' + path
55    except WrongFileType:
56        pass
57#        print 'ignored non-object file ' + path
58    except NameClash:
59        pass
60#        print 'ignored already loaded file ' + path
61    return res
Note: See TracBrowser for help on using the repository browser.