Skip to content

Commit

Permalink
Merge pull request #236 from tv2/SOF-1789/warnForInvalidSchemaDesignE…
Browse files Browse the repository at this point in the history
…ntries

SOF-1789 Notify user about incorrect CasparCgDesignValues
  • Loading branch information
LindvedKrvang authored Mar 15, 2024
2 parents 0b7c07d + e9bb98d commit 98b8ca1
Showing 1 changed file with 23 additions and 1 deletion.
24 changes: 23 additions & 1 deletion src/tv2-common/cues/gfx-schema-generator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,20 @@ import { CueType, SharedGraphicLLayer, SharedOutputLayer, SharedSourceLayer } fr
import { Tv2PieceType } from '../../tv2-constants/tv2-piece-type'
import { DveLoopGenerator } from '../helpers/graphics/caspar/dve-loop-generator'

interface CasparCgDesignValues {
name: string
properties: unknown
}

const NON_BASELINE_SCHEMA: string = 'NON_BASELINE_SCHEMA'
const VALID_EMPTY_SCHEMA_VALUE: string = 'N/A'

export class GfxSchemaGenerator {
constructor(private dveLoopGenerator: DveLoopGenerator) {}

public createBaselineTimelineObjectsFromGfxDefaults(context: ShowStyleContext): TSR.TSRTimelineObjBase[] {
this.assertAllCasparCgDesignValues(context)

const schemaId: string = context.config.showStyle.GfxDefaults[0].DefaultSchema.value
if (VALID_EMPTY_SCHEMA_VALUE === schemaId) {
return []
Expand All @@ -32,7 +39,6 @@ export class GfxSchemaGenerator {
)
return []
}

const cue: CueDefinitionGfxSchema = {
type: CueType.GraphicSchema,
schema: schema.VizTemplate,
Expand All @@ -42,6 +48,22 @@ export class GfxSchemaGenerator {
return this.createBaselineTimelineObjects(context, cue, 10)
}

private assertAllCasparCgDesignValues(context: ShowStyleContext): void {
context.config.showStyle.GfxSchemaTemplates.forEach((schema) => {
if (!schema.CasparCgDesignValues) {
return
}
const casparCgDesignValues: CasparCgDesignValues[] = JSON.parse(schema.CasparCgDesignValues)
casparCgDesignValues.forEach((designValues) => {
if (designValues.name && designValues.name.includes(' ')) {
context.core.notifyUserError(
`Schema for ${schema.VizTemplate} has invalid CasparCgDesignValues. The Design ${designValues.name} has whitespace in it's name!`
)
}
})
})
}

public createBlueprintPieceFromGfxSchemaCue(
context: ShowStyleContext,
pieces: IBlueprintPiece[],
Expand Down

0 comments on commit 98b8ca1

Please sign in to comment.