aboutsummaryrefslogtreecommitdiff
path: root/helpers.py
diff options
context:
space:
mode:
authorIsmaël Bouya <ismael.bouya@normalesup.org>2016-06-15 09:34:47 +0200
committerIsmaël Bouya <ismael.bouya@normalesup.org>2016-06-15 09:35:21 +0200
commitd8ab67c745b78d0b2f5896cf6642004b3951433c (patch)
tree3ad10c636f68c3cd3bf63fe1f29decfded7c11c3 /helpers.py
parent8f88a3e417d6eff7666571eccf0b6ad453c88ccd (diff)
downloadMusicSampler-d8ab67c745b78d0b2f5896cf6642004b3951433c.tar.gz
MusicSampler-d8ab67c745b78d0b2f5896cf6642004b3951433c.tar.zst
MusicSampler-d8ab67c745b78d0b2f5896cf6642004b3951433c.zip
Add stub commands
Diffstat (limited to 'helpers.py')
-rw-r--r--helpers.py45
1 files changed, 40 insertions, 5 deletions
diff --git a/helpers.py b/helpers.py
index b4a0fe0..7fbfb99 100644
--- a/helpers.py
+++ b/helpers.py
@@ -3,9 +3,9 @@ from pygame import *
3 3
4class Action: 4class Action:
5 action_types = [ 5 action_types = [
6 'command',
6 'pause', 7 'pause',
7 'play', 8 'play',
8 'run',
9 'stop', 9 'stop',
10 'volume', 10 'volume',
11 'wait', 11 'wait',
@@ -22,10 +22,30 @@ class Action:
22 def run(self, callback): 22 def run(self, callback):
23 getattr(self, self.action)(callback, **self.arguments) 23 getattr(self, self.action)(callback, **self.arguments)
24 24
25 def stop(self, callback, musique = None, fade_out = 0): 25 def command(self, callback, command = "", **kwargs):
26 pass
27
28 def pause(self, callback, music = None, **kwargs):
29 pass
30
31 def play(self, callback,
32 music = None,
33 fade_in = 0,
34 restart_if_running = False,
35 volume = 100,
36 **kwargs):
37 pass
38
39 def stop(self, callback, music = None, fade_out = 0, **kwargs):
26 print('stopping') 40 print('stopping')
27 return callback() 41 return callback()
28 42
43 def volume(self, callback, music = None, value = 100, **kwargs):
44 pass
45
46 def wait(self, callback, time = 0, **kwargs):
47 pass
48
29class Key: 49class Key:
30 row_positions = { 50 row_positions = {
31 'first': 5, 51 'first': 5,
@@ -106,7 +126,22 @@ class Key:
106 if len(self.actions) > 0: 126 if len(self.actions) > 0:
107 self.actions[0].run(self.next_action) 127 self.actions[0].run(self.next_action)
108 128
109 def find_from_unicode(key_sym): 129 def list_actions(self, surface):
130 print("bouh", self.key_sym)
131 surface.fill((255, 0, 0))
132
133 def find_by_key_num(key_num):
134 if key_num in Mapping.KEYS:
135 return Mapping.KEYS[key_num]
136 return None
137
138 def find_by_collidepoint(position):
139 for key in Mapping.KEYS:
140 if Mapping.KEYS[key].collidepoint(position):
141 return Mapping.KEYS[key]
142 return None
143
144 def find_by_unicode(key_sym):
110 for key in Mapping.KEYS: 145 for key in Mapping.KEYS:
111 if Mapping.KEYS[key].key_sym == key_sym: 146 if Mapping.KEYS[key].key_sym == key_sym:
112 return Mapping.KEYS[key] 147 return Mapping.KEYS[key]
@@ -294,7 +329,7 @@ def parse_config():
294 seen_files = {} 329 seen_files = {}
295 330
296 for mapped_key in config['keys']: 331 for mapped_key in config['keys']:
297 key = Key.find_from_unicode(mapped_key) 332 key = Key.find_by_unicode(mapped_key)
298 if key is None: 333 if key is None:
299 continue 334 continue
300 335
@@ -317,7 +352,7 @@ def parse_config():
317 if filename not in seen_files: 352 if filename not in seen_files:
318 seen_files[filename] = MusicFile.new(filename) 353 seen_files[filename] = MusicFile.new(filename)
319 354
320 action_args['file'] = seen_files[filename] 355 action_args['music'] = seen_files[filename]
321 356
322 else: 357 else:
323 action_args[argument] = action[action_name][argument] 358 action_args[argument] = action[action_name][argument]