1+ import { FIELDS } from './fields.js'
2+
3+ export function getActions ( instance ) {
4+ return {
5+ setHeadsetName : {
6+ name : 'Set Headset Name' ,
7+ options : [ FIELDS . headsetId ( 'headsetId' ) ,
8+ {
9+ type : 'textinput' ,
10+ label : 'New Name' ,
11+ id : 'newHeadsetName' ,
12+ default : '' ,
13+ useVariables : true ,
14+ } ,
15+ ] ,
16+ callback : async ( action , context ) => {
17+ const headsetId = parseInt ( action . options . headsetId )
18+ const newHeadsetName = await context . parseVariablesInString ( action . options . newHeadsetName )
19+ await instance . setHeadsetName ( headsetId , newHeadsetName )
20+ } ,
21+ } ,
22+ setHeadsetChannel : {
23+ name : 'Set Headset Channel' ,
24+ options : [
25+ FIELDS . showCheckbox ( 'Use Headset ID' , 'useHeadsetId' , false ) ,
26+ {
27+ ...FIELDS . headsetId ( 'headsetId' ) ,
28+ isVisible : ( options ) => options . useHeadsetId === true ,
29+ } ,
30+ {
31+ ...FIELDS . headsetDropdown ( instance , 'headsetName' ) ,
32+ isVisible : ( options ) => options . useHeadsetId !== true ,
33+ } ,
34+ FIELDS . comDropdown ( ) ,
35+ FIELDS . channelDropdown ( ) ,
36+ ] ,
37+ callback : async ( action , context ) => {
38+ let headsetName = action . options . headsetName
39+
40+ // If using ID, convert ID to name
41+ if ( action . options . useHeadsetId ) {
42+ const headsetId = parseInt ( action . options . headsetId )
43+ const headset = instance . ppInfoData ?. [ 0 ] ?. PP ?. find ( headset => headset . id === headsetId )
44+ headsetName = headset . name
45+ }
46+
47+ // if (action.options.channelPosition.label === 'None') {
48+
49+ // }
50+
51+ const channelPosition = action . options . channelPosition
52+ const comPosition = action . options . comPosition
53+ await instance . setHeadsetChannel ( headsetName , channelPosition , comPosition )
54+ } ,
55+ } ,
56+ setHeadsetRole : {
57+ name : 'Set Headset Role' ,
58+ options : [
59+ FIELDS . showCheckbox ( 'Use Headset ID' , 'useHeadsetId' , false ) ,
60+ {
61+ ...FIELDS . headsetId ( 'headsetId' ) ,
62+ isVisible : ( options ) => options . useHeadsetId === true ,
63+ } ,
64+ {
65+ ...FIELDS . headsetDropdown ( instance , 'headsetName' ) ,
66+ isVisible : ( options ) => options . useHeadsetId !== true ,
67+ } ,
68+ FIELDS . roleDropdown ( instance ) ,
69+ {
70+ ...FIELDS . showCheckbox ( 'Head' , 'isHead' , false ) ,
71+ isVisible : ( options ) => {
72+ const validRoles = [ 'Lighting' , 'CamA' , 'CamB' , 'Production' , 'Grip' ]
73+ return validRoles . includes ( options . roleName )
74+ } ,
75+ } ,
76+ ] ,
77+ callback : async ( action , context ) => {
78+ let headsetName = action . options . headsetName
79+
80+ // If using ID, convert ID to name
81+ if ( action . options . useHeadsetId ) {
82+ const headsetId = parseInt ( action . options . headsetId )
83+ const headset = instance . ppInfoData ?. [ 0 ] ?. PP ?. find ( pp => pp . id === headsetId )
84+ if ( headset ) {
85+ headsetName = headset . name
86+ } else {
87+ instance . log ( 'error' , `Headset with ID ${ headsetId } not found` )
88+ return
89+ }
90+ }
91+
92+ const roleName = await context . parseVariablesInString ( action . options . roleName )
93+ const isHead = action . options . isHead
94+ await instance . setHeadsetRole ( headsetName , roleName , isHead )
95+ } ,
96+ } ,
97+ setHeadsetTalkMode : {
98+ name : 'Set Headset Talk Mode' ,
99+ options : [
100+ FIELDS . showCheckbox ( 'Use Headset ID' , 'useHeadsetId' , false ) ,
101+ {
102+ ...FIELDS . headsetId ( 'headsetId' ) ,
103+ isVisible : ( options ) => options . useHeadsetId === true ,
104+ } ,
105+ {
106+ ...FIELDS . headsetDropdown ( instance , 'headsetName' ) ,
107+ isVisible : ( options ) => options . useHeadsetId !== true ,
108+ } ,
109+ FIELDS . talkModeDropdown ( ) ,
110+ ] ,
111+ callback : async ( action , context ) => {
112+ let headsetName = action . options . headsetName
113+
114+ // If using ID, convert ID to name
115+ if ( action . options . useHeadsetId ) {
116+ const headsetId = parseInt ( action . options . headsetId )
117+ const headset = instance . ppInfoData ?. [ 0 ] ?. PP ?. find ( pp => pp . id === headsetId )
118+ if ( headset ) {
119+ headsetName = headset . name
120+ } else {
121+ instance . log ( 'error' , `Headset with ID ${ headsetId } not found` )
122+ return
123+ }
124+ }
125+
126+ const talkMode = action . options . talkMode
127+ await instance . setHeadsetTalkMode ( headsetName , talkMode )
128+ } ,
129+ } ,
130+ }
131+ }
0 commit comments