aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIsmaël Bouya <ismael.bouya@normalesup.org>2016-06-24 20:46:52 +0200
committerIsmaël Bouya <ismael.bouya@normalesup.org>2016-06-24 20:46:52 +0200
commitcd255f24c1a3b199c2b446537aff60be767676d4 (patch)
tree55108716bc56e8ef281a139522c6dd6203b1c011
parent87f211fb622ef640249628b65d0bc8daca889f2c (diff)
downloadMusicSampler-cd255f24c1a3b199c2b446537aff60be767676d4.tar.gz
MusicSampler-cd255f24c1a3b199c2b446537aff60be767676d4.tar.zst
MusicSampler-cd255f24c1a3b199c2b446537aff60be767676d4.zip
Add checkmarks to the action list
-rw-r--r--helpers/key.py21
-rw-r--r--music_sampler.py2
2 files changed, 18 insertions, 5 deletions
diff --git a/helpers/key.py b/helpers/key.py
index 56cccaa..d923b1d 100644
--- a/helpers/key.py
+++ b/helpers/key.py
@@ -118,17 +118,21 @@ class Key:
118 def add_action(self, action_name, **arguments): 118 def add_action(self, action_name, **arguments):
119 self.actions.append(Action(action_name, self, **arguments)) 119 self.actions.append(Action(action_name, self, **arguments))
120 120
121 def do_actions(self): 121 def do_actions(self, screen):
122 print("running actions for {}".format(self.key_sym)) 122 print("running actions for {}".format(self.key_sym))
123 start_time = time.time() 123 start_time = time.time()
124 self.mapping.start_running(self, start_time) 124 self.mapping.start_running(self, start_time)
125 action_number = 0
125 for action in self.actions: 126 for action in self.actions:
126 if self.mapping.keep_running(self, start_time): 127 if self.mapping.keep_running(self, start_time):
128 self.list_actions(screen, action_number = action_number + 0.5)
127 action.run() 129 action.run()
130 action_number += 1
131 self.list_actions(screen, action_number = action_number)
128 132
129 self.mapping.finished_running(self, start_time) 133 self.mapping.finished_running(self, start_time)
130 134
131 def list_actions(self, screen): 135 def list_actions(self, screen, action_number = 0):
132 action_descriptions = [action.description() for action in self.actions] 136 action_descriptions = [action.description() for action in self.actions]
133 #print("actions linked to key {}:".format(self.key_sym)) 137 #print("actions linked to key {}:".format(self.key_sym))
134 #print("\t" + "\n\t".join(action_descriptions)) 138 #print("\t" + "\n\t".join(action_descriptions))
@@ -144,9 +148,18 @@ class Key:
144 offset += police.get_linesize() 148 offset += police.get_linesize()
145 149
146 police.set_bold(False) 150 police.set_bold(False)
147 for description in action_descriptions: 151 icon_police = font(14, font = "Symbola")
152 for index, description in enumerate(action_descriptions):
153 if index < int(action_number):
154 icon = icon_police.render("✓", True, (0,0,0))
155 elif index + 0.5 == action_number:
156 icon = icon_police.render("✅", True, (0,0,0))
157 else:
158 icon = icon_police.render(" ", True, (0,0,0))
159
148 text = police.render(description, True, (0,0,0)) 160 text = police.render(description, True, (0,0,0))
149 surface.blit(text, (0, offset)) 161 surface.blit(icon, (0, offset))
162 surface.blit(text, (10, offset))
150 offset += police.get_linesize() 163 offset += police.get_linesize()
151 164
152 screen.blit(surface, (5, 308)) 165 screen.blit(surface, (5, 308))
diff --git a/music_sampler.py b/music_sampler.py
index 6fed26b..42c01e3 100644
--- a/music_sampler.py
+++ b/music_sampler.py
@@ -48,7 +48,7 @@ while 1:
48 if event.type == pygame.KEYDOWN: 48 if event.type == pygame.KEYDOWN:
49 key = mapping.find_by_key_num(event.key) 49 key = mapping.find_by_key_num(event.key)
50 if key is not None and not key.disabled: 50 if key is not None and not key.disabled:
51 threading.Thread(name = "MSKeyAction", target=key.do_actions).start() 51 threading.Thread(name = "MSKeyAction", target=key.do_actions, args = [screen]).start()
52 threading.Thread(name = "MSClic", target=key.list_actions, args = [screen]).start() 52 threading.Thread(name = "MSClic", target=key.list_actions, args = [screen]).start()
53 elif event.type == pygame.MOUSEBUTTONUP: 53 elif event.type == pygame.MOUSEBUTTONUP:
54 key = mapping.find_by_collidepoint(pygame.mouse.get_pos()) 54 key = mapping.find_by_collidepoint(pygame.mouse.get_pos())