This commit is contained in:
larssand
2026-03-22 18:13:35 +01:00
parent cb904520e3
commit 45574a2687

View File

@@ -1623,25 +1623,30 @@ let raceFormatAdvanced = false;
const OBS_LAYOUTS = ["leaderboard", "grid", "lowerthird"]; const OBS_LAYOUTS = ["leaderboard", "grid", "lowerthird"];
const OBS_THEMES = ["panel", "transparent", "chroma"]; const OBS_THEMES = ["panel", "transparent", "chroma"];
const DEFAULT_OBS_OVERLAY_SETTINGS = Object.freeze({ function createDefaultObsOverlaySettings() {
rows: 10, return {
showClock: true, rows: 10,
showFastest: true, showClock: true,
showGrid: true, showFastest: true,
showLaps: true, showGrid: true,
showResult: true, showLaps: true,
showBest: true, showResult: true,
showGap: true, showBest: true,
layout: "leaderboard", showGap: true,
theme: "panel", layout: "leaderboard",
publicToken: "", theme: "panel",
}); publicToken: "",
};
}
const DEFAULT_OBS_OVERLAY_SETTINGS = Object.freeze(createDefaultObsOverlaySettings());
function normalizeObsOverlaySettings(raw = {}) { function normalizeObsOverlaySettings(raw = {}) {
const defaults = createDefaultObsOverlaySettings();
const rowValue = Number(raw?.rows); const rowValue = Number(raw?.rows);
const rows = Number.isFinite(rowValue) ? Math.max(3, Math.min(12, Math.round(rowValue))) : DEFAULT_OBS_OVERLAY_SETTINGS.rows; const rows = Number.isFinite(rowValue) ? Math.max(3, Math.min(12, Math.round(rowValue))) : defaults.rows;
const layout = OBS_LAYOUTS.includes(String(raw?.layout || "").toLowerCase()) ? String(raw.layout).toLowerCase() : DEFAULT_OBS_OVERLAY_SETTINGS.layout; const layout = OBS_LAYOUTS.includes(String(raw?.layout || "").toLowerCase()) ? String(raw.layout).toLowerCase() : defaults.layout;
const theme = OBS_THEMES.includes(String(raw?.theme || "").toLowerCase()) ? String(raw.theme).toLowerCase() : DEFAULT_OBS_OVERLAY_SETTINGS.theme; const theme = OBS_THEMES.includes(String(raw?.theme || "").toLowerCase()) ? String(raw.theme).toLowerCase() : defaults.theme;
return { return {
rows, rows,
showClock: raw?.showClock !== false, showClock: raw?.showClock !== false,