A town simulation in pale isometric line art, implemented with Ritmo ECS and PixiJs 3D
Phone goods: the chip opens the flow table in one tap, it fits the screen, and panning keeps it open
SandroMaglionecae426d51948
diff --git a/DEVELOPMENT.md b/DEVELOPMENT.mdindex 5c05cb8..60f0233 100644--- a/DEVELOPMENT.md+++ b/DEVELOPMENT.md@@ -50,7 +50,9 @@ people, and a chip of planks, stone and tools), one tool bar along the bottomshare, guide, save, load, new town and recentre), and two buttons top rightfor the guide and the map overlays. `host.ts` sets `body.fold-goods`,`fold-guide`, `fold-views` or `fold-more` while one is open; a tap on the map-folds it. A new guide step peeks above the tool bar for a few seconds. Sheets+folds it, a pan or pinch does not. Once the town has a minute of goods+(`body.flow-ready`), the goods chip opens the made/used table straight away,+each good by its icon. A new guide step peeks above the tool bar for a few seconds. Sheetsopen from the side on a landscape phone (`max-height: 500px`) and from thebottom in portrait. Dialogs take the whole screen with their actions pinnedto the bottom. The camera bar is hidden: pinch zooms and turns. New UI needsdiff --git a/src/host.ts b/src/host.tsindex ffe3f8e..591c15c 100644--- a/src/host.ts+++ b/src/host.ts@@ -298,9 +298,19 @@ export const createHost = async (}guideBulb.onclick = () => toggleFold("guide")layersButton.onclick = () => toggleFold("views")- mount.addEventListener("pointerdown", () => {- if (fold !== null) setFold(null)+ // A tap on the map folds them; a pan or a pinch, to look around with the goods or the guide open, does not.+ let mapPress: { id: number; x: number; y: number; moved: boolean } | null = null+ mount.addEventListener("pointerdown", (e) => {+ mapPress = mapPress === null && e.isPrimary ? { id: e.pointerId, x: e.clientX, y: e.clientY, moved: false } : null})+ mount.addEventListener("pointermove", (e) => {+ if (mapPress?.id === e.pointerId && Math.hypot(e.clientX - mapPress.x, e.clientY - mapPress.y) > 8) mapPress.moved = true+ })+ mount.addEventListener("pointerup", (e) => {+ if (mapPress?.id === e.pointerId && !mapPress.moved && fold !== null) setFold(null)+ if (mapPress?.id === e.pointerId) mapPress = null+ })+ mount.addEventListener("pointercancel", () => (mapPress = null))// The people's card joins the top line on a phone, and goes back to the top right on a wider screen.const placeFolk = () => {if (phone.matches) topline.insertBefore(folk, goodsChip)@@ -1831,7 +1841,9 @@ export const createHost = async (? `\nLast minute: made ${s.flow.made[g]}, used ${s.flow.used[g]}${s.flow.traded[g] !== 0 ? `, ${s.flow.traded[g] > 0 ? "bought" : "sold"} ${Math.abs(s.flow.traded[g])}` : ""}. ${s.stock[g]} in storage, ${s.flow.elsewhere[g]} about town (in workshops and markets, and on the way).`: "")}- if (flowCard.classList.contains("open")) setHtml(flowCard, flowHtml(s))+ // On a phone the goods chip opens the table itself, once there is a minute to show; the plain goods until then.+ document.body.classList.toggle("flow-ready", s.flow !== null)+ if (flowCard.classList.contains("open") || (phone.matches && fold === "goods")) setHtml(flowCard, flowHtml(s))// The crown's request.request.classList.toggle("show", s.crown.open && s.fate.state === "playing")if (s.crown.open) {@@ -1982,7 +1994,7 @@ const flowHtml = (s: Stats): string => {const body = rows.map((g) => {const way = flowTrend(f, g)const traded = f.traded[g] === 0 ? `<i>–</i>` : f.traded[g] > 0 ? `+${f.traded[g]}` : `−${-f.traded[g]}`- return `<span class="name">${goodIcon(g, 14)}${goods[g].title}<span class="trend ${trendClass(way)}">${trendMark(way)}</span></span>` ++ return `<span class="name" title="${goods[g].title}">${goodIcon(g, 14)}<span class="label">${goods[g].title}</span><span class="trend ${trendClass(way)}">${trendMark(way)}</span></span>` +`${cell(f.made[g])}${cell(f.used[g])}<span>${traded}</span>${cell(s.stock[g])}${cell(f.elsewhere[g])}`}).join("")return `<div class="flow-grid">${head}${body}</div>`diff --git a/src/phone.css b/src/phone.cssindex 91df10d..8121cac 100644--- a/src/phone.css+++ b/src/phone.css@@ -36,7 +36,17 @@/* The goods: folded into the chip; open, every good in a wrapped card under the top line. */.hud .stock { display: none; }.hud .flow.open { display: none; }- .fold-goods .hud .flow.open { display: flex; max-width: min(430px, 100%); }+ /* Once the town has a minute of goods to show, the chip opens the table straight away: storage is a column of it. */+ .fold-goods.flow-ready .hud .stock { display: none; }+ .fold-goods.flow-ready .hud .flow {+ display: flex; box-sizing: border-box; width: min(430px, 100%); padding: 4px 10px 6px;+ max-height: calc(100dvh - 190px - env(safe-area-inset-top) - env(safe-area-inset-bottom)); overflow-y: auto;+ }+ /* Narrow: a good by its icon (its name on a long press), the numbers close. */+ .hud .flow .flow-grid { grid-template-columns: auto repeat(5, minmax(0, 1fr)); font-size: 12px; }+ .hud .flow .flow-grid > * { padding: 5px 0 5px 6px; }+ .hud .flow .flow-grid > b { font-size: 10px; white-space: normal; line-height: 1.2; align-self: end; }+ .hud .flow .name .label { display: none; }.fold-goods .hud .stock { display: flex; flex-wrap: wrap; gap: 4px 0; padding: 5px; max-width: min(430px, 100%); }.hud .stock .group { flex-wrap: wrap; gap: 3px; padding: 0 3px; }.hud .good { gap: 4px; padding: 3px 7px 3px 4px; }