-
Notifications
You must be signed in to change notification settings - Fork 1
/
actions.js
406 lines (392 loc) · 9.47 KB
/
actions.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
module.exports = function (self) {
const sendOscMessage = (path, args) => {
self.log('debug', `Sending OSC ${self.config.host} ${path} ${JSON.stringify(args)}`)
if (self.osc) {
try {
self.osc.send({ address: path, args: args })
} catch (e) {
// Ignore
}
}
}
self.setActionDefinitions({
go: {
name: 'Go',
callback: async (action) => {
sendOscMessage('/go', [])
},
},
back: {
name: 'Back',
callback: async (action) => {
sendOscMessage('/back', [])
},
},
jump_cue: {
name: 'Jump to cue',
options: [
{
type: 'textinput',
label: 'Cue number',
id: 'jumpcue',
default: '0',
},
],
callback: async (action) => {
sendOscMessage('/jump', [
{
type: 's',
value: action.options.jumpcue,
},
])
},
},
keypad_entry: {
name: 'Keypad entry',
description: 'For use with with "jump to keypad cue" and "allocate keypad channel to spare backup" actions',
options: [
{
type: 'dropdown',
label: 'Key',
id: 'key',
default: '0',
choices: [
{ id: '0', label: '0' },
{ id: '1', label: '1' },
{ id: '2', label: '2' },
{ id: '3', label: '3' },
{ id: '4', label: '4' },
{ id: '5', label: '5' },
{ id: '6', label: '6' },
{ id: '7', label: '7' },
{ id: '8', label: '8' },
{ id: '9', label: '9' },
{ id: '.', label: '.' },
],
},
],
callback: async (action) => {
if (self.keypadMode == 'cue') {
if (self.keypadJumpCue == '' && action.options.key == '.') {
// prepend 0 to empty point input
self.keypadJumpCue = '0.'
} else if (self.keypadJumpCue == '0' && action.options.key != '.') {
// strip leading 0 if not a point input
self.keypadJumpCue = action.options.key
} else if (
!(self.keypadJumpCue.includes('.') && action.options.key == '.') &&
self.keypadJumpCue.length < 7
) {
// prohibit multiple points in input
// tmix maximum cue number is 9999.99 => 7 characters
if (self.keypadJumpCue.includes('.') && self.keypadJumpCue.length > 3) {
if (self.keypadJumpCue.substring(self.keypadJumpCue.length - 3, self.keypadJumpCue.length - 2) != '.') {
// only accept two digits after a point
self.keypadJumpCue = self.keypadJumpCue + action.options.key
}
} else if (
!(self.keypadJumpCue.length == 4 && !self.keypadJumpCue.includes('.') && action.options.key != '.')
) {
// tmix maximum whole cue number is 9999, after 4 digits only accept a point
self.keypadJumpCue = self.keypadJumpCue + action.options.key
}
}
self.setVariableValues({
keypad_jump_entry: self.keypadJumpCue,
keypad_spare_entry: '',
})
} else if (self.keypadMode == 'spare') {
if (self.keypadJumpCue == '' && (action.options.key == '0' || action.options.key == '.')) {
// map single 0 or . to x (remove)
self.keypadJumpCue = 'x'
} else if (self.keypadJumpCue == 'x' && action.options.key != '.') {
// strip leading 0 (x) if followed by other input
// but also map single 0 to x (remove)
if (action.options.key == '0') action.options.key = 'x'
self.keypadJumpCue = action.options.key
} else if (action.options.key != '.' && self.keypadJumpCue.length <= 2) {
// don't allow point input
// but allow single 0 => unallocate
// max 3 digits
self.keypadJumpCue = self.keypadJumpCue + action.options.key
}
self.setVariableValues({
keypad_jump_entry: '',
keypad_spare_entry: self.keypadJumpCue,
})
}
self.checkFeedbacks('keypad_cue_entry', 'keypad_spare_entry')
},
},
keypad_clear: {
name: 'Keypad clear',
description: 'For use with with "jump to keypad cue" and "allocate keypad channel to spare backup" actions',
callback: async (action) => {
self.keypadJumpCue = ''
self.keypadMode = 'cue'
self.setVariableValues({
keypad_jump_entry: '',
keypad_spare_entry: '',
})
self.checkFeedbacks('keypad_cue_entry', 'keypad_spare_entry')
},
},
jump_keypad: {
name: 'Jump to keypad cue',
description: 'Select a cue number using keypad entry actions, then execute this action to jump',
callback: async (action) => {
if (self.keypadMode == 'cue') {
if (self.keypadJumpCue != '') {
if (self.keypadJumpCue.endsWith('.')) {
// strip off trailing point
keypad_jump_cue = keypad_jump_cue.slice(0, -1)
}
sendOscMessage('/jump', [
{
type: 's',
value: self.keypadJumpCue,
},
])
}
self.keypadJumpCue = ''
self.setVariableValues({
keypad_jump_entry: '',
keypad_spare_entry: '',
})
}
self.checkFeedbacks('keypad_cue_entry', 'keypad_spare_entry')
},
},
keypad_spare: {
name: 'Allocate keypad channel to spare backup',
description:
'First execute this action, then select a channel using keypad entry actions, then execute this action again to allocate. Use 0 to remove the allocation.',
callback: async (action) => {
if (self.keypadJumpCue == '' && self.keypadMode == 'cue') {
self.keypadMode = 'spare'
} else if (
self.keypadMode == 'spare' &&
self.keypadJumpCue.length > 0 &&
self.keypadJumpCue.length <= 3 &&
!self.keypadJumpCue.includes('.')
) {
// doiiiittttt
intChannel = parseInt(self.keypadJumpCue)
if (intChannel <= 0 || self.keypadJumpCue == 'x') {
// treat as unallocate
sendOscMessage('/removespare', [])
} else {
sendOscMessage('/allocatespare', [
{
type: 'i',
value: intChannel,
},
])
}
self.keypadJumpCue = ''
self.keypadMode = 'cue'
self.setVariableValues({
keypad_jump_entry: '',
keypad_spare_entry: '',
})
} else if (self.keypadMode == 'spare') {
// invalid input, reset
self.keypadJumpCue = ''
self.keypadMode = 'cue'
self.setVariableValues({
keypad_jump_entry: '',
keypad_spare_entry: '',
})
}
self.checkFeedbacks('keypad_cue_entry', 'keypad_spare_entry')
},
},
select_current: {
name: 'Select current cue',
callback: async (action) => {
sendOscMessage('/select', [
{
type: 's',
value: 'current',
},
])
},
},
select_up: {
name: 'Select up',
callback: async (action) => {
sendOscMessage('/select', [
{
type: 's',
value: 'up',
},
])
},
},
select_down: {
name: 'Select down',
callback: async (action) => {
sendOscMessage('/select', [
{
type: 's',
value: 'down',
},
])
},
},
jump_selected: {
name: 'Jump to selected cue',
callback: async (action) => {
sendOscMessage('/jump', [
{
type: 's',
value: 'selected',
},
])
},
},
mark_cue: {
name: 'Mark cue',
options: [
{
type: 'dropdown',
label: 'Which cue',
choices: [
{ id: 'current', label: 'Current cue' },
{ id: 'selected', label: 'Selected cue' },
],
id: 'selection',
default: 'current',
},
{
type: 'textinput',
label: 'Notes (optional)',
id: 'notes',
default: '',
},
],
callback: async (action) => {
sendOscMessage('/markcue', [
{
type: 's',
value: action.options.selection,
},
{
type: 's',
value: action.options.notes,
},
])
},
},
insert_cue: {
name: 'Insert cue',
callback: async (action) => {
sendOscMessage('/insertcue', [])
},
},
clone_cue: {
name: 'Clone cue',
callback: async (action) => {
sendOscMessage('/clonecue', [])
},
},
delete_cue: {
name: 'Delete cue',
callback: async (action) => {
sendOscMessage('/deletecue', [])
},
},
undo: {
name: 'Undo',
callback: async (action) => {
sendOscMessage('/undo', [])
},
},
redo: {
name: 'Redo',
callback: async (action) => {
sendOscMessage('/redo', [])
},
},
unlock: {
name: 'Unlock editing',
callback: async (action) => {
sendOscMessage('/unlock', [])
},
},
lock: {
name: 'Lock editing',
callback: async (action) => {
sendOscMessage('/lock', [])
},
},
record_offsets: {
name: 'Record level offsets',
callback: async (action) => {
sendOscMessage('/recordoffsets', [])
},
},
clone_offsets: {
name: 'Clone level offsets',
callback: async (action) => {
sendOscMessage('/cloneoffsets', [])
},
},
toggle_backup: {
name: 'Toggle backup channel',
options: [
{
type: 'number',
label: 'Main channel',
id: 'channel',
min: 1,
max: 500,
required: true,
default: 1,
},
],
callback: async (action) => {
sendOscMessage('/togglebackup', [
{
type: 'i',
value: parseInt(action.options.channel),
},
])
},
},
allocate_spare: {
name: 'Allocate spare backup',
options: [
{
type: 'number',
label: 'Main channel',
id: 'channel',
min: 1,
max: 500,
required: true,
default: 1,
},
],
callback: async (action) => {
sendOscMessage('/allocatespare', [
{
type: 'i',
value: parseInt(action.options.channel),
},
])
},
},
toggle_spare: {
name: 'Toggle spare backup',
callback: async (action) => {
sendOscMessage('/togglespare', [])
},
},
remove_spare: {
name: 'Remove spare allocation',
callback: async (action) => {
sendOscMessage('/removespare', [])
},
},
})
}