A town simulation in pale isometric line art, implemented with Ritmo ECS and PixiJs 3D
Hold a touch stroke with just Cancel and Build; a thinner full-width hint strip
SandroMaglionee98b439831f9
diff --git a/DEVELOPMENT.md b/DEVELOPMENT.mdindex 680f48a..5c05cb8 100644--- a/DEVELOPMENT.md+++ b/DEVELOPMENT.md@@ -33,13 +33,13 @@ build; camera gestures never place anything. A finger has no hover, so ontouch the tap tools (buildings, park pieces, bulldoze) take two taps: thefirst holds the ghost or outline where it landed, a second on the same spotcommits it. The drag tools (road, pave, homes, park ground) hold the stroke-on touch too: a bar above the tool bar says what it lays and costs, with-**Build** and ✕; a tap on the stroke's end builds it, a tap elsewhere drops+on touch too: **Cancel** and **Build** sit above the tool bar (in the guide's+place) and the tooltip says what it lays and costs; a tap on the stroke's end builds it, a tap elsewhere dropsit, and two fingers move the camera under it. With any pointer, a stroke letgo off the map (over the tool bar, say) is dropped and shows red while itwould be, as are a right click or Esc mid-drag. On touch the tooltip showsonly for what is about to be built, never while panning or picking, in a-strip under the top line. This lives entirely in `src/render3d/input.ts`+thin full-width strip under the top line. This lives entirely in `src/render3d/input.ts`(and the bar in `host.ts`); the game still sees one ordinary press andrelease.diff --git a/src/factory.css b/src/factory.cssindex 3271c7f..40050cc 100644--- a/src/factory.css+++ b/src/factory.css@@ -113,19 +113,17 @@ body { font-family: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, monospace;font-size: 12px; padding: 7px 14px; border-radius: 4px; opacity: 0; transition: opacity 160ms ease; pointer-events: none; z-index: 20;}.toast.show { opacity: 1; }-/* A stroke let go of on a touch screen: what it lays and costs, with build and cancel, above the tool bar. */+/* A stroke let go of on a touch screen: cancel and build, above the tool bar. */.stroke-bar {position: fixed; left: 50%; bottom: calc(70px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 5;- display: none; align-items: center; gap: 6px; padding: 5px 5px 5px 12px; max-width: calc(100vw - 16px);- background: #f7f8f4; border: 1px solid #c9cec4; border-radius: 10px; box-shadow: 0 2px 0 #dfe2db; font-size: 12px; color: #3d4943;+ display: none; gap: 6px; font-size: 12px;}.stroke-bar.open { display: flex; }-.stroke-bar .what { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }.stroke-bar button {- font: inherit; font-weight: 700; display: flex; align-items: center; justify-content: center; min-width: 40px; min-height: 36px;- padding: 0 12px; border-radius: 7px; border: 1px solid #3d4943; background: #f7f8f4; color: #3d4943; cursor: pointer;+ font: inherit; font-weight: 700; min-height: 34px; padding: 0 16px; border-radius: 8px; cursor: pointer;+ border: 1px solid #c9cec4; background: #f7f8f4; color: #3d4943; box-shadow: 0 2px 0 #dfe2db;}-.stroke-bar button.primary { background: #3d4943; color: #f7f8f4; padding: 0 16px; }+.stroke-bar button.primary { background: #3d4943; border-color: #3d4943; color: #f7f8f4; }@media (max-width: 1000px) {.system button.labelled { font-size: 0; gap: 0; padding: 6px 9px; }.toolbar button kbd, .toolbar .town-button kbd { display: none; }diff --git a/src/host.ts b/src/host.tsindex 77ca8e0..a9d493d 100644--- a/src/host.ts+++ b/src/host.ts@@ -1674,16 +1674,14 @@ export const createHost = async (mount: HTMLElement, persistence: () => Persiste}const input = new MapInput(stage, ui)- // A road, a row of homes, or a patch of park let go of on a touch screen is held here until built or dropped.+ // A road, a row of homes, or a patch of park let go of on a touch screen is held here until built or+ // dropped; the tooltip says what it lays and costs.const strokeBar = el("div", "stroke-bar")- const strokeText = el("span", "what")- const strokeBuild = el("button", "frame primary", "Build")+ const strokeBuild = el("button", "primary", "Build")strokeBuild.onclick = () => input.confirmStroke()- const strokeDrop = el("button", "frame", "")- strokeDrop.append(iconEl("close", 14))- strokeDrop.setAttribute("aria-label", "Cancel")+ const strokeDrop = el("button", "", "Cancel")strokeDrop.onclick = () => input.cancelStroke()- strokeBar.append(strokeText, strokeDrop, strokeBuild)+ strokeBar.append(strokeDrop, strokeBuild)document.body.append(strokeBar)const resetPage = () => {choose("select")@@ -1906,8 +1904,8 @@ export const createHost = async (mount: HTMLElement, persistence: () => Persisteconst text = ui.dragFrom && ui.stroke !== "cancel" && ui.preview.stroke ? ui.preview.stroke : ui.preview.tooltip// A held touch stroke waits for its build button.const held = ui.stroke === "held" && ui.preview.stroke !== null- if (held) strokeText.textContent = ui.preview.strokestrokeBar.classList.toggle("open", held)+ document.body.classList.toggle("stroke-held", held)if (text && screenPointer) {tooltip.textContent = texttooltip.style.display = "block"diff --git a/src/phone.css b/src/phone.cssindex cb10510..3c225b8 100644--- a/src/phone.css+++ b/src/phone.css@@ -126,7 +126,9 @@}.toast { bottom: calc(108px + env(safe-area-inset-bottom)); max-width: calc(100vw - 28px); white-space: normal; text-align: center; }- .stroke-bar { bottom: calc(56px + env(safe-area-inset-bottom)); width: max-content; }+ .stroke-bar { bottom: calc(56px + env(safe-area-inset-bottom)); }+ /* A held stroke's buttons take the guide's place above the tool bar. */+ .stroke-held .hud .ticker.peek { display: none; }/* ── Dialogs: the whole screen, the body scrolling, the actions pinned to the bottom ── */.dialog { padding: 0; }@@ -201,14 +203,14 @@/* No hover, so no key hints. */.toolbar button kbd, .views button kbd { display: none; }.panel .close { min-width: 40px; min-height: 40px; }- /* The build hint follows no finger: a slim strip at the top, under the top line, clear of the town in the middle. */+ /* The build hint follows no finger: a thin strip the width of the screen, under the top line, clear of the town in the middle. */.tooltip {- left: 50% !important; top: calc(58px + env(safe-area-inset-top)) !important; transform: translateX(-50%);- width: max-content; max-width: calc(100vw - 20px); white-space: normal; text-align: center;- font-size: 11px; line-height: 1.35; padding: 4px 10px; background: rgba(47, 70, 57, 0.82); border-radius: 6px;+ left: 0 !important; right: 0; top: calc(52px + env(safe-area-inset-top)) !important; transform: none;+ white-space: normal; text-align: center; font-size: 9.5px; line-height: 1.3; padding: 3px 8px;+ background: rgba(47, 70, 57, 0.8); border-radius: 0;}}/* A portrait phone's top line takes two rows: the hint goes under both. */@media (pointer: coarse) and (max-width: 760px) and (min-height: 501px) {- .tooltip { top: calc(88px + env(safe-area-inset-top)) !important; }+ .tooltip { top: calc(84px + env(safe-area-inset-top)) !important; }}diff --git a/src/render3d/input.ts b/src/render3d/input.tsindex 8c11c39..7b1841f 100644--- a/src/render3d/input.ts+++ b/src/render3d/input.ts@@ -300,13 +300,12 @@ export class MapInput {return this.screen}/** Where the tooltip goes, or `null` for none. A finger shows it only for what it is about to- * build (a stroke being drawn, an armed tap), never while it moves the camera or picks a- * building, whose panel says the same, nor for a held stroke, whose bar says it; the- * stylesheet pins it to the top on touch. */+ * build (a stroke being drawn or held, an armed tap), never while it moves the camera or+ * picks a building, whose panel says the same; the stylesheet pins it to the top on touch. */get tip(): Point | null {if (!this.touch) return this.screen- if (this.pinch || this.held) return null- if (this.armed) return this.screen ?? { x: 0, y: 0 }+ if (this.pinch) return null+ if (this.held || this.armed) return this.screen ?? { x: 0, y: 0 }return this.press?.mode === "edit" ? this.screen : null}sync() {