Mercurial > fife-parpg
view clients/editor/plugins/maploader.py @ 144:d2f1e81fbe2c
* Fixed a scons issue, where libraries checked for C instead of C++
* Fixed a shutdown order problem - deleting a GLImage will reference the RenderBackend, thus image pools must be deleted first.
* Added an explicit Engine.destroy method to force the shutdown, in case python fails to do so. Necessary - see above.
* The Pool::printStatistics now gives out information how many resources are loaded. Called before destruction. Add 'pool' to the LogModules to check memory pooling issues.
author | phoku@33b003aa-7bff-0310-803a-e67f0ece8222 |
---|---|
date | Thu, 09 Oct 2008 06:18:36 +0000 |
parents | 816b17db2bec |
children |
line wrap: on
line source
#!/usr/bin/env python # coding: utf-8 # Plugin for the editor. See fifedit.py. MapLoader presents a directory browser for finding and loading xml maps. import plugin import filebrowser import loaders, savers from loaders import loadMapFile from savers import saveMapFile class MapLoader(plugin.Plugin): def __init__(self, engine): super(MapLoader,self).__init__() self.engine = engine self.filebrowser = filebrowser.FileBrowser(engine,self.loadFile, extensions = loaders.fileExtensions) self.menu_items = { 'Load' : self.filebrowser.showBrowser, } self.newMap = None def loadFile(self, path, filename): content = path.split('/') print content self.newMap = loadMapFile('/'.join([path, filename]), self.engine) class MapSaver(plugin.Plugin): def __init__(self, engine): super(MapSaver,self).__init__() self.engine = engine self.filebrowser = filebrowser.FileBrowser(engine,self._selectFile,savefile=True, extensions = savers.fileExtensions) self.menu_items = { 'Save' : self.save, 'Save As' : self.filebrowser.showBrowser, } self.saveRequested = False self._location = None self.path = '.' def save(self): self.saveRequested = True def saveMap(self, map, importList): curname = None try: curname = map.getResourceLocation().getFilename() except RuntimeError: pass # no name set for map yet if self._location: fname = '/'.join([self.path, self._location]) saveMapFile(fname, self.engine, map, importList) print "map saved as " + fname self._location = None elif curname: saveMapFile(curname, self.engine, map, importList) print "map saved with old name " + curname else: print 'MapSaver: error, no file location specified.' def _selectFile(self,path,filename): self._location = filename self.path = path self.saveRequested = True