]> git.immae.eu Git - perso/Immae/Projets/Python/MusicSampler.git/blame - run.py
Add stub commands
[perso/Immae/Projets/Python/MusicSampler.git] / run.py
CommitLineData
d8ab67c7
IB
1import sys
2
3if getattr(sys, 'frozen', False):
4 os.chdir(sys._MEIPASS)
5
189bf90c 6import pygame
8f88a3e4 7import pydub
189bf90c
IB
8import helpers
9
8f88a3e4 10pygame.mixer.pre_init(frequency = 44100)
189bf90c
IB
11pygame.init()
12
13size = width, height = 1024, 600
14
15screen = pygame.display.set_mode(size)
16background = pygame.Surface(screen.get_size())
17background = background.convert()
18background.fill((250, 250, 250))
19
d8ab67c7
IB
20action_surface = pygame.Surface((600, 250)).convert()
21action_surface.fill((0,0,0))
8f88a3e4
IB
22helpers.parse_config()
23
24for key_name in helpers.Mapping.KEYS:
25 key = helpers.Mapping.KEYS[key_name]
189bf90c
IB
26 key.draw(background)
27
28screen.blit(background, (0, 0))
d8ab67c7
IB
29screen.blit(action_surface, (10, 330))
30
189bf90c
IB
31pygame.display.flip()
32
33contexts = [
34 'normal'
35]
36
37context = 'normal'
38
39while 1:
40 event = pygame.event.wait()
41 if event.type == pygame.QUIT or (
42 event.type == pygame.KEYDOWN and
43 event.mod == 4160 and
44 event.key == pygame.K_c):
45 pygame.quit()
46 sys.exit()
47
48 if context == 'normal':
d8ab67c7
IB
49 if event.type == pygame.KEYDOWN:
50 key = helpers.Key.find_by_key_num(event.key)
51 if key is not None:
52 key.do_actions()
53 elif event.type == pygame.MOUSEBUTTONUP:
54 key = helpers.Key.find_by_collidepoint(pygame.mouse.get_pos())
55 if key is not None:
56 key.list_actions(action_surface)
189bf90c
IB
57
58 pygame.display.flip()
59