feat(overlay): practice ranked on laps in a row shows only result, gap and best lap (1.89.6)

This commit is contained in:
larssand committed 2026-11-12 13:09:38 +01:00
1 parent 119619d6ff
commit 56be3d5918
9 files changed
+54 -15

No files matched your search

+3 -3
View File
@@ -1,4 +1,4 @@
import { isOpenPracticeSession } from "./overlays.js";
import { isOpenPracticeSession, isPracticeRankedSession } from "./overlays.js";
let activeGuideTab = "start";
const GUIDE_TAB_IDS = ["start", "create", "run", "series", "training", "videos", "install"];
@@ -329,7 +329,7 @@ export function renderOverlayPageView(deps) {
<div class="overlay-fastest-meta">${t("table.laps")}: ${topRow?.laps || 0} | ${t("timing.total_passings")}: ${getVisiblePassings(result).length || 0}</div>
</section>
<div class="overlay-leaderboard-card overlay-leaderboard-card-tv overlay-leaderboard-card-dense">
${renderOverlayLeaderboard(leaderboard, { t, escapeHtml, formatTeamActiveMemberLabel, formatLap, formatPredictedLapDelta }, { lastLap: isOpenPracticeSession(active) })}
${renderOverlayLeaderboard(leaderboard, { t, escapeHtml, formatTeamActiveMemberLabel, formatLap, formatPredictedLapDelta }, { lastLap: isOpenPracticeSession(active), practiceRank: isPracticeRankedSession(active) })}
</div>
</div>
</section>
@@ -345,7 +345,7 @@ export function renderOverlayPageView(deps) {
<div class="overlay-fastest-meta">${t("table.laps")}: ${topRow?.laps || 0} | ${t("timing.total_passings")}: ${result?.passings.length || 0}</div>
</section>
<div class="overlay-leaderboard-card overlay-leaderboard-card-dense">
${renderOverlayLeaderboard(leaderboard, { t, escapeHtml, formatTeamActiveMemberLabel, formatLap, formatPredictedLapDelta }, { lastLap: isOpenPracticeSession(active) })}
${renderOverlayLeaderboard(leaderboard, { t, escapeHtml, formatTeamActiveMemberLabel, formatLap, formatPredictedLapDelta }, { lastLap: isOpenPracticeSession(active), practiceRank: isPracticeRankedSession(active) })}
</div>
</div>
<aside class="overlay-side">
+19 -9
View File
@@ -59,13 +59,15 @@ 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, lastLap = false } = {}) {
export function renderOverlayLeaderboard(rows, { t, escapeHtml, formatTeamActiveMemberLabel, formatLap, formatPredictedLapDelta }, { sortable = true, driverLinks = false, lastLap = false, practiceRank = 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(lastLap ? "table.last_lap" : "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(practiceRank
? [t("table.pos"), t("table.driver"), t("table.result"), t("table.gap"), t("table.best_lap")]
: [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.
@@ -73,11 +75,13 @@ export function renderOverlayLeaderboard(rows, { t, escapeHtml, formatTeamActive
const liveMarks = overlayLiveMarks.observe(rows);
const markLabels = { pit: t("table.pit"), split: t("table.split") };
return `
<div class="overlay-race-list ${compact ? "overlay-race-list-compact" : ""}"${sortAttrs}>
<div class="overlay-race-list ${compact ? "overlay-race-list-compact" : ""} ${practiceRank ? "overlay-race-list-ranked" : ""}"${sortAttrs}>
${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, lastLap ? row.lastLapMs || null : row.resultDisplay, row.gapDisplay || row.gapAhead || null, row.gapAhead || null, row.lapDelta || null, row.bestLapMs || null])}"` : "";
const rowSortAttr = sortable ? ` data-sort-values="${sortValuesAttribute(practiceRank
? [idx + 1, row.displayName || row.driverName, row.practiceMetric?.comparableMs ?? null, row.gapDisplay || null, row.bestLapMs || null]
: [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);
@@ -101,10 +105,10 @@ export function renderOverlayLeaderboard(rows, { t, escapeHtml, formatTeamActive
</div>
</div>
</div>
<div class="overlay-race-metric">
${practiceRank ? "" : `<div class="overlay-race-metric">
<label>${t("table.laps")}</label>
<strong>${row.laps ?? 0}</strong>
</div>
</div>`}
<div class="overlay-race-metric">
<label>${t(lastLap ? "table.last_lap" : "table.result")}</label>
<strong>${lastLap ? (row.lastLapMs > 0 ? escapeHtml(formatLap(row.lastLapMs)) : "-") : escapeHtml(row.resultDisplay)}</strong>
@@ -113,14 +117,14 @@ export function renderOverlayLeaderboard(rows, { t, escapeHtml, formatTeamActive
<label>${t("table.gap")}</label>
<strong>${escapeHtml(row.gapDisplay || row.gapAhead || "-")}</strong>
</div>
<div class="overlay-race-metric">
${practiceRank ? "" : `<div class="overlay-race-metric">
<label>${t("table.ahead_gap")}</label>
<strong>${escapeHtml(row.gapAhead || "-")}</strong>
</div>
<div class="overlay-race-metric">
<label>${t("table.own_delta")}</label>
<strong>${escapeHtml(row.lapDelta || "-")}</strong>
</div>
</div>`}
<div class="overlay-race-best">
<label>${t("table.best_lap")}</label>
<strong>${formatLap(row.bestLapMs)}</strong>
@@ -273,6 +277,12 @@ 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 N laps in a row or X minutes: the overlay shows only what the
// rule ranks on (the result, the gap and the best lap), not the race columns.
export function isPracticeRankedSession(session) {
return ["open_practice", "free_practice"].includes(String(session?.type || ""))
&& ["consecutive", "window"].includes(String(session?.practiceRanking || ""));
}
// 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.
@@ -354,7 +364,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, lastLap: isOpenPracticeSession(active) })}
${showStartGrid ? renderPositionGrid(active) : renderOverlayLeaderboard(compactRows, deps, { sortable: false, lastLap: isOpenPracticeSession(active), practiceRank: isPracticeRankedSession(active) })}
</section>
</section>
`;
+5
View File
@@ -3567,6 +3567,11 @@ select:focus {
overflow-x: auto;
}
/* Practice ranked on N laps in a row / X minutes: position, driver, result, gap, best lap. */
.overlay-race-list-ranked {
--overlay-columns: 30px minmax(148px, 1.42fr) repeat(3, minmax(80px, 0.5fr));
}
.overlay-race-row {
display: grid;
min-width: 610px;