-
Notifications
You must be signed in to change notification settings - Fork 8
/
HK.py
95 lines (76 loc) · 2.29 KB
/
HK.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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
from menuclass import *
class HK(Menu):
def __init__(self, process, openmenu="MN"):
self.menu = "HK"
self.m = openmenu
self.keys = json.load(open(os.path.join(path2hotkeys, globalsettings["hotkeydescfile"])))
self.scroll = 0
self.lines = 0
super().__init__(process, "HK")
self.fontsize = self.labels[0].fontsize
self.load_menu(openmenu)
def load_menu(self, name):
if name != self.m:
self.m = name
self.scroll = 0
text = self.m + "\n"
text2 = "\n"
scc = self.scroll
self.lines = 0
for key, func in hotkeys[self.m].items():
self.lines += 1
if scc >= 0:
scc -= 1
continue
if key == "unlock_keys":
continue
try:
desc = self.keys[self.m][func]
except KeyError:
desc = "???"
tx = pg.key.name(getattr(pg, key.replace("@", "").replace("+", ""))).title() + "\n"
tx2 = desc+"\n"
if "+" in key:
tx = "Ctrl + " + tx
text += tx
text2 += tx2
self.labels[0].set_text(text)
self.labels[1].set_text(text2)
def scroll_up(self):
if self.scroll - 1 > -1:
self.scroll -= 1
self.load_menu(self.m)
def scroll_down(self):
if self.scroll + 1 < self.lines - 1:
self.scroll += 1
self.load_menu(self.m)
def MN(self):
self.load_menu("MN")
def GE(self):
self.load_menu("GE")
def HK(self):
self.load_menu("HK")
def TE(self):
self.load_menu("TE")
def LE(self):
self.load_menu("LE")
def CE(self):
self.load_menu("CE")
def FE(self):
self.load_menu("FE")
def PE(self):
self.load_menu("PE")
def LP(self):
self.load_menu("LP")
def globalkeys(self):
self.load_menu("global")
def resize(self):
super().resize()
self.load_menu(self.m)
def goback(self):
self.sendtoowner(self.m)
def edit(self):
if islinux:
os.system(f"open {os.path.join(path, 'files/hotkeys.json')}")
else:
os.system(f"\"{os.path.join(path, 'hotkeys.json')}\"")