Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,18 @@ All notable changes to this project are documented in this file. The format is b

### Changed

- The hall on a portrait phone draws a wider view (it keeps at least 66 degrees across, up to a
100 degree vertical field of view), so walking down an aisle shows the cabinets' screens, not only
their sides. Landscape screens and the Field of view setting are unchanged.
- The hall's card and play button name only a cabinet the visitor is facing (within about 73 degrees
of the view), not one beside them and out of sight. A cabinet they chose to walk to (a click, a tap,
Tab, the map) stays offered unless they turn their back on it or walk off themselves, since the walk
there never turns the view.
- The hall's help opens by itself on a first visit only (then from "?"), and closes as soon as the
visitor walks or looks round instead of staying 9 seconds.
- On a phone (up to 480 px) the bar no longer shows a clipped "5.." where it names the spot; the card
names the cabinet.

- Internal: the server's hosting policy (which game a host names, `/api/games` descriptions, upload and
rollback, play counting) moved out of `server.py` into `src/arcade/hosting/`, a pure core behind small
ports (`GameCatalog`, `VersionStore`, `PlayCounter`, `EventReporter`, `ReleaseNotes`) with the
Expand Down
29 changes: 25 additions & 4 deletions src/arcade/hall_assets/hall-walk.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@
HallWalk.settle(x, z, world) -> the nearest clear spot (for places saved under an older layout)
HallWalk.step(me, input, dt, world) -> the visitor after dt seconds of input (eased velocity, sliding)
HallWalk.bob(phase, speed) -> head-bob height offset (off unless asked for)
HallWalk.near(me, layout) -> the cabinet the visitor is at, or null
HallWalk.near(me, layout, chosen) -> the cabinet the visitor is at (and faces), or null;
chosen (a slug) need only not be behind them
HallWalk.viewFov(fov, aspect) -> the vertical fov to draw with: fov, widened on a
tall view so it still sees MIN_HFOV degrees across
HallWalk.front(cabinet, d) -> {x, z, yaw}: d metres in front of it, facing it
HallWalk.stick(dx, dy, radius) -> a joystick offset in CSS px -> {forward, right, run}
HallWalk.ray(view, nx, ny) -> a camera ray through normalised screen coords
Expand All @@ -27,6 +30,10 @@
const SUBSTEP = 0.04;
const REACH = 2.3; // within this of a cabinet's front you can play it
const FOV = 62; // vertical, degrees (hall3d/main.cpp's default)
const MIN_HFOV = 66; // degrees across that a tall (portrait) view keeps
const MAX_VFOV = 100; // ...without the vertical fov going past this
const FACING = 0.3; // cos of how far off the view a cabinet can be and still be "at" it (~73 deg)
const CHOSEN_FACING = -0.3; // ...and one the visitor walked to on purpose (~107 deg)

function clamp(v, lo, hi) { return v < lo ? lo : (v > hi ? hi : v); }

Expand Down Expand Up @@ -173,7 +180,7 @@

/* The cabinet whose front the visitor stands at (nearest first), preferring
the one they look towards. */
function near(me, layout) {
function near(me, layout, chosen = null) {
let best = null, bestScore = Infinity;
const fx = -Math.cos(me.yaw), fz = -Math.sin(me.yaw);
for (const c of layout.cabinets) {
Expand All @@ -185,12 +192,26 @@
const side = (me.x - fr.o[0]) * fr.f[0] + (me.z - fr.o[2]) * fr.f[2];
if (side < 0.5) continue;
const facing = d > 1e-6 ? (dx * fx + dz * fz) / d : 1;
// Beside the visitor and out of sight is not the one they are at.
if (facing < (c.slug === chosen ? CHOSEN_FACING : FACING)) continue;
const score = d - 0.6 * facing;
if (score < bestScore) { bestScore = score; best = c; }
}
return best;
}

/* A portrait phone has a narrow view across: at the settings' vertical fov
(62 degrees on a 390x664 screen) it sees ~39 degrees, so down an aisle
there are only cabinet sides. Widen the vertical fov until the view sees
MIN_HFOV across (or the setting's own, if wider), capped at MAX_VFOV. */
function viewFov(fov, aspect) {
const f = Number.isFinite(fov) ? fov : FOV;
if (!(aspect > 0) || aspect >= 1) return f;
const rad = Math.PI / 180;
const need = 2 * Math.atan(Math.tan(MIN_HFOV * rad / 2) / aspect) / rad;
return Math.max(f, Math.min(MAX_VFOV, need));
}

function stick(dx, dy, radius) {
let x = dx / radius, y = -dy / radius;
const m = Math.hypot(x, y);
Expand Down Expand Up @@ -247,8 +268,8 @@
return {x: 0, z: Math.min(5.2, layout.room.near - 1.2), yaw: Math.PI / 2, pitch: 0.06};
}

const HallWalk = {frame, world, resolve, clear, settle, step, near, front, stick, ray, pick, spawn, bob,
RADIUS, EYE, WALK, RUN, REACH, FOV, ACCEL, DAMP};
const HallWalk = {frame, world, resolve, clear, settle, step, near, front, viewFov, stick, ray, pick, spawn, bob,
RADIUS, EYE, WALK, RUN, REACH, FOV, MIN_HFOV, MAX_VFOV, FACING, ACCEL, DAMP};
if (typeof module !== "undefined" && module.exports) module.exports = HallWalk;
else root.HallWalk = HallWalk;
})(typeof window !== "undefined" ? window : globalThis);
10 changes: 5 additions & 5 deletions src/arcade/hall_assets/hall.css
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,10 @@ body.moving #bar > * { pointer-events: none; }
#player-frame { flex: 1; width: 100%; border: 0; display: block; background: #000; }
.nojs { position: fixed; inset: auto 16px 16px; }
body.touch #bar #look { display: none; }
@media (max-width: 480px) { #bar #look { display: none; } #where { font-size: 12px; } }
/* On a phone the bar has room for a word or two at most ("5.." helped no
one), and the card already names the cabinet: the line keeps its place as
the bar's spacer but says nothing (the live region still reads it). */
@media (max-width: 480px) { #bar #look { display: none; } #where { font-size: 0; } }
/* Economy (hall.js setEconomy): a blur behind the buttons is redrawn with
every frame of the canvas under it, which costs a software renderer more
than the hall itself. Solid panels instead. */
Expand Down Expand Up @@ -288,7 +291,4 @@ body.touch #bar #visible-pill { min-height: 44px; min-width: 44px; }
#bar #sound svg { display: block; }
body.touch #bar #leave, body.touch #bar #sound { width: 44px; min-height: 44px; }
}
/* There, the line saying where you are keeps its place as the bar's spacer but
shows no text (a few letters and an ellipsis say nothing); the card says it. */
@media (max-width: 389px) { #where { font-size: 0; } }
@media (max-width: 480px) { body.visible-me #where { font-size: 0; } }
/* (The line saying where you are shows no text up to 480 px: see #bar #look above.) */
67 changes: 49 additions & 18 deletions src/arcade/hall_assets/hall.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
const params = new URLSearchParams(location.search);
const touchFirst = matchMedia("(hover: none), (pointer: coarse)").matches;
const POS_KEY = "arcade-hall.pos";
const HELPED_KEY = "arcade-hall.helped"; // "1" once the help has opened by itself
const TEX_MIPS = 1, TEX_CLAMP = 2 | 4;
// hall3d/main.cpp keeps these meshes drawn after the rest: the room's big
// surfaces, so the pixels the cabinets hide are never shaded.
Expand All @@ -40,6 +41,16 @@
hum: StrataKit.store.get("arcade-hall.sound") === "1",
});
let reducedMotion = settings.reduceMotion, fov = settings.fov;
/* The fov the hall draws with: the setting's, widened on a portrait view
(HallWalk.viewFov) so cabinets down an aisle show their screens. */
const aspectNow = () => canvas.clientWidth / Math.max(canvas.clientHeight, 1);
const drawFov = () => W.viewFov(fov, aspectNow());
let sentFov = null;
function sendView() {
if (!mod || !layout) return;
sentFov = drawFov();
mod._hall_set_view(economy ? ECONOMY_AMBIENT : (layout.room.style ? layout.room.style.ambient : 0.32), sentFov);
}
let bobOn = params.has("bob") ? params.get("bob") === "1" : settings.bob;

const session = {
Expand All @@ -49,6 +60,13 @@

let layout = null, world = null, mod = null, kit = null;
let me = null, near = null, target = null, playing = null;
let autoHelp = null; // where the visitor stood when the help opened by itself
/* The cabinet the visitor chose to walk to (a click, a tap, Tab, the map).
The walk there never turns the view, so they can arrive with it off to a
side: it stays the one they are at (HallWalk.near) until they walk off
themselves or turn well away from it. */
let chosen = null;
function goTo(c) { target = W.front(c, standOff()); chosen = c.slug; }
const state = {posters: 0, posterErrors: 0, sides: 0, frames: 0, mode: self.crossOriginIsolated ? "isolated" : "plain"};

/* --------------------------------------------------------- the heap */
Expand Down Expand Up @@ -361,8 +379,8 @@
function drawPeople() {
const P = window.HallPeople;
if (!P || !scenePoints || !kit) return;
const out = P.frame({x: kit.cam.tx, y: kit.cam.ty, z: kit.cam.tz, yaw: kit.cam.yaw, pitch: kit.cam.pitch, fov,
aspect: canvas.clientWidth / Math.max(canvas.clientHeight, 1), width: canvas.clientWidth, height: canvas.clientHeight,
const out = P.frame({x: kit.cam.tx, y: kit.cam.ty, z: kit.cam.tz, yaw: kit.cam.yaw, pitch: kit.cam.pitch, fov: drawFov(),
aspect: aspectNow(), width: canvas.clientWidth, height: canvas.clientHeight,
lite: economy || touchFirst, reduced: reducedMotion, layout});
state.people = P.stats;
// Ghosts and fading people: translucent meshes, built once per slot and colour, then only moved.
Expand Down Expand Up @@ -409,7 +427,7 @@
sceneItems = items;
rows(mod._hall_set_items, items);
rows(mod._hall_set_points, points);
mod._hall_set_view(layout.room.style ? layout.room.style.ambient : 0.32, fov);
sendView();
setLights();
}

Expand Down Expand Up @@ -892,7 +910,7 @@
const nowMs = () => (kit && kit.driven ? clock : performance.now());
const standPose = () => ({x: me.x, y: W.EYE, z: me.z, yaw: kit.cam.yaw, pitch: kit.cam.pitch});
const screenPose = (c) => HallPlay.screenPose(c.fr, layout.cabinet.screen,
canvas.clientWidth / Math.max(canvas.clientHeight, 1), fov);
aspectNow(), drawFov());
function switchUrl(c) {
const url = new URL(location.href);
url.search = "";
Expand Down Expand Up @@ -1125,7 +1143,7 @@
if (tabAt < 0 || tabAt >= tabList.length) { clearFocus(); return false; }
const c = tabList[tabAt];
focused = c; arrivedSaid = null;
target = W.front(c, standOff());
goTo(c);
keys.clear();
const org = c.org || (c.repo ? c.repo.split("/")[0] : "");
announce(`${c.title}${org ? ", " + org : ""}. ${tabAt + 1} of ${tabList.length}. `
Expand Down Expand Up @@ -1280,7 +1298,7 @@
}
if (window.ResizeObserver) new ResizeObserver(placeHelp).observe($("card"));
document.addEventListener("hall:card", () => requestAnimationFrame(placeHelp));
helpBtn.addEventListener("click", () => showHelp($("help").hidden));
helpBtn.addEventListener("click", () => { autoHelp = null; showHelp($("help").hidden); });

/* Settings, in the "?" panel: look sensitivity, invert Y, field of view,
head bob, reduce motion, the hum and the ghosts. Each applies at once and is kept. */
Expand All @@ -1296,7 +1314,7 @@
document.body.classList.toggle("reduce", reducedMotion);
if (fov !== settings.fov) {
fov = settings.fov;
if (mod && layout) mod._hall_set_view(economy ? ECONOMY_AMBIENT : (layout.room.style ? layout.room.style.ambient : 0.32), fov);
sendView();
}
state.settings = Object.assign({}, settings);
}
Expand Down Expand Up @@ -1349,13 +1367,20 @@

// How far in front of a cabinet to stop: further on a tall, narrow
// (portrait phone) view, so the whole cabinet stays in sight.
function standOff() { return canvas.clientWidth < canvas.clientHeight ? 1.9 : 1.15; }
function standOff() { return canvas.clientWidth < canvas.clientHeight ? 1.55 : 1.15; }
function view() {
return {x: me.x, y: W.EYE, z: me.z, yaw: kit.cam.yaw, pitch: kit.cam.pitch,
aspect: canvas.clientWidth / Math.max(canvas.clientHeight, 1), fov};
aspect: aspectNow(), fov: drawFov()};
}
function tick(t, now, dt) {
if (!me) return;
// A turned phone or a resized window changes the view's shape.
if (sentFov !== null && Math.abs(drawFov() - sentFov) > 0.05) sendView();
if (autoHelp && (Math.hypot(me.x - autoHelp.x, me.z - autoHelp.z) > 0.6 || Math.abs(kit.cam.yaw - autoHelp.yaw) > 0.35)) {
const keep = !setPanel.hidden || $("help").contains(document.activeElement);
autoHelp = null;
if (!keep) showHelp(false);
}
try { walk(t, now, dt); } finally { drawPeople(); }
}
function walk(t, now, dt) {
Expand Down Expand Up @@ -1399,6 +1424,7 @@
turn: (has("arrowright") - has("arrowleft")) * 1.9 * sens,
run: keys.has("shift") || stickIn.run || pad.run,
};
if (input.forward || input.right) chosen = null;
if (target && !input.forward && !input.right) {
const dx = target.x - me.x, dz = target.z - me.z, d = Math.hypot(dx, dz);
if (d < 0.08) {
Expand All @@ -1416,7 +1442,7 @@
}
}
if (input) me = W.step(me, input, dt, world);
near = W.near(me, layout);
near = W.near(me, layout, chosen);
stepTrailers(now);
stepVoices(now);
let eye = W.EYE;
Expand Down Expand Up @@ -1523,8 +1549,8 @@
let best = null, bestD = 0.9;
for (const c of layout.cabinets) { const d = Math.hypot(c.x - x, c.z - z); if (d < bestD) { bestD = d; best = c; } }
keys.clear();
if (best) target = W.front(best, standOff());
else { const p = W.settle(x, z, world); target = {x: p.x, z: p.z}; }
if (best) goTo(best);
else { const p = W.settle(x, z, world); target = {x: p.x, z: p.z}; chosen = null; }
state.mapTarget = best ? best.slug : "floor";
});

Expand Down Expand Up @@ -1638,7 +1664,7 @@
document.body.classList.toggle("lite", economy);
if (!kit) return;
if (economy) kit.dprCap = Math.min(kit.dprCap, ECONOMY_SCALE);
mod._hall_set_view(economy ? ECONOMY_AMBIENT : (layout.room.style ? layout.room.style.ambient : 0.32), fov);
sendView();
setLights();
setLods();
}
Expand Down Expand Up @@ -1726,10 +1752,11 @@
clearFocus();
if (hit.cabinet) {
if (near === hit.cabinet) { play(hit.cabinet); return; }
target = W.front(hit.cabinet, standOff());
goTo(hit.cabinet);
} else if (hit.floor) {
const p = W.resolve(hit.floor.x, hit.floor.z, world);
target = {x: p.x, z: p.z};
chosen = null;
}
},
// Still slow at the lowest tier: economy first, then the loader's lighter offer.
Expand All @@ -1752,10 +1779,14 @@
kit.start();
StrataLoader.done();
if (touchSeen) $("stick").hidden = false;
if (!resuming) {
// The help opens by itself on a first visit only (after that, "?" has it).
// It goes once the visitor starts walking or looking round (tick), or
// after 9 s, unless they have gone into it (to the settings, say).
if (!resuming && StrataKit.store.get(HELPED_KEY) !== "1") {
StrataKit.store.set(HELPED_KEY, "1");
showHelp(true);
// Unless the visitor has gone into it (to the settings, say).
setTimeout(() => { if (setPanel.hidden && !$("help").contains(document.activeElement)) showHelp(false); }, 9000);
autoHelp = {x: me.x, z: me.z, yaw: kit.cam.yaw};
setTimeout(() => { if (autoHelp && setPanel.hidden && !$("help").contains(document.activeElement)) showHelp(false); }, 9000);
}
canvas.focus({preventScroll: true});
queuePosters();
Expand Down Expand Up @@ -1797,7 +1828,7 @@
get focused() { return focused ? focused.slug : null; },
get settings() { return Object.assign({}, settings, {reducedMotion, fov}); },
get pad() { return state.pad || null; },
walkTo(slug) { const c = layout.cabinets.find((k) => k.slug === slug); if (c) target = W.front(c, standOff()); return !!c; },
walkTo(slug) { const c = layout.cabinets.find((k) => k.slug === slug); if (c) goTo(c); return !!c; },
play(slug) { play(layout.cabinets.find((k) => k.slug === slug)); },
back: closeFrame,
howFor(slug) { const c = layout.cabinets.find((k) => k.slug === slug); return c ? canFrame(c) : null; },
Expand Down
27 changes: 22 additions & 5 deletions tests/browser/hall_ui_check.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,16 @@ const NAMES = ["Ada", "Bo", "Cyrus"];
for (let tries = 0; tries < 12; tries++) {
const r = await tapLayerOnce(layer, caption);
if (r.ok) return r;
// A narrow phone view can have someone (or a cabinet) between the
// visitor and a walking figure for a while: after a few tries, turn
// to face it where it is now (the hall never turns the view itself).
if (tries >= 2) {
await page.evaluate((layer) => {
const d = HallPeople.dots().find((p) => p.layer === layer);
const me = __hall.me;
if (d) __hall.place(me.x, me.z, Math.atan2(me.z - d.z, me.x - d.x), 0.05);
}, layer);
}
await page.waitForTimeout(400);
}
return tapLayerOnce(layer, caption);
Expand All @@ -154,10 +164,14 @@ const NAMES = ["Ada", "Bo", "Cyrus"];
for (const id of cands) {
const s = await spot(layer, id);
if (!s || s.y < 110 || s.y > h - 170 || s.d > 20) continue;
// Not when a person is in front of it at that point.
const hit = await page.evaluate(([x, y]) => __hall.kit.pickAt(x, y), [s.x, s.y]);
if (!hit || !hit.person || hit.person.layer !== layer) continue;
await tapAt(s.x, s.y);
// A point of its column where nobody (and no cabinet) is in front of it.
let at = null;
for (const dy of [0, -12, 12, -24, 24, -36]) {
const hit = await page.evaluate(([x, y]) => __hall.kit.pickAt(x, y), [s.x, s.y + dy]);
if (hit && hit.person && hit.person.layer === layer) { at = {x: s.x, y: s.y + dy}; break; }
}
if (!at) continue;
await tapAt(at.x, at.y);
await page.waitForTimeout(600);
const ls = await labels();
return {id, ok: ls.includes(caption), labels: ls};
Expand Down Expand Up @@ -200,7 +214,10 @@ const NAMES = ["Ada", "Bo", "Cyrus"];
check(label, "tap on the floor still walks", !!floor && walked, floor);
await page.waitForTimeout(2500);

// 2. The map.
// 2. The map. A phone hides it at a cabinet (the card has the room), and
// the walk above can end at one: back to the door first.
await page.evaluate(() => { const s = HallWalk.spawn(__hall.layout); __hall.place(s.x, s.z, s.yaw, s.pitch); });
await page.waitForTimeout(300);
await page.evaluate(() => { if (!__hall.map.on) document.getElementById("map-btn").click(); });
await page.waitForTimeout(800);
const map1 = await page.evaluate(() => __hall.state.mapPeople);
Expand Down
Loading
Loading