comparison tools/editor/scripts/editor.py @ 402:bc6730a27820

* Fixed a bug where the editor would not activate the new mapview after closing a map * Fixed a crash caused by not all cameras belonging to a map being removed
author cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
date Fri, 29 Jan 2010 10:55:21 +0000
parents ac7806c46b94
children 9d94f4676d17
comparison
equal deleted inserted replaced
401:ac7806c46b94 402:bc6730a27820
84 self._edit_menu = None 84 self._edit_menu = None
85 self._view_menu = None 85 self._view_menu = None
86 self._tools_menu = None 86 self._tools_menu = None
87 self._help_menu = None 87 self._help_menu = None
88 88
89 self._change_map = -1
90
89 self._settings = None 91 self._settings = None
90 92
91 self._help_dialog = None 93 self._help_dialog = None
92 94
93 ApplicationBase.__init__(self, *args, **kwargs) 95 ApplicationBase.__init__(self, *args, **kwargs)
315 317
316 def showMapView(self, mapview): 318 def showMapView(self, mapview):
317 """ Switches to mapview. """ 319 """ Switches to mapview. """
318 if mapview is None or mapview == self._mapview: 320 if mapview is None or mapview == self._mapview:
319 return 321 return
320 322
321 events.preMapShown.send(sender=self, mapview=mapview) 323 events.preMapShown.send(sender=self, mapview=mapview)
322 self._mapview = mapview 324 self._mapview = mapview
323 self._mapview.show() 325 self._mapview.show()
324 events.postMapShown.send(sender=self, mapview=mapview) 326 events.postMapShown.send(sender=self, mapview=mapview)
325 327
362 364
363 # Change mapview 365 # Change mapview
364 if len(self._mapviewlist) > 0: 366 if len(self._mapviewlist) > 0:
365 if index < 0: 367 if index < 0:
366 index = 0 368 index = 0
367 self.showMapView(self._mapviewlist[index]) 369 self._change_map = index
368 else: 370 else:
369 self._mapview = None 371 self._mapview = None
370 self.getEngine().getView().clearCameras() 372 self.getEngine().getView().clearCameras()
371 373
372 def openFile(self, path): 374 def openFile(self, path):
403 if self._inited == False: 405 if self._inited == False:
404 self._initGui() 406 self._initGui()
405 self._initTools() 407 self._initTools()
406 if self._params: self.openFile(self._params) 408 if self._params: self.openFile(self._params)
407 self._inited = True 409 self._inited = True
410
411 # FIXME: This isn't very nice, but it is needed to change the map
412 # outside the callback.
413 if self._change_map >= 0 and len(self._mapviewlist) > 0:
414 if self._change_map >= len(self._mapviewlist):
415 self._change_map = len(self._mapviewlist)-1
416 mapview = self._mapviewlist[self._change_map]
417
418 self.showMapView(mapview)
419 self._change_map = -1
408 420
409 events.onPump.send(sender=self) 421 events.onPump.send(sender=self)
410 422
411 def __sendMouseEvent(self, event, **kwargs): 423 def __sendMouseEvent(self, event, **kwargs):
412 """ Function used to capture mouse events for EventListener """ 424 """ Function used to capture mouse events for EventListener """