blob: 3c960f12df1a29c67db0a21d768a429e43c6164d (
plain)
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
|
;;; wasp-obs --- OBS controls -*- lexical-binding: t; -*-
;;; Commentary:
;;; Code:
(require 'dash)
(require 's)
(require 'f)
(require 'wasp-utils)
(require 'wasp-bus)
(defun w/obs-toggle-modclonk ()
"Toggle the MODCLONK panel."
(w/pub '(monitor obs toggle) (list "MODCLONK" "MODCLONK Chibi")))
(defun w/obs-toggle-live-reaction ()
"Toggle the Live LCOLONQ Reaction panel."
(w/pub '(monitor obs toggle) (list "Live LCOLONQ Reaction" "Live Reaction")))
(defun w/obs-toggle-live-friend-reaction ()
"Toggle the Live Friend Reaction panel."
(w/pub '(monitor obs toggle) (list "Live Friend Reaction" "Live Friend Reaction Group")))
(defun w/obs-toggle-thug-life ()
"Toggle the Thug Life overlay."
(w/pub '(monitor obs toggle) (list "Thug Life" "Thug Life Video")))
(defun w/obs-toggle-intj-stare ()
"Toggle the INTJ Stare overlay."
(w/pub '(monitor obs toggle) (list "INTJ" "INTJ Image")))
(defun w/obs-toggle-critical-hit ()
"Toggle the Critical Hit overlay."
(w/pub '(monitor obs toggle) (list "Critical Hit Wrapper" "Critical Hit")))
(defun w/obs-toggle-vhs ()
"Toggle the VHS overlay."
(w/pub '(monitor obs toggle) (list "VHS" "VHS Group")))
(defun w/obs-toggle-saiyan ()
"Toggle the Super Saiyan overlay."
(w/pub '(monitor obs toggle) (list "Saiyan" "Saiyan Video")))
(defun w/obs-toggle-persona4 ()
"Toggle the Persona 4 dialogue box."
(w/pub '(monitor obs toggle) (list "Persona 4" "Persona 4 Background")))
(defun w/obs-toggle-explosion ()
"Toggle the explosion effect."
(w/pub '(monitor obs toggle) (list "Explosion" "Explosion Video")))
(defun w/obs-set-clickbait-text (msg)
"Change the clickbait text to MSG."
(w/pub '(monitor obs set-text) (list "Red Arrow Text" (w/encode-string (s-trim msg)))))
(defun w/obs-toggle-clickbait (&optional msg)
"Toggle the clickbait arrow.
Optionally, change text to MSG."
(when msg
(w/obs-set-clickbait-text msg))
(w/pub '(monitor obs toggle) (list "Red Arrow" "Red Arrow Group")))
(defun w/obs-toggle-chase-dreams ()
"Toggle the Chasing Dreams effect."
(w/pub '(monitor obs toggle) (list "Chasing Dreams" "Dreams")))
(w/defstruct
w/obs-toggle
toggle
reset
(timer 0))
(defun w/obs-activate-toggle-helper (toggle &rest args)
"Pass ARGS to the callback for TOGGLE and start its timer."
(unless (w/obs-toggle-timer toggle)
(apply (w/obs-toggle-toggle toggle) args))
(setf (w/obs-toggle-timer toggle) (w/obs-toggle-reset toggle)))
(defvar w/obs-toggles
(list
(cons 'modclonk (w/make-obs-toggle :toggle #'w/obs-toggle-modclonk :reset 11))
(cons 'live-reaction (w/make-obs-toggle :toggle #'w/obs-toggle-live-reaction :reset 17))
(cons 'live-friend-reaction (w/make-obs-toggle :toggle #'w/obs-toggle-live-friend-reaction :reset 17))
(cons 'thug-life (w/make-obs-toggle :toggle #'w/obs-toggle-thug-life :reset 17))
(cons 'intj-stare (w/make-obs-toggle :toggle #'w/obs-toggle-intj-stare :reset 17))
(cons 'critical-hit (w/make-obs-toggle :toggle #'w/obs-toggle-critical-hit :reset 3))
(cons 'clickbait (w/make-obs-toggle :toggle #'w/obs-toggle-clickbait :reset 31))
(cons 'chase-dreams (w/make-obs-toggle :toggle #'w/obs-toggle-chase-dreams :reset 31))
))
(defun w/obs-activate-toggle (tnm &rest args)
"Pass ARGS to the callback for toggle symbol TNM and start its timer."
(when-let ((toggle (alist-get tnm w/obs-toggles)))
(apply #'w/obs-activate-toggle-helper toggle args)))
(defun w/obs-handle-toggles ()
"Process all OBS toggle timers."
(--each w/obs-toggles
(when (w/obs-toggle-timer (cdr it))
(cl-decf (w/obs-toggle-timer (cdr it)))
(when (<= (w/obs-toggle-timer (cdr it)) 0)
(setf (w/obs-toggle-timer (cdr it)) nil)
(funcall (w/obs-toggle-toggle (cdr it)))))
))
(defvar w/obs-timer nil)
(defun w/run-obs-timer ()
"Run the obs timer."
(when w/obs-timer
(cancel-timer w/obs-timer))
(w/obs-handle-toggles)
(setq
w/obs-timer
(run-with-timer 1 nil #'w/run-obs-timer)))
(provide 'wasp-obs)
;;; wasp-obs.el ends here
|