aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcopilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>2026-05-07 11:32:54 +0000
committerstonedDiscord <Tukz@gmx.de>2026-05-17 15:00:45 +0200
commit5e6efbad8ebbbfbf2f39c9b6d0e8069c6132e6aa (patch)
treee0412736d024ca4484800ca139abb2a15d41039c
parent2fce78540e20c4653f401456f3a9540c5e0aa287 (diff)
fix: add .webp and extension-agnostic desk overlay support in setSide.ts
Agent-Logs-Url: https://github.com/SyntaxNyah/LemmyAO/sessions/8c0f84ca-716e-4e8a-8c93-720ece8e07b7
-rw-r--r--webAO/viewport/constants/positions.ts12
-rw-r--r--webAO/viewport/interfaces/Desk.ts2
-rw-r--r--webAO/viewport/utils/setSide.ts23
3 files changed, 26 insertions, 11 deletions
diff --git a/webAO/viewport/constants/positions.ts b/webAO/viewport/constants/positions.ts
index 3627db73..765a9530 100644
--- a/webAO/viewport/constants/positions.ts
+++ b/webAO/viewport/constants/positions.ts
@@ -4,12 +4,12 @@ import { Desk } from "../interfaces/Desk";
export const positions: Positions = {
def: {
bg: "defenseempty",
- desk: { ao2: "defensedesk.png", ao1: "bancodefensa.png" } as Desk,
+ desk: { ao2: "defensedesk", ao1: "bancodefensa" } as Desk,
speedLines: "defense_speedlines.gif",
},
pro: {
bg: "prosecutorempty",
- desk: { ao2: "prosecutiondesk.png", ao1: "bancoacusacion.png" } as Desk,
+ desk: { ao2: "prosecutiondesk", ao1: "bancoacusacion" } as Desk,
speedLines: "prosecution_speedlines.gif",
},
hld: {
@@ -24,22 +24,22 @@ export const positions: Positions = {
},
wit: {
bg: "witnessempty",
- desk: { ao2: "stand.png", ao1: "estrado.png" } as Desk,
+ desk: { ao2: "stand", ao1: "estrado" } as Desk,
speedLines: "prosecution_speedlines.gif",
},
jud: {
bg: "judgestand",
- desk: { ao2: "judgedesk.png", ao1: "judgedesk.gif" } as Desk,
+ desk: { ao2: "judgedesk", ao1: "judgedesk" } as Desk,
speedLines: "prosecution_speedlines.gif",
},
jur: {
bg: "jurystand",
- desk: { ao2: "jurydesk.png", ao1: "estrado.png" } as Desk,
+ desk: { ao2: "jurydesk", ao1: "estrado" } as Desk,
speedLines: "defense_speedlines.gif",
},
sea: {
bg: "seancestand",
- desk: { ao2: "seancedesk.png", ao1: "estrado.png" } as Desk,
+ desk: { ao2: "seancedesk", ao1: "estrado" } as Desk,
speedLines: "prosecution_speedlines.gif",
},
};
diff --git a/webAO/viewport/interfaces/Desk.ts b/webAO/viewport/interfaces/Desk.ts
index 2bcba963..947a1c00 100644
--- a/webAO/viewport/interfaces/Desk.ts
+++ b/webAO/viewport/interfaces/Desk.ts
@@ -1,4 +1,6 @@
export interface Desk {
+ /** Filename without extension for the AO2 desk overlay (e.g. "defensedesk") */
ao2?: string;
+ /** Filename without extension for the AO1 desk overlay (e.g. "bancodefensa") */
ao1?: string;
}
diff --git a/webAO/viewport/utils/setSide.ts b/webAO/viewport/utils/setSide.ts
index 564d477c..a9dbfdb3 100644
--- a/webAO/viewport/utils/setSide.ts
+++ b/webAO/viewport/utils/setSide.ts
@@ -1,7 +1,6 @@
import { positions } from "../constants/positions";
import { AO_HOST } from "../../client/aoHost";
import { client } from "../../client";
-import findImgSrc from "../../utils/findImgSrc";
import transparentPng from "../../constants/transparentPng";
import fileExists from "../../utils/fileExists";
@@ -70,7 +69,7 @@ export const set_side = async ({
speedLines = positions[position].speedLines;
} else {
bg = `${position}`;
- desk = { ao2: `${position}_overlay.png`, ao1: "_overlay.png" };
+ desk = { ao2: `${position}_overlay`, ao1: "_overlay" };
speedLines = "defense_speedlines.gif";
}
@@ -82,9 +81,23 @@ export const set_side = async ({
if (showDesk === true && desk) {
const bg_folder = client.viewport.getBackgroundFolder();
- const urls_to_try = [bg_folder + desk.ao2, bg_folder + desk.ao1];
- bench.src = await findImgSrc(urls_to_try);
- bench.style.opacity = "1";
+ const stems = [desk.ao2, desk.ao1].filter((s): s is string => typeof s === "string");
+ let found = false;
+ outer:
+ for (const stem of stems) {
+ for (const ext of client.background_extensions) {
+ const url = `${bg_folder}${stem}${ext}`;
+ if (await fileExists(url)) {
+ bench.src = url;
+ bench.style.opacity = "1";
+ found = true;
+ break outer;
+ }
+ }
+ }
+ if (!found) {
+ bench.src = transparentPng;
+ }
} else {
bench.style.opacity = "0";
}