This repository has been archived by the owner on Sep 22, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathw_i_menu_h.py
60 lines (49 loc) · 2.05 KB
/
w_i_menu_h.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
58
59
60
from w_i_menu import IMenu
class IMenuHorizontal(IMenu):
def __init__(self, col_height, frame):
self.COLUMN_HEIGHT = col_height
IMenu.__init__(self, frame=frame)
def readKeys(self, task):
keysPressed = sum(base.directionMap.values())
if keysPressed == 0:
self.isButtonUp = True
if base.commandMap["confirm"]:
self.menuVerticalEvent()
base.messenger.send("playConfirm")
elif base.commandMap["cancel"]:
self.cancelCommand()
base.messenger.send("playCancel")
base.resetButtons()
return task.cont
if not self.isButtonUp:
return task.cont
if base.directionMap["up"]:
self.navigateChoice(-1, self.menuVerticalChoice,
self.menuVerticalChoicesList)
self.isButtonUp = False
elif base.directionMap["down"]:
self.navigateChoice(1, self.menuVerticalChoice,
self.menuVerticalChoicesList)
self.isButtonUp = False
elif base.directionMap["left"]:
self.navigateChoice(-self.COLUMN_HEIGHT, self.menuVerticalChoice,
self.menuVerticalChoicesList)
self.isButtonUp = False
self.menuHorizontalEvent()
elif base.directionMap["right"]:
self.navigateChoice(self.COLUMN_HEIGHT, self.menuVerticalChoice,
self.menuVerticalChoicesList)
self.isButtonUp = False
self.menuHorizontalEvent()
base.resetButtons()
return task.cont
def navigateChoice(self, value, choice, choiceList):
choice[0] += value
lc = len(choiceList)
if choice[0] < 0:
c = (lc// self.COLUMN_HEIGHT) * self.COLUMN_HEIGHT
p = c + self.COLUMN_HEIGHT + choice[0]
choice[0] = min(p, lc - 1)
elif choice[0] > lc - 1:
choice[0] = choice[0] % self.COLUMN_HEIGHT
self.updateCheckbuttons()