Skip to content

Commit 77f28e6

Browse files
committed
add: presets for sends on fade buttons
1 parent a4a9c0f commit 77f28e6

File tree

3 files changed

+53
-6
lines changed

3 files changed

+53
-6
lines changed

src/actions/control.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,9 @@ export function createControlActions(self: InstanceBaseExt<WingConfig>): Compani
170170
callback: async (event) => {
171171
const cmd = ControlCommands.SetSof()
172172
const channel = ActionUtil.getStringWithVariables(event, 'channel')
173+
const channelIndex = ActionUtil.getStripIndexFromString(channel)
174+
const currentSelectedIndex = StateUtil.getNumberFromState(cmd, state) ?? 0
175+
173176
/* explicitely use a string as argument. OSC Documentation:
174177
* -1: sof active
175178
* 0: sof not active
@@ -180,13 +183,10 @@ export function createControlActions(self: InstanceBaseExt<WingConfig>): Compani
180183
* When pressing on the console, the state is updated from the string the console sends,
181184
* which is always lower by 1 compared to the integer
182185
*/
183-
const channelIndex = `${ActionUtil.getStripIndexFromString(channel)}`
184-
const currentSelectedIndex = StateUtil.getStringFromState(cmd, state) ?? '0'
185-
186186
if (channelIndex === currentSelectedIndex) {
187-
await send(cmd, '0')
187+
await send(cmd, 1)
188188
} else {
189-
await send(cmd, channelIndex)
189+
await send(cmd, channelIndex + 1)
190190
}
191191
},
192192
},

src/feedbacks.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -646,7 +646,7 @@ export function GetFeedbacksList(_self: InstanceBaseExt<WingConfig>): CompanionF
646646
const channel = ActionUtil.getStringWithVariables(event, 'channel')
647647
const channelIndex = ActionUtil.getStripIndexFromString(channel)
648648
const cmd = ControlCommands.SetSof()
649-
const currentSelectedIndex = parseInt(StateUtil.getStringFromState(cmd, state) ?? '-1')
649+
const currentSelectedIndex = StateUtil.getNumberFromState(cmd, state)
650650
return currentSelectedIndex === channelIndex
651651
},
652652
subscribe: async (event): Promise<void> => {

src/presets.ts

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,27 +17,32 @@ export function GetPresets(_instance: InstanceBaseExt<WingConfig>): CompanionPre
1717
presets[`ch${i}-mute-button`] = getMutePreset('ch', i)
1818
presets[`ch${i}-solo-button`] = getSoloPreset('ch', i)
1919
presets[`ch${i}-boost-and-center-button`] = getBoostAndCenterPreset('ch', i)
20+
presets[`ch${i}-sof-button`] = getSofPresets('ch', i)
2021
}
2122

2223
for (let i = 1; i <= model.auxes; i++) {
2324
presets[`aux${i}-mute-button`] = getMutePreset('aux', i)
2425
presets[`aux${i}-solo-button`] = getSoloPreset('aux', i)
2526
presets[`aux${i}-boost-and-center-button`] = getBoostAndCenterPreset('aux', i)
27+
presets[`aux${i}-sof-button`] = getSofPresets('aux', i)
2628
}
2729

2830
for (let i = 1; i <= model.busses; i++) {
2931
presets[`bus${i}-mute-button`] = getMutePreset('bus', i)
3032
presets[`bus${i}-solo-button`] = getSoloPreset('bus', i)
33+
presets[`bus${i}-sof-button`] = getSofPresets('bus', i)
3134
}
3235

3336
for (let i = 1; i <= model.matrices; i++) {
3437
presets[`mtx${i}-mute-button`] = getMutePreset('mtx', i)
3538
presets[`mtx${i}-solo-button`] = getSoloPreset('mtx', i)
39+
presets[`mtx${i}-sof-button`] = getSofPresets('mtx', i)
3640
}
3741

3842
for (let i = 1; i <= model.mains; i++) {
3943
presets[`main${i}-mute-button`] = getMutePreset('main', i)
4044
presets[`main${i}-solo-button`] = getSoloPreset('main', i)
45+
presets[`main${i}-sof-button`] = getSofPresets('main', i)
4146
}
4247

4348
for (let i = 1; i <= model.dcas; i++) {
@@ -324,3 +329,45 @@ function getLightPresetDark(): CompanionButtonPresetDefinition {
324329
feedbacks: [],
325330
}
326331
}
332+
333+
function getSofPresets(base: string, val: number): CompanionButtonPresetDefinition {
334+
const path = `/${base}/${val}`
335+
const name = `${base.toUpperCase()}${val}`
336+
return {
337+
name: 'Sends on Fader',
338+
category: 'Sends on Fader',
339+
type: 'button',
340+
style: {
341+
text: `let name = 'SOF'const realName = $(wing:${base}${val}_name)let hasNoName = realName === '' || isreturn hasNoName ? 'SOF ${name}' : \`SOF \${realName}\``,
342+
textExpression: true,
343+
size: 'auto',
344+
color: combineRgb(255, 255, 255),
345+
bgcolor: combineRgb(0, 0, 0),
346+
},
347+
steps: [
348+
{
349+
down: [
350+
{
351+
actionId: OtherActionId.SetSOF,
352+
options: {
353+
toggle: true,
354+
channel: path,
355+
},
356+
},
357+
],
358+
up: [],
359+
},
360+
],
361+
feedbacks: [
362+
{
363+
feedbackId: FeedbackId.SofActive,
364+
options: {
365+
channel: path,
366+
},
367+
style: {
368+
bgcolor: combineRgb(255, 165, 0),
369+
},
370+
},
371+
],
372+
}
373+
}

0 commit comments

Comments
 (0)