Mercurial > rinkhals
comparison 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 |
comparison
equal
deleted
inserted
replaced
559:b71b7fcf6dc1 | 560:8cd13b82585e |
---|---|
1 """The Game Over Screen""" | 1 """The Game Over Screen""" |
2 import random | 2 import random |
3 import os | 3 import os |
4 | 4 |
5 from pgu import gui | 5 from pgu import gui |
6 from pgu import html | |
6 from pgu.high import Highs | 7 from pgu.high import Highs |
7 import pygame | 8 import pygame |
9 from pygame.locals import KEYDOWN, K_ESCAPE | |
8 | 10 |
9 import engine | 11 import engine |
10 import constants | 12 import constants |
11 import imagecache | 13 import imagecache |
12 import config | 14 import config |
172 def add_spacer(self, height=5): | 174 def add_spacer(self, height=5): |
173 self.tr() | 175 self.tr() |
174 self.td(gui.Spacer(0, height), colspan=3) | 176 self.td(gui.Spacer(0, height), colspan=3) |
175 | 177 |
176 | 178 |
177 class Scoreboard(gui.Table): | 179 class ScoreDialog(gui.Dialog): |
178 | 180 |
179 def __init__(self, level, **params): | 181 def __init__(self, level, **params): |
180 gui.Table.__init__(self, **params) | 182 title = html.HTML("<b>High Scores for Level<i>%s</i></b>" |
181 | 183 % level.level_name) |
182 scoreboard = ScoreTable(level) | 184 scoreboard = ScoreTable(level) |
183 | 185 |
184 self.tr() | 186 tbl = gui.Table() |
185 self.td(gui.Label('Level: %s' % level.level_name, colspan=3)) | 187 for highscore in scoreboard: |
188 tbl.tr() | |
189 tbl.td(gui.Label(highscore.name), colspan=2) | |
190 tbl.td(gui.Label('%d' % highscore.score)) | |
186 | 191 |
187 for highscore in scoreboard: | 192 gui.Dialog.__init__(self, title, tbl, **params) |
188 self.tr() | |
189 self.td(gui.Label(highscore.name), colspan=2) | |
190 self.td(gui.Label('%d' % highscore.score)) | |
191 | 193 |
194 def event(self, e): | |
195 if e.type == KEYDOWN and e.key == K_ESCAPE: | |
196 self.close() | |
197 return True | |
198 return gui.Dialog.event(self, e) |