# HG changeset patch # User Neil Muller # Date 1259436821 0 # Node ID 37f7454518d54e9200fdd957a29e7062e709414c # Parent a8dde729000a6bca4b5bc8e1b92e1656459eea78 Move quit stuff into seperate function diff -r a8dde729000a -r 37f7454518d5 gamelib/gameboard.py --- a/gamelib/gameboard.py Sat Nov 28 19:30:06 2009 +0000 +++ b/gamelib/gameboard.py Sat Nov 28 19:33:41 2009 +0000 @@ -888,26 +888,30 @@ dialog = self.open_dialog(tbl, x=x, y=y) + def _do_quit(self): + + def check_saved(_widget): + if _widget.value: + # OK to quit, rely on pgu ordering that this happens in + # the right order + pygame.event.post(constants.GO_GAME_OVER) + + def sure(val): + if val == 2: + savedialog = savegame.SaveDialog(self) + savedialog.connect(gui.CHANGE, check_saved) + savedialog.open() + elif val: + pygame.event.post(constants.GO_GAME_OVER) + + dialog = misc.CheckDialog(sure, + "Do you REALLY want to exit this game?", + "Yes, Quit", "No, Don't Quit", "Save & Quit") + self.disp.open(dialog) + def event(self, e): if e.type == KEYDOWN and e.key == K_ESCAPE: - def check_saved(_widget): - if _widget.value: - # OK to quit, rely on pgu ordering that this happens in - # the right order - pygame.event.post(constants.GO_GAME_OVER) - - def sure(val): - if val == 2: - savedialog = savegame.SaveDialog(self) - savedialog.connect(gui.CHANGE, check_saved) - savedialog.open() - elif val: - pygame.event.post(constants.GO_GAME_OVER) - - dialog = misc.CheckDialog(sure, - "Do you REALLY want to exit this game?", - "Yes, Quit", "No, Don't Quit", "Save & Quit") - self.disp.open(dialog) + self._do_quit() return True elif e.type == KEYDOWN and e.key == K_n and self.day: pygame.event.post(constants.START_NIGHT)