Video Power-ups: Custom Power-ups, ?parts=video overlay, new redeems editor

- Custom Power-ups (bits) are redeem triggers: channel.custom_power_up_redemption.add
  -> redeems.handle('custom_power_up', ...) with the bits amount; listed live from
  Helix /bits/custom_power_ups on the Redeems page; labels/replay in Recent activity.
- Variations can show a video (reward_variations.video): style 'video' plays only on
  the opt-in ?parts=video overlay (public/alerts/video.js), full-screen, one at a time,
  with a yellow camcorder box ("TRIGGERED <name>", viewer, bits, POWER-UP) in the alert
  corner. Any source size; 2560x1440 like HUDFX gives sharper video.
- Redeems page rewritten as one editor: Display (Cassette / Sound only / Video),
  volume slider, sticker thumbnails, live % chances, one Save button + Ctrl+S
  (POST /redeems/save), tests/add/delete save first, unsaved edits kept as a browser
  draft with an inline restore bar (no dialogs).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Bashy 2026-11-22 16:10:56 +02:00
parent 19a0965eb2
commit b3caac7a31
11 changed files with 512 additions and 135 deletions

35
public/alerts/video.css Normal file
View file

@ -0,0 +1,35 @@
/* Video redeems (?parts=video, see video.js): full-screen video + a camcorder notification box,
the HUDFX box's look in yellow, in the alert corner (85,110, 440px wide on 1920x1080; video.js zooms the box
to the page width, so a 2560x1440 source looks the same, only sharper). */
@import url('https://fonts.googleapis.com/css2?family=VT323&display=swap');
#vfx-video { position:fixed; inset:0; width:100vw; height:100vh; object-fit:contain; background:transparent;
visibility:hidden; pointer-events:none; z-index:40; }
#vfx-box {
--yellow:#eeb434; --pale:#ffe7a3; --screen:#241e12;
position:fixed; left:85px; top:110px; width:440px; box-sizing:border-box; z-index:41; visibility:hidden;
padding:46px 22px 26px; border:5px solid var(--yellow); border-radius:12px;
box-shadow:0 0 0 3px #15110a, 0 0 22px rgba(238,180,52,.55), 0 14px 26px rgba(0,0,0,.5);
background:
linear-gradient(#fff,#fff) 12px 12px / 26px 4px no-repeat, linear-gradient(#fff,#fff) 12px 12px / 4px 26px no-repeat,
linear-gradient(#fff,#fff) right 12px top 12px / 26px 4px no-repeat, linear-gradient(#fff,#fff) right 12px top 12px / 4px 26px no-repeat,
linear-gradient(#fff,#fff) left 12px bottom 12px / 26px 4px no-repeat, linear-gradient(#fff,#fff) left 12px bottom 12px / 4px 26px no-repeat,
linear-gradient(#fff,#fff) right 12px bottom 12px / 26px 4px no-repeat, linear-gradient(#fff,#fff) right 12px bottom 12px / 4px 26px no-repeat,
repeating-linear-gradient(0deg, rgba(255,255,255,.045) 0 2px, transparent 2px 4px),
radial-gradient(ellipse at 50% 45%, #43361a 0%, var(--screen) 70%) #241e12;
font-family:'VT323', monospace; color:#fff; text-align:center;
}
#vfx-box .rec { position:absolute; left:24px; top:16px; font-size:26px; color:#ff3b4e; text-shadow:0 0 6px rgba(255,59,78,.7);
animation:vfx-blink 1s steps(1) infinite; }
#vfx-box .tc { position:absolute; right:24px; top:16px; font-size:24px; opacity:.85; }
#vfx-box .title { font-size:36px; line-height:1; text-transform:uppercase; overflow-wrap:anywhere;
text-shadow:2px 0 rgba(255,59,120,.75), -2px 0 rgba(80,220,255,.75); }
#vfx-box .who { font-size:32px; line-height:1; margin-top:10px; color:var(--pale); text-transform:uppercase; overflow-wrap:anywhere;
text-shadow:2px 0 rgba(255,59,120,.6), -2px 0 rgba(80,220,255,.6); }
#vfx-box .amt { display:inline-block; margin-top:16px; padding:2px 16px; background:var(--yellow); color:#241e12; font-size:28px;
border-radius:4px; text-transform:uppercase; box-shadow:0 0 12px rgba(238,180,52,.7); }
#vfx-box .amt:empty { display:none; }
#vfx-box .brand { position:absolute; right:46px; bottom:14px; font:900 13px/1 'Nunito', sans-serif; letter-spacing:1.5px;
color:var(--yellow); opacity:.8; }
@keyframes vfx-blink { 0% { opacity:1; } 50% { opacity:0; } }

75
public/alerts/video.js Normal file
View file

@ -0,0 +1,75 @@
/*
Video redeems, for the ?parts=video overlay (an OBS source of its own, e.g. instead of HUDFX).
Any source size works; 2560x1440 like HUDFX gives sharper video. The box is laid out for 1920x1080 and
zoomed to the page width, so it always lands in the alert corner.
Redeem variations with a video (style 'video', see src/redeems.js) play here full-screen, one at a time,
with a camcorder notification box (video.css) while the video runs.
VideoFX.play(alert) queue it
VideoFX.playTest(alert) test: replaces a playing/queued test at once
VideoFX.skip() stop the current one, carry on with the queue
alert: { video, volume, user, reward, variation, bits, test }
*/
(() => {
const queue = [];
let cur = null, vid = null, box = null, tcTimer = null;
function els() {
if (vid) return;
vid = document.createElement('video'); vid.id = 'vfx-video'; vid.playsInline = true; document.body.appendChild(vid);
box = document.createElement('div'); box.id = 'vfx-box';
box.innerHTML = '<div class="rec">● REC</div><div class="tc"></div><div class="title"></div><div class="who"></div><div class="amt"></div><div class="brand">POWER-UP</div>';
document.body.appendChild(box);
fit(); addEventListener('resize', fit);
}
function fit() { if (box) box.style.zoom = innerWidth / 1920; }
const fmt = s => { s = Math.max(0, Math.floor(s)); return `▶ ${Math.floor(s / 3600)}:${String(Math.floor(s / 60) % 60).padStart(2, '0')}:${String(s % 60).padStart(2, '0')}`; };
function show(a) {
els();
const name = a.variation && a.variation !== a.reward ? a.variation : (a.reward || 'Power-up');
box.querySelector('.title').textContent = `Triggered ${name}`;
box.querySelector('.who').textContent = a.user || '';
box.querySelector('.amt').textContent = a.bits ? `◆ ${a.bits} bits ◆` : '';
box.querySelector('.tc').textContent = fmt(0);
box.style.visibility = 'visible';
box.animate([{ opacity: 0, transform: 'translateY(-12px)' }, { opacity: 1, transform: 'none' }], { duration: 400, easing: 'ease-out', fill: 'both' });
clearInterval(tcTimer); tcTimer = setInterval(() => { box.querySelector('.tc').textContent = fmt(vid.currentTime); }, 250);
}
function hideBox() {
clearInterval(tcTimer);
if (!box || box.style.visibility !== 'visible') return;
box.animate([{ opacity: 1 }, { opacity: 0 }], { duration: 500, fill: 'both' }).finished
.then(() => { if (!cur) box.style.visibility = 'hidden'; }).catch(() => {});
}
function finish(a) {
if (cur !== a) return;
clearTimeout(a._guard);
vid.pause(); vid.removeAttribute('src'); vid.load(); vid.style.visibility = 'hidden';
cur = null;
hideBox();
setTimeout(next, 600);
}
function next() {
if (cur || !queue.length) return;
const a = cur = queue.shift();
show(a);
vid.src = a.video; vid.volume = Math.max(0, Math.min(1, a.volume ?? 0.8)); vid.currentTime = 0;
vid.style.visibility = 'visible';
vid.onended = () => finish(a);
vid.onerror = () => { console.warn('[video] could not play', a.video); setTimeout(() => finish(a), 2500); };
vid.play().catch(e => { console.warn('[video] play:', e.message); setTimeout(() => finish(a), 2500); });
a._guard = setTimeout(() => finish(a), 120000); // never block the queue on a broken/endless file
}
function play(a) { if (!a?.video) return; queue.push(a); next(); }
function playTest(a) {
if (!a?.video) return;
for (let i = queue.length - 1; i >= 0; i--) if (queue[i].test) queue.splice(i, 1);
if (cur?.test) { queue.unshift({ ...a, test: true }); finish(cur); }
else play({ ...a, test: true });
}
function skip() { if (cur) finish(cur); }
window.VideoFX = { play, playTest, skip };
})();

View file