Mercurial > rinkhals
changeset 553:7963fc09fac2
Make checkdialog take strings to show as input. Add possiblity of 3rd button on dialog
author | Neil Muller <drnlmuller@gmail.com> |
---|---|
date | Sat, 28 Nov 2009 17:45:28 +0000 |
parents | 11c4cebfe4c5 |
children | 46fa3cdfddf4 |
files | gamelib/gameboard.py gamelib/misc.py |
diffstat | 2 files changed, 17 insertions(+), 8 deletions(-) [+] |
line wrap: on
line diff
--- a/gamelib/gameboard.py Sat Nov 28 17:37:13 2009 +0000 +++ b/gamelib/gameboard.py Sat Nov 28 17:45:28 2009 +0000 @@ -832,7 +832,9 @@ if val: import engine pygame.event.post(engine.GO_GAME_OVER) - dialog = misc.CheckDialog(sure) + dialog = misc.CheckDialog(sure, + "Do you REALLY want to exit this game?", + "Yes, Quit", "No, Don't Quit", None) self.disp.open(dialog) return True elif e.type == KEYDOWN and e.key == K_n and self.day:
--- a/gamelib/misc.py Sat Nov 28 17:37:13 2009 +0000 +++ b/gamelib/misc.py Sat Nov 28 17:45:28 2009 +0000 @@ -82,20 +82,27 @@ roll -= weight class CheckDialog(gui.Dialog): - def __init__(self, sure_func, **params): + def __init__(self, sure_func, message, yes_choice, no_choice, + maybe_choice, **params): self._sure_func = sure_func title = gui.Label('Are You Sure?') tbl = gui.Table() tbl.tr() - tbl.td(gui.Label("Do you REALLY want to exit this game?"), colspan=2) + tbl.td(gui.Label(message), colspan=3) tbl.tr() - tbl.td(gui.Spacer(0, 15), colspan=2) + tbl.td(gui.Spacer(0, 15), colspan=3) tbl.tr() - yes_button = gui.Button('Yes') - yes_button.connect(gui.CLICK, self.clicked, True) - no_button = gui.Button('No') - no_button.connect(gui.CLICK, self.clicked, False) + no_button = gui.Button(no_choice) + no_button.connect(gui.CLICK, self.clicked, 0) tbl.td(no_button, align=-1) + if maybe_choice: + maybe_button = gui.Button(maybe_choice) + maybe_button.connect(gui.CLICK, self.clicked, 2) + tbl.td(maybe_button, align=1) + else: + tbl.td(gui.Spacer(0, 15)) + yes_button = gui.Button(yes_choice) + yes_button.connect(gui.CLICK, self.clicked, 1) tbl.td(yes_button, align=1) gui.Dialog.__init__(self, title, tbl, **params)