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
|
|
8 from albow.resource import get_font
|
|
9
|
|
10 class PopupMenu(Menu):
|
|
11
|
|
12 def __init__(self, shell):
|
|
13 self.shell = shell
|
|
14 items = [
|
|
15 ('Resume Game', 'hide'),
|
|
16 ('Exit to Main Menu', 'main_menu'),
|
|
17 ]
|
|
18 # albow.menu.Menu ignores title string
|
|
19 Menu.__init__(self, None, items)
|
|
20 self.font = get_font(16, 'Vera.ttf')
|
|
21
|
|
22 def show_menu(self):
|
|
23 """Call present, with the correct position"""
|
|
24 item_height = self.font.get_linesize()
|
|
25 menu_top = 600 - (len(self.items) * item_height + BUTTON_SIZE)
|
|
26 item = self.present(self.shell, (0, menu_top))
|
|
27 if item > -1:
|
|
28 # A menu item needs to be invoked
|
|
29 self.invoke_item(item)
|
|
30
|