Mercurial > fife-parpg
comparison clients/editor/plugins/LayerTool.py @ 323:b64ce990abb1
LayerTool:
* Fixed bug where newly created layers wasn't rendered
* Added tool tips for buttons
author | cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222 |
---|---|
date | Tue, 18 Aug 2009 18:03:54 +0000 |
parents | 3853f8659598 |
children | e249fa887259 |
comparison
equal
deleted
inserted
replaced
322:3853f8659598 | 323:b64ce990abb1 |
---|---|
98 self.container = pychan.loadXML('gui/layertool.xml') | 98 self.container = pychan.loadXML('gui/layertool.xml') |
99 self.wrapper = self.container.findChild(name="layers_wrapper") | 99 self.wrapper = self.container.findChild(name="layers_wrapper") |
100 self.removeLayerButton = self.container.findChild(name="remove_layer_button") | 100 self.removeLayerButton = self.container.findChild(name="remove_layer_button") |
101 self.createLayerButton = self.container.findChild(name="add_layer_button") | 101 self.createLayerButton = self.container.findChild(name="add_layer_button") |
102 self.editLayerButton = self.container.findChild(name="edit_layer_button") | 102 self.editLayerButton = self.container.findChild(name="edit_layer_button") |
103 | |
103 self.removeLayerButton.capture(self.removeSelectedLayer) | 104 self.removeLayerButton.capture(self.removeSelectedLayer) |
105 self.removeLayerButton.capture(cbwa(self._editor.getStatusBar().showTooltip, self.removeLayerButton.helptext), 'mouseEntered') | |
106 self.removeLayerButton.capture(self._editor.getStatusBar().hideTooltip, 'mouseExited') | |
107 | |
104 self.createLayerButton.capture(self.showLayerWizard) | 108 self.createLayerButton.capture(self.showLayerWizard) |
109 self.createLayerButton.capture(cbwa(self._editor.getStatusBar().showTooltip, self.createLayerButton.helptext), 'mouseEntered') | |
110 self.createLayerButton.capture(self._editor.getStatusBar().hideTooltip, 'mouseExited') | |
111 | |
105 self.editLayerButton.capture(self.showEditDialog) | 112 self.editLayerButton.capture(self.showEditDialog) |
113 self.editLayerButton.capture(cbwa(self._editor.getStatusBar().showTooltip, self.editLayerButton.helptext), 'mouseEntered') | |
114 self.editLayerButton.capture(self._editor.getStatusBar().hideTooltip, 'mouseExited') | |
115 | |
106 self.update(None) | 116 self.update(None) |
107 | 117 |
108 def _adjust_position(self): | 118 def _adjust_position(self): |
109 """ adjusts the position of the container - we don't want to | 119 """ adjusts the position of the container - we don't want to |
110 let the window appear at the center of the screen. | 120 let the window appear at the center of the screen. |
150 | 160 |
151 def showLayerWizard(self): | 161 def showLayerWizard(self): |
152 if not self._mapview: return | 162 if not self._mapview: return |
153 | 163 |
154 if self._layer_wizard: self._layer_wizard._widget.hide() | 164 if self._layer_wizard: self._layer_wizard._widget.hide() |
155 self._layer_wizard = LayerEditor(self._editor.getEngine(), self._mapview.getMap(), callback=cbwa(self.update, self._mapview)) | 165 self._layer_wizard = LayerEditor(self._editor.getEngine(), self._mapview.getMap(), callback=self._layerCreated) |
166 | |
167 def _layerCreated(self, layer): | |
168 self.update(self._mapview) | |
169 self.select_active_layer(None, self.wrapper.findChild(name=_LABEL_NAME_PREFIX + layer.getId())) | |
156 | 170 |
157 def showEditDialog(self): | 171 def showEditDialog(self): |
158 if not self._mapview: return | 172 if not self._mapview: return |
159 layer = self.getActiveLayer() | 173 layer = self.getActiveLayer() |
160 if not layer: return | 174 if not layer: return |
427 cellgrid.setXShift(x_offset) | 441 cellgrid.setXShift(x_offset) |
428 cellgrid.setYShift(y_offset) | 442 cellgrid.setYShift(y_offset) |
429 | 443 |
430 try: | 444 try: |
431 layer = self.map.createLayer(str(layerId), cellgrid) | 445 layer = self.map.createLayer(str(layerId), cellgrid) |
446 | |
432 except: | 447 except: |
433 print 'The layer ' + str(layerId) + ' already exists!' | 448 print 'The layer ' + str(layerId) + ' already exists!' |
434 return | 449 return |
435 else: | 450 else: |
436 cellgrid = layer.getCellGrid() | 451 cellgrid = layer.getCellGrid() |
440 cellgrid.setXShift(x_offset) | 455 cellgrid.setXShift(x_offset) |
441 cellgrid.setYShift(y_offset) | 456 cellgrid.setYShift(y_offset) |
442 | 457 |
443 layer.setPathingStrategy(pathing) | 458 layer.setPathingStrategy(pathing) |
444 | 459 |
460 self.engine.getView().resetRenderers() | |
461 | |
445 # Hide dialog and call back | 462 # Hide dialog and call back |
446 self._widget.hide() | 463 self._widget.hide() |
447 | 464 |
448 if self.callback: | 465 if self.callback: |
449 self.callback() | 466 pychan.tools.applyOnlySuitable(self.callback, layer=layer) |
450 | 467 |