# HG changeset patch # User cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222 # Date 1258938709 0 # Node ID 22222a9007510d717fd077645dbf62617610bfeb # Parent 91e352f81f630e22b64ed68e05de897cdd5cd38c Editor: * New event signal: layerSelected * Grid and blocking info will only be rendered for the active layer diff -r 91e352f81f63 -r 22222a900751 clients/editor/scripts/events/events.py --- a/clients/editor/scripts/events/events.py Sat Nov 21 15:15:55 2009 +0000 +++ b/clients/editor/scripts/events/events.py Mon Nov 23 01:11:49 2009 +0000 @@ -37,6 +37,7 @@ onInstancesSelected = Signal(providing_args=["instances"]) onObjectSelected = Signal(providing_args=["object"]) onObjectsImported = Signal(providing_args=[]) +layerSelected = Signal(providing_args=["mapcontroller", "layer"]) # Signals emitted by EventListener onQuit = Signal(providing_args=[]) diff -r 91e352f81f63 -r 22222a900751 clients/editor/scripts/gui/mapeditor.py --- a/clients/editor/scripts/gui/mapeditor.py Sat Nov 21 15:15:55 2009 +0000 +++ b/clients/editor/scripts/gui/mapeditor.py Mon Nov 23 01:11:49 2009 +0000 @@ -93,6 +93,7 @@ events.mouseWheelMovedUp.connect(self.mouseWheelMovedUp) events.mouseWheelMovedDown.connect(self.mouseWheelMovedDown) events.onPump.connect(self.pump) + events.layerSelected.connect(self._layerSelected) def _clear(self): self._clearToolbarButtons() @@ -109,6 +110,7 @@ events.mouseWheelMovedUp.disconnect(self.mouseWheelMovedUp) events.mouseWheelMovedDown.disconnect(self.mouseWheelMovedDown) events.onPump.disconnect(self.pump) + events.layerSelected.disconnect(self._layerSelected) def _mapChanged(self, sender, mapview): self.setController(mapview.getController()) @@ -156,6 +158,18 @@ cursor = self._editor.getEngine().getCursor() cursor.set(fife.CURSOR_NATIVE, fife.NC_ARROW) + def _layerSelected(self, sender, mapcontroller, layer): + gridrenderer = self._controller._camera.getRenderer('GridRenderer') + gridrenderer.clearActiveLayers() + if layer is not None: + gridrenderer.addActiveLayer(self._controller.getLayer()) + + blockrenderer = self._controller._camera.getRenderer('BlockingInfoRenderer') + blockrenderer.clearActiveLayers() + if layer is not None: + blockrenderer.addActiveLayer(self._controller.getLayer()) + + def setObject(self, object): self._object = object @@ -512,6 +526,9 @@ elif keystr == 't': gridrenderer = self._controller._camera.getRenderer('GridRenderer') gridrenderer.setEnabled(not gridrenderer.isEnabled()) + gridrenderer.clearActiveLayers() + if self._controller.getLayer() is not None: + gridrenderer.addActiveLayer(self._controller.getLayer()) elif keystr == 'b': blockrenderer = self._controller._camera.getRenderer('BlockingInfoRenderer') diff -r 91e352f81f63 -r 22222a900751 clients/editor/scripts/mapcontroller.py --- a/clients/editor/scripts/mapcontroller.py Sat Nov 21 15:15:55 2009 +0000 +++ b/clients/editor/scripts/mapcontroller.py Mon Nov 23 01:11:49 2009 +0000 @@ -96,6 +96,11 @@ layers = [l for l in self._map.getLayers() if l.getId() == layerid] if len(layers) == 1: self._layer = layers[0] + events.layerSelected.send(sender=self, layer=layers[0], mapcontroller=self) + + def getLayer(self): + """ Returns active layer """ + return self._layer def deselectSelection(self): """ Deselects all selected cells """