Mercurial > boomslang
annotate gamelib/popupmenu.py @ 93:350ce4ebe122
Detail view without any functionality.
author | Jeremy Thurgood <firxen@gmail.com> |
---|---|
date | Tue, 24 Aug 2010 00:43:32 +0200 |
parents | c76f2fad2af5 |
children | ca10d7e9a2c1 |
rev | line source |
---|---|
58 | 1 # popmenu.py |
2 # Copyright Boomslang team (see COPYING file) | |
3 # Popup menu for the game screen | |
4 | |
5 from constants import BUTTON_SIZE | |
6 | |
7 from albow.menu import Menu | |
70 | 8 from albow.controls import Button |
58 | 9 from albow.resource import get_font |
70 | 10 from pygame.rect import Rect |
11 | |
84
c76f2fad2af5
Draw CursorWidget on top of StateWidget
Stefano Rivera <stefano@rivera.za.net>
parents:
70
diff
changeset
|
12 class PopupMenuButton(Button): |
70 | 13 |
14 def __init__(self, text, action): | |
15 Button.__init__(self, text, action) | |
16 | |
17 self.font = get_font(16, 'Vera.ttf') | |
18 self.set_rect(Rect(0, 0, BUTTON_SIZE, BUTTON_SIZE)) | |
19 self.margin = (BUTTON_SIZE - self.font.get_linesize()) / 2 | |
20 | |
58 | 21 class PopupMenu(Menu): |
22 | |
23 def __init__(self, shell): | |
24 self.shell = shell | |
25 items = [ | |
26 ('Resume Game', 'hide'), | |
69
d4bbb26099cc
Some debug object cleanup.
Jeremy Thurgood <firxen@gmail.com>
parents:
58
diff
changeset
|
27 ('Quit Game', 'quit'), |
58 | 28 ('Exit to Main Menu', 'main_menu'), |
29 ] | |
30 # albow.menu.Menu ignores title string | |
31 Menu.__init__(self, None, items) | |
32 self.font = get_font(16, 'Vera.ttf') | |
33 | |
34 def show_menu(self): | |
35 """Call present, with the correct position""" | |
36 item_height = self.font.get_linesize() | |
37 menu_top = 600 - (len(self.items) * item_height + BUTTON_SIZE) | |
38 item = self.present(self.shell, (0, menu_top)) | |
39 if item > -1: | |
40 # A menu item needs to be invoked | |
41 self.invoke_item(item) | |
42 |