@@ -15,6 +15,7 @@ import { mutations as typeManifestMutations } from './typeManifests'
1515import { Server , Socket } from 'socket.io'
1616import { ografHandler } from '../ografHandler'
1717import { getDefaultDataFromSchema } from '../lib/ograf-default-data'
18+ import * as OGraf from 'ograf'
1819
1920export const mutations = {
2021 async create (
@@ -126,6 +127,8 @@ export function registerSettingsHandlers(socket: Socket, _io: Server) {
126127 {
127128 const ografs = await ografHandler . loadGraphics ( payload )
128129
130+ console . log ( `Loaded ${ ografs . length } graphics from OGraf server` )
131+
129132 const readPieceManifests = await typeManifestMutations . read ( {
130133 entityType : TypeManifestEntity . Piece
131134 } )
@@ -134,47 +137,20 @@ export function registerSettingsHandlers(socket: Socket, _io: Server) {
134137 if ( readPieceManifests && Array . isArray ( readPieceManifests . result ) )
135138 pieceManifests = readPieceManifests . result
136139
137- const OGRAF_GRAPHICS_ID_PREFIX = 'ograf_graphic_'
138140 for ( const ograf of ografs ) {
139- const id = `${ OGRAF_GRAPHICS_ID_PREFIX } ${ ograf . id } `
140- const name = `OGraf: ${ ograf . name } `
141- const shortName = ograf . name
142- const payload : PayloadManifest [ ] = [
143- {
144- id : 'data' ,
145- label : 'Data' ,
146- type : ManifestFieldType . OGrafForm ,
147- defaultValue : getDefaultDataFromSchema ( ograf . manifest . schema ) ,
148- includeInName : true ,
149- ografManifest : ograf . manifest
150- }
151- ]
141+ const typeManifest = getOGrafManifest ( ograf . id , ograf . manifest )
152142
153143 const existingPieceManifest = pieceManifests . find (
154- ( pieceManifest ) => pieceManifest . id === id
144+ ( pieceManifest ) => pieceManifest . id === typeManifest . id
155145 )
156146 if ( ! existingPieceManifest ) {
157- await typeManifestMutations . create ( {
158- id,
159- entityType : TypeManifestEntity . Piece ,
160- name,
161- shortName,
162- colour : '#FFCC00' ,
163- includeTypeInName : true ,
164- payload
165- } )
147+ console . log ( `Creating new piece manifest for OGraf graphic ${ typeManifest . id } ` )
148+ await typeManifestMutations . create ( typeManifest )
166149 } else {
150+ console . log ( `Updating existing piece manifest for OGraf graphic ${ typeManifest . id } ` )
167151 await typeManifestMutations . update ( {
168- id,
169- update : {
170- id,
171- // entityType: TypeManifestEntity.Piece,
172- colour : existingPieceManifest . colour ?? '#FFCC00' ,
173- // includeTypeInName: existingPieceManifest.includeTypeInName ?? true,
174- name,
175- shortName,
176- payload
177- }
152+ id : typeManifest . id ,
153+ update : typeManifest
178154 } )
179155 }
180156 }
@@ -235,3 +211,45 @@ export async function initializeDefaults(force: boolean = false): Promise<void>
235211 }
236212 }
237213}
214+
215+ function getOGrafManifest ( id : string , manifest : OGraf . GraphicsManifest ) : TypeManifest {
216+ return {
217+ id : `ograf-${ id } ` ,
218+ colour : '#5555ff' ,
219+ entityType : TypeManifestEntity . Piece ,
220+ name : `${ manifest . name } ` ,
221+ shortName : 'OGraf' ,
222+ includeTypeInName : true ,
223+
224+ payload : [
225+ {
226+ id : 'ograf-id' ,
227+ label : 'OGraf Id' ,
228+ type : ManifestFieldType . Const ,
229+ defaultValue : id
230+ } ,
231+ {
232+ id : 'type' ,
233+ label : 'Type of Graphics' ,
234+ type : ManifestFieldType . Enum ,
235+ enumValues : [
236+ { label : 'Full Screen' , value : 'full-screen' } ,
237+ { label : 'Overlay 1' , value : 'overlay1' } ,
238+ { label : 'Overlay 2' , value : 'overlay2' } ,
239+ { label : 'Overlay 3' , value : 'overlay3' } ,
240+ { label : 'Studio Screen 1' , value : 'studio1' } ,
241+ { label : 'Studio Screen 2' , value : 'studio2' } ,
242+ { label : 'Studio Screen 3' , value : 'studio3' }
243+ ] ,
244+ defaultValue : 'overlay1'
245+ } ,
246+ {
247+ id : 'ograf-data' ,
248+ label : 'OGraf Data' ,
249+ type : ManifestFieldType . OGrafForm ,
250+ ografManifest : manifest ,
251+ defaultValue : manifest . schema ? getDefaultDataFromSchema ( manifest . schema ) : undefined
252+ }
253+ ]
254+ } satisfies TypeManifest
255+ }
0 commit comments