Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: support tally on streamdecks #25

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion packages/input-gateway/src/inputManagerHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -646,7 +646,15 @@ export class InputManagerHandler {
.reverse()

if (previewedAdlibs.length > 0) {
tally = tally | Tally.PRESENT
tally =
tally |
Tally.PRESENT |
previewedAdlibs.reduce(
(acc, adlib) =>
// @ts-expect-error: needs new build of core-integration, but we're on release50, which causes some incompatibilities, even though things just work...
acc | (adlib.isCurrent ? Tally.CURRENT : Tally.NONE) | (adlib.isNext ? Tally.NEXT : Tally.NONE),
Tally.NONE
)
contentLayerLongName = previewedAdlibs[0].sourceLayerName?.name
contentLayerShortName = previewedAdlibs[0].sourceLayerName?.abbreviation
contentLabel = previewedAdlibs.map((adlib) => InputManagerHandler.getStringLabel(adlib.label)).join(', ')
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ClassNames, BitmapFeedback } from '../../../feedback'
import { ClassNames, BitmapFeedback, Tally } from '../../../feedback'
import { BaseRenderer } from '../base'

/**
Expand Down Expand Up @@ -54,6 +54,11 @@ const COLORS: Record<string, string> = {
[ClassNames.UNKNOWN]: '#4b4b4b',
}

const TALLY_COLORS: Record<string, string> = {
[Tally.CURRENT]: '#ff0000',
[Tally.NEXT]: '#00ff00',
}

export class BaseAdLibRenderer extends BaseRenderer {
private getAdLibColor(classNames: string[] | undefined): string {
if (classNames === undefined) return COLORS[ClassNames.UNKNOWN]
Expand All @@ -62,6 +67,13 @@ export class BaseAdLibRenderer extends BaseRenderer {
return COLORS[ClassNames.UNKNOWN]
}

private getTallyColor(tally: Tally | undefined): string | undefined {
if (tally === undefined) return undefined
if (Tally.CURRENT & tally) return TALLY_COLORS[Tally.CURRENT]
if (Tally.NEXT & tally) return TALLY_COLORS[Tally.NEXT]
return undefined
}

private getFontSize(label: string): number {
if (label.length <= 3) {
return 2.5
Expand All @@ -86,7 +98,7 @@ export class BaseAdLibRenderer extends BaseRenderer {
spring: true,
fontSize: this.percentToPixels(this.getFontSize(label)),
lineHeight: this.percentToPixels(this.getFontSize(label)),
background: this.getAdLibColor(feedback.classNames),
background: this.getTallyColor(feedback.tally) ?? this.getAdLibColor(feedback.classNames),
textShadowOffset: 1,
lineClamp: 4,
})
Expand Down
4 changes: 2 additions & 2 deletions packages/input-manager/src/generated/streamdeck.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export interface StreamdeckStylePreset {
fontWeight?: 'normal' | 'bold'
fontWidth?: 'normal' | 'narrow'
fontStyle?: 'normal' | 'italic'
color?: boolean & string
color?: string
textStrokeColor?: string
textShadowColor?: string
textShadowOffset?: number
Expand All @@ -43,7 +43,7 @@ export interface StreamdeckStylePreset {
| 'left bottom'
| 'center bottom'
| 'right bottom'
textTransform?: 'capitalize' | 'uppercase' | 'lowercase'
textTransform?: 'none' | 'capitalize' | 'uppercase' | 'lowercase'
lineClamp?: number
inlineBackground?: string
inlineBackgroundPadding?: string
Expand Down