Mercurial > rinkhals
diff gamelib/gameover.py @ 560:8cd13b82585e
Allow ESC to exit high score menu and then still exit game if pressed a second time.
author | Simon Cross <hodgestar@gmail.com> |
---|---|
date | Sat, 28 Nov 2009 18:27:59 +0000 |
parents | 296c73dcd286 |
children | 80725d647569 |
line wrap: on
line diff
--- a/gamelib/gameover.py Sat Nov 28 18:27:02 2009 +0000 +++ b/gamelib/gameover.py Sat Nov 28 18:27:59 2009 +0000 @@ -3,8 +3,10 @@ import os from pgu import gui +from pgu import html from pgu.high import Highs import pygame +from pygame.locals import KEYDOWN, K_ESCAPE import engine import constants @@ -174,18 +176,23 @@ self.td(gui.Spacer(0, height), colspan=3) -class Scoreboard(gui.Table): +class ScoreDialog(gui.Dialog): def __init__(self, level, **params): - gui.Table.__init__(self, **params) - + title = html.HTML("<b>High Scores for Level<i>%s</i></b>" + % level.level_name) scoreboard = ScoreTable(level) - self.tr() - self.td(gui.Label('Level: %s' % level.level_name, colspan=3)) - + tbl = gui.Table() for highscore in scoreboard: - self.tr() - self.td(gui.Label(highscore.name), colspan=2) - self.td(gui.Label('%d' % highscore.score)) + tbl.tr() + tbl.td(gui.Label(highscore.name), colspan=2) + tbl.td(gui.Label('%d' % highscore.score)) + + gui.Dialog.__init__(self, title, tbl, **params) + def event(self, e): + if e.type == KEYDOWN and e.key == K_ESCAPE: + self.close() + return True + return gui.Dialog.event(self, e)