comparison tools/editor/scripts/editor.py @ 422:9d94f4676d17

Moved the management of cameras into the Map class. The View class no longer exists since it now serves no purpose. The engine class itself holds the renderers and these get passed to each map that is loaded and then passed to each camera on each map. This change makes it possible for multiple maps to be loaded at the same time with the same camera id without a name clash. fixes[t:342]
author vtchill@33b003aa-7bff-0310-803a-e67f0ece8222
date Fri, 12 Feb 2010 06:34:50 +0000
parents bc6730a27820
children 3a6441d9e01c
comparison
equal deleted inserted replaced
421:293e812316c0 422:9d94f4676d17
317 317
318 def showMapView(self, mapview): 318 def showMapView(self, mapview):
319 """ Switches to mapview. """ 319 """ Switches to mapview. """
320 if mapview is None or mapview == self._mapview: 320 if mapview is None or mapview == self._mapview:
321 return 321 return
322
323 if self._mapview != None and mapview != self._mapview:
324 # need to disable the cameras from the previous map
325 # if it exists before switching
326 if self._mapview.getMap() != None:
327 for cam in self._mapview.getMap().getCameras():
328 cam.setEnabled(False)
322 329
323 events.preMapShown.send(sender=self, mapview=mapview) 330 events.preMapShown.send(sender=self, mapview=mapview)
324 self._mapview = mapview 331 self._mapview = mapview
325 self._mapview.show() 332 self._mapview.show()
326 events.postMapShown.send(sender=self, mapview=mapview) 333 events.postMapShown.send(sender=self, mapview=mapview)
352 359
353 return mapview 360 return mapview
354 361
355 def _mapRemoved(self, mapview): 362 def _mapRemoved(self, mapview):
356 index = self._mapviewlist.index(mapview)-1 363 index = self._mapviewlist.index(mapview)-1
364
365 for cam in mapview.getMap().getCameras():
366 cam.setEnabled(False)
367
357 self._mapviewlist.remove(mapview) 368 self._mapviewlist.remove(mapview)
358 369
359 # Remove tab 370 # Remove tab
360 for map_action in self._mapgroup.getActions(): 371 for map_action in self._mapgroup.getActions():
361 if map_action.text == unicode(mapview.getMap().getId()): 372 if map_action.text == unicode(mapview.getMap().getId()):
367 if index < 0: 378 if index < 0:
368 index = 0 379 index = 0
369 self._change_map = index 380 self._change_map = index
370 else: 381 else:
371 self._mapview = None 382 self._mapview = None
372 self.getEngine().getView().clearCameras()
373 383
374 def openFile(self, path): 384 def openFile(self, path):
375 """ Opens a file """ 385 """ Opens a file """
376 try: 386 try:
377 map = loaders.loadMapFile(path, self.engine) 387 map = loaders.loadMapFile(path, self.engine)