TTS redeems, skip button, per-source chat placement
- Redeem variations can have a TTS voice: the viewer's text is cleaned (links out, repeats collapsed, max length, blocked words -> not read), spoken as "<name> says: ..." and shown as the big paper note; the variation's sound is not played when TTS is on (picker greyed out) - Settings: TTS max length, say-the-name, blocked words (never sent to overlay pages: db.getOverlaySettings) - Dashboard "Skip current alert" -> /alerts/skip -> overlay skips it - db.migrate()/addColumn: new columns on existing databases - Chat: ?chat=left,top,width,height and ?chatflow=up per browser source (e.g. the Intermission panel); default unchanged Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
b5a81bdb15
commit
4fda6060bf
16 changed files with 228 additions and 28 deletions
|
|
@ -2,7 +2,8 @@
|
|||
Special redeem visuals, called by polaroid.js (shared queue). Each returns a Promise that resolves when done.
|
||||
FxAlert.giant(d, cur, snd) Gigantify Power-up: the viewer's emote grows huge, pulses while the sound plays
|
||||
FxAlert.rain(d, cur, snd) On-Screen Celebration Power-up: copies of the emote bounce around the screen
|
||||
FxAlert.message(d, cur, snd) Highlight my message / Message Effect: big taped paper note with the message
|
||||
FxAlert.message(d, cur, snd) Highlight my message / Message Effect / TTS redeems: big taped paper note with the message
|
||||
(d.tts = spoken message URL, d.ttsMs = its length; TTS redeems come without a sound)
|
||||
d: { name (user), line, msg, emote (image URL or null) }; snd: { url, len, volume }
|
||||
cur: { anims, timer, audio } so reset/skip can stop it (anything with cancel() can go in anims).
|
||||
*/
|
||||
|
|
@ -118,7 +119,14 @@
|
|||
{ delay:550, duration:Math.min(1600, 300 + 18 * text.length), easing:'ease-in-out' });
|
||||
playSound(cur, snd);
|
||||
const read = 2000 + 70 * text.length; // time to read it
|
||||
const exitAt = Math.max(650 + AFTER_ANIM, 650 + read, SOUND_LEAD + snd.len);
|
||||
let exitAt = Math.max(650 + AFTER_ANIM, 650 + read, SOUND_LEAD + snd.len);
|
||||
if (d.tts) { // TTS: after the intro sound, keep the note up until it is said
|
||||
const ttsAt = SOUND_LEAD + (snd.url ? snd.len + 250 : 300);
|
||||
const a = new Audio(d.tts); a.volume = snd.volume;
|
||||
const t = setTimeout(() => { cur.audio = a; a.play().catch(err => console.warn('[alerts] TTS blocked:', err.message)); }, ttsAt);
|
||||
cur.anims.push({ cancel: () => { clearTimeout(t); a.pause(); } }); // skip/reset stop the voice too
|
||||
exitAt = Math.max(exitAt, ttsAt + (d.ttsMs || 4000) + 900);
|
||||
}
|
||||
return done(cur, A(cur, el, [{ transform:'translateY(0)', opacity:1 }, { transform:'translateY(140px) rotate(8deg)', opacity:0 }],
|
||||
{ delay:exitAt, duration:500, easing:'ease-in' }));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@
|
|||
but never interrupts or drops a real one (it queues behind it).
|
||||
A real alert cuts off a test that is showing.
|
||||
window.PolaroidAlerts.reset() stop the current alert and clear the queue
|
||||
window.PolaroidAlerts.skip() stop the current alert (e.g. a TTS message), carry on with the queue
|
||||
|
||||
Alert shapes come from src/alerts.js:
|
||||
{ type:'follow', user }
|
||||
|
|
@ -127,7 +128,8 @@
|
|||
return { cassette: true, style: e.style || 'cassette', emote: e.emote || null, sticker: rebase(e.art) || null,
|
||||
name: e.user || 'Someone', line: fill(e.caption || 'redeemed it! ♡'), msg: e.input,
|
||||
title: e.variation || e.reward, sub: e.reward, rarity: e.rarity,
|
||||
sound: e.sound || null, volume: e.volume, soundOnly: e.polaroid === false };
|
||||
sound: e.sound || null, volume: e.volume, soundOnly: e.polaroid === false && !e.tts,
|
||||
tts: e.tts ? rebase(e.tts) : null, ttsMs: e.tts_ms || 0 };
|
||||
}
|
||||
case 'bits': {
|
||||
if (!(e.bits >= BITS_MIN)) return null;
|
||||
|
|
@ -211,6 +213,13 @@
|
|||
play({ ...alert, test: true }); // a real one on screen: wait
|
||||
}
|
||||
|
||||
// dashboard Skip button: cut what is on screen (sound/TTS too), then play the next queued alert
|
||||
function skip() {
|
||||
if (!current) return;
|
||||
skipCurrent();
|
||||
setTimeout(() => { if (!busy) next(); }, GAP);
|
||||
}
|
||||
|
||||
function reset() {
|
||||
gen++;
|
||||
queue.length = 0;
|
||||
|
|
@ -362,6 +371,6 @@
|
|||
.catch(() => {}); // cancelled by reset()
|
||||
}
|
||||
|
||||
window.PolaroidAlerts = { play, playTest, reset, describe };
|
||||
window.PolaroidAlerts = { play, playTest, reset, skip, describe };
|
||||
if (document.readyState === 'loading') document.addEventListener('DOMContentLoaded', preload); else preload();
|
||||
})();
|
||||
|
|
|
|||
|
|
@ -2,16 +2,17 @@
|
|||
The box sits under the webcam (Game scene: camera group at 1920,600, 640x360 on the 2560 canvas
|
||||
= 1440,450 480x270 on this 1920x1080 page). Newest message on top, slides out from under the camera,
|
||||
older ones are pushed down and dissolve at the bottom edge.
|
||||
Move or resize it with Custom CSS in Settings, e.g. #chat { --chat-top: 60%; --chat-height: 37%; } */
|
||||
Per browser source: ?chat=left,top,width,height (px of the 1920x1080 page) and ?chatflow=up (newest at the bottom),
|
||||
e.g. the Intermission panel: ?parts=chat&chat=130,640,700,360&chatflow=up. Default (no ?chat): under the camera, flowing down. */
|
||||
#chat {
|
||||
--chat-right: 2%;
|
||||
--chat-left: 78%;
|
||||
--chat-top: 63%; /* 680px: just above the bottom of the camera ring, so messages come out from under it */
|
||||
--chat-width: 20%;
|
||||
--chat-height: 34%; /* down to the bottom edge */
|
||||
--ink: #3a2a20;
|
||||
--cream: #fffdf7;
|
||||
position: fixed;
|
||||
right: var(--chat-right);
|
||||
left: var(--chat-left);
|
||||
top: var(--chat-top);
|
||||
width: var(--chat-width);
|
||||
height: var(--chat-height);
|
||||
|
|
@ -25,6 +26,16 @@
|
|||
mask-image: linear-gradient(transparent 0, #000 30px, #000 calc(100% - 60px), transparent);
|
||||
}
|
||||
|
||||
/* up: like a normal chat, newest at the bottom, the oldest fade out at the top */
|
||||
#chat.up {
|
||||
justify-content: flex-end;
|
||||
padding: 14px 8px 8px;
|
||||
-webkit-mask-image: linear-gradient(transparent 0, #000 50px);
|
||||
mask-image: linear-gradient(transparent 0, #000 50px);
|
||||
}
|
||||
#chat.up .msg.in { animation-name: chat-in-up; }
|
||||
@keyframes chat-in-up { from { opacity: 0; transform: translateY(24px) rotate(calc(var(--tilt, 0deg) * -3)) scale(.95); } }
|
||||
|
||||
#chat .msg {
|
||||
position: relative;
|
||||
flex: none;
|
||||
|
|
|
|||
|
|
@ -128,9 +128,10 @@
|
|||
d.innerHTML = `<span class="u">${esc(name)}</span>${r.html}`;
|
||||
d._n = ++seq;
|
||||
|
||||
// FLIP: remember where the others are, put the new one on top, then glide them down from the old spot
|
||||
// FLIP: remember where the others are, add the new one (on top, or at the bottom for ?chatflow=up),
|
||||
// then glide the others from their old spot
|
||||
const before = new Map([...box.children].map(m => [m, m.getBoundingClientRect().top]));
|
||||
box.prepend(d);
|
||||
if (box.classList.contains('up')) box.append(d); else box.prepend(d);
|
||||
before.forEach((top, m) => {
|
||||
const dy = top - m.getBoundingClientRect().top;
|
||||
if (dy && m.animate) m.animate([{ translate: `0 ${dy}px` }, { translate: '0 0' }], { duration: 320, easing: 'cubic-bezier(.2,.8,.3,1)' });
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue