diff --git a/CHANGELOG.md b/CHANGELOG.md index 76df64b..71632eb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,12 @@ The application version is maintained in `package.json` and displayed in the adm No changes recorded yet. +## 1.76.0 + +### Added +- OBS overlay: new layout **TV graphics**, a title plate (event and heat) top left and a timing tower top right with the clock on top and real columns (place / start position, driver, laps, time, best, gap) in large bold type, podium colours for the top three and no backdrop, so the camera image shows through. +- OBS settings: **Start position next to the place** (on by default), the driver's grid slot or start number shown as "2 / 3"; hidden in practice. + ## 1.75.0 ### Added diff --git a/README.md b/README.md index b34dda7..68fec3f 100644 --- a/README.md +++ b/README.md @@ -274,8 +274,9 @@ Settings → Audio: ### Overlays and OBS -The **Overlay** menu has leaderboard, speaker, results, TV and team modes, plus an OBS mode with layout (leaderboard, grid, lower third), theme (panel, transparent, chroma), rows and columns: +The **Overlay** menu has leaderboard, speaker, results, TV and team modes, plus an OBS mode with layout (leaderboard, TV graphics, grid, lower third), theme (panel, transparent, chroma), rows and columns: - Columns: laps, result, best, gap, and **places since the start** (▲/▼ in heats and finals). +- **TV graphics:** a title plate top left (event and heat) and a timing tower top right with the clock on top and real columns: place / **start position** (e.g. "2 / 3"), driver, laps, time, best and gap, in large bold type with podium colours for the top three. No backdrop of its own, so the camera image shows through. The start position can be turned off and is not shown in practice. - **Click a driver** in RaceCore's own overlay to open that driver's training stats (the stand-alone overlay window opens them in a new tab). The public overlay has no such links. - **Copy OBS URL** gives a browser-source link; the chosen columns are part of the link. - Public overlays live at `/public-overlay/` and can require a token: set `PUBLIC_OVERLAY_TOKEN` and add `?token=...`. Publish only `/public-overlay/*` through your reverse proxy. diff --git a/README.sv.md b/README.sv.md index 917ddb8..5bce7b6 100644 --- a/README.sv.md +++ b/README.sv.md @@ -287,8 +287,9 @@ Inställningar → Ljud: ### Overlays och OBS -Menyn **Overlay** har lägena leaderboard, speaker, resultat, TV och lag, plus ett OBS-läge med layout (leaderboard, grid, lower third), tema (panel, transparent, chroma), rader och kolumner: +Menyn **Overlay** har lägena leaderboard, speaker, resultat, TV och lag, plus ett OBS-läge med layout (leaderboard, TV-grafik, grid, lower third), tema (panel, transparent, chroma), rader och kolumner: - Kolumner: varv, resultat, bästa, gap och **placering sedan start** (▲/▼ i heat och finaler). +- **TV-grafik:** rubrikskylt uppe till vänster (event och heat) och en topplista uppe till höger med klockan överst och raka kolumner: placering / **startplats** (t.ex. "2 / 3"), förare, varv, tid, bästa och gap, i stor fet text och medaljfärger för topp 3. Ingen egen bakgrund, så kamerabilden syns igenom. Startplatsen kan stängas av och visas inte i träning. - **Klicka på en förare** i RaceCores egen overlay för att öppna förarens träningsstatistik (det fristående overlay-fönstret öppnar den i en ny flik). Den publika overlayn har inga sådana länkar. - **Kopiera OBS-URL** ger en länk för browser source; valda kolumner ingår i länken. - Publika overlays finns på `/public-overlay/` och kan kräva en nyckel: sätt `PUBLIC_OVERLAY_TOKEN` och lägg till `?token=...`. Publicera bara `/public-overlay/*` via din reverse proxy. diff --git a/index.html b/index.html index d0b36c2..200e998 100644 --- a/index.html +++ b/index.html @@ -7,7 +7,7 @@ diff --git a/package-lock.json b/package-lock.json index 36fef1a..7e37e65 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "rc-racecore", - "version": "1.75.0", + "version": "1.76.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "rc-racecore", - "version": "1.75.0", + "version": "1.76.0", "hasInstallScript": true, "dependencies": { "better-sqlite3": "^12.11.1", diff --git a/package.json b/package.json index 6c06a87..be8cea3 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "rc-racecore", - "version": "1.75.0", + "version": "1.76.0", "private": true, "description": "RC RaceCore live timing and race control with AMMC ingest and SQLite persistence", "engines": { diff --git a/src/app.js b/src/app.js index 58cb5e3..4113d08 100644 --- a/src/app.js +++ b/src/app.js @@ -1299,6 +1299,8 @@ const TRANSLATIONS = { "timing.live_elsewhere": "Varv registreras just nu på \"{name}\", som pågår - inte på den valda sessionen.", "timing.show_live": "Visa den", "overlay.obs_show_position_change": "Placering sedan start (▲/▼) i race", + "overlay.obs_show_start": "Startplats bredvid placeringen (TV-grafik)", + "overlay.col_start": "Start", "overlay.position_change_title": "Placeringar vunna (▲) eller förlorade (▼) sedan starten", "settings.public_address_title": "Publik adress (domän / DynDNS)", "settings.public_address_hint": "Gäller alla förares mobilprofiler: länkar och QR-koder byggs med den här adressen, t.ex. https://klubben.dyndns.org eller https://klubben.se:8443. Lämna tomt för att använda datorns adress i det lokala nätverket (fungerar bara på samma wifi).", @@ -3236,6 +3238,7 @@ const TRANSLATIONS = { "overlay.obs_public_token": "Publik token", "overlay.obs_public_token_hint": "Valfri klienttoken som läggs i public-overlay-länken.", "overlay.obs_layout_leaderboard": "Leaderboard", + "overlay.obs_layout_broadcast": "TV-grafik", "overlay.obs_layout_grid": "Startgrid", "overlay.obs_layout_lowerthird": "Lower third", "overlay.obs_theme_panel": "Panel", @@ -3434,6 +3437,8 @@ const TRANSLATIONS = { "timing.live_elsewhere": "Laps are being recorded on \"{name}\", which is running - not on the selected session.", "timing.show_live": "Show it", "overlay.obs_show_position_change": "Places since the start (▲/▼) in races", + "overlay.obs_show_start": "Start position next to the place (TV graphics)", + "overlay.col_start": "Start", "overlay.position_change_title": "Places gained (▲) or lost (▼) since the start", "settings.public_address_title": "Public address (domain / DynDNS)", "settings.public_address_hint": "Used for every driver's mobile profile: links and QR codes are built with this address, e.g. https://club.dyndns.org or https://club.example:8443. Leave empty to use this computer's local network address (works on the same wifi only).", @@ -5371,6 +5376,7 @@ const TRANSLATIONS = { "overlay.obs_public_token": "Public token", "overlay.obs_public_token_hint": "Optional client token appended to the public overlay URL.", "overlay.obs_layout_leaderboard": "Leaderboard", + "overlay.obs_layout_broadcast": "TV graphics", "overlay.obs_layout_grid": "Start grid", "overlay.obs_layout_lowerthird": "Lower third", "overlay.obs_theme_panel": "Panel", @@ -5483,7 +5489,7 @@ let carBrandFilter = ""; let raceFormatAdvanced = false; function getObsLayouts() { - return ["leaderboard", "grid", "lowerthird"]; + return ["leaderboard", "broadcast", "grid", "lowerthird"]; } function getObsThemes() { @@ -5504,6 +5510,7 @@ function createDefaultObsOverlaySettings() { showBest: true, showGap: true, showPositionChange: true, + showStart: true, layout: "leaderboard", theme: "panel", publicToken: "", @@ -5530,6 +5537,7 @@ function normalizeObsOverlaySettings(raw = {}) { showBest: raw?.showBest !== false, showGap: raw?.showGap !== false, showPositionChange: raw?.showPositionChange !== false, + showStart: raw?.showStart !== false, layout, theme, publicToken: String(raw?.publicToken || "").trim(), @@ -5639,6 +5647,7 @@ function getObsOverlayConfig() { showBest: parseOverlayBooleanParam("showBest", base.showBest), showGap: parseOverlayBooleanParam("showGap", base.showGap), showPositionChange: parseOverlayBooleanParam("showPositionChange", base.showPositionChange), + showStart: parseOverlayBooleanParam("showStart", base.showStart), layout: getObsLayouts().includes(String(urlParams.get("layout") || "").toLowerCase()) ? String(urlParams.get("layout")).toLowerCase() : base.layout, theme: getObsThemes().includes(String(urlParams.get("obsTheme") || "").toLowerCase()) ? String(urlParams.get("obsTheme")).toLowerCase() : base.theme, publicToken: String(urlParams.get("token") || base.publicToken || "").trim(), @@ -5656,6 +5665,7 @@ function writeObsOverlayParams(url, config) { url.searchParams.set("showBest", normalized.showBest ? "1" : "0"); url.searchParams.set("showGap", normalized.showGap ? "1" : "0"); url.searchParams.set("showPositionChange", normalized.showPositionChange ? "1" : "0"); + url.searchParams.set("showStart", normalized.showStart ? "1" : "0"); url.searchParams.set("layout", normalized.layout); url.searchParams.set("obsTheme", normalized.theme); if (normalized.publicToken) { diff --git a/src/overlays.js b/src/overlays.js index dddd902..b916a82 100644 --- a/src/overlays.js +++ b/src/overlays.js @@ -200,6 +200,61 @@ export function getPositionChange(session, startOrder, driverId, currentPosition return startPosition > 0 ? startPosition - currentPosition : null; } +// TV graphics: a title plate top left and a timing tower top right with real columns - +// place / start position, driver, laps, time, best lap and gap - large enough to read on a phone. +function renderObsBroadcast({ active, compactRows, startOrder, showStartGrid, fastestRow, elapsedOrRemaining, branding, obsConfig, positionChangeMarkup, deps }) { + const { t, escapeHtml, formatLap, getEventName, getSessionGridEntries } = deps; + const practice = PRACTICE_TYPES.has(String(active.type || "")); + const showStart = obsConfig.showStart && !practice && !showStartGrid && compactRows.some((row) => startOrder.includes(row.driverId)); + const showResult = obsShowsResult(active, obsConfig); + const columns = showStartGrid + ? [["pos", "2.4em"], ["name", "minmax(0, 1fr)"]] + : [ + ["pos", "2.4em"], showStart && ["start", "2.4em"], ["name", "minmax(6em, 1fr)"], + obsConfig.showPositionChange && !practice && ["change", "2.6em"], obsConfig.showLaps && ["laps", "max-content"], + showResult && ["result", "max-content"], obsConfig.showBest && ["best", "max-content"], obsConfig.showGap && ["gap", "max-content"], + ].filter(Boolean); + const label = { pos: "#", start: t("overlay.col_start"), name: t("table.driver"), change: "", laps: t("table.laps"), result: t("table.result"), best: t("table.best_lap"), gap: t("table.gap") }; + const cell = (key, html) => `${html}`; + // With laps in their own column the result's "14/" prefix only repeats them. + const timeOnly = (value) => (obsConfig.showLaps ? String(value || "").replace(/^\d+\//, "") : String(value || "")); + const podium = (place) => (place <= 3 ? ` is-p${place}` : ""); + const rows = showStartGrid + ? getSessionGridEntries(active).slice(0, obsConfig.rows).map((entry, idx) => ` +
${cell("pos", entry.slot)}${cell("name", escapeHtml(entry.name))}
`) + : compactRows.map((row, idx) => { + const start = startOrder.indexOf(row.driverId) + 1; + const values = { + pos: idx + 1, + start: start ? `/${start}` : "", + name: `${escapeHtml(row.displayName || row.driverName)}${row.heatCarName ? ` 🚗 ${escapeHtml(row.heatCarName)}` : ""}${row.suspectPending ? ' ⚠' : ""}`, + change: positionChangeMarkup(row, idx + 1), + laps: row.laps ?? 0, + result: escapeHtml(timeOnly(row.resultDisplay)), + best: Number.isFinite(row.bestLapMs) ? escapeHtml(formatLap(row.bestLapMs)) : "-", + gap: escapeHtml(idx === 0 ? "" : row.gapDisplay || row.gapAhead || ""), + }; + return `
${columns.map(([key]) => cell(key, values[key])).join("")}
`; + }); + const eventName = String(getEventName(active.eventId) || "").trim(); + return ` +
+
+ ${eventName && eventName !== active.name ? `

${escapeHtml(eventName)}

` : ""} +

${escapeHtml(active.name)}

+
+
+
+ ${branding.logoDataUrl ? `` : `${escapeHtml(branding.brandName || "RC RaceCore")}`} + ${obsConfig.showClock ? `${elapsedOrRemaining}` : ""} +
+
${columns.map(([key]) => cell(key, escapeHtml(label[key]))).join("")}
+ ${rows.join("") || `

${t("timing.no_laps")}

`} + ${!showStartGrid && obsConfig.showFastest && fastestRow ? `
${t("overlay.fastest_lap")}: ${escapeHtml(formatLap(fastestRow.bestLapMs))} · ${escapeHtml(fastestRow.displayName || fastestRow.driverName || "")}
` : ""} +
+
`; +} + // In practice the ranking value *is* the best lap, so "result" and "best" would print the // same time twice - show it once. function obsShowsResult(session, obsConfig) { @@ -224,7 +279,7 @@ export function renderObsOverlay(active, leaderboard, result, sessionTiming, bra formatTeamActiveMemberLabel, } = deps; const obsConfig = getObsOverlayConfig(); - const startOrder = active && obsConfig.showPositionChange ? getSessionGridOrder(active) : []; + const startOrder = active && (obsConfig.showPositionChange || obsConfig.showStart) ? getSessionGridOrder(active) : []; const positionChangeMarkup = (row, position) => { const change = obsConfig.showPositionChange ? getPositionChange(active, startOrder, row.driverId, position) : null; if (!change) return ""; @@ -243,6 +298,10 @@ export function renderObsOverlay(active, leaderboard, result, sessionTiming, bra ? formatCountdownLocal(sessionTiming?.followUpRemainingMs ?? 0) : formatCountdownLocal(sessionTiming?.remainingMs ?? 0); + if (obsConfig.layout === "broadcast") { + return renderObsBroadcast({ active, compactRows, startOrder, showStartGrid, fastestRow, elapsedOrRemaining, branding, obsConfig, positionChangeMarkup, deps }); + } + if (obsConfig.layout === "grid") { return `
diff --git a/src/settings.js b/src/settings.js index 8aa6d8c..28a3bb3 100644 --- a/src/settings.js +++ b/src/settings.js @@ -389,6 +389,7 @@ export function renderSettings(deps) { +
@@ -776,6 +777,7 @@ Erik Eriksson;654321;4WD;Associated;; ["obsShowBest", "showBest", (value, el) => Boolean(el?.checked)], ["obsShowGap", "showGap", (value, el) => Boolean(el?.checked)], ["obsShowPositionChange", "showPositionChange", (value, el) => Boolean(el?.checked)], + ["obsShowStart", "showStart", (value, el) => Boolean(el?.checked)], ].forEach(([id, key, mapper]) => { const el = document.getElementById(id); if (!el) { diff --git a/src/styles.css b/src/styles.css index bb622fd..2e00d1c 100644 --- a/src/styles.css +++ b/src/styles.css @@ -4899,3 +4899,36 @@ tr:has(> td > .medal-1) { background: linear-gradient(90deg, rgba(240, 197, 63, tr:has(> td > .medal-2) { background: linear-gradient(90deg, rgba(190, 199, 210, 0.26), rgba(190, 199, 210, 0) 70%); } tr:has(> td > .medal-1) > td, tr:has(> td > .medal-2) > td, tr:has(> td > .medal-3) > td { background: transparent; } tr:has(> td > .medal-3) { background: linear-gradient(90deg, rgba(205, 127, 60, 0.26), rgba(205, 127, 60, 0) 70%); } + +/* OBS TV graphics: title plate top left, timing tower top right. No backdrop of its own, + so the camera image shows through (chroma keeps its green). */ +.overlay-shell-obs-layout-broadcast:not(.overlay-shell-obs-theme-chroma) { background: transparent; } +.overlay-shell-obs-layout-broadcast { padding: 0; } +.obs-tv { position: relative; min-height: 100vh; font-family: "Barlow Condensed", Barlow, "Arial Narrow", sans-serif; color: #fff; text-transform: uppercase; font-size: clamp(16px, 1.45vw, 30px); } +.obs-tv-plate { position: absolute; top: 1.2em; left: 1.2em; max-width: 46vw; filter: drop-shadow(0 0.15em 0.4em rgb(0 0 0 / 45%)); } +.obs-tv-event { margin: 0; padding: 0.15em 1.6em 0.1em 0.6em; background: #15181f; font-size: 1.35em; font-weight: 800; letter-spacing: 0.01em; clip-path: polygon(0 0, 100% 0, calc(100% - 0.8em) 100%, 0 100%); } +.obs-tv-session { margin: 0; padding: 0.1em 1.8em 0.1em 0.6em; background: linear-gradient(90deg, var(--accent), color-mix(in srgb, var(--accent) 70%, #fff)); color: #fff; font-size: 1.8em; font-weight: 800; line-height: 1.15; clip-path: polygon(0 0, 100% 0, calc(100% - 0.9em) 100%, 0 100%); text-shadow: 0 0.05em 0.1em rgb(0 0 0 / 35%); } +.obs-tv-tower { position: absolute; top: 1em; right: 1em; min-width: clamp(320px, 26vw, 560px); max-width: 52vw; filter: drop-shadow(0 0.15em 0.5em rgb(0 0 0 / 50%)); } +.obs-tv-head { display: flex; align-items: center; justify-content: space-between; gap: 0.6em; padding: 0.2em 0.5em; background: linear-gradient(90deg, #15181f 55%, var(--accent)); } +.obs-tv-logo { max-height: 1.9em; max-width: 50%; object-fit: contain; } +.obs-tv-brand { font-weight: 800; font-size: 1.05em; letter-spacing: 0.04em; } +.obs-tv-clock { font-size: 1.75em; font-weight: 800; font-variant-numeric: tabular-nums; letter-spacing: 0.02em; } +.obs-tv-row { display: grid; grid-template-columns: var(--obs-tv-cols); align-items: center; column-gap: 0.45em; padding: 0 0.45em 0 0; min-height: 1.6em; background: rgb(17 21 30 / 88%); border-bottom: 1px solid rgb(255 255 255 / 10%); font-weight: 700; font-variant-numeric: tabular-nums; } +.obs-tv-row:nth-child(even of .obs-tv-row:not(.obs-tv-labels)) { background: rgb(27 33 45 / 88%); } +.obs-tv-labels { min-height: 1.15em; background: rgb(10 12 18 / 92%); color: rgb(255 255 255 / 60%); font-size: 0.62em; letter-spacing: 0.08em; } +.obs-tv-cell { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; text-align: right; } +.obs-tv-pos { align-self: stretch; display: grid; place-items: center; text-align: center; background: rgb(255 255 255 / 14%); font-weight: 800; } +.obs-tv-labels .obs-tv-pos { background: none; } +.obs-tv-start { text-align: left; color: #9fd3ff; } +.obs-tv-slash { margin-right: 0.12em; opacity: 0.55; } +.obs-tv-name { text-align: left; letter-spacing: 0.01em; } +.obs-tv-name small { font-size: 0.7em; opacity: 0.75; text-transform: none; } +.obs-tv-change { text-align: center; font-size: 0.8em; } +.obs-tv-gap { color: rgb(255 255 255 / 75%); } +.obs-tv-row.is-p1 .obs-tv-pos { background: linear-gradient(180deg, #ffe27a, #d4a017); color: #3b2a00; } +.obs-tv-row.is-p2 .obs-tv-pos { background: linear-gradient(180deg, #f1f3f6, #a9b1bc); color: #22262d; } +.obs-tv-row.is-p3 .obs-tv-pos { background: linear-gradient(180deg, #f0b27a, #a8642c); color: #2e1606; } +.obs-tv-row.is-fastest .obs-tv-best { color: #d39bff; } +.obs-tv-foot { padding: 0.15em 0.5em; background: rgb(10 12 18 / 92%); font-size: 0.7em; font-weight: 600; letter-spacing: 0.04em; } +.obs-tv-foot strong { color: #d39bff; } +.obs-tv-empty { margin: 0; padding: 0.4em 0.6em; background: rgb(17 21 30 / 88%); } diff --git a/tests/browser_overlays.js b/tests/browser_overlays.js index 9d7bd7d..2163229 100644 --- a/tests/browser_overlays.js +++ b/tests/browser_overlays.js @@ -87,4 +87,28 @@ export async function runOverlaySmoke({ evaluate }) { assert.equal(obs.finalRows[2], "13L 13/5:01.000 0:21.000 +1L", "same place as at the start: no arrow"); assert.equal(obs.practiceRow, "23L 0:15.833 -", "practice: the best lap once, not twice"); console.log("PASS OBS overlay shows places gained/lost since the start in finals, and the best lap once in practice"); + + // TV graphics: a title plate and a tower with columns, the start position next to the place. + const tv = await evaluate(`(async () => { + const { renderObsOverlay } = await import('/src/overlays.js'); + const { escapeHtml } = await import('/src/html_escape.js'); + const config = { layout: 'broadcast', rows: 10, showClock: true, showFastest: true, showLaps: true, showResult: true, showBest: false, showGap: true, showPositionChange: false, showStart: true }; + const deps = { t: (key) => key, escapeHtml, formatLap: (ms) => (ms / 1000).toFixed(3), formatTeamActiveMemberLabel: () => '', getVisiblePassings: () => [], getEventName: () => 'Winter Cup', getSessionTypeLabel: () => 'Final', getStartModeLabel: () => 'Position', getStatusLabel: () => 'Running', getObsOverlayConfig: () => config, normalizeStartMode: (v) => v, renderPositionGrid: () => '', getSessionGridEntries: () => [], getSessionGridOrder: () => ['a', 'b', 'c'] }; + const rows = [ + { key: 'c', driverId: 'c', displayName: 'Cid', laps: 14, resultDisplay: '14/5:02.312', bestLapMs: 20100, gapDisplay: '-' }, + { key: 'a', driverId: 'a', displayName: 'Ann', laps: 14, resultDisplay: '14/5:05.000', bestLapMs: 20300, gapDisplay: '+2.688' }, + ]; + const box = document.createElement('div'); + const cells = () => [...box.querySelectorAll('.obs-tv-row:not(.obs-tv-labels)')].map((row) => [...row.children].map((cell) => cell.textContent.trim()).join('|')); + box.innerHTML = renderObsOverlay({ eventId: 'e', name: '4WD A-final 2', type: 'final', startMode: 'position', status: 'running' }, rows, {}, { remainingMs: 217000 }, {}, deps); + const final = { plate: box.querySelector('.obs-tv-session').textContent, event: box.querySelector('.obs-tv-event').textContent, rows: cells(), podium: box.querySelector('.obs-tv-row.is-p1') !== null, clock: box.querySelector('.obs-tv-clock[data-overlay-clock]') !== null }; + box.innerHTML = renderObsOverlay({ eventId: 'e', name: 'Open practice', type: 'open_practice', startMode: 'mass', status: 'running' }, [{ key: 'p', driverId: 'a', displayName: 'Pia', laps: 23, resultDisplay: '0:15.833', bestLapMs: 15833, gapDisplay: '-' }], {}, { untimed: true, elapsedMs: 1000 }, {}, deps); + return { final, practice: cells() }; + })()`); + assert.equal(tv.final.plate, "4WD A-final 2"); + assert.equal(tv.final.event, "Winter Cup"); + assert.deepEqual(tv.final.rows, ["1|/3|Cid|14|5:02.312|", "2|/1|Ann|14|5:05.000|+2.688"], "place / start, then laps and time without the laps prefix"); + assert.ok(tv.final.podium && tv.final.clock, "podium colours and the live clock"); + assert.deepEqual(tv.practice, ["1|Pia|23|0:15.833|"], "practice has no start column"); + console.log("PASS OBS TV graphics: title plate, tower with place / start position, laps, time and gap"); }