-
Notifications
You must be signed in to change notification settings - Fork 18
/
Copy pathpreset.ts
163 lines (147 loc) · 4.93 KB
/
preset.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
import type { CompanionFeedbackButtonStyleResult } from './feedback.js'
import type { CompanionOptionValues } from './input.js'
import type { CompanionButtonStyleProps } from './style.js'
/**
* The options for a button preset
*/
export interface CompanionButtonPresetOptions {
/** Use relative delays between the actions executing (default = false) */
relativeDelay?: boolean
/** Auto-progress the current step when releasing the button (default = true) */
stepAutoProgress?: boolean
/** Enable rotary actions for this button (default = false) */
rotaryActions?: boolean
}
/**
* The configuration of an feedback in a preset
*/
export interface CompanionPresetFeedback {
/** The id of the feedback definition */
feedbackId: string
/** The option values for the action */
options: CompanionOptionValues
/**
* If a boolean feedback, the style effect of the feedback
*/
style?: CompanionFeedbackButtonStyleResult
/**
* If a boolean feedback, invert the value of the feedback
*/
isInverted?: boolean
}
/**
* The configuration of an action in a preset
*/
export interface CompanionPresetAction {
/** The id of the action definition */
actionId: string
/** The execution delay of the action */
delay?: number
/** The option values for the action */
options: CompanionOptionValues
}
/**
* The definition of a press button preset
*/
export interface CompanionButtonPresetDefinition {
/** The type of this preset */
type: 'button'
/** The category of this preset, for grouping */
category: string
/** The name of this preset */
name: string
/** The base style of this preset, this will be copied to the button */
style: CompanionButtonStyleProps
/** Preview style for preset, will be used in GUI for preview */
previewStyle?: CompanionButtonStyleProps
/** Options for this preset */
options?: CompanionButtonPresetOptions
/** The feedbacks on the button */
feedbacks: CompanionPresetFeedback[]
steps: CompanionButtonStepActions[]
}
export interface CompanionPresetActionsWithOptions {
options?: CompanionActionSetOptions
actions: CompanionPresetAction[]
}
export interface CompanionActionSetOptions {
runWhileHeld?: boolean
}
export interface CompanionButtonStepActions {
/** The button down actions */
down: CompanionPresetAction[]
/** The button up actions */
up: CompanionPresetAction[]
rotate_left?: CompanionPresetAction[]
rotate_right?: CompanionPresetAction[]
[delay: number]: CompanionPresetActionsWithOptions | CompanionPresetAction[]
}
/**
* The definitions of a group of feedbacks
*/
export interface CompanionPresetDefinitions {
[id: string]: CompanionButtonPresetDefinition | undefined
}
export type StrictPresetDefinitions<TActions, TFeedbacks> = StrictPresetDefinitionCategory<TActions, TFeedbacks>[]
export type StrictPresetDefinitionCategory<TActions, TFeedbacks> = {
name: string
presets: Record<string, StrictButtonPresetDefinition<TActions, TFeedbacks>>
}
export interface StrictButtonPresetDefinition<TActions, TFeedbacks> {
/** The type of this preset */
type: 'button-strict'
/** The category of this preset, for grouping */
// category: string
/** The name of this preset */
name: string
/** The base style of this preset, this will be copied to the button */
style: CompanionButtonStyleProps
/** Preview style for preset, will be used in GUI for preview */
previewStyle?: CompanionButtonStyleProps
/** Options for this preset */
options?: CompanionButtonPresetOptions
/** The feedbacks on the button */
feedbacks: StrictPresetFeedback<TFeedbacks>[]
steps: StrictButtonStepActions<TActions>[]
}
type StrictPresetFeedbackInner<TTypes, Id extends keyof TTypes> = Id extends any
? {
/** The id of the feedback definition */
feedbackId: Id
/** The option values for the feedback */
options: TTypes[Id]
/**
* If a boolean feedback, the style effect of the feedback
*/
style?: CompanionFeedbackButtonStyleResult
/**
* If a boolean feedback, invert the value of the feedback
*/
isInverted?: boolean
}
: never
export type StrictPresetFeedback<TFeedbacks> = StrictPresetFeedbackInner<TFeedbacks, keyof TFeedbacks>
type StrictPresetActionInner<TTypes, Id extends keyof TTypes> = Id extends any
? {
/** The id of the action definition */
actionId: Id
/** The option values for the action */
options: TTypes[Id]
/** The execution delay of the action */
delay?: number
}
: never
export type StrictPresetAction<TActions> = StrictPresetActionInner<TActions, keyof TActions>
export interface StrictButtonStepActions<TActions> {
/** The button down actions */
down: StrictPresetAction<TActions>[]
/** The button up actions */
up: StrictPresetAction<TActions>[]
rotateLeft?: StrictPresetAction<TActions>[]
rotateRight?: StrictPresetAction<TActions>[]
[delay: number]: StrictPresetActionsWithOptions<TActions> | StrictPresetAction<TActions>[]
}
export interface StrictPresetActionsWithOptions<TActions> {
options?: CompanionActionSetOptions
actions: StrictPresetAction<TActions>[]
}