forked from MyreMylar/pygame_gui_examples
-
Notifications
You must be signed in to change notification settings - Fork 0
/
translations_test.py
95 lines (76 loc) · 3.43 KB
/
translations_test.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
import pygame
import pygame_gui
pygame.init()
pygame.display.set_caption('Quick Start')
window_surface = pygame.display.set_mode((800, 600))
manager = pygame_gui.UIManager((800, 600),
theme_path='data/themes/translations_theme.json',
starting_language='en',
translation_directory_paths=['data/translations'])
background = pygame.Surface((800, 600))
background.fill(manager.ui_theme.get_colour('dark_bg'))
languages_list = ['pygame-gui.English',
'pygame-gui.French',
'pygame-gui.Italian',
'pygame-gui.German',
'pygame-gui.Spanish',
'pygame-gui.Portuguese',
'pygame-gui.Indonesian',
'pygame-gui.Japanese',
'pygame-gui.Russian',
'pygame-gui.Chinese']
languages_dropdown = pygame_gui.elements.UIDropDownMenu(languages_list,
'pygame-gui.English',
pygame.Rect((10, 20), (150, 30)),
manager=manager)
test_label = pygame_gui.elements.UILabel(pygame.Rect((10, 100), (150, 30)),
'pygame-gui.English',
manager)
confirmation_dialog = pygame_gui.windows.UIConfirmationDialog(
pygame.Rect((50, 50), (300, 200)),
manager=manager,
action_long_desc="examples.hello_world_message_text",
blocking=False)
text_box = pygame_gui.elements.UITextBox(
html_text="examples.holmes_text_test",
relative_rect=pygame.Rect(300, 100, 400, 200),
manager=manager)
file_dialog = pygame_gui.windows.UIFileDialog(pygame.Rect(160, 50, 440, 500),
manager)
clock = pygame.time.Clock()
is_running = True
debug_mode = False
while is_running:
time_delta = clock.tick(60)/1000.0
for event in pygame.event.get():
if event.type == pygame.QUIT:
is_running = False
if event.type == pygame.KEYDOWN and event.key == pygame.K_d:
debug_mode = False if debug_mode else True
manager.set_visual_debug_mode(debug_mode)
if event.type == pygame_gui.UI_DROP_DOWN_MENU_CHANGED:
if event.text == 'pygame-gui.English':
manager.set_locale('en')
elif event.text == 'pygame-gui.French':
manager.set_locale('fr')
elif event.text == 'pygame-gui.Italian':
manager.set_locale('it')
elif event.text == 'pygame-gui.German':
manager.set_locale('de')
elif event.text == 'pygame-gui.Spanish':
manager.set_locale('es')
elif event.text == 'pygame-gui.Portuguese':
manager.set_locale('pt')
elif event.text == 'pygame-gui.Indonesian':
manager.set_locale('id')
elif event.text == 'pygame-gui.Japanese':
manager.set_locale('ja')
elif event.text == 'pygame-gui.Russian':
manager.set_locale('ru')
elif event.text == 'pygame-gui.Chinese':
manager.set_locale('zh')
manager.process_events(event)
manager.update(time_delta)
window_surface.blit(background, (0, 0))
manager.draw_ui(window_surface)
pygame.display.update()