]> git.immae.eu Git - perso/Immae/Projets/Python/MusicSampler.git/blobdiff - helpers.py
Add stub commands
[perso/Immae/Projets/Python/MusicSampler.git] / helpers.py
index b4a0fe00da53e8c2bb4f04f9ae9080f40247b4f4..7fbfb99b59bb665db42fa533df9e807641f81295 100644 (file)
@@ -3,9 +3,9 @@ from pygame import *
 
 class Action:
     action_types = [
+        'command',
         'pause',
         'play',
-        'run',
         'stop',
         'volume',
         'wait',
@@ -22,10 +22,30 @@ class Action:
     def run(self, callback):
         getattr(self, self.action)(callback, **self.arguments)
 
-    def stop(self, callback, musique = None, fade_out = 0):
+    def command(self, callback, command = "", **kwargs):
+        pass
+
+    def pause(self, callback, music = None, **kwargs):
+        pass
+
+    def play(self, callback,
+            music = None,
+            fade_in = 0,
+            restart_if_running = False,
+            volume = 100,
+            **kwargs):
+        pass
+
+    def stop(self, callback, music = None, fade_out = 0, **kwargs):
         print('stopping')
         return callback()
 
+    def volume(self, callback, music = None, value = 100, **kwargs):
+        pass
+
+    def wait(self, callback, time = 0, **kwargs):
+        pass
+
 class Key:
     row_positions = {
         'first':    5,
@@ -106,7 +126,22 @@ class Key:
         if len(self.actions) > 0:
             self.actions[0].run(self.next_action)
 
-    def find_from_unicode(key_sym):
+    def list_actions(self, surface):
+        print("bouh", self.key_sym)
+        surface.fill((255, 0, 0))
+
+    def find_by_key_num(key_num):
+        if key_num in Mapping.KEYS:
+            return Mapping.KEYS[key_num]
+        return None
+
+    def find_by_collidepoint(position):
+        for key in Mapping.KEYS:
+            if Mapping.KEYS[key].collidepoint(position):
+                return Mapping.KEYS[key]
+        return None
+
+    def find_by_unicode(key_sym):
         for key in Mapping.KEYS:
             if Mapping.KEYS[key].key_sym == key_sym:
                 return Mapping.KEYS[key]
@@ -294,7 +329,7 @@ def parse_config():
     seen_files = {}
 
     for mapped_key in config['keys']:
-        key = Key.find_from_unicode(mapped_key)
+        key = Key.find_by_unicode(mapped_key)
         if key is None:
             continue
 
@@ -317,7 +352,7 @@ def parse_config():
                     if filename not in seen_files:
                         seen_files[filename] = MusicFile.new(filename)
 
-                    action_args['file'] = seen_files[filename]
+                    action_args['music'] = seen_files[filename]
 
                 else:
                     action_args[argument] = action[action_name][argument]