From 9720d309faab13b64653c1c4ce576805b4e8f322 Mon Sep 17 00:00:00 2001 From: Burrowdev Date: Wed, 21 Oct 2026 20:50:44 +0300 Subject: [PATCH] feat(theatre): an experimental web browser on the theatre screen In a theatre, "Browser" puts a web page on the screen for that player alone, beside "Your Video". The desktop client (1.3.3) draws it in a sandboxed webview of its own over the game page, which tells it where, what the game draws over it, and where to go; nothing of it goes to the server. - off by default: the admin panel's Debug tab turns it on for everyone (setting theatreBrowser). the server marks the game page with data-theatre-browser="on" as it sends it (lib/http.js), and the page shows the button only when the server allows it and the client says it can draw it, so older clients never see a button that does nothing. - the boxes over the screen share one style (.aj-box), and a clicked button no longer keeps Chromium 87's focus ring. Co-Authored-By: Claude Opus 5.5 --- lib/http.js | 4 +- lib/panel.js | 15 ++- public/admin.html | 11 ++ public/game.html | 261 +++++++++++++++++++++++++++++++++++++++++++--- 4 files changed, 272 insertions(+), 19 deletions(-) diff --git a/lib/http.js b/lib/http.js index 9e0a5ae..dafb893 100644 --- a/lib/http.js +++ b/lib/http.js @@ -1104,7 +1104,9 @@ const handle = async (req, res) => { // not to be put in a frame of anyone's; the client shows it in a view of its own. res.setHeader("X-Frame-Options", "DENY"); res.setHeader("Referrer-Policy", "no-referrer"); - send(res, 200, await fs.promises.readFile(path.join(config.publicDir, "game.html")), MIME[".html"]); + // the admin's switch for the theatre browser (lib/panel.js), for the page to read + send(res, 200, String(await fs.promises.readFile(path.join(config.publicDir, "game.html"))) + .replace("", panel.theatreBrowserOn() ? '' : ""), MIME[".html"]); return; } diff --git a/lib/panel.js b/lib/panel.js index 3d9ce76..6f3d346 100644 --- a/lib/panel.js +++ b/lib/panel.js @@ -285,6 +285,12 @@ const ROOM_GROUP_NOTES = { adventures: "adventure maps; nothing in them moves", }; +// the theatre's browser (experimental; the server's game.html and client +// 1.3.3): off unless the admin turns it on. what players see in it never +// reaches the server; this only says whether the game offers it. +const THEATRE_BROWSER_SETTING = "theatreBrowser"; +const theatreBrowserOn = () => accounts.setting(THEATRE_BROWSER_SETTING) === "on"; + const debugState = () => ({ players: world.players().map(player => player.username).sort((a, b) => a.localeCompare(b)), rooms: defpacks.roomPaths().map(roomPath => { @@ -292,6 +298,7 @@ const debugState = () => ({ return {path: roomPath, group, note: ROOM_NOTES[roomPath] || ROOM_GROUP_NOTES[group] || ""}; }).sort((a, b) => a.path.localeCompare(b.path)), everythingOnSale: sales.everythingOnSale(), + theatreBrowser: theatreBrowserOn(), }); const debugAct = body => { @@ -309,6 +316,12 @@ const debugAct = body => { ? "Sale dates are off: every item shows, for players who start the game from now on." : "Sale dates are back on, for players who start the game from now on."}; } + if (body.action === "theatreBrowser") { + accounts.setSetting(THEATRE_BROWSER_SETTING, body.on === true ? "on" : "off"); + return {ok: body.on === true + ? "The theatre browser is on, for players on client 1.3.3 or newer once their game page loads again." + : "The theatre browser is off, once players' game pages load again."}; + } return {error: "Unknown debug action."}; }; @@ -1160,4 +1173,4 @@ const handle = async (req, res, url, from, web) => { } }; -module.exports = {load, handle, signedIn, PASSWORD_SETTING}; +module.exports = {load, handle, signedIn, theatreBrowserOn, PASSWORD_SETTING}; diff --git a/public/admin.html b/public/admin.html index e24d425..bd8be34 100644 --- a/public/admin.html +++ b/public/admin.html @@ -1091,6 +1091,12 @@

+
+

Theatre browser (experimental)

+ +

For each player alone, on desktop client 1.3.3 or newer; nothing they see reaches the server. The client's browser is an old Chrome, so a bad site could harm a player's computer.

+

+
@@ -2609,6 +2615,7 @@ $("debug-player").value = player; } $("debug-onsale").checked = data.everythingOnSale; + $("debug-theatre-browser").checked = data.theatreBrowser; if (debugRooms.length !== data.rooms.length) { debugRooms = data.rooms; renderDebugRooms(); @@ -2621,6 +2628,10 @@ setStatus($("debug-status"), result.data.ok || result.data.error || "That did not work.", !result.ok); }); $("debug-room").addEventListener("dblclick", () => $("debug-go").click()); + $("debug-theatre-browser").addEventListener("change", async () => { + const result = await api("debug", {action: "theatreBrowser", on: $("debug-theatre-browser").checked}); + setStatus($("debug-browser-status"), result.data.ok || result.data.error || "That did not work.", !result.ok); + }); $("debug-onsale").addEventListener("change", async () => { const result = await api("debug", {action: "everythingOnSale", on: $("debug-onsale").checked}); setStatus($("debug-sale-status"), result.data.ok || result.data.error || "That did not work.", !result.ok); diff --git a/public/game.html b/public/game.html index 6acccd3..25b1147 100644 --- a/public/game.html +++ b/public/game.html @@ -32,6 +32,11 @@ #theatre[hidden], #theatre [hidden] { display: none !important; } + /* no ring around a button that was clicked (the desktop client's + Chromium 87 still draws one); the keyboard's still shows */ + #theatre button:focus:not(:focus-visible) { + outline: none; + } /* the game draws over it just now (ajTheatreScreen) */ #theatre .covered { visibility: hidden; @@ -55,8 +60,12 @@ display: block; } /* in the game's own colours: cream panels, brown edges, a green "go" */ - #own-video-open { + #theatre-pills { position: absolute; + display: flex; + gap: calc(8 * var(--px)); + } + .theatre-pill { pointer-events: auto; font: 700 calc(13 * var(--px)) / 1 "DigitalDelivery", Arial, sans-serif; color: #6d4330; @@ -68,14 +77,75 @@ cursor: pointer; white-space: nowrap; } - #own-video-open:hover { + .theatre-pill:hover { background: linear-gradient(#fffef5, #fff0be); } - #own-video-open:active { + .theatre-pill:active { transform: translateY(calc(2 * var(--px))); box-shadow: none; } - #own-video-box { + /* the theatre browser's bar (experimental; the desktop client draws + the page itself, over the screen) */ + #browser-bar { + position: absolute; + pointer-events: auto; + box-sizing: border-box; + display: flex; + align-items: center; + gap: calc(5 * var(--px)); + height: calc(30 * var(--px)); + padding: 0 calc(5 * var(--px)); + background: #fff2c4; + border: calc(2 * var(--px)) solid #7f6744; + border-radius: 999px; + box-shadow: 0 calc(2 * var(--px)) 0 #7f6744; + } + .aj-round { + flex: none; + width: calc(22 * var(--px)); + height: calc(22 * var(--px)); + padding: 0; + font: 700 calc(12 * var(--px)) / 1 Arial, sans-serif; + color: #6d4330; + background: linear-gradient(#fffbe6, #ffe39a); + border: calc(2 * var(--px)) solid #7f6744; + border-radius: 50%; + cursor: pointer; + } + .aj-round:hover { + background: linear-gradient(#fffef5, #fff0be); + } + .aj-round:disabled { + opacity: 0.4; + cursor: default; + } + #browser-address { + flex: 1; + min-width: 0; + height: calc(20 * var(--px)); + box-sizing: border-box; + font: 400 calc(12 * var(--px)) / 1 Arial, Helvetica, sans-serif; + color: #3d2716; + background: #fff; + border: calc(2 * var(--px)) solid #c9a86a; + border-radius: 999px; + padding: 0 calc(9 * var(--px)); + outline: none; + } + #browser-address:focus { + border-color: #7f6744; + } + #browser-bar .aj-button { + min-width: 0; + font-size: calc(12 * var(--px)); + padding: calc(4 * var(--px)) calc(11 * var(--px)); + } + #browser-close { + background: radial-gradient(circle at 50% 35%, #ff7a5c, #c8321a 70%); + border-color: #8e2b16; + color: #fff; + } + .aj-box { position: absolute; pointer-events: auto; box-sizing: border-box; @@ -88,7 +158,7 @@ border-radius: calc(18 * var(--px)); box-shadow: inset 0 0 0 calc(2 * var(--px)) #ffe39a, 0 calc(4 * var(--px)) 0 rgba(0, 0, 0, 0.35); } - #own-video-box h2 { + .aj-box h2 { margin: 0 calc(24 * var(--px)) calc(10 * var(--px)) 0; font-size: calc(20 * var(--px)); font-weight: 700; @@ -96,7 +166,7 @@ letter-spacing: 0.02em; text-shadow: 0 0 calc(2 * var(--px)) #6d4330, calc(1.5 * var(--px)) calc(1.5 * var(--px)) 0 #6d4330, calc(-1.5 * var(--px)) calc(1.5 * var(--px)) 0 #6d4330, calc(1.5 * var(--px)) calc(-1.5 * var(--px)) 0 #6d4330, calc(-1.5 * var(--px)) calc(-1.5 * var(--px)) 0 #6d4330; } - #own-video-url { + .aj-box input { box-sizing: border-box; width: 100%; font: 400 calc(13 * var(--px)) / 1.2 Arial, Helvetica, sans-serif; @@ -108,10 +178,10 @@ box-shadow: inset 0 calc(2 * var(--px)) calc(3 * var(--px)) rgba(109, 67, 48, 0.25); outline: none; } - #own-video-url:focus { + .aj-box input:focus { border-color: #7f6744; } - #own-video-url::placeholder { + .aj-box input::placeholder { color: #a88f6a; } .own-video-buttons { @@ -149,7 +219,7 @@ .aj-button.stop:hover { background: linear-gradient(#ffab7c, #e05634); } - #own-video-close { + .aj-box-close { position: absolute; top: calc(-10 * var(--px)); right: calc(-10 * var(--px)); @@ -164,10 +234,10 @@ box-shadow: 0 0 0 calc(2 * var(--px)) #7f6744, 0 calc(2 * var(--px)) 0 calc(2 * var(--px)) rgba(0, 0, 0, 0.3); cursor: pointer; } - #own-video-close:hover { + .aj-box-close:hover { background: radial-gradient(circle at 50% 35%, #ff8f74, #d93d22 70%); } - #own-video-said { + .aj-box-said { min-height: calc(15 * var(--px)); margin: calc(8 * var(--px)) 0 0; font: 400 calc(12 * var(--px)) / 1.25 Arial, Helvetica, sans-serif; @@ -179,16 +249,27 @@