-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmenu.py
43 lines (40 loc) · 1.04 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
import globals as g
import sys
import time
from AGK.speech import auto
from openal import *
sourcelist=[]
def cleanup():
try:
for a in sourcelist:
if a == None or a.get_state()==AL_STOPPED:
a.destroy()
sourcelist.remove(a)
except Exception as e:
auto.speak("\r\nError acurd on cleaning up sound sources: {0}".format(str(e)))
class Menu:
def __init__(self, clicksound, edgesound, wrapsound, entersound, opensound, items, itempos=0, title="menu", fpscap=120):
self.clicksound=clicksound
self.edgesound=edgesound
self.wrapsound=wrapsound
self.entersound=entersound
self.opensound=opensound
self.itempos=itempos
self.items=items
auto.speak(title+". "+items[itempos])
# self.clock=pygame.time.Clock()
self.fpscap=fpscap
def run(self):
try:
return self.loop()
except Exception as e:
auto.speak(str(e))
def loop(self):
while 1:
# self.clock.tick(self.fpscap)
cleanup()
if 'ENTER' in g.input:
source=oalopen(entersound)
sourcelist.append(source)
source.play()
return self.items[self.itempos]