comparison clients/editor/plugins/mapeditor.py @ 192:bec4b69ad83a

* Redid the editor's ObjectSelector to display previews for all objects instead of only 1 preview + paths/filenames * ImageButton now takes GuiImage's as argument for up/down/hover image, like icon does. * Tab cleanup
author nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
date Sat, 28 Feb 2009 22:33:21 +0000
parents fcef34d67ad9
children 9b50a2702054
comparison
equal deleted inserted replaced
191:c725ecb2ce4c 192:bec4b69ad83a
58 class Toolbar(object): 58 class Toolbar(object):
59 def __init__(self, onSelect, onMove, onInsert, onDelete, onBtnEnter, onBtnExit): 59 def __init__(self, onSelect, onMove, onInsert, onDelete, onBtnEnter, onBtnExit):
60 self._onSelect, self._onMove, self._onInsert, self._onDelete = onSelect, onMove, onInsert, onDelete 60 self._onSelect, self._onMove, self._onInsert, self._onDelete = onSelect, onMove, onInsert, onDelete
61 self.onBtnEnter, self.onBtnExit = onBtnEnter, onBtnExit 61 self.onBtnEnter, self.onBtnExit = onBtnEnter, onBtnExit
62 self._toolbar = None 62 self._toolbar = None
63 63
64 def show(self): 64 def show(self):
65 if not self._toolbar: 65 if not self._toolbar:
66 self._toolbar = pychan.loadXML('gui/tools.xml') 66 self._toolbar = pychan.loadXML('gui/tools.xml')
67 evtmap = { 67 evtmap = {
68 'btnSelect' : self._onSelect, 68 'btnSelect' : self._onSelect,
73 self._toolbar.mapEvents(evtmap) 73 self._toolbar.mapEvents(evtmap)
74 for k in evtmap.keys(): 74 for k in evtmap.keys():
75 btn = self._toolbar.findChild(name=k) 75 btn = self._toolbar.findChild(name=k)
76 btn.setEnterCallback(self.onBtnEnter) 76 btn.setEnterCallback(self.onBtnEnter)
77 btn.setExitCallback(self.onBtnExit) 77 btn.setExitCallback(self.onBtnExit)
78 78
79 #self._toolbar.adaptLayout() 79 #self._toolbar.adaptLayout()
80 self._toolbar.show() 80 self._toolbar.show()
81 self._toolbar.x = 10 81 self._toolbar.x = 10
82 self._toolbar.y = 50 82 self._toolbar.y = 50
83 83
84 def hide(self): 84 def hide(self):
85 self._toolbar.hide() 85 self._toolbar.hide()
86 86
87 def _enableBtn(self, enabled, btn): 87 def _enableBtn(self, enabled, btn):
88 btn.toggled = enabled; 88 btn.toggled = enabled;
89 89
90 def enableSelect(self, enabled): 90 def enableSelect(self, enabled):
91 self._enableBtn(enabled, self._toolbar.findChild(name='btnSelect')) 91 self._enableBtn(enabled, self._toolbar.findChild(name='btnSelect'))
102 def disableAll(self): 102 def disableAll(self):
103 self.enableDelete(False) 103 self.enableDelete(False)
104 self.enableSelect(False) 104 self.enableSelect(False)
105 self.enableInsert(False) 105 self.enableInsert(False)
106 self.enableMove(False) 106 self.enableMove(False)
107 107
108 class StatusBar(object): 108 class StatusBar(object):
109 def __init__(self, screenw, screenh): 109 def __init__(self, screenw, screenh):
110 self._statusbar = pychan.loadXML('gui/statuspanel.xml') 110 self._statusbar = pychan.loadXML('gui/statuspanel.xml')
111 self._statusbar.show() 111 self._statusbar.show()
112 height = 25 112 height = 25
117 117
118 def setStatus(self, msg): 118 def setStatus(self, msg):
119 self.statustxt = msg 119 self.statustxt = msg
120 self.lbl.text = ' ' + msg 120 self.lbl.text = ' ' + msg
121 self.lbl.resizeToContent() 121 self.lbl.resizeToContent()
122 122
123 def showTooltip(self, elem): 123 def showTooltip(self, elem):
124 self.lbl.text = elem.helptext 124 self.lbl.text = elem.helptext
125 self.lbl.resizeToContent() 125 self.lbl.resizeToContent()
126 126
127 def hideTooltip(self, elem): 127 def hideTooltip(self, elem):
158 self._altdown = False 158 self._altdown = False
159 self._dragx = NOT_INITIALIZED 159 self._dragx = NOT_INITIALIZED
160 self._dragy = NOT_INITIALIZED 160 self._dragy = NOT_INITIALIZED
161 self._scrollx = 0 161 self._scrollx = 0
162 self._scrolly = 0 162 self._scrolly = 0
163 163
164 self._mapselector = MapSelection(self._selectLayer, self._selectObject) 164 self._mapselector = MapSelection(self._selectLayer, self._selectObject)
165 self._objectselector = None 165 self._objectselector = None
166 rb = self._engine.getRenderBackend() 166 rb = self._engine.getRenderBackend()
167 self._statusbar = StatusBar(rb.getWidth(), rb.getHeight()) 167 self._statusbar = StatusBar(rb.getWidth(), rb.getHeight())
168 self._toolbar = Toolbar(cbwa(self._setMode, VIEWING), cbwa(self._setMode, MOVING), 168 self._toolbar = Toolbar(cbwa(self._setMode, VIEWING), cbwa(self._setMode, MOVING),
176 176
177 def _assert(self, statement, msg): 177 def _assert(self, statement, msg):
178 if not statement: 178 if not statement:
179 print msg 179 print msg
180 raise EditorLogicError(msg) 180 raise EditorLogicError(msg)
181 181
182 def _setMode(self, mode): 182 def _setMode(self, mode):
183 if (mode != NOTHING_LOADED) and (not self._camera): 183 if (mode != NOTHING_LOADED) and (not self._camera):
184 self._statusbar.setStatus('Please load map first') 184 self._statusbar.setStatus('Please load map first')
185 self._toolbar.disableAll() 185 self._toolbar.disableAll()
186 return 186 return
187 if (mode == INSERTING) and (not self._object): 187 if (mode == INSERTING) and (not self._object):
188 self._statusbar.setStatus('Please select object first') 188 self._statusbar.setStatus('Please select object first')
189 mode = self._mode 189 mode = self._mode
190 190
191 # Update toolbox buttons 191 # Update toolbox buttons
192 if (mode == INSERTING): 192 if (mode == INSERTING):
193 self._toolbar.enableInsert(True) 193 self._toolbar.enableInsert(True)
194 elif mode == VIEWING: 194 elif mode == VIEWING:
195 self._toolbar.enableSelect(True) 195 self._toolbar.enableSelect(True)
197 self._toolbar.enableDelete(True) 197 self._toolbar.enableDelete(True)
198 elif mode == MOVING: 198 elif mode == MOVING:
199 self._toolbar.enableMove(True) 199 self._toolbar.enableMove(True)
200 else: 200 else:
201 self._toolbar.disableAll() 201 self._toolbar.disableAll()
202 202
203 self._mode = mode 203 self._mode = mode
204 print "Entered mode " + mode 204 print "Entered mode " + mode
205 self._statusbar.setStatus(mode.replace('_', ' ').capitalize()) 205 self._statusbar.setStatus(mode.replace('_', ' ').capitalize())
206 206
207 # gui for selecting a map 207 # gui for selecting a map
208 def _selectMap(self): 208 def _selectMap(self):
209 Selection([map.getId() for map in self._engine.getModel().getMaps()], self.editMap) 209 Selection([map.getId() for map in self._engine.getModel().getMaps()], self.editMap)
210 210
211 def _selectDefaultCamera(self, map): 211 def _selectDefaultCamera(self, map):
212 self._camera = None 212 self._camera = None
213 213
214 self._engine.getView().resetRenderers() 214 self._engine.getView().resetRenderers()
215 for cam in self._engine.getView().getCameras(): 215 for cam in self._engine.getView().getCameras():
216 cam.setEnabled(False) 216 cam.setEnabled(False)
217 217
218 for cam in self._engine.getView().getCameras(): 218 for cam in self._engine.getView().getCameras():
219 if cam.getLocationRef().getMap().getId() == map.getId(): 219 if cam.getLocationRef().getMap().getId() == map.getId():
220 rb = self._engine.getRenderBackend() 220 rb = self._engine.getRenderBackend()
221 cam.setViewPort(fife.Rect(0, 0, rb.getScreenWidth(), rb.getScreenHeight())) 221 cam.setViewPort(fife.Rect(0, 0, rb.getScreenWidth(), rb.getScreenHeight()))
222 cam.setEnabled(True) 222 cam.setEnabled(True)
231 self._layer = None 231 self._layer = None
232 self._object = None 232 self._object = None
233 self._selection = None 233 self._selection = None
234 self._instances = None 234 self._instances = None
235 self._setMode(NOTHING_LOADED) 235 self._setMode(NOTHING_LOADED)
236 236
237 self._map = self._engine.getModel().getMap(mapid) 237 self._map = self._engine.getModel().getMap(mapid)
238 if not self._map.getLayers(): 238 if not self._map.getLayers():
239 raise AttributeError('Editor error: map ' + self._map.getId() + ' has no layers. Cannot edit.') 239 raise AttributeError('Editor error: map ' + self._map.getId() + ' has no layers. Cannot edit.')
240 240
241 self._layer = self._map.getLayers()[0] 241 self._layer = self._map.getLayers()[0]
242 self._selectDefaultCamera(self._map) 242 self._selectDefaultCamera(self._map)
243 self._setMode(VIEWING) 243 self._setMode(VIEWING)
244 244
245 self._mapselector.show(self._map) 245 self._mapselector.show(self._map)
246 246
247 # zero-projekt plugin 247 # zero-projekt plugin
248 if self.layertool is not None: 248 if self.layertool is not None:
249 self.layertool.update() 249 self.layertool.update()
250 250
251 def _selectLayer(self): 251 def _selectLayer(self):
252 Selection([layer.getId() for layer in self._map.getLayers()], self._editLayer) 252 Selection([layer.getId() for layer in self._map.getLayers()], self._editLayer)
253 253
254 def _editLayer(self, layerid): 254 def _editLayer(self, layerid):
255 self._layer = None 255 self._layer = None
265 def _editObject(self, object): 265 def _editObject(self, object):
266 self._object = object 266 self._object = object
267 267
268 def _selectCell(self, screenx, screeny, preciseCoords=False): 268 def _selectCell(self, screenx, screeny, preciseCoords=False):
269 self._assert(self._camera, 'No camera bind yet, cannot select any cell') 269 self._assert(self._camera, 'No camera bind yet, cannot select any cell')
270 270
271 self._selection = self._camera.toMapCoordinates(fife.ScreenPoint(screenx, screeny), False) 271 self._selection = self._camera.toMapCoordinates(fife.ScreenPoint(screenx, screeny), False)
272 self._selection.z = 0 272 self._selection.z = 0
273 loc = fife.Location(self._layer) 273 loc = fife.Location(self._layer)
274 if preciseCoords: 274 if preciseCoords:
275 self._selection = self._layer.getCellGrid().toExactLayerCoordinates(self._selection) 275 self._selection = self._layer.getCellGrid().toExactLayerCoordinates(self._selection)
282 282
283 def _getInstancesFromPosition(self, position, top_only): 283 def _getInstancesFromPosition(self, position, top_only):
284 self._assert(self._layer, 'No layer assigned in _getInstancesFromPosition') 284 self._assert(self._layer, 'No layer assigned in _getInstancesFromPosition')
285 self._assert(position, 'No position assigned in _getInstancesFromPosition') 285 self._assert(position, 'No position assigned in _getInstancesFromPosition')
286 self._assert(self._camera, 'No camera assigned in _getInstancesFromPosition') 286 self._assert(self._camera, 'No camera assigned in _getInstancesFromPosition')
287 287
288 loc = fife.Location(self._layer) 288 loc = fife.Location(self._layer)
289 if type(position) == fife.ExactModelCoordinate: 289 if type(position) == fife.ExactModelCoordinate:
290 loc.setExactLayerCoordinates(position) 290 loc.setExactLayerCoordinates(position)
291 else: 291 else:
292 loc.setLayerCoordinates(position) 292 loc.setLayerCoordinates(position)
299 if self._undoStack != []: 299 if self._undoStack != []:
300 # execute inverse of last action 300 # execute inverse of last action
301 self._undo = True 301 self._undo = True
302 self._undoStack.pop()() 302 self._undoStack.pop()()
303 self._undo = False 303 self._undo = False
304 304
305 def _placeInstance(self,position,object): 305 def _placeInstance(self,position,object):
306 mname = '_placeInstance' 306 mname = '_placeInstance'
307 self._assert(object, 'No object assigned in %s' % mname) 307 self._assert(object, 'No object assigned in %s' % mname)
308 self._assert(position, 'No position assigned in %s' % mname) 308 self._assert(position, 'No position assigned in %s' % mname)
309 self._assert(self._layer, 'No layer assigned in %s' % mname) 309 self._assert(self._layer, 'No layer assigned in %s' % mname)
310 310
311 print 'Placing instance of ' + object.getId() + ' at ' + str(position) 311 print 'Placing instance of ' + object.getId() + ' at ' + str(position)
312 print object 312 print object
313 313
314 # don't place repeat instances 314 # don't place repeat instances
315 for i in self._getInstancesFromPosition(position, False): 315 for i in self._getInstancesFromPosition(position, False):
316 if i.getObject().getId() == object.getId(): 316 if i.getObject().getId() == object.getId():
317 print 'Warning: attempt to place duplicate instance of object %s. Ignoring request.' % object.getId() 317 print 'Warning: attempt to place duplicate instance of object %s. Ignoring request.' % object.getId()
318 return 318 return
333 print '>>> ' + i.getObject().getId() 333 print '>>> ' + i.getObject().getId()
334 print '>>> ' + str(i.getObject()) 334 print '>>> ' + str(i.getObject())
335 object = i.getObject() 335 object = i.getObject()
336 self._undoStack.append(lambda: self._placeInstance(position,object)) 336 self._undoStack.append(lambda: self._placeInstance(position,object))
337 self._layer.deleteInstance(i) 337 self._layer.deleteInstance(i)
338 338
339 def _moveInstances(self): 339 def _moveInstances(self):
340 mname = '_moveInstances' 340 mname = '_moveInstances'
341 self._assert(self._selection, 'No selection assigned in %s' % mname) 341 self._assert(self._selection, 'No selection assigned in %s' % mname)
342 self._assert(self._layer, 'No layer assigned in %s' % mname) 342 self._assert(self._layer, 'No layer assigned in %s' % mname)
343 self._assert(self._mode == MOVING, 'Mode is not MOVING in %s (is instead %s)' % (mname, str(self._mode))) 343 self._assert(self._mode == MOVING, 'Mode is not MOVING in %s (is instead %s)' % (mname, str(self._mode)))
344 344
345 loc = fife.Location(self._layer) 345 loc = fife.Location(self._layer)
346 if self._shiftdown: 346 if self._shiftdown:
347 loc.setExactLayerCoordinates(self._selection) 347 loc.setExactLayerCoordinates(self._selection)
348 else: 348 else:
349 loc.setLayerCoordinates(self._selection) 349 loc.setLayerCoordinates(self._selection)
350 for i in self._instances: 350 for i in self._instances:
351 f = fife.Location(self._layer) 351 f = fife.Location(self._layer)
352 f.setExactLayerCoordinates(i.getFacingLocation().getExactLayerCoordinates() + fife.ExactModelCoordinate(float(self._selection.x), float(self._selection.y)) - i.getLocation().getExactLayerCoordinates()) 352 f.setExactLayerCoordinates(i.getFacingLocation().getExactLayerCoordinates() + fife.ExactModelCoordinate(float(self._selection.x), float(self._selection.y)) - i.getLocation().getExactLayerCoordinates())
353 i.setLocation(loc) 353 i.setLocation(loc)
354 i.setFacingLocation(f) 354 i.setFacingLocation(f)
355 355
356 def _rotateInstances(self): 356 def _rotateInstances(self):
357 mname = '_rotateInstances' 357 mname = '_rotateInstances'
358 self._assert(self._selection, 'No selection assigned in %s' % mname) 358 self._assert(self._selection, 'No selection assigned in %s' % mname)
359 self._assert(self._layer, 'No layer assigned in %s' % mname) 359 self._assert(self._layer, 'No layer assigned in %s' % mname)
360 360
361 for i in self._getInstancesFromPosition(self._selection, top_only=True): 361 for i in self._getInstancesFromPosition(self._selection, top_only=True):
362 # by c 09/11/08 362 # by c 09/11/08
363 # FIXME: 363 # FIXME:
364 # "hardcoded" rotation is bad for offset editing 364 # "hardcoded" rotation is bad for offset editing
365 # instead we should use the angle list given from the object 365 # instead we should use the angle list given from the object
379 elif index == length: 379 elif index == length:
380 index = 0 380 index = 0
381 else: 381 else:
382 index = 0 382 index = 0
383 # print "index, new: ", index 383 # print "index, new: ", index
384 384
385 i.setRotation( int(self._objectedit_rotations[index]) ) 385 i.setRotation( int(self._objectedit_rotations[index]) )
386 # print "new rotation: ", self._objectedit_rotations[index] 386 # print "new rotation: ", self._objectedit_rotations[index]
387 except: 387 except:
388 # Fallback 388 # Fallback
389 i.setRotation((i.getRotation() + 90) % 360) 389 i.setRotation((i.getRotation() + 90) % 360)
390 390
391 # end FIXME 391 # end FIXME
392 # end edit c 392 # end edit c
393 393
394 ## Surprisingly, the following "snap-to-rotation" code is actually incorrect. Object 394 ## Surprisingly, the following "snap-to-rotation" code is actually incorrect. Object
395 ## rotation is independent of the camera, whereas the choice of an actual rotation image 395 ## rotation is independent of the camera, whereas the choice of an actual rotation image
413 # print "rotation not supported for this instance" 413 # print "rotation not supported for this instance"
414 414
415 def changeRotation(self): 415 def changeRotation(self):
416 currot = self._camera.getRotation() 416 currot = self._camera.getRotation()
417 self._camera.setRotation((currot + 90) % 360) 417 self._camera.setRotation((currot + 90) % 360)
418 418
419 def _moveCamera(self, screen_x, screen_y): 419 def _moveCamera(self, screen_x, screen_y):
420 coords = self._camera.getLocationRef().getMapCoordinates() 420 coords = self._camera.getLocationRef().getMapCoordinates()
421 z = self._camera.getZoom() 421 z = self._camera.getZoom()
422 r = self._camera.getRotation() 422 r = self._camera.getRotation()
423 if screen_x: 423 if screen_x:
426 if screen_y: 426 if screen_y:
427 coords.x -= screen_y / z * math.sin(-r / 180.0 * math.pi) / 100; 427 coords.x -= screen_y / z * math.sin(-r / 180.0 * math.pi) / 100;
428 coords.y -= screen_y / z * math.cos(-r / 180.0 * math.pi) / 100; 428 coords.y -= screen_y / z * math.cos(-r / 180.0 * math.pi) / 100;
429 coords = self._camera.getLocationRef().setMapCoordinates(coords) 429 coords = self._camera.getLocationRef().setMapCoordinates(coords)
430 self._camera.refresh() 430 self._camera.refresh()
431 431
432 def mousePressed(self, evt): 432 def mousePressed(self, evt):
433 if evt.isConsumedByWidgets(): 433 if evt.isConsumedByWidgets():
434 return 434 return
435 435
436 if self._ctrldown: 436 if self._ctrldown:
437 if evt.getButton() == fife.MouseEvent.LEFT: 437 if evt.getButton() == fife.MouseEvent.LEFT:
438 self._dragx = evt.getX() 438 self._dragx = evt.getX()
439 self._dragy = evt.getY() 439 self._dragy = evt.getY()
440 else: 440 else:
448 self._removeInstances(self._selection) 448 self._removeInstances(self._selection)
449 elif self._mode == MOVING: 449 elif self._mode == MOVING:
450 self._instances = self._getInstancesFromPosition(self._selection, top_only=True) 450 self._instances = self._getInstancesFromPosition(self._selection, top_only=True)
451 else: 451 else:
452 self._setMode(self._mode) # refresh status 452 self._setMode(self._mode) # refresh status
453 453
454 def mouseDragged(self, evt): 454 def mouseDragged(self, evt):
455 if evt.isConsumedByWidgets(): 455 if evt.isConsumedByWidgets():
456 return 456 return
457 457
458 if self._ctrldown: 458 if self._ctrldown:
459 if (self._dragx != NOT_INITIALIZED) and (self._dragy != NOT_INITIALIZED): 459 if (self._dragx != NOT_INITIALIZED) and (self._dragy != NOT_INITIALIZED):
460 self._moveCamera(evt.getX() - self._dragx, evt.getY() - self._dragy) 460 self._moveCamera(evt.getX() - self._dragx, evt.getY() - self._dragy)
461 self._dragx = evt.getX() 461 self._dragx = evt.getX()
462 self._dragy = evt.getY() 462 self._dragy = evt.getY()
472 self._moveInstances() 472 self._moveInstances()
473 473
474 def mouseReleased(self, evt): 474 def mouseReleased(self, evt):
475 if evt.isConsumedByWidgets(): 475 if evt.isConsumedByWidgets():
476 return 476 return
477 477
478 self._dragx = NOT_INITIALIZED 478 self._dragx = NOT_INITIALIZED
479 self._dragy = NOT_INITIALIZED 479 self._dragy = NOT_INITIALIZED
480 480
481 def mouseMoved(self, evt): 481 def mouseMoved(self, evt):
482 if self._camera: 482 if self._camera:
483 screen_x = self._engine.getRenderBackend().getWidth() 483 screen_x = self._engine.getRenderBackend().getWidth()
484 screen_y = self._engine.getRenderBackend().getHeight() 484 screen_y = self._engine.getRenderBackend().getHeight()
485 ratio = float(screen_x) / screen_y 485 ratio = float(screen_x) / screen_y
507 pass 507 pass
508 def mouseExited(self, evt): 508 def mouseExited(self, evt):
509 pass 509 pass
510 def mouseClicked(self, evt): 510 def mouseClicked(self, evt):
511 pass 511 pass
512 512
513 def mouseWheelMovedUp(self, evt): 513 def mouseWheelMovedUp(self, evt):
514 if self._ctrldown and self._camera: 514 if self._ctrldown and self._camera:
515 self._camera.setZoom(self._camera.getZoom() * 1.05) 515 self._camera.setZoom(self._camera.getZoom() * 1.05)
516 516
517 def mouseWheelMovedDown(self, evt): 517 def mouseWheelMovedDown(self, evt):
518 if self._ctrldown and self._camera: 518 if self._ctrldown and self._camera:
519 self._camera.setZoom(self._camera.getZoom() / 1.05) 519 self._camera.setZoom(self._camera.getZoom() / 1.05)
520 520
521 521
522 def keyPressed(self, evt): 522 def keyPressed(self, evt):
523 keyval = evt.getKey().getValue() 523 keyval = evt.getKey().getValue()
524 keystr = evt.getKey().getAsString().lower() 524 keystr = evt.getKey().getAsString().lower()
525 525
526 if keyval == fife.Key.LEFT: 526 if keyval == fife.Key.LEFT:
527 self._moveCamera(50, 0) 527 self._moveCamera(50, 0)
528 elif keyval == fife.Key.RIGHT: 528 elif keyval == fife.Key.RIGHT:
529 self._moveCamera(-50, 0) 529 self._moveCamera(-50, 0)
530 elif keyval == fife.Key.UP: 530 elif keyval == fife.Key.UP:
535 self._ctrldown = True 535 self._ctrldown = True
536 elif keyval in (fife.Key.LEFT_SHIFT, fife.Key.RIGHT_SHIFT): 536 elif keyval in (fife.Key.LEFT_SHIFT, fife.Key.RIGHT_SHIFT):
537 self._shiftdown = True 537 self._shiftdown = True
538 elif keyval in (fife.Key.LEFT_ALT, fife.Key.RIGHT_ALT): 538 elif keyval in (fife.Key.LEFT_ALT, fife.Key.RIGHT_ALT):
539 self._altdown = True 539 self._altdown = True
540 540
541 elif keyval == fife.Key.INSERT: 541 elif keyval == fife.Key.INSERT:
542 if self._mode != INSERTING: 542 if self._mode != INSERTING:
543 self._setMode(INSERTING) 543 self._setMode(INSERTING)
544 else: 544 else:
545 self._setMode(VIEWING) 545 self._setMode(VIEWING)
547 elif keyval == fife.Key.DELETE: 547 elif keyval == fife.Key.DELETE:
548 if self._mode != REMOVING: 548 if self._mode != REMOVING:
549 self._setMode(REMOVING) 549 self._setMode(REMOVING)
550 else: 550 else:
551 self._setMode(VIEWING) 551 self._setMode(VIEWING)
552 552
553 elif keystr == 'm': 553 elif keystr == 'm':
554 if self._mode != MOVING: 554 if self._mode != MOVING:
555 self._setMode(MOVING) 555 self._setMode(MOVING)
556 else: 556 else:
557 self._setMode(VIEWING) 557 self._setMode(VIEWING)
558 558
559 elif keystr == 't': 559 elif keystr == 't':
560 gridrenderer = self._camera.getRenderer('GridRenderer') 560 gridrenderer = self._camera.getRenderer('GridRenderer')
561 gridrenderer.setEnabled(not gridrenderer.isEnabled()) 561 gridrenderer.setEnabled(not gridrenderer.isEnabled())
562 562
563 elif keystr == 'b': 563 elif keystr == 'b':
564 blockrenderer = self._camera.getRenderer('BlockingInfoRenderer') 564 blockrenderer = self._camera.getRenderer('BlockingInfoRenderer')
565 blockrenderer.setEnabled(not blockrenderer.isEnabled()) 565 blockrenderer.setEnabled(not blockrenderer.isEnabled())
566 566
567 elif keystr == 'r': 567 elif keystr == 'r':
568 if self._selection: 568 if self._selection:
569 self._rotateInstances() 569 self._rotateInstances()
570 570
571 elif keystr == 'o': 571 elif keystr == 'o':
572 self.changeRotation() 572 self.changeRotation()
573 573
574 elif keystr == 'u': 574 elif keystr == 'u':
575 self.undo() 575 self.undo()
576 576
577 def keyReleased(self, evt): 577 def keyReleased(self, evt):
578 keyval = evt.getKey().getValue() 578 keyval = evt.getKey().getValue()
579 if keyval in (fife.Key.LEFT_CONTROL, fife.Key.RIGHT_CONTROL): 579 if keyval in (fife.Key.LEFT_CONTROL, fife.Key.RIGHT_CONTROL):
580 self._ctrldown = False 580 self._ctrldown = False
581 elif keyval in (fife.Key.LEFT_SHIFT, fife.Key.RIGHT_SHIFT): 581 elif keyval in (fife.Key.LEFT_SHIFT, fife.Key.RIGHT_SHIFT):