-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgame_keys_actions.py
64 lines (58 loc) · 1.92 KB
/
game_keys_actions.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
from talon import actions
from .game_keys_ui import game_keys_ui
from .actions_ui import actions_ui
sprinting = False
def unhighlight_all_dir():
global sprinting
for key in ["up", "down", "left", "right"]:
actions.user.ui_elements_unhighlight(key)
sprinting = False
def highlight_dir(dir):
unhighlight_all_dir()
actions.user.ui_elements_highlight(dir)
def sprint_toggle():
global sprinting
sprinting = not sprinting
if sprinting:
actions.user.ui_elements_highlight("shift")
else:
actions.user.ui_elements_unhighlight("shift")
def set_game_keys_actions_state():
actions.user.ui_elements_set_state("actions", [{
"text": 'Go left',
"action": lambda: highlight_dir("left")
}, {
"text": 'Go right',
"action": lambda: highlight_dir("right")
}, {
"text": 'Go up',
"action": lambda: highlight_dir("up")
}, {
"text": 'Go down',
"action": lambda: highlight_dir("down")
}, {
"text": 'Stop',
"action": lambda: (unhighlight_all_dir(), actions.user.ui_elements_unhighlight("shift"))
}, {
"text": 'Jump',
"action": lambda: actions.user.ui_elements_highlight_briefly("space")
}, {
"text": 'LMB',
"action": lambda: actions.user.ui_elements_highlight_briefly("lmb")
}, {
"text": 'RMB',
"action": lambda: actions.user.ui_elements_highlight_briefly("rmb")
}, {
"text": 'Dash',
"action": lambda: actions.user.ui_elements_highlight_briefly("q")
}, {
"text": 'Heal',
"action": lambda: actions.user.ui_elements_highlight_briefly("e")
}, {
"text": 'Sprint toggle',
"action": sprint_toggle
}])
def game_keys_show():
set_game_keys_actions_state()
actions.user.ui_elements_show(game_keys_ui)
actions.user.ui_elements_show(actions_ui)