Skip to content

Commit

Permalink
Feat: Adjusting title text color/visibility
Browse files Browse the repository at this point in the history
  • Loading branch information
thedist committed Nov 30, 2024
1 parent 3ddc5fa commit 8226339
Show file tree
Hide file tree
Showing 3 changed files with 102 additions and 0 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ This module now supports Companions HTTP API, providing endpoints that can be us
- Added Actions:
- `Audio - Fade Bus Volume`
- `Audio - Set Input Channel Volume` (for separate mono inputs)
- `Title - Adjust title text Color`
- `Title - Adjust title text visibility`
- `VideoCall - Connect / Reconnect`, `Zoom - Join Meeting`
- Added Feedbacks:
- `vMix - Output Status`
Expand Down
2 changes: 2 additions & 0 deletions docs/PATCH_NOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
- Added Actions:
- `Audio - Fade Bus Volume`
- `Audio - Set Input Channel Volume` (for separate mono inputs)
- `Title - Adjust title text Color`
- `Title - Adjust title text visibility`
- `VideoCall - Connect / Reconnect`, `Zoom - Join Meeting`
- Added Feedbacks:
- `vMix - Output Status`
Expand Down
98 changes: 98 additions & 0 deletions src/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,8 @@ export interface VMixActions {
changeCountdown: VMixAction<ChangeCountdownCallback>
adjustCountdown: VMixAction<AdjustCountdownCallback>
setText: VMixAction<SetTextCallback>
setTextColor: VMixAction<SetTextColorCallback>
setTextVisible: VMixAction<SetTextVisibileCallback>
setColor: VMixAction<SetColorCallback>
selectTitlePreset: VMixAction<SelectTitlePresetCallback>
titlePreset: VMixAction<TitlePresetCallback>
Expand Down Expand Up @@ -784,6 +786,24 @@ interface SetTextCallback {
}>
}

interface SetTextColorCallback {
actionId: 'setTextColor'
options: Readonly<{
input: string
selectedIndex: string
value: string
}>
}

interface SetTextVisibileCallback {
actionId: 'setTextVisible'
options: Readonly<{
input: string
selectedIndex: string
adjustment: 'Toggle' | 'On' | 'Off'
}>
}

interface SetColorCallback {
actionId: 'setColor'
options: Readonly<{
Expand Down Expand Up @@ -1475,6 +1495,8 @@ export type ActionCallbacks =
| ChangeCountdownCallback
| AdjustCountdownCallback
| SetTextCallback
| SetTextColorCallback
| SetTextVisibileCallback
| SetColorCallback
| SelectTitlePresetCallback
| TitlePresetCallback
Expand Down Expand Up @@ -3891,6 +3913,82 @@ export function getActions(instance: VMixInstance): VMixActions {
},
},

setTextColor: {
name: 'Title - Adjust title text Color',
description: 'Adjusts text on a title layer',
options: [
options.input,
{
type: 'textinput',
label: 'Layer',
tooltip: '(Indexed from 0 or by name)',
id: 'selectedIndex',
default: '0',
useVariables: true,
},
{
type: 'textinput',
label: 'Color (#RRGGBB)',
id: 'value',
default: '',
useVariables: true,
},
],
callback: async (action) => {
const input = (await instance.parseOption(action.options.input))[instance.buttonShift.state]
const index = (await instance.parseOption(action.options.selectedIndex))[instance.buttonShift.state]
const value = (await instance.parseOption(action.options.value))[instance.buttonShift.state]

if (isNaN(parseInt(index, 10))) {
if (instance.tcp) instance.tcp.sendCommand(`FUNCTION SetTextColour Input=${input}&Value=${value}&SelectedName=${index}`)
} else {
if (instance.tcp) instance.tcp.sendCommand(`FUNCTION SetTextColour Input=${input}&Value=${value}&SelectedIndex=${index}`)
}
}
},

setTextVisible: {
name: 'Title - Adjust title text visibility',
description: 'Sets the visibility of title text Toggle, On, or Off',
options: [
options.input,
{
type: 'textinput',
label: 'Layer',
tooltip: '(Indexed from 0 or by name)',
id: 'selectedIndex',
default: '0',
useVariables: true,
},
{
type: 'dropdown',
label: 'Adjustment',
id: 'adjustment',
default: 'Toggle',
choices: [
{ id: 'Toggle', label: 'Toggle' },
{ id: 'On', label: 'On' },
{ id: 'Off', label: 'Off' },
],
},
],
callback: async (action) => {
const input = (await instance.parseOption(action.options.input))[instance.buttonShift.state]
const index = (await instance.parseOption(action.options.selectedIndex))[instance.buttonShift.state]
let type = 'SetTextVisible'

if (action.options.adjustment === 'On') type = 'SetTextVisibleOn'
if (action.options.adjustment === 'Off') type = 'SetTextVisibleOff'


if (isNaN(parseInt(index, 10))) {
if (instance.tcp) instance.tcp.sendCommand(`FUNCTION ${type} Input=${input}&SelectedName=${index}`)
} else {
if (instance.tcp) instance.tcp.sendCommand(`FUNCTION ${type} Input=${input}&SelectedIndex=${index}`)
}
}
},

setColor: {
name: 'Title - Adjust title shape color',
description: 'Requires vMix v25. only works on solid colors',
Expand Down

0 comments on commit 8226339

Please sign in to comment.