feat(overlay): last lap column in the OBS tower and the Open Practice leaderboard (1.89.4)
This commit is contained in:
1 parent
f5ff1b9acd
commit
d5f81f4290
10 files changed
+73
-16
No files matched your search
+19
-9
@@ -59,13 +59,13 @@ export function renderOverlaySidePanel(panel, { t, escapeHtml }) {
|
||||
|
||||
// driverLinks: a click on a driver opens their training stats (RaceCore's own overlay only - never
|
||||
// the public overlay, see openDriverTrainingStats in app.js).
|
||||
export function renderOverlayLeaderboard(rows, { t, escapeHtml, formatTeamActiveMemberLabel, formatLap, formatPredictedLapDelta }, { sortable = true, driverLinks = false } = {}) {
|
||||
export function renderOverlayLeaderboard(rows, { t, escapeHtml, formatTeamActiveMemberLabel, formatLap, formatPredictedLapDelta }, { sortable = true, driverLinks = false, lastLap = false } = {}) {
|
||||
if (!rows.length) {
|
||||
return `<p>${t("timing.no_laps")}</p>`;
|
||||
}
|
||||
|
||||
const sortAttrs = sortable
|
||||
? ` data-sort-id="overlay-leaderboard" data-sort-text-columns="1" data-sort-labels="${sortValuesAttribute([t("table.pos"), t("table.driver"), t("table.laps"), t("table.result"), t("table.gap"), t("table.ahead_gap"), t("table.own_delta"), t("table.best_lap")])}"`
|
||||
? ` data-sort-id="overlay-leaderboard" data-sort-text-columns="1" data-sort-labels="${sortValuesAttribute([t("table.pos"), t("table.driver"), t("table.laps"), t(lastLap ? "table.last_lap" : "table.result"), t("table.gap"), t("table.ahead_gap"), t("table.own_delta"), t("table.best_lap")])}"`
|
||||
: "";
|
||||
// More than 12 cars (a busy Open Practice): compact rows so all of them fit on a TV that
|
||||
// can't scroll - no per-cell labels (the header names the columns), sub-line or prediction bar.
|
||||
@@ -77,7 +77,7 @@ export function renderOverlayLeaderboard(rows, { t, escapeHtml, formatTeamActive
|
||||
${rows
|
||||
.map((row, idx) => {
|
||||
const posClass = idx === 0 ? "pos-1" : idx === 1 ? "pos-2" : idx === 2 ? "pos-3" : "";
|
||||
const rowSortAttr = sortable ? ` data-sort-values="${sortValuesAttribute([idx + 1, row.displayName || row.driverName, row.laps ?? 0, row.resultDisplay, row.gapDisplay || row.gapAhead || null, row.gapAhead || null, row.lapDelta || null, row.bestLapMs || null])}"` : "";
|
||||
const rowSortAttr = sortable ? ` data-sort-values="${sortValuesAttribute([idx + 1, row.displayName || row.driverName, row.laps ?? 0, lastLap ? row.lastLapMs || null : row.resultDisplay, row.gapDisplay || row.gapAhead || null, row.gapAhead || null, row.lapDelta || null, row.bestLapMs || null])}"` : "";
|
||||
const linkAttrs = driverLinks && row.driverId && !row.teamId ? ` data-training-driver="${escapeHtml(row.driverId)}" title="${escapeHtml(t("overlay.open_training_stats"))}"` : "";
|
||||
const mark = liveMarks.get(String(row.key ?? ""));
|
||||
const flash = passingFlashAttrs(mark);
|
||||
@@ -106,8 +106,8 @@ export function renderOverlayLeaderboard(rows, { t, escapeHtml, formatTeamActive
|
||||
<strong>${row.laps ?? 0}</strong>
|
||||
</div>
|
||||
<div class="overlay-race-metric">
|
||||
<label>${t("table.result")}</label>
|
||||
<strong>${escapeHtml(row.resultDisplay)}</strong>
|
||||
<label>${t(lastLap ? "table.last_lap" : "table.result")}</label>
|
||||
<strong>${lastLap ? (row.lastLapMs > 0 ? escapeHtml(formatLap(row.lastLapMs)) : "-") : escapeHtml(row.resultDisplay)}</strong>
|
||||
</div>
|
||||
<div class="overlay-race-metric">
|
||||
<label>${t("table.gap")}</label>
|
||||
@@ -217,9 +217,9 @@ function renderObsBroadcast({ active, compactRows, startOrder, showStartGrid, fa
|
||||
: [
|
||||
["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"],
|
||||
obsConfig.showLast && ["last", "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 label = { pos: "#", start: t("overlay.col_start"), name: t("table.driver"), change: "", laps: t("table.laps"), last: t("overlay.col_last"), result: t("table.result"), best: t("table.best_lap"), gap: t("table.gap") };
|
||||
const cell = (key, html) => `<span class="obs-tv-cell obs-tv-${key}">${html}</span>`;
|
||||
// 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 || ""));
|
||||
@@ -238,6 +238,7 @@ function renderObsBroadcast({ active, compactRows, startOrder, showStartGrid, fa
|
||||
name: `${escapeHtml(row.displayName || row.driverName)}${row.heatCarName ? ` <small>🚗 ${escapeHtml(row.heatCarName)}</small>` : ""}${row.suspectPending ? ' <span class="suspect-flag">⚠</span>' : ""}`,
|
||||
change: positionChangeMarkup(row, idx + 1),
|
||||
laps: row.laps ?? 0,
|
||||
last: row.lastLapMs > 0 ? escapeHtml(formatLap(row.lastLapMs)) : "-",
|
||||
result: escapeHtml(timeOnly(row.resultDisplay)),
|
||||
best: Number.isFinite(row.bestLapMs) ? escapeHtml(formatLap(row.bestLapMs)) : "-",
|
||||
gap: escapeHtml(idx === 0 ? "" : row.gapDisplay || row.gapAhead || ""),
|
||||
@@ -272,8 +273,15 @@ function renderObsBroadcast({ active, compactRows, startOrder, showStartGrid, fa
|
||||
|
||||
// In practice the ranking value *is* the best lap, so "result" and "best" would print the
|
||||
// same time twice - show it once.
|
||||
// An Open Practice ranked on the best lap: its result only repeats the best-lap column, and the
|
||||
// last lap is what changes at each passing. Ranked on N laps in a row or X minutes, the result
|
||||
// ("2 laps 35.104") says something of its own and stays.
|
||||
export function isOpenPracticeSession(session) {
|
||||
return ["open_practice", "free_practice"].includes(String(session?.type || ""))
|
||||
&& !["consecutive", "window"].includes(String(session?.practiceRanking || ""));
|
||||
}
|
||||
function obsShowsResult(session, obsConfig) {
|
||||
return obsConfig.showResult && !(obsConfig.showBest && ["open_practice", "free_practice"].includes(String(session?.type || "")));
|
||||
return obsConfig.showResult && !(obsConfig.showBest && isOpenPracticeSession(session));
|
||||
}
|
||||
|
||||
export function renderObsOverlay(active, leaderboard, result, sessionTiming, branding, deps) {
|
||||
@@ -346,7 +354,7 @@ export function renderObsOverlay(active, leaderboard, result, sessionTiming, bra
|
||||
<h3>${showStartGrid ? t("events.start_grid") : t("overlay.leaderboard_live")}</h3>
|
||||
<span class="pill">${t("overlay.mode_obs")}</span>
|
||||
</div>
|
||||
${showStartGrid ? renderPositionGrid(active) : renderOverlayLeaderboard(compactRows, deps, { sortable: false })}
|
||||
${showStartGrid ? renderPositionGrid(active) : renderOverlayLeaderboard(compactRows, deps, { sortable: false, lastLap: isOpenPracticeSession(active) })}
|
||||
</section>
|
||||
</section>
|
||||
`;
|
||||
@@ -371,6 +379,7 @@ export function renderObsOverlay(active, leaderboard, result, sessionTiming, bra
|
||||
<strong>${escapeHtml(row.displayName || row.driverName)}${row.personalTimeUp ? " 🏁" : ""}${row.suspectPending ? ` <span class="suspect-flag" title="${escapeHtml(t("suspect.flag_title"))}">⚠</span>` : ""}</strong>
|
||||
${row.heatCarName ? `<span class="overlay-heat-car">🚗 ${escapeHtml(row.heatCarName)}</span>` : ""}
|
||||
${obsConfig.showLaps ? `<span>${t("table.laps")}: ${row.laps ?? 0}</span>` : ""}
|
||||
${obsConfig.showLast && row.lastLapMs > 0 ? `<span>${t("overlay.col_last")}: ${escapeHtml(formatLap(row.lastLapMs))}</span>` : ""}
|
||||
${obsShowsResult(active, obsConfig) ? `<span>${t("table.result")}: ${escapeHtml(row.resultDisplay)}</span>` : ""}
|
||||
${obsConfig.showGap ? `<span>${t("table.gap")}: ${escapeHtml(row.gapDisplay || row.gapAhead || "-")}</span>` : ""}
|
||||
</article>
|
||||
@@ -407,6 +416,7 @@ export function renderObsOverlay(active, leaderboard, result, sessionTiming, bra
|
||||
const trail = [
|
||||
positionChangeMarkup(row, idx + 1),
|
||||
obsConfig.showLaps ? `<span>${row.laps ?? 0}L</span>` : "",
|
||||
obsConfig.showLast ? `<span>${row.lastLapMs > 0 ? escapeHtml(formatLap(row.lastLapMs)) : "-"}</span>` : "",
|
||||
obsShowsResult(active, obsConfig) ? `<span>${escapeHtml(row.resultDisplay)}</span>` : "",
|
||||
obsConfig.showBest ? `<span>${formatLap(row.bestLapMs)}</span>` : "",
|
||||
obsConfig.showGap ? `<span>${escapeHtml(row.gapDisplay || row.gapAhead || "-")}</span>` : "",
|
||||
|
||||
Reference in new issue
Block a user