-
Notifications
You must be signed in to change notification settings - Fork 0
/
settings_menu.py
71 lines (51 loc) · 1.73 KB
/
settings_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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
import time
import pygame_menu
from react import GameEngine
def reset_menu_selection(menu):
menu.select_widget(None)
def led_check(menu, game_engine: GameEngine, check_time: int):
"""Turn on all led for check_time seconds"""
print("Start led_check")
start = time.time()
elapsed = lambda: time.time() - start
game_engine.lights.on()
while elapsed() <= check_time:
time.sleep(1)
game_engine.lights.off()
reset_menu_selection(menu)
print("Done led_check")
def led_button_check(menu, game_engine: GameEngine):
"""Light up the buttons 1 by 1 to verify that it all work"""
print("Start led_button_check")
game_engine.button_test()
print("Done led_button_check")
reset_menu_selection(menu)
def init_settings_menu(on_close_cb, game_engine) -> "pygame_menu.Menu":
theme_menu = pygame_menu.themes.THEME_BLUE.copy()
theme_menu.scrollbar_cursor = pygame_menu.locals.CURSOR_HAND
# Main menu, pauses execution of the application
menu = pygame_menu.Menu(
height=400, onclose=on_close_cb, theme=theme_menu, title="Main Menu", width=600
)
cheat_sub_menu = pygame_menu.Menu(
height=400, onclose=on_close_cb, theme=theme_menu, title="Cheat Menu", width=600
)
# Led check
led_check_time = 30 # sec
menu.add.button(
f"Led check ({led_check_time} sec)",
led_check,
menu,
game_engine,
led_check_time,
)
menu.add.button(
f"Led & Button check",
led_button_check,
menu,
game_engine,
)
menu.add.button("Cheat Menu", cheat_sub_menu)
cheat_sub_menu.add.button("What were you expecting?!")
menu.add.button("Exit Game", pygame_menu.events.EXIT)
return menu