Mercurial > fife-parpg
comparison tools/editor/scripts/editor.py @ 401:ac7806c46b94
* Fixed a crash when opening two maps and closing them
* Fixed a bug where closing the first map would destroy all cameras
author | cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222 |
---|---|
date | Thu, 28 Jan 2010 22:47:20 +0000 |
parents | 64738befdf3b |
children | bc6730a27820 |
comparison
equal
deleted
inserted
replaced
400:ef0c7a0cacab | 401:ac7806c46b94 |
---|---|
174 self._centralwidget.addChild(self._maparea) | 174 self._centralwidget.addChild(self._maparea) |
175 | 175 |
176 self._initActions() | 176 self._initActions() |
177 | 177 |
178 self._toolbox.show() | 178 self._toolbox.show() |
179 | |
180 events.preMapClosed.connect(self._mapRemoved) | |
179 | 181 |
180 def _initActions(self): | 182 def _initActions(self): |
181 """ Initializes toolbar and menubar buttons """ | 183 """ Initializes toolbar and menubar buttons """ |
182 exitAction = Action(u"Exit", "gui/icons/quit.png") | 184 exitAction = Action(u"Exit", "gui/icons/quit.png") |
183 exitAction.helptext = u"Exit program" | 185 exitAction.helptext = u"Exit program" |
342 action.activated.connect(cbwa(self.showMapView, mapview), sender=map_action, weak=False) | 344 action.activated.connect(cbwa(self.showMapView, mapview), sender=map_action, weak=False) |
343 self._mapgroup.addAction(map_action) | 345 self._mapgroup.addAction(map_action) |
344 | 346 |
345 self.showMapView(mapview) | 347 self.showMapView(mapview) |
346 | 348 |
347 events.preMapClosed.connect(self._mapRemoved) | |
348 events.mapAdded.send(sender=self, map=map) | 349 events.mapAdded.send(sender=self, map=map) |
349 | 350 |
350 return mapview | 351 return mapview |
351 | 352 |
352 def _mapRemoved(self, mapview): | 353 def _mapRemoved(self, mapview): |
353 events.preMapClosed.disconnect(self._mapRemoved) | |
354 | |
355 index = self._mapviewlist.index(mapview)-1 | 354 index = self._mapviewlist.index(mapview)-1 |
356 self._mapviewlist.remove(mapview) | 355 self._mapviewlist.remove(mapview) |
357 | 356 |
358 # Remove tab | 357 # Remove tab |
359 for map_action in self._mapgroup.getActions(): | 358 for map_action in self._mapgroup.getActions(): |
360 if map_action.text == unicode(mapview.getMap().getId()): | 359 if map_action.text == unicode(mapview.getMap().getId()): |
361 self._mapgroup.removeAction(map_action) | 360 self._mapgroup.removeAction(map_action) |
362 break | 361 break |
363 | 362 |
364 # Change mapview | 363 # Change mapview |
365 if index >= 0: | 364 if len(self._mapviewlist) > 0: |
365 if index < 0: | |
366 index = 0 | |
366 self.showMapView(self._mapviewlist[index]) | 367 self.showMapView(self._mapviewlist[index]) |
367 else: | 368 else: |
368 self._mapview = None | 369 self._mapview = None |
369 self.getEngine().getView().clearCameras() | 370 self.getEngine().getView().clearCameras() |
370 | 371 |