diff options
Diffstat (limited to 'helpers/key.py')
-rw-r--r-- | helpers/key.py | 21 |
1 files changed, 17 insertions, 4 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)) |