]> git.immae.eu Git - perso/Immae/Projets/Python/MusicSampler.git/commitdiff
Add pirate example config.yml + description
authorIsmaël Bouya <ismael.bouya@normalesup.org>
Sun, 19 Jun 2016 19:31:54 +0000 (21:31 +0200)
committerIsmaël Bouya <ismael.bouya@normalesup.org>
Sun, 19 Jun 2016 19:31:54 +0000 (21:31 +0200)
config.yml
helpers/__init__.py
helpers/action.py
helpers/key.py
helpers/music_file.py

index ae87de5be8f8d890fb6e9d11afd545e3c978002c..ca6c3991ad383c68d3a15c20f18f73078b1882c2 100644 (file)
 aliases:
-  jongle:
-    file: "/home/immae/temp/Pirates/PIRATE_01-1-intro_jonglacro.mp3"
-    volume: 110 # pouvoir dire que "par défaut" la musique a un volume à 110%
-  acros:
-    file: "../../temp/Pirates/PIRATE_01-2-jonglacro_suite.mp3"
+  intro_jonglacro:
+    file: "PIRATE_01-1-intro_jonglacro.mp3"
+  jonglacro_suite:
+    file: "PIRATE_01-2-jonglacro_suite.mp3"
+  lancer_prisonniere:
+    file: "PIRATE_02-lancers_de_prisonniere.mp3"
+  quete:
+    file: "PIRATE_03-quete.mp3"
+  entree_ondine:
+    file: "PIRATE_04-entree_ondine.mp3"
+  cour_ondine:
+    file: "PIRATE_05-cour_a_londine.mp3"
+  fouille_jonglage:
+    file: "PIRATE_07-fouille_jonglage.mp3"
+  liberation_prisonniere:
+    file: "PIRATE_08-liberation_prisonniere.mp3"
+  duo_pirate_ondine:
+    file: "PIRATE_09-duo_pirate_ondine.mp3"
+  trio_jalousie:
+    file: "PIRATE_10-trios_jalousie.mp3"
+  piquage_2_4:
+    file: "PIRATE_11-piquage_2_4.mp3"
+  baston:
+    file: "PIRATE_12-1-baston.mp3"
+  baston_ascension:
+    file: "PIRATE_12-3-baston_ascension.mp3"
+  bruit:
+    file: "PIRATE_bruit.wav"
+  paf:
+    file: "PIRATE_paf.mp3"
+  ralenti:
+    file: "PIRATE_12-2-ralenti.mp3"
+
+key_properties:
+  'a':
+    description:
+      - Chloé
+      - Jonglacro
+    color: [255, 0, 0]
+  'z':
+    description:
+      - Chloé
+      - Jonglacro 2
+    color: [255, 0, 0]
+  'e':
+    description:
+      - Chloé
+      - Stop jonglacro 2
+    color: [255, 0, 0]
+  'r':
+    description:
+      - Chloé
+      - Lancer prisonnière
+    color: [255, 0, 0]
+  't':
+    description:
+      - Chloé
+      - Stop lancer prisonnière
+    color: [255, 0, 0]
+  'y':
+    description:
+      - Chloé
+      - Quête
+    color: [255, 0, 0]
+  'u':
+    description:
+      - Chloé
+      - Grrr
+    color: [255, 0, 0]
+  'i':
+    description:
+      - Chloé
+      - Transition -> entrée ondine
+    color: [255, 0, 0]
+  'o':
+    description:
+      - Denise
+      - Cour ondine
+    color: [0, 255, 0]
+  'p':
+    description:
+      - Denise
+      - Stop cour ondine
+    color: [0, 255, 0]
+  'q':
+    description:
+      - Chloé
+      - Fouille jonglage
+    color: [255, 0, 0]
+  's':
+    description:
+      - Denise
+      - Stop fouille jonglage
+    color: [0, 255, 0]
+  'd':
+    description:
+      - Denise
+      - Libération prisonnière
+    color: [0, 255, 0]
+  'f':
+    description:
+      - Denise
+      - Paf + baisser musique
+    color: [0, 255, 0]
+  'g':
+    description:
+      - Denise
+      - Stop musique
+    color: [0, 255, 0]
+  'h':
+    description:
+      - Denise
+      - Duos
+    color: [0, 255, 0]
+  'j':
+    description:
+      - Jérôme
+      - Transition trios
+    color: [0, 0, 255]
+  'k':
+    description:
+      - Jérôme
+      - Stop trios
+    color: [0, 0, 255]
+  'l':
+    description:
+      - Jérôme
+      - Jeu à 2-4
+    color: [0, 0, 255]
+  'm':
+    description:
+      - Chloé
+      - Début baston
+    color: [255, 0, 0]
+  'w':
+    description:
+      - Christophe
+      - Transition ralenti
+    color: [255, 255, 0]
+  'x':
+    description:
+      - Christophe
+      - Stop ralenti
+    color: [255, 255, 0]
+  'c':
+    description:
+      - Christophe
+      - Début baston 2
+    color: [255, 255, 0]
+  'v':
+    description:
+      - Auréliane
+      - Stop baston 2
+    color: [0, 255, 255]
+
 
 keys:
   'a':
     - play:
-        include: jongle
-        fade_in: 5
-        restart_if_running: False
+        include: intro_jonglacro
   'z': 
     - stop:
-        include: jongle
+        include: intro_jonglacro
+        fade_out: 5
     - wait:
-        duration: 3
+        duration: 7
+    - play:
+        include: jonglacro_suite
+  'e':
+    - stop:
+        include: jonglacro_suite
+        fade_out: 5
+  'r':
+    - play:
+        include: lancer_prisonniere
+  't':
+    - stop:
+        include: lancer_prisonniere
+        fade_out: 3
+  'y':
     - play:
-        include: acros
-        fade_in: 4
-        start_at: 40
+        include: quete
+  'u':
+    - volume:
+        include: quete
+        value: 50
+    - play:
+        include: bruit
     - wait:
-        duration: 10
+        duration: 2
     - volume:
-        include: acros
-        value:  50
+        include: quete
+        value: 100
+  'i':
     - stop:
-        include: acros
-        fade_out: 10
-  'e':
+        include: quete
+        fade_out: 5
+    - wait:
+        duration: 20
     - play:
-        include: acros
-        restart_if_running: true
-  'r':
+        include: entree_ondine
+  'o':
+    - stop:
+        include: entree_ondine
+        fade_out: 5
+    - wait:
+        duration: 5
     - play:
-        include: acros
+        include: cour_ondine
+  'p':
+    - stop:
+        include: cour_ondine
+        fade_out: 5
+  'q':
+    - play:
+        include: fouille_jonglage
+  's':
+    - stop:
+        include: fouille_jonglage
+        fade_out: 2
+  'd':
+    - play:
+        include: liberation_prisonniere
+  'f':
+    - volume:
+        include: liberation_prisonniere
+        value: 20
+    - play:
+        include: paf
+  'g':
+    - stop:
+        include: liberation_prisonniere
+        fade_out: 3
+  'h':
+    - play:
+        include: duo_pirate_ondine
+  'j':
+    - stop:
+        include: duo_pirate_ondine
+        fade_out: 2
+    - wait:
+        duration: 2
+    - play:
+        include: trio_jalousie
+  'k':
+    - stop:
+        include: trio_jalousie
+  'l':
+    - play:
+        include: piquage_2_4
+  'm':
+    - stop:
+        include: piquage_2_4
+        fade_out: 5
+    - wait:
+        duration: 7
+    - play:
+        include: baston
+  'w':
+    - stop:
+        include: baston
+        fade_out: 1
+    - wait:
+        duration: 1
+    - play:
+        include: ralenti
+  'x':
+    - stop:
+        include: ralenti
+        fade_out: 2
+  'c':
+    - play:
+        include: baston_ascension
+  'v':
+    - stop:
+        include: baston_ascension
+        fade_out: 2
   'ESC':
     - stop: ~
     - stop_all_actions: ~
-  '-':
-    - volume:
-        value: 90
-  'p':
-    - command:
-        command: une_super_commande_de_feu_d'artifice
+
index b1723ee8e51c169ef5ccd922169a0e4ecefb6340..b7acbf55ee89683d447daee097d4bc78effb0d5b 100644 (file)
@@ -47,3 +47,13 @@ def parse_config(mapping):
                     action_args[argument] = action[action_name][argument]
 
             key.add_action(action_name, **action_args)
+
+    for key_property in config['key_properties']:
+        key = mapping.find_by_unicode(key_property)
+        if key is None:
+            continue
+
+        if 'description' in config['key_properties'][key_property]:
+            key.set_description(config['key_properties'][key_property]['description'])
+        if 'color' in config['key_properties'][key_property]:
+            key.set_color(config['key_properties'][key_property]['color'])
index 97873a0029d8e24e8a93b239174b305ab76bdd65..5afe43763c2f303ca8f6351ff14cf44e51287619 100644 (file)
@@ -74,10 +74,14 @@ class Action:
         else:
             pass
 
-    def wait(self, duration = 0, **kwargs):
+    def wait(self, duration = 0, music = None, **kwargs):
         # FIXME: Make it stoppable
         # http://stackoverflow.com/questions/29082268/python-time-sleep-vs-event-wait
-        time.sleep(duration)
+        if music is None:
+            time.sleep(duration)
+        else:
+            # TODO
+            music.wait_end()
 
     def command_print(self, command = "", **kwargs):
         return "running command {}".format(command)
index 6997e702d75a78040e391e77e225a02a40b08d76..9a6cb3b29f2a1b0270a1081490eab4efdc90f844 100644 (file)
@@ -18,7 +18,8 @@ class Key:
     lighter_outer_color = (200, 200, 200)
     default_inner_color = (255, 255, 255)
     mapped_inner_color  = (  0, 255,   0)
-    mapped_unready_inner_color = (255, 165, 0)
+    mapped_unready_inner_color  = (  0, 255,   0, 100)
+    #mapped_unready_inner_color = (255, 165, 0)
 
     def __init__(self, mapping, draw_lock, key_name, key_sym, top, left, width = 48, height = 48, disabled = False):
         self.draw_lock = draw_lock
@@ -50,13 +51,16 @@ class Key:
 
         self.inner_color = self.default_inner_color
         self.actions = []
+        self.description = []
+        self.custom_color = None
+        self.custom_unready_color = None
 
     def square(self, all_actions_ready):
         if self.has_actions():
             if all_actions_ready:
-                self.inner_color = self.mapped_inner_color
+                self.inner_color = self.custom_color or self.mapped_inner_color
             else:
-                self.inner_color = self.mapped_unready_inner_color
+                self.inner_color = self.custom_unready_color or self.mapped_unready_inner_color
 
         return RoundedRect((0, 0, self.width, self.height),
             self.outer_color, self.inner_color, self.linewidth)
@@ -67,6 +71,14 @@ class Key:
                 position[1] - self.position[1]
                 )
 
+    def set_description(self, description):
+        self.description = description
+
+    def set_color(self, color):
+        self.custom_color = tuple(color)
+        color.append(100)
+        self.custom_unready_color = tuple(color)
+
     def draw(self, background_surface):
         self.draw_lock.acquire()
         all_actions_ready = self.all_actions_ready()
@@ -75,11 +87,27 @@ class Key:
 
         if getattr(sys, 'frozen', False):
             police = pygame.font.Font(sys._MEIPASS + "/Ubuntu-Regular.ttf", 14)
+            text_police = pygame.font.Font(sys._MEIPASS + "/Ubuntu-Regular.ttf", 10)
         else:
             police = pygame.font.Font("Ubuntu-Regular.ttf", 14)
+            text_police = pygame.font.Font("Ubuntu-Regular.ttf", 10)
 
+        police.set_bold(True)
         text = police.render(self.key_sym, True, (0,0,0))
         self.surface.blit(text, (5,5))
+
+        is_first_line = True
+        offset = 11 + text_police.get_linesize()
+        first_line_offset = 18
+        for description in self.description:
+            text = text_police.render(description, True, (0,0,0))
+            if is_first_line:
+                self.surface.blit(text, (first_line_offset, 9))
+                is_first_line = False
+            else:
+                self.surface.blit(text, (5, offset))
+                offset += text_police.get_linesize()
+
         background_surface.blit(self.surface, self.position)
         self.draw_lock.release()
 
@@ -114,8 +142,8 @@ class Key:
 
     def list_actions(self, screen):
         action_descriptions = [action.description() for action in self.actions]
-        print("actions linked to key {}:".format(self.key_sym))
-        print("\t" + "\n\t".join(action_descriptions))
+        #print("actions linked to key {}:".format(self.key_sym))
+        #print("\t" + "\n\t".join(action_descriptions))
         self.draw_lock.acquire()
         surface = pygame.Surface((800, 250)).convert()
         surface.fill((250, 250, 250))
index 36a7dd9ee913bc350058ae24de4079c17a4eb749..b834104fe6b01d95930d4ea1e23bc8f108747015 100644 (file)
@@ -56,3 +56,5 @@ class MusicFile:
             value = 100
         self.sound.set_volume(value / 100)
 
+    def wait_end(self):
+        pass