Mercurial > rinkhals
comparison gamelib/gameboard.py @ 567:37f7454518d5
Move quit stuff into seperate function
author | Neil Muller <drnlmuller@gmail.com> |
---|---|
date | Sat, 28 Nov 2009 19:33:41 +0000 |
parents | a8dde729000a |
children | 3ec614e6fd4a |
comparison
equal
deleted
inserted
replaced
566:a8dde729000a | 567:37f7454518d5 |
---|---|
886 button.connect(gui.CLICK, sell_item, item, button) | 886 button.connect(gui.CLICK, sell_item, item, button) |
887 tbl.td(button, align=1, **kwargs) | 887 tbl.td(button, align=1, **kwargs) |
888 | 888 |
889 dialog = self.open_dialog(tbl, x=x, y=y) | 889 dialog = self.open_dialog(tbl, x=x, y=y) |
890 | 890 |
891 def _do_quit(self): | |
892 | |
893 def check_saved(_widget): | |
894 if _widget.value: | |
895 # OK to quit, rely on pgu ordering that this happens in | |
896 # the right order | |
897 pygame.event.post(constants.GO_GAME_OVER) | |
898 | |
899 def sure(val): | |
900 if val == 2: | |
901 savedialog = savegame.SaveDialog(self) | |
902 savedialog.connect(gui.CHANGE, check_saved) | |
903 savedialog.open() | |
904 elif val: | |
905 pygame.event.post(constants.GO_GAME_OVER) | |
906 | |
907 dialog = misc.CheckDialog(sure, | |
908 "Do you REALLY want to exit this game?", | |
909 "Yes, Quit", "No, Don't Quit", "Save & Quit") | |
910 self.disp.open(dialog) | |
911 | |
891 def event(self, e): | 912 def event(self, e): |
892 if e.type == KEYDOWN and e.key == K_ESCAPE: | 913 if e.type == KEYDOWN and e.key == K_ESCAPE: |
893 def check_saved(_widget): | 914 self._do_quit() |
894 if _widget.value: | |
895 # OK to quit, rely on pgu ordering that this happens in | |
896 # the right order | |
897 pygame.event.post(constants.GO_GAME_OVER) | |
898 | |
899 def sure(val): | |
900 if val == 2: | |
901 savedialog = savegame.SaveDialog(self) | |
902 savedialog.connect(gui.CHANGE, check_saved) | |
903 savedialog.open() | |
904 elif val: | |
905 pygame.event.post(constants.GO_GAME_OVER) | |
906 | |
907 dialog = misc.CheckDialog(sure, | |
908 "Do you REALLY want to exit this game?", | |
909 "Yes, Quit", "No, Don't Quit", "Save & Quit") | |
910 self.disp.open(dialog) | |
911 return True | 915 return True |
912 elif e.type == KEYDOWN and e.key == K_n and self.day: | 916 elif e.type == KEYDOWN and e.key == K_n and self.day: |
913 pygame.event.post(constants.START_NIGHT) | 917 pygame.event.post(constants.START_NIGHT) |
914 return True | 918 return True |
915 elif e.type == KEYDOWN and e.key == K_d and self.night: | 919 elif e.type == KEYDOWN and e.key == K_d and self.night: |