forked from vojtapolasek/united_guards
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmenu.py
57 lines (42 loc) · 1.13 KB
/
menu.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#!/usr/bin/env python
# -*- coding: UTF-8 -*-
#module for menus
#released on September 03, 2012 by Vojtěch Polášek <[email protected]>
import __main__
items = None
current = None
class menuitem:
def __init__(self, caption, action):
self.caption = caption
self.action = action
def say(self):
s.say(self.caption, 1)
def select(self):
exec self.action
class menu:
def __init__(self,title,items,movesound=None,selectsound=None,bgsound=None):
self.title = title
self.items = items
self.movesound = movesound
self.selectsound = selectsound
self.bgsound = bgsound
self.current = None
def init(self,current=0):
self.current = current
s.say(self.title, 0)
s.say(self.items[self.current].caption, 0)
return self
def movedown(self):
if self.current < len (self.items) -1:
self.current += 1
else:
self.current = 0
self.items[self.current].say()
def moveup(self):
if self.current > 0:
self.current -= 1
else:
self.current = len (self.items) -1
self.items[self.current].say()
def select(self):
self.items[self.current].select()