-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
148 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
79 changes: 79 additions & 0 deletions
79
src/commands/Settings/MultiViewerWindowOverlayPropertiesCommand.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
import { DeserializedCommand, WritableCommand } from '../CommandBase' | ||
import { MultiViewerWindowOverlayPropertiesState } from '../../state/settings' | ||
import { AtemState, AtemStateUtil, InvalidIdError } from '../../state' | ||
|
||
export class MultiViewerWindowOverlayPropertiesCommand extends WritableCommand<MultiViewerWindowOverlayPropertiesState> { | ||
public static MaskFlags = { | ||
labelVisible: 1 << 0, | ||
borderVisible: 1 << 1, | ||
} | ||
|
||
public static readonly rawName = 'CMvO' | ||
|
||
public readonly multiViewerId: number | ||
public readonly windowIndex: number | ||
|
||
constructor(multiviewerId: number, windowIndex: number) { | ||
super() | ||
|
||
this.multiViewerId = multiviewerId | ||
this.windowIndex = windowIndex | ||
} | ||
|
||
public serialize(): Buffer { | ||
const buffer = Buffer.alloc(8) | ||
buffer.writeUInt8(this.multiViewerId, 0) | ||
buffer.writeUInt8(this.windowIndex || 0, 1) | ||
|
||
let value = 0 | ||
if (this.properties.labelVisible) value |= 0x01 | ||
if (this.properties.borderVisible) value |= 0x02 | ||
|
||
buffer.writeUInt8(value, 3) | ||
buffer.writeUInt8(this.flag, 5) | ||
return buffer | ||
} | ||
} | ||
|
||
export class MultiViewerWindowOverlayPropertiesUpdateCommand extends DeserializedCommand<MultiViewerWindowOverlayPropertiesState> { | ||
public static readonly rawName = 'MvOv' | ||
|
||
public readonly multiViewerId: number | ||
public readonly windowIndex: number | ||
|
||
constructor(multiviewerId: number, windowIndex: number, props: MultiViewerWindowOverlayPropertiesState) { | ||
super(props) | ||
|
||
this.multiViewerId = multiviewerId | ||
this.windowIndex = windowIndex | ||
} | ||
|
||
public static deserialize(rawCommand: Buffer): MultiViewerWindowOverlayPropertiesUpdateCommand { | ||
const multiViewerId = rawCommand.readUInt8(0) | ||
const windowIndex = rawCommand.readUInt8(1) | ||
|
||
const values = rawCommand.readUInt8(3) | ||
|
||
const props: MultiViewerWindowOverlayPropertiesState = { | ||
labelVisible: (values & 0x01) > 0, | ||
borderVisible: (values & 0x02) > 0, | ||
} | ||
|
||
return new MultiViewerWindowOverlayPropertiesUpdateCommand(multiViewerId, windowIndex, props) | ||
} | ||
|
||
public applyToState(state: AtemState): string { | ||
if (!state.info.multiviewer || this.multiViewerId >= state.info.multiviewer.count) { | ||
throw new InvalidIdError('MultiViewer', this.multiViewerId) | ||
} | ||
|
||
const multiviewer = AtemStateUtil.getMultiViewer(state, this.multiViewerId) | ||
const window = multiviewer.windows[this.windowIndex] | ||
if (!window) { | ||
throw new InvalidIdError('MultiViewer Window', this.multiViewerId, this.windowIndex) | ||
} | ||
window.overlayProperties = this.properties | ||
|
||
return `settings.multiViewers.${this.multiViewerId}.windows.${this.windowIndex}.overlayProperties` | ||
} | ||
} |
51 changes: 51 additions & 0 deletions
51
src/commands/Settings/MultiViewerWindowSafeAreaTypeCommand.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import { SymmetricalCommand } from '../CommandBase' | ||
import { AtemState, AtemStateUtil, InvalidIdError } from '../../state' | ||
import { SafeTitlePattern } from '../../enums' | ||
import { combineComponents, getComponents } from '../../lib/atemUtil' | ||
|
||
export class MultiViewerWindowOverlaySafeAreaPatternCommand extends SymmetricalCommand<{ | ||
safeTitlePattern: SafeTitlePattern[] | ||
}> { | ||
public static readonly rawName = 'StMw' | ||
|
||
public readonly multiViewerId: number | ||
public readonly windowIndex: number | ||
|
||
constructor(multiviewerId: number, windowIndex: number, safeTitlePattern: SafeTitlePattern[]) { | ||
super({ safeTitlePattern }) | ||
|
||
this.multiViewerId = multiviewerId | ||
this.windowIndex = windowIndex | ||
} | ||
|
||
public serialize(): Buffer { | ||
const buffer = Buffer.alloc(4) | ||
buffer.writeUInt8(this.multiViewerId, 0) | ||
buffer.writeUInt8(this.windowIndex, 1) | ||
buffer.writeUInt8(combineComponents(this.properties.safeTitlePattern), 2) | ||
return buffer | ||
} | ||
|
||
public static deserialize(rawCommand: Buffer): MultiViewerWindowOverlaySafeAreaPatternCommand { | ||
const multiViewerId = rawCommand.readUInt8(0) | ||
const windowIndex = rawCommand.readUInt8(1) | ||
const safeTitlePattern = getComponents(rawCommand.readUInt8(2)) as SafeTitlePattern[] | ||
|
||
return new MultiViewerWindowOverlaySafeAreaPatternCommand(multiViewerId, windowIndex, safeTitlePattern) | ||
} | ||
|
||
public applyToState(state: AtemState): string { | ||
if (!state.info.multiviewer || this.multiViewerId >= state.info.multiviewer.count) { | ||
throw new InvalidIdError('MultiViewer', this.multiViewerId) | ||
} | ||
|
||
const multiviewer = AtemStateUtil.getMultiViewer(state, this.multiViewerId) | ||
const window = multiviewer.windows[this.windowIndex] | ||
if (!window) { | ||
throw new InvalidIdError('MultiViewer Window', this.multiViewerId, this.windowIndex) | ||
} | ||
window.safeTitlePattern = this.properties.safeTitlePattern | ||
|
||
return `settings.multiViewers.${this.multiViewerId}.windows.${this.windowIndex}.safeTitlePattern` | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters