comparison clients/editor/scripts/mapview.py @ 324:e249fa887259

* Split EventListener into several internal subclasses. This fixes issue with multiple inheritance where each BaseClass.__init__() call would overwrite the previous one. This meant that you could only add EventListener to one type of event managers. * MapView now adds maps and layers to EventListener * LayerEditor should now fetch only NameClash exceptions when creating or editing layers
author cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
date Fri, 21 Aug 2009 14:39:54 +0000
parents 7ddec4ce99b3
children 8b125ec749d7
comparison
equal deleted inserted replaced
323:b64ce990abb1 324:e249fa887259
19 print "No map passed to MapView!" 19 print "No map passed to MapView!"
20 else: 20 else:
21 if not self._map.getLayers(): 21 if not self._map.getLayers():
22 raise AttributeError('Editor error: map ' + self._map.getId() + ' has no layers. Cannot edit.') 22 raise AttributeError('Editor error: map ' + self._map.getId() + ' has no layers. Cannot edit.')
23 23
24 map.addChangeListener(self._editor.getEventListener().mapchangelistener)
25 for layer in map.getLayers():
26 layer.addChangeListener(self._editor.getEventListener().layerchangelistener)
27
28 events.onLayerCreate.connect(self._layerCreated)
29
24 self.importlist = [] 30 self.importlist = []
25 if hasattr(map, "importDirs"): 31 if hasattr(map, "importDirs"):
26 self.importlist.extend(map.importDirs) 32 self.importlist.extend(map.importDirs)
33
34 def _layerCreated(self, map, layer):
35 if map.getId() == self._map.getId():
36 layer.addChangeListener(self._editor.getEventListener().layerchangelistener)
27 37
28 # Copied from mapeditor.py 38 # Copied from mapeditor.py
29 def show(self): 39 def show(self):
30 """ Sets up the camera to display the map. Size of the camera is equal to the 40 """ Sets up the camera to display the map. Size of the camera is equal to the
31 screen size """ 41 screen size """