aboutsummaryrefslogtreecommitdiff
path: root/helpers/mapping.py
diff options
context:
space:
mode:
Diffstat (limited to 'helpers/mapping.py')
-rw-r--r--helpers/mapping.py14
1 files changed, 14 insertions, 0 deletions
diff --git a/helpers/mapping.py b/helpers/mapping.py
index 43cacf2..0c81af4 100644
--- a/helpers/mapping.py
+++ b/helpers/mapping.py
@@ -11,6 +11,7 @@ from .music_file import *
11from .mixer import Mixer 11from .mixer import Mixer
12from . import Config, gain, error_print 12from . import Config, gain, error_print
13from .music_effect import GainEffect 13from .music_effect import GainEffect
14from .action import Action
14 15
15class Mapping(RelativeLayout): 16class Mapping(RelativeLayout):
16 expected_keys = NumericProperty(0) 17 expected_keys = NumericProperty(0)
@@ -27,6 +28,7 @@ class Mapping(RelativeLayout):
27 self._keyboard = Window.request_keyboard(self._keyboard_closed, self) 28 self._keyboard = Window.request_keyboard(self._keyboard_closed, self)
28 self._keyboard.bind(on_key_down=self._on_keyboard_down) 29 self._keyboard.bind(on_key_down=self._on_keyboard_down)
29 self.running = [] 30 self.running = []
31 self.wait_ids = {}
30 Clock.schedule_interval(self.not_all_keys_ready, 1) 32 Clock.schedule_interval(self.not_all_keys_ready, 1)
31 33
32 @property 34 @property
@@ -53,6 +55,18 @@ class Mapping(RelativeLayout):
53 else: 55 else:
54 music.set_gain(db_gain) 56 music.set_gain(db_gain)
55 57
58 def add_wait_id(self, wait_id, action_or_wait):
59 self.wait_ids[wait_id] = action_or_wait
60
61 def interrupt_wait(self, wait_id):
62 if wait_id in self.wait_ids:
63 action_or_wait = self.wait_ids[wait_id]
64 del(self.wait_ids[wait_id])
65 if isinstance(action_or_wait, Action):
66 action_or_wait.interrupt()
67 else:
68 action_or_wait.set()
69
56 def _keyboard_closed(self): 70 def _keyboard_closed(self):
57 self._keyboard.unbind(on_key_down=self._on_keyboard_down) 71 self._keyboard.unbind(on_key_down=self._on_keyboard_down)
58 self._keyboard = None 72 self._keyboard = None