aboutsummaryrefslogtreecommitdiff
path: root/helpers/mapping.py
diff options
context:
space:
mode:
Diffstat (limited to 'helpers/mapping.py')
-rw-r--r--helpers/mapping.py50
1 files changed, 40 insertions, 10 deletions
diff --git a/helpers/mapping.py b/helpers/mapping.py
index 864afbe..1256696 100644
--- a/helpers/mapping.py
+++ b/helpers/mapping.py
@@ -1,5 +1,5 @@
1from kivy.uix.relativelayout import RelativeLayout 1from kivy.uix.relativelayout import RelativeLayout
2from kivy.properties import NumericProperty, ListProperty 2from kivy.properties import NumericProperty, ListProperty, StringProperty
3from kivy.core.window import Window 3from kivy.core.window import Window
4from kivy.clock import Clock 4from kivy.clock import Clock
5 5
@@ -56,13 +56,34 @@ class Mapping(RelativeLayout):
56 'trigger': 'success', 56 'trigger': 'success',
57 'source': 'loading', 57 'source': 'loading',
58 'dest': 'loaded' 58 'dest': 'loaded'
59 },
60 {
61 'trigger': 'reload',
62 'source': 'loaded',
63 'dest': 'configuring'
59 } 64 }
60 ] 65 ]
61 66
62 master_volume = NumericProperty(100) 67 master_volume = NumericProperty(100)
63 ready_color = ListProperty([1, 165/255, 0, 1]) 68 ready_color = ListProperty([1, 165/255, 0, 1])
69 state = StringProperty("")
64 70
65 def __init__(self, **kwargs): 71 def __init__(self, **kwargs):
72 self.keys = []
73 self.running = []
74 self.wait_ids = {}
75 self.open_files = {}
76
77 Machine(model=self, states=self.STATES,
78 transitions=self.TRANSITIONS, initial='initial',
79 ignore_invalid_triggers=True, queued=True)
80 super(Mapping, self).__init__(**kwargs)
81 self.keyboard = Window.request_keyboard(self.on_keyboard_closed, self)
82 self.keyboard.bind(on_key_down=self.on_keyboard_down)
83
84 self.configure()
85
86 def on_enter_configuring(self):
66 if Config.builtin_mixing: 87 if Config.builtin_mixing:
67 self.mixer = Mixer() 88 self.mixer = Mixer()
68 else: 89 else:
@@ -74,14 +95,13 @@ class Mapping(RelativeLayout):
74 error_print("Error while loading configuration: {}".format(e), 95 error_print("Error while loading configuration: {}".format(e),
75 with_trace=True) 96 with_trace=True)
76 sys.exit() 97 sys.exit()
98 else:
99 self.success()
77 100
78 self.keys = [] 101 def on_enter_loading(self):
79 self.running = [] 102 for key in self.keys:
80 self.wait_ids = {} 103 key.reload()
81 104 self.success()
82 super(Mapping, self).__init__(**kwargs)
83 self.keyboard = Window.request_keyboard(self.on_keyboard_closed, self)
84 self.keyboard.bind(on_key_down=self.on_keyboard_down)
85 105
86 # Kivy events 106 # Kivy events
87 def add_widget(self, widget, index=0): 107 def add_widget(self, widget, index=0):
@@ -112,6 +132,8 @@ class Mapping(RelativeLayout):
112 thread.join() 132 thread.join()
113 133
114 sys.exit() 134 sys.exit()
135 elif 'ctrl' in modifiers and keycode[0] == 114:
136 threading.Thread(name="MSReload", target=self.reload).start()
115 return True 137 return True
116 138
117 # Helpers 139 # Helpers
@@ -143,6 +165,8 @@ class Mapping(RelativeLayout):
143 self.ready_color = [0, 1, 0, 1] 165 self.ready_color = [0, 1, 0, 1]
144 elif result == "partial": 166 elif result == "partial":
145 self.ready_color = [1, 0, 0, 1] 167 self.ready_color = [1, 0, 0, 1]
168 else:
169 self.ready_color = [1, 165/255, 0, 1]
146 170
147 ## Some global actions 171 ## Some global actions
148 def stop_all_running(self): 172 def stop_all_running(self):
@@ -347,8 +371,14 @@ class Mapping(RelativeLayout):
347 music_properties[filename], 371 music_properties[filename],
348 filename) 372 filename)
349 373
350 seen_files[filename] = MusicFile( 374 if filename in self.open_files:
351 filename, self, **music_property) 375 self.open_files[filename]\
376 .reload_properties(**music_property)
377
378 seen_files[filename] = self.open_files[filename]
379 else:
380 seen_files[filename] = MusicFile(
381 filename, self, **music_property)
352 382
353 if filename not in key_properties[mapped_key]['files']: 383 if filename not in key_properties[mapped_key]['files']:
354 key_properties[mapped_key]['files'] \ 384 key_properties[mapped_key]['files'] \