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_THEMES = ["panel", "transparent", "chroma"];
const DEFAULT_OBS_OVERLAY_SETTINGS = Object.freeze({
rows: 10,
showClock: true,
showFastest: true,
showGrid: true,
showLaps: true,
showResult: true,
showBest: true,
showGap: true,
layout: "leaderboard",
theme: "panel",
publicToken: "",
});
function createDefaultObsOverlaySettings() {
return {
rows: 10,
showClock: true,
showFastest: true,
showGrid: true,
showLaps: true,
showResult: true,
showBest: true,
showGap: true,
layout: "leaderboard",
theme: "panel",
publicToken: "",
};
}
const DEFAULT_OBS_OVERLAY_SETTINGS = Object.freeze(createDefaultObsOverlaySettings());
function normalizeObsOverlaySettings(raw = {}) {
const defaults = createDefaultObsOverlaySettings();
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 layout = OBS_LAYOUTS.includes(String(raw?.layout || "").toLowerCase()) ? String(raw.layout).toLowerCase() : DEFAULT_OBS_OVERLAY_SETTINGS.layout;
const theme = OBS_THEMES.includes(String(raw?.theme || "").toLowerCase()) ? String(raw.theme).toLowerCase() : DEFAULT_OBS_OVERLAY_SETTINGS.theme;
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() : defaults.layout;
const theme = OBS_THEMES.includes(String(raw?.theme || "").toLowerCase()) ? String(raw.theme).toLowerCase() : defaults.theme;
return {
rows,
showClock: raw?.showClock !== false,