castle-web-cli 0.4.231 → 0.4.233
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/agent-failures.d.ts +8 -0
- package/dist/agent-failures.js +19 -2
- package/dist/agent-prompts.d.ts +1 -1
- package/dist/agent-prompts.js +10 -3
- package/dist/agent.d.ts +64 -3
- package/dist/agent.js +170 -81
- package/dist/castle-host/host.d.ts +1 -0
- package/dist/castle-host/host.js +51 -3
- package/dist/castleJson.d.ts +4 -2
- package/dist/castleJson.js +2 -0
- package/dist/check.d.ts +3 -1
- package/dist/check.js +11 -1
- package/dist/devSessionStorage.js +47 -1
- package/dist/importPinMismatch.d.ts +22 -0
- package/dist/importPinMismatch.js +77 -0
- package/dist/importRegression.js +3 -15
- package/dist/imports.d.ts +10 -3
- package/dist/imports.js +88 -20
- package/dist/index.js +5 -4
- package/dist/init.js +1 -1
- package/dist/platformDoc.js +22 -0
- package/dist/routerFences.d.ts +5 -0
- package/dist/routerFences.js +12 -2
- package/dist/save-deck.d.ts +5 -0
- package/dist/save-deck.js +37 -4
- package/dist/serve.js +3 -0
- package/dist/serverBundle.js +5 -3
- package/dist/shell/assets/{index-D2tWM896.js → index-BjOxR-lW.js} +4 -4
- package/dist/shell/assets/index-MVLfNYd9.css +1 -0
- package/dist/shell/index.html +2 -2
- package/dist/taskSteer.d.ts +13 -0
- package/dist/taskSteer.js +22 -2
- package/kits/base/castle.json +1 -1
- package/kits/base/package-lock.json +1 -1
- package/kits/base/sdk/README.md +79 -2
- package/kits/base/sdk/avatar.d.ts +6 -2
- package/kits/base/sdk/avatar.js +12 -4
- package/kits/base/sdk/castle.d.ts +1 -1
- package/kits/base/sdk/commands.d.ts +14 -0
- package/kits/base/sdk/hub.d.ts +6 -2
- package/kits/base/sdk/hub.js +13 -0
- package/kits/base/sdk/multiplayer.js +17 -1
- package/kits/base/sdk/save.js +2 -1
- package/kits/base/sdk/server/hub.d.ts +87 -0
- package/kits/base/sdk/server/hub.js +70 -0
- package/kits/base/sdk/server/platformHandle.d.ts +31 -1
- package/kits/base/sdk/server/storage.d.ts +13 -0
- package/kits/base/sdk/server/storage.js +46 -0
- package/kits/base/sdk/server/wrapper.d.ts +36 -5
- package/kits/base/sdk/server/wrapper.js +83 -8
- package/kits/hub-game/CLAUDE.md +352 -12
- package/kits/hub-game/blueprints/avatar-10.scene +28 -0
- package/kits/hub-game/blueprints/avatar-11.scene +28 -0
- package/kits/hub-game/blueprints/avatar-12.scene +28 -0
- package/kits/hub-game/blueprints/avatar-13.scene +28 -0
- package/kits/hub-game/blueprints/avatar-14.scene +28 -0
- package/kits/hub-game/blueprints/avatar-15.scene +28 -0
- package/kits/hub-game/blueprints/avatar-4.scene +28 -0
- package/kits/hub-game/blueprints/avatar-5.scene +28 -0
- package/kits/hub-game/blueprints/avatar-6.scene +28 -0
- package/kits/hub-game/blueprints/avatar-7.scene +28 -0
- package/kits/hub-game/blueprints/avatar-8.scene +28 -0
- package/kits/hub-game/blueprints/avatar-9.scene +28 -0
- package/kits/hub-game/code/client/actorBudget.js +47 -0
- package/kits/hub-game/code/client/attention.js +11 -2
- package/kits/hub-game/code/client/avatar.js +345 -32
- package/kits/hub-game/code/client/avatarCap.js +228 -0
- package/kits/hub-game/code/client/avatarColors.js +70 -0
- package/kits/hub-game/code/client/avatarFaces.js +21 -0
- package/kits/hub-game/code/client/avatarShare.js +251 -0
- package/kits/hub-game/code/client/ballot.js +467 -0
- package/kits/hub-game/code/client/build.js +22 -0
- package/kits/hub-game/code/client/chat.js +12 -0
- package/kits/hub-game/code/client/chrome.js +1334 -50
- package/kits/hub-game/code/client/companion.js +716 -0
- package/kits/hub-game/code/client/companionDress.js +99 -0
- package/kits/hub-game/code/client/decor.js +509 -0
- package/kits/hub-game/code/client/earned.js +131 -0
- package/kits/hub-game/code/client/emoteBubble.js +75 -0
- package/kits/hub-game/code/client/grab.js +363 -20
- package/kits/hub-game/code/client/hats.js +26 -0
- package/kits/hub-game/code/client/hookLayer.js +328 -15
- package/kits/hub-game/code/client/hudClear.js +126 -0
- package/kits/hub-game/code/client/idle.js +163 -22
- package/kits/hub-game/code/client/interestCap.js +81 -0
- package/kits/hub-game/code/client/keys.js +36 -0
- package/kits/hub-game/code/client/labelsNear.js +205 -0
- package/kits/hub-game/code/client/menuIcons.js +34 -0
- package/kits/hub-game/code/client/pack.js +6 -2
- package/kits/hub-game/code/client/packFormat.js +3 -3
- package/kits/hub-game/code/client/rehello.js +167 -0
- package/kits/hub-game/code/client/shot.js +92 -0
- package/kits/hub-game/code/client/sound.js +63 -8
- package/kits/hub-game/code/client/soundscape.js +1151 -0
- package/kits/hub-game/code/client/soundscapeActions.js +99 -0
- package/kits/hub-game/code/client/soundscapeAmbience.js +453 -0
- package/kits/hub-game/code/client/soundscapeBaked.js +143 -0
- package/kits/hub-game/code/client/soundscapeBusker.js +217 -0
- package/kits/hub-game/code/client/soundscapeCourt.js +200 -0
- package/kits/hub-game/code/client/soundscapeCrowd.js +331 -0
- package/kits/hub-game/code/client/soundscapeCues.js +362 -0
- package/kits/hub-game/code/client/soundscapeMap.js +181 -0
- package/kits/hub-game/code/client/soundscapeMarket.js +176 -0
- package/kits/hub-game/code/client/soundscapeMusic.js +126 -0
- package/kits/hub-game/code/client/soundscapeMusicEngine.js +460 -0
- package/kits/hub-game/code/client/soundscapeSimlish.js +737 -0
- package/kits/hub-game/code/client/soundscapeSongs.js +127 -0
- package/kits/hub-game/code/client/soundscapeSongsRound3.js +63 -0
- package/kits/hub-game/code/client/soundscapeSynthesis.js +168 -0
- package/kits/hub-game/code/client/soundscapeUi.js +211 -0
- package/kits/hub-game/code/client/soundscapeVoice.js +1209 -0
- package/kits/hub-game/code/client/soundscapeWaves.js +206 -0
- package/kits/hub-game/code/client/spin.js +101 -0
- package/kits/hub-game/code/client/state.js +131 -1
- package/kits/hub-game/code/client/stuck.js +259 -0
- package/kits/hub-game/code/client/talk.js +538 -47
- package/kits/hub-game/code/client/tiers.js +541 -27
- package/kits/hub-game/code/client/toastBand.js +37 -0
- package/kits/hub-game/code/client/together.js +98 -1
- package/kits/hub-game/code/client/visibility.js +43 -0
- package/kits/hub-game/code/client/wear.js +470 -97
- package/kits/hub-game/code/client/yours.js +199 -0
- package/kits/hub-game/code/companionSpec.js +45 -0
- package/kits/hub-game/code/privateText.js +7 -0
- package/kits/hub-game/code/server/actions.js +133 -0
- package/kits/hub-game/code/server/actors.js +14 -1
- package/kits/hub-game/code/server/ask.js +155 -0
- package/kits/hub-game/code/server/ballot.js +539 -0
- package/kits/hub-game/code/server/cells.js +100 -0
- package/kits/hub-game/code/server/companion.js +82 -0
- package/kits/hub-game/code/server/cues.js +70 -0
- package/kits/hub-game/code/server/decor.js +269 -0
- package/kits/hub-game/code/server/earned.js +461 -0
- package/kits/hub-game/code/server/friendBests.js +166 -0
- package/kits/hub-game/code/server/friendsAmong.js +232 -0
- package/kits/hub-game/code/server/grab.js +296 -11
- package/kits/hub-game/code/server/history.js +5 -0
- package/kits/hub-game/code/server/hub.js +1317 -52
- package/kits/hub-game/code/server/idle.js +30 -11
- package/kits/hub-game/code/server/index.js +2 -2
- package/kits/hub-game/code/server/labels.js +28 -2
- package/kits/hub-game/code/server/manifest.js +424 -8
- package/kits/hub-game/code/server/menu.js +133 -0
- package/kits/hub-game/code/server/npcs.js +830 -80
- package/kits/hub-game/code/server/party.js +13 -2
- package/kits/hub-game/code/server/players.js +22 -0
- package/kits/hub-game/code/server/say.js +8 -2
- package/kits/hub-game/code/server/shot.js +110 -0
- package/kits/hub-game/code/server/standing.js +124 -0
- package/kits/hub-game/code/server/vis.js +113 -0
- package/kits/hub-game/code/server/wear.js +128 -11
- package/kits/hub-game/code/server/yours.js +59 -0
- package/kits/hub-game/code/shared/cues.js +9 -0
- package/kits/hub-game/code/shared/decor.js +41 -0
- package/kits/hub-game/code/shared/shot.js +19 -0
- package/kits/hub-game/code/shared/spin.js +57 -0
- package/kits/hub-game/code/systems/hub.js +1083 -85
- package/kits/hub-game/docs/content-pack.md +1 -1
- package/kits/hub-game/docs/contract.md +2440 -61
- package/kits/hub-game/docs/home-pieces.md +64 -0
- package/kits/hub-game/models/avatar-10.pxmodel +28 -0
- package/kits/hub-game/models/avatar-11.pxmodel +28 -0
- package/kits/hub-game/models/avatar-12.pxmodel +27 -0
- package/kits/hub-game/models/avatar-13.pxmodel +24 -0
- package/kits/hub-game/models/avatar-14.pxmodel +29 -0
- package/kits/hub-game/models/avatar-15.pxmodel +24 -0
- package/kits/hub-game/models/avatar-4.pxmodel +29 -0
- package/kits/hub-game/models/avatar-5.pxmodel +27 -0
- package/kits/hub-game/models/avatar-6.pxmodel +26 -0
- package/kits/hub-game/models/avatar-7.pxmodel +25 -0
- package/kits/hub-game/models/avatar-8.pxmodel +24 -0
- package/kits/hub-game/models/avatar-9.pxmodel +30 -0
- package/kits/hub-game/models/earned/badge-round.pxmodel +100 -0
- package/kits/hub-game/models/earned/badge-shield.pxmodel +117 -0
- package/kits/hub-game/models/earned/badge-star.pxmodel +87 -0
- package/kits/hub-game/models/earned/belt-plain.pxmodel +72 -0
- package/kits/hub-game/models/earned/held-ball.pxmodel +43 -0
- package/kits/hub-game/models/earned/held-lantern.pxmodel +85 -0
- package/kits/hub-game/models/earned/held-net.pxmodel +57 -0
- package/kits/hub-game/models/earned/held-trophy.pxmodel +109 -0
- package/kits/hub-game/models/earned/pin-round.pxmodel +62 -0
- package/kits/hub-game/models/earned/sash-plain.pxmodel +66 -0
- package/kits/hub-game/models/earned/square/belt-plain.pxmodel +104 -0
- package/kits/hub-game/models/earned/square/sash-plain.pxmodel +98 -0
- package/kits/hub-game/models/hats/bat-clip.pxmodel +206 -0
- package/kits/hub-game/models/hats/beekeeper.pxmodel +149 -0
- package/kits/hub-game/models/hats/cap.pxmodel +162 -0
- package/kits/hub-game/models/hats/captain.pxmodel +178 -0
- package/kits/hub-game/models/hats/crooked-top.pxmodel +172 -0
- package/kits/hub-game/models/hats/flower-crown.pxmodel +451 -0
- package/kits/hub-game/models/hats/foam-crown.pxmodel +179 -0
- package/kits/hub-game/models/hats/lantern.pxmodel +230 -0
- package/kits/hub-game/models/hats/laurel.pxmodel +533 -0
- package/kits/hub-game/models/hats/lighthouse.pxmodel +96 -0
- package/kits/hub-game/models/hats/sailor.pxmodel +141 -0
- package/kits/hub-game/models/hats/souwester.pxmodel +131 -0
- package/kits/hub-game/models/hats/straw.pxmodel +139 -0
- package/kits/hub-game/models/hats/sunflower.pxmodel +406 -0
- package/kits/hub-game/models/hats/sweatband.pxmodel +112 -0
- package/kits/hub-game/models/hats/witch.pxmodel +147 -0
- package/kits/hub-game/package-lock.json +2 -0
- package/kits/hub-game/package.json +2 -1
- package/kits/hub-game/scripts/check.mjs +78 -11
- package/kits/hub-game/scripts/companion-follower-wire.json +1 -0
- package/kits/hub-game/scripts/fixtures/decor-keyless-draw.json +121 -0
- package/kits/hub-game/scripts/fixtures/decor-keyless.json +293 -0
- package/kits/hub-game/scripts/fixtures/engine-models-stub.mjs +23 -0
- package/kits/hub-game/scripts/fixtures/fake-dom.mjs +107 -0
- package/kits/hub-game/scripts/fixtures/interest-legacy.json +385 -0
- package/kits/hub-game/scripts/fixtures/npc-notes-v1.77.jsonl +4 -0
- package/kits/hub-game/scripts/fixtures/vis-shared-wire.json +1 -0
- package/kits/hub-game/scripts/gen-avatars.mjs +933 -16
- package/kits/hub-game/scripts/gen-earned.mjs +285 -0
- package/kits/hub-game/scripts/gen-hats.mjs +827 -0
- package/kits/hub-game/scripts/grab.before-orbit.mjs +400 -0
- package/kits/hub-game/scripts/soundscape-wave-analysis.mjs +125 -0
- package/kits/hub-game/scripts/test-actions-client.mjs +488 -0
- package/kits/hub-game/scripts/test-actions.mjs +298 -0
- package/kits/hub-game/scripts/test-actor-budget.mjs +44 -0
- package/kits/hub-game/scripts/test-actors.mjs +19 -17
- package/kits/hub-game/scripts/test-ask-client.mjs +358 -0
- package/kits/hub-game/scripts/test-ask.mjs +269 -0
- package/kits/hub-game/scripts/test-attention.mjs +10 -1
- package/kits/hub-game/scripts/test-avatar-cap.mjs +379 -0
- package/kits/hub-game/scripts/test-avatar-colors.mjs +72 -0
- package/kits/hub-game/scripts/test-avatar-models.mjs +181 -0
- package/kits/hub-game/scripts/test-avatar-share.mjs +318 -0
- package/kits/hub-game/scripts/test-avatar-wire.mjs +753 -0
- package/kits/hub-game/scripts/test-avatar.mjs +540 -7
- package/kits/hub-game/scripts/test-ballot.mjs +1001 -0
- package/kits/hub-game/scripts/test-build.mjs +31 -0
- package/kits/hub-game/scripts/test-cells.mjs +71 -0
- package/kits/hub-game/scripts/test-chat.mjs +694 -0
- package/kits/hub-game/scripts/test-classic.mjs +2 -0
- package/kits/hub-game/scripts/test-companion-chat.mjs +198 -0
- package/kits/hub-game/scripts/test-companion-client.mjs +1167 -0
- package/kits/hub-game/scripts/test-companion.mjs +259 -0
- package/kits/hub-game/scripts/test-decor-client.mjs +303 -0
- package/kits/hub-game/scripts/test-decor.mjs +457 -0
- package/kits/hub-game/scripts/test-earned-client.mjs +459 -0
- package/kits/hub-game/scripts/test-earned.mjs +1194 -0
- package/kits/hub-game/scripts/test-emote-bubble.mjs +110 -0
- package/kits/hub-game/scripts/test-friend-bests.mjs +435 -0
- package/kits/hub-game/scripts/test-grab-client.mjs +186 -3
- package/kits/hub-game/scripts/test-grab-orbit.mjs +918 -0
- package/kits/hub-game/scripts/test-grab.mjs +864 -3
- package/kits/hub-game/scripts/test-hats.mjs +483 -0
- package/kits/hub-game/scripts/test-hub-leaving.mjs +203 -0
- package/kits/hub-game/scripts/test-hub-ops.mjs +439 -2
- package/kits/hub-game/scripts/test-hub-trip.mjs +1228 -1
- package/kits/hub-game/scripts/test-hud-clear.mjs +1000 -0
- package/kits/hub-game/scripts/test-idle.mjs +361 -1
- package/kits/hub-game/scripts/test-interest-cap.mjs +36 -0
- package/kits/hub-game/scripts/test-interest-cells.mjs +493 -0
- package/kits/hub-game/scripts/test-interest-client.mjs +118 -0
- package/kits/hub-game/scripts/test-keys.mjs +46 -1
- package/kits/hub-game/scripts/test-labels.mjs +596 -0
- package/kits/hub-game/scripts/test-manifest.mjs +282 -0
- package/kits/hub-game/scripts/test-menu-client.mjs +480 -0
- package/kits/hub-game/scripts/test-menu.mjs +296 -0
- package/kits/hub-game/scripts/test-npcs.mjs +1718 -12
- package/kits/hub-game/scripts/test-object-entry.mjs +76 -0
- package/kits/hub-game/scripts/test-pack.mjs +7 -0
- package/kits/hub-game/scripts/test-party.mjs +22 -1
- package/kits/hub-game/scripts/test-picker.mjs +314 -0
- package/kits/hub-game/scripts/test-rehello.mjs +1039 -0
- package/kits/hub-game/scripts/test-relations-among.mjs +222 -0
- package/kits/hub-game/scripts/test-relations-refresh.mjs +188 -0
- package/kits/hub-game/scripts/test-say.mjs +59 -2
- package/kits/hub-game/scripts/test-shot.mjs +756 -0
- package/kits/hub-game/scripts/test-soundscape.mjs +5432 -0
- package/kits/hub-game/scripts/test-spin.mjs +314 -0
- package/kits/hub-game/scripts/test-standing.mjs +416 -0
- package/kits/hub-game/scripts/test-stuck.mjs +1903 -0
- package/kits/hub-game/scripts/test-tier-cells.mjs +706 -0
- package/kits/hub-game/scripts/test-tiers-render.mjs +339 -0
- package/kits/hub-game/scripts/test-tiers.mjs +666 -3
- package/kits/hub-game/scripts/test-toast-band.mjs +61 -0
- package/kits/hub-game/scripts/test-try-on.mjs +940 -0
- package/kits/hub-game/scripts/test-vis.mjs +343 -0
- package/kits/hub-game/scripts/test-visibility.mjs +134 -0
- package/kits/hub-game/scripts/test-yours-chrome.mjs +166 -0
- package/kits/hub-game/scripts/test-yours.mjs +372 -0
- package/kits/multiplayer-3d/CLAUDE.md +50 -0
- package/kits/multiplayer-3d/castle.json +5 -5
- package/kits/multiplayer-3d/code/client/avatars.js +7 -0
- package/kits/multiplayer-3d/code/client/gait.js +65 -0
- package/kits/multiplayer-3d/code/client/nameTags.js +59 -4
- package/kits/multiplayer-3d/code/options.js +5 -0
- package/kits/multiplayer-3d/code/server/ownership.js +10 -2
- package/kits/multiplayer-3d/code/server/sceneBodies.js +12 -0
- package/kits/multiplayer-3d/code/server/world.js +7 -0
- package/kits/multiplayer-3d/code/systems/multiplayer.js +74 -4
- package/kits/multiplayer-3d/package.json +2 -1
- package/kits/multiplayer-3d/scripts/fixtures/README.md +11 -0
- package/kits/multiplayer-3d/scripts/fixtures/ownership-legacy.json +2 -0
- package/kits/multiplayer-3d/scripts/ownership-harness.mjs +102 -0
- package/kits/multiplayer-3d/scripts/ownership-loader.mjs +46 -0
- package/kits/multiplayer-3d/scripts/ownership-worker.mjs +15 -0
- package/kits/multiplayer-3d/scripts/record-ownership-session.mjs +98 -0
- package/kits/multiplayer-3d/scripts/test-eligible-claims.mjs +167 -0
- package/kits/multiplayer-3d/scripts/test-own-name-tag.mjs +247 -0
- package/kits/physics-2d/CLAUDE.md +9 -0
- package/kits/physics-2d/castle.json +2 -2
- package/kits/physics-2d/engine/scene.js +288 -1
- package/kits/physics-2d/engine/skyKey.js +129 -0
- package/kits/physics-2d/engine/stillClock.js +106 -0
- package/kits/physics-2d/engine/updateBudget.js +21 -0
- package/kits/physics-2d/scripts/test-skip-unchanged.mjs +370 -1
- package/kits/physics-3d/CLAUDE.md +1391 -0
- package/kits/physics-3d/behaviors/Player.jsx +921 -3
- package/kits/physics-3d/castle.json +3 -3
- package/kits/physics-3d/docs/pxmodel-format.md +12 -0
- package/kits/physics-3d/engine3d/Scene3DPlayer.jsx +98 -10
- package/kits/physics-3d/engine3d/actornode.js +86 -0
- package/kits/physics-3d/engine3d/animationBudget.js +23 -0
- package/kits/physics-3d/engine3d/editorWorld.js +6 -0
- package/kits/physics-3d/engine3d/emptynodes.js +232 -0
- package/kits/physics-3d/engine3d/framecap.js +96 -0
- package/kits/physics-3d/engine3d/gait.js +118 -0
- package/kits/physics-3d/engine3d/kithooks.js +47 -0
- package/kits/physics-3d/engine3d/look.js +507 -48
- package/kits/physics-3d/engine3d/lookbake.js +208 -0
- package/kits/physics-3d/engine3d/materialpresets.js +2 -0
- package/kits/physics-3d/engine3d/motion.js +39 -10
- package/kits/physics-3d/engine3d/nearshadows.js +37 -19
- package/kits/physics-3d/engine3d/optimize.js +58 -5
- package/kits/physics-3d/engine3d/orbitinput.js +755 -0
- package/kits/physics-3d/engine3d/orbitlens.js +48 -0
- package/kits/physics-3d/engine3d/ownmodel.js +213 -0
- package/kits/physics-3d/engine3d/pxmodel.js +42 -11
- package/kits/physics-3d/engine3d/shadowfade.js +882 -0
- package/kits/physics-3d/engine3d/sky.js +547 -0
- package/kits/physics-3d/engine3d/skylife.js +306 -0
- package/kits/physics-3d/engine3d/unchanged.js +11 -0
- package/kits/physics-3d/engine3d/viewrange.js +52 -0
- package/kits/physics-3d/engine3d/world3d.js +870 -87
- package/kits/physics-3d/main.jsx +5 -0
- package/kits/physics-3d/package.json +1 -1
- package/kits/physics-3d/scripts/Player.before-orbit.mjs +310 -0
- package/kits/physics-3d/scripts/Scene3DPlayer.before-orbit.jsx +337 -0
- package/kits/physics-3d/scripts/look-baseline.mjs +155 -0
- package/kits/physics-3d/scripts/test-camera-follow.mjs +12 -2
- package/kits/physics-3d/scripts/test-camera-orbit.mjs +4588 -0
- package/kits/physics-3d/scripts/test-drop-empty-parts.mjs +787 -0
- package/kits/physics-3d/scripts/test-frame-cap-bob.mjs +435 -0
- package/kits/physics-3d/scripts/test-frame-cap.mjs +452 -0
- package/kits/physics-3d/scripts/test-gait.mjs +387 -0
- package/kits/physics-3d/scripts/test-look-bake.mjs +1056 -0
- package/kits/physics-3d/scripts/test-model-parse-cache.mjs +92 -0
- package/kits/physics-3d/scripts/test-near-shadows.mjs +3 -0
- package/kits/physics-3d/scripts/test-orbit-shadow-fade.mjs +1920 -0
- package/kits/physics-3d/scripts/test-orbit-shift-lock.mjs +545 -0
- package/kits/physics-3d/scripts/test-orbit-shot.mjs +583 -0
- package/kits/physics-3d/scripts/test-orbit-view.mjs +230 -0
- package/kits/physics-3d/scripts/test-skip-empty-nodes.mjs +845 -0
- package/kits/physics-3d/scripts/test-sky.mjs +2470 -0
- package/kits/physics-3d/scripts/test-static-actors.mjs +13 -1
- package/kits/physics-3d/scripts/test-static-passes.mjs +1 -1
- package/kits/physics-3d/scripts/test-static-scenery.mjs +2171 -0
- package/kits/physics-3d/scripts/test-steady-hover.mjs +635 -0
- package/kits/physics-3d/scripts/test-view-range.mjs +260 -0
- package/kits/physics-3d/systems/physics3d.js +474 -12
- package/kits/real-time/castle.json +2 -2
- package/kits/real-time/code/server/gameHooks.js +7 -0
- package/kits/real-time/code/server/session.js +97 -19
- package/package.json +2 -2
- package/dist/shell/assets/index-Cf61cNfT.css +0 -1
|
@@ -7,10 +7,22 @@
|
|
|
7
7
|
// reports), the pointers to friends out of sight,
|
|
8
8
|
// the Grab / Throw button (a place with `grab`, v1.3), the emote picker and
|
|
9
9
|
// the Sit / Stand button (a place with `idle`, v1.6), an arcade cabinet's
|
|
10
|
-
// board card (v1.7), and
|
|
10
|
+
// board card (v1.7), the "Stuck?" chip and Doors row (a deck with `hub.stuck`,
|
|
11
|
+
// v1.33), the sound control (a deck with `hub.soundscape`), and the frame-rate
|
|
12
|
+
// readout behind `?hubstats`. In a place
|
|
13
|
+
// that asks (`hud.clear`, v1.26) the HUD is kept short and what is drawn over
|
|
14
|
+
// the world is kept out from under it (`hudClear.js`).
|
|
11
15
|
|
|
16
|
+
import * as Colors from './avatarColors.js';
|
|
17
|
+
import { AVATAR_FACES } from './avatarFaces.js';
|
|
12
18
|
import { cardMode, makeCardView, tapCard } from './cabinets.js';
|
|
13
|
-
import {
|
|
19
|
+
import { boxAt, fitPx, hudLayout, pushBelow } from './hudClear.js';
|
|
20
|
+
import { chipShift } from './stuck.js';
|
|
21
|
+
import { toastBand } from './toastBand.js';
|
|
22
|
+
import { emoteBubbleShift, placeEmoteBubble } from './emoteBubble.js';
|
|
23
|
+
import { guardScrollKeys, takeKeys } from './keys.js';
|
|
24
|
+
import { validPrivateText } from '../privateText.js';
|
|
25
|
+
import { menuIcon } from './menuIcons.js';
|
|
14
26
|
|
|
15
27
|
const Z = 2147480000;
|
|
16
28
|
|
|
@@ -21,8 +33,22 @@ function el(tag, style, parent = document.body) {
|
|
|
21
33
|
return node;
|
|
22
34
|
}
|
|
23
35
|
|
|
24
|
-
|
|
36
|
+
// White text drawn straight over the world (the HUD, the feed): an outline
|
|
37
|
+
// close around each letter as well as the soft drop shadow, so it reads over a
|
|
38
|
+
// pale sky as it does over a dark street.
|
|
39
|
+
const BARE_TEXT_SHADOW = '0 0 2px rgba(0,0,0,0.95), 0 0 2px rgba(0,0,0,0.95), 0 1px 4px rgba(0,0,0,0.75), 0 0 10px rgba(0,0,0,0.45)';
|
|
40
|
+
|
|
41
|
+
// The character picker's grid: four cells across, each a tap target this wide
|
|
42
|
+
// (and 62 px tall).
|
|
43
|
+
const PICKER_COLUMNS = 4;
|
|
44
|
+
const PICKER_CELL_PX = 64;
|
|
45
|
+
|
|
46
|
+
// The talk panel's log counts as at its end within this many pixels of it.
|
|
47
|
+
const TALK_END_PX = 8;
|
|
48
|
+
|
|
49
|
+
export function makeChrome({ onBack, onAvatar, onColor = () => {}, avatarCount, onPerson = () => {}, onJumpDoor = () => {}, onReport = () => {}, onAsk = () => {}, onHeart = () => {}, onLeaveParty = () => {}, onReportChat = () => {}, onChip }) {
|
|
25
50
|
const unguardKeys = guardScrollKeys();
|
|
51
|
+
takeKeys();
|
|
26
52
|
// A desktop stage (a mouse, room to spare): NPC lines are narrower and the
|
|
27
53
|
// talk panel sits in the bottom-left corner, clear of the avatar. Phones
|
|
28
54
|
// and narrow stages keep the layout they were tuned on.
|
|
@@ -35,6 +61,8 @@ export function makeChrome({ onBack, onAvatar, avatarCount, onPerson = () => {},
|
|
|
35
61
|
const cover = el('div', { position: 'absolute', inset: '0', opacity: '0', background: 'radial-gradient(ellipse at center, #2a1d14 0%, #0b0806 70%)', display: 'flex', alignItems: 'center', justifyContent: 'center', transition: 'none' }, root);
|
|
36
62
|
const coverText = el('div', { opacity: '0.85', letterSpacing: '0.12em', textTransform: 'uppercase', fontSize: '14px', color: '#e9c48f' }, cover);
|
|
37
63
|
|
|
64
|
+
let coverLine = null;
|
|
65
|
+
|
|
38
66
|
const back = el('button', { position: 'absolute', top: 'max(12px, env(safe-area-inset-top))', left: '12px', pointerEvents: 'auto', padding: '9px 16px 9px 12px', borderRadius: '22px', border: '1px solid rgba(255,255,255,0.35)', background: 'rgba(20,16,12,0.72)', color: '#fff', font: 'inherit', display: 'none', cursor: 'pointer' }, root);
|
|
39
67
|
back.textContent = '‹ Town';
|
|
40
68
|
back.addEventListener('pointerdown', (event) => {
|
|
@@ -42,13 +70,28 @@ export function makeChrome({ onBack, onAvatar, avatarCount, onPerson = () => {},
|
|
|
42
70
|
onBack();
|
|
43
71
|
});
|
|
44
72
|
|
|
45
|
-
const hud = el('div', { position: 'absolute', top: 'max(12px, env(safe-area-inset-top))', left: '50%', transform: 'translateX(-50%)', textAlign: 'center', textShadow:
|
|
73
|
+
const hud = el('div', { position: 'absolute', top: 'max(12px, env(safe-area-inset-top))', left: '50%', transform: 'translateX(-50%)', textAlign: 'center', textShadow: BARE_TEXT_SHADOW, display: 'none', maxWidth: '70vw' }, root);
|
|
46
74
|
const hudTitle = el('div', { fontSize: '13px', opacity: '0.85', letterSpacing: '0.06em', textTransform: 'uppercase' }, hud);
|
|
47
75
|
const hudBig = el('div', { fontSize: '56px', fontWeight: '800', lineHeight: '1.05' }, hud);
|
|
48
76
|
const hudText = el('div', { fontSize: '14px', fontWeight: '500' }, hud);
|
|
49
77
|
|
|
50
78
|
const labels = el('div', { position: 'absolute', inset: '0' }, root);
|
|
79
|
+
// v1.43 `measureLabel`: nothing until a deck that keeps its labels apart asks.
|
|
80
|
+
let labelMeasure = null;
|
|
81
|
+
const labelSizes = new Map();
|
|
82
|
+
// Pointers to friends out of sight (a town) and to a place's goals: a small
|
|
83
|
+
// chip over one far off, or at the screen's edge with an arrow when it is
|
|
84
|
+
// off screen. v1.34: made here, with the labels, so every panel, card and
|
|
85
|
+
// button made after them is drawn over a pointer (they were made after the
|
|
86
|
+
// talk panel, and a goal's arrow sat on the words of the NPC being read).
|
|
87
|
+
// v1.38: and put UNDER the labels, so an NPC's speech bubble is read over a
|
|
88
|
+
// chip (a goal's chip over an NPC cut through the words it was saying).
|
|
89
|
+
const pointers = el('div', { position: 'absolute', inset: '0' }, root);
|
|
90
|
+
root.insertBefore(pointers, labels);
|
|
91
|
+
const pointerNodes = new Map();
|
|
51
92
|
const labelNodes = new Map();
|
|
93
|
+
// An emote's emoji -> its drawn size `{ w, h }` (`setLabels`).
|
|
94
|
+
const emoteSizes = new Map();
|
|
52
95
|
|
|
53
96
|
// An arcade cabinet's card (v1.7). By the cabinet it is a chip: the best
|
|
54
97
|
// score and whose it is (their photo in a circle, their frame drawn over it
|
|
@@ -146,32 +189,128 @@ export function makeChrome({ onBack, onAvatar, avatarCount, onPerson = () => {},
|
|
|
146
189
|
|
|
147
190
|
const ribbon = el('div', { position: 'absolute', display: 'none', transform: 'translate(-50%, -100%)', padding: '4px 10px', borderRadius: '6px', background: 'linear-gradient(#f2c94c, #d69e2e)', color: '#3b2600', fontSize: '13px', fontWeight: '800', whiteSpace: 'nowrap', boxShadow: '0 2px 6px rgba(0,0,0,0.4)' }, root);
|
|
148
191
|
|
|
149
|
-
const toast = el('div', { position: 'absolute',
|
|
192
|
+
const toast = el('div', { position: 'absolute', top: 'max(12px, env(safe-area-inset-top))', left: '50%', transform: 'translateX(-50%)', width: 'max-content', maxWidth: 'calc(100vw - 24px)', boxSizing: 'border-box', textAlign: 'center', padding: '8px 14px', borderRadius: '8px', background: 'rgba(20,16,12,0.8)', fontSize: '14px', display: 'none' }, root);
|
|
193
|
+
toast.dataset.hub = 'toast';
|
|
194
|
+
// Where a phone's toast starts, read in pixels: the safe area's inset has
|
|
195
|
+
// no other way to be measured.
|
|
196
|
+
const toastStart = el('div', { position: 'absolute', top: 'max(12px, env(safe-area-inset-top))', left: '0', width: '0', height: '0', visibility: 'hidden' }, root);
|
|
197
|
+
let toastWrap = null;
|
|
150
198
|
|
|
151
199
|
// The avatar picker: one button, "Character", that opens the kit's
|
|
152
|
-
// characters under their own heading
|
|
200
|
+
// characters under their own heading: a grid, four across, each cell the
|
|
201
|
+
// character's face and name (`avatarFaces.js`, written with the models) and
|
|
202
|
+
// the one worn ringed in gold. The card never stands taller than the screen
|
|
203
|
+
// has room for over the button, and scrolls inside itself where it would;
|
|
204
|
+
// a phone on its side lays the grid eight across instead. A cell is picked
|
|
205
|
+
// on `click`, not on the press, so a finger that scrolls the card picks
|
|
206
|
+
// nothing.
|
|
207
|
+
const overPicker = [];
|
|
208
|
+
const shutRound = [];
|
|
153
209
|
const picker = el('div', { position: 'absolute', right: '10px', bottom: 'max(10px, env(safe-area-inset-bottom))', display: 'none', flexDirection: 'column', alignItems: 'flex-end', gap: '6px', pointerEvents: 'auto' }, root);
|
|
154
210
|
picker.addEventListener('pointerdown', (event) => event.stopPropagation());
|
|
155
|
-
const pickerCard = el('div', { display: 'none', flexDirection: 'column', gap: '6px', padding: '8px', borderRadius: '12px', background: 'rgba(20,16,12,0.88)', boxShadow: '0 4px 14px rgba(0,0,0,0.45)' }, picker);
|
|
211
|
+
const pickerCard = el('div', { display: 'none', flexDirection: 'column', gap: '6px', padding: '8px', borderRadius: '12px', background: 'rgba(20,16,12,0.88)', boxShadow: '0 4px 14px rgba(0,0,0,0.45)', boxSizing: 'border-box', maxWidth: 'calc(100vw - 20px)', overflowY: 'auto', overscrollBehavior: 'contain', touchAction: 'pan-y' }, picker);
|
|
212
|
+
// What is left over the button and its margins; `dvh` where the browser has
|
|
213
|
+
// it (a phone's toolbars), `vh` where it does not.
|
|
214
|
+
for (const unit of ['vh', 'dvh']) {
|
|
215
|
+
pickerCard.style.maxHeight = `calc(100${unit} - 76px - env(safe-area-inset-top) - env(safe-area-inset-bottom))`;
|
|
216
|
+
}
|
|
156
217
|
el('div', { fontSize: '12px', opacity: '0.8' }, pickerCard).textContent = 'Your character';
|
|
157
|
-
const pickerRow = el('div', { display: '
|
|
218
|
+
const pickerRow = el('div', { display: 'grid', gridTemplateColumns: `repeat(${PICKER_COLUMNS}, ${PICKER_CELL_PX}px)`, gap: '6px' }, pickerCard);
|
|
158
219
|
const pickerButtons = [];
|
|
159
220
|
let pickerOpen = false;
|
|
221
|
+
let pickerSelected = null;
|
|
160
222
|
const setPickerOpen = (open) => {
|
|
161
223
|
pickerOpen = open;
|
|
224
|
+
showCompanionBadge();
|
|
225
|
+
if (open) {
|
|
226
|
+
// A short, wide screen (a phone on its side) has room for two rows of eight.
|
|
227
|
+
const wide = window.innerHeight < 440 && window.innerWidth >= 8 * (PICKER_CELL_PX + 6) + 30;
|
|
228
|
+
pickerRow.style.gridTemplateColumns = `repeat(${wide ? PICKER_COLUMNS * 2 : PICKER_COLUMNS}, ${PICKER_CELL_PX}px)`;
|
|
229
|
+
}
|
|
230
|
+
// Open, the card lies under the round buttons up the right edge and the
|
|
231
|
+
// talk button along the bottom, which would take its taps; they are out
|
|
232
|
+
// of sight until it shuts, and what a round one had open shuts with it.
|
|
233
|
+
for (const button of overPicker) {
|
|
234
|
+
button.style.visibility = open ? 'hidden' : '';
|
|
235
|
+
}
|
|
236
|
+
if (open) {
|
|
237
|
+
for (const shut of shutRound) {
|
|
238
|
+
shut();
|
|
239
|
+
}
|
|
240
|
+
}
|
|
162
241
|
pickerCard.style.display = open ? 'flex' : 'none';
|
|
163
242
|
};
|
|
164
243
|
for (let i = 0; i < avatarCount; i += 1) {
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
button.
|
|
168
|
-
|
|
244
|
+
// A character this kit has no face for is a number, as all of them were.
|
|
245
|
+
const [name, face] = AVATAR_FACES[i] ?? [`Character ${i + 1}`, null];
|
|
246
|
+
const button = el('button', { width: `${PICKER_CELL_PX}px`, minHeight: '62px', boxSizing: 'border-box', padding: '4px 0 3px', borderRadius: '12px', border: '2px solid rgba(255,255,255,0.4)', background: 'rgba(20,16,12,0.7)', color: '#fff', font: '600 11px/1.2 system-ui, sans-serif', cursor: 'pointer', display: 'flex', flexDirection: 'column', alignItems: 'center', justifyContent: 'center', gap: '2px', touchAction: 'pan-y', overflow: 'hidden' }, pickerRow);
|
|
247
|
+
if (face) {
|
|
248
|
+
el('div', { width: '36px', height: '36px', flex: 'none', pointerEvents: 'none' }, button).innerHTML = `<svg viewBox="0 0 24 24" width="36" height="36" stroke="#241a2e" stroke-width="1.3" stroke-linejoin="round" stroke-linecap="round" aria-hidden="true">${face}</svg>`;
|
|
249
|
+
}
|
|
250
|
+
el('div', { maxWidth: '100%', overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap', pointerEvents: 'none', fontSize: face ? '11px' : '13px' }, button).textContent = face ? name : String(i + 1);
|
|
251
|
+
button.setAttribute('aria-label', face ? `Character: ${name}` : name);
|
|
252
|
+
button.setAttribute('aria-pressed', 'false');
|
|
253
|
+
button.addEventListener('click', (event) => {
|
|
169
254
|
event.stopPropagation();
|
|
170
255
|
setPickerOpen(false);
|
|
171
256
|
onAvatar(i);
|
|
172
257
|
});
|
|
173
258
|
pickerButtons.push(button);
|
|
174
259
|
}
|
|
260
|
+
let colorRow = null;
|
|
261
|
+
let colorKey = null;
|
|
262
|
+
const colorButtons = [];
|
|
263
|
+
function showColors(selected, { available = false, style = 'toon', color = 0, files = null, model = null } = {}) {
|
|
264
|
+
const palette = Colors.AVATAR_COLORS[selected];
|
|
265
|
+
if (!available || style !== 'toon' || !palette) {
|
|
266
|
+
if (colorRow) {
|
|
267
|
+
colorRow.style.display = 'none';
|
|
268
|
+
}
|
|
269
|
+
colorKey = null;
|
|
270
|
+
return;
|
|
271
|
+
}
|
|
272
|
+
const wornColor = Colors.known(selected, color);
|
|
273
|
+
const key = `${selected}:${wornColor}`;
|
|
274
|
+
if (colorKey === key) {
|
|
275
|
+
return;
|
|
276
|
+
}
|
|
277
|
+
// Dot zero is read from the model's named main part, never a face colour.
|
|
278
|
+
let original;
|
|
279
|
+
try {
|
|
280
|
+
const data = JSON.parse(files?.[model]);
|
|
281
|
+
original = data.parts?.find((part) => palette.main.includes(part.id))?.color;
|
|
282
|
+
} catch {
|
|
283
|
+
// A pack still loading has no original colour to show yet.
|
|
284
|
+
}
|
|
285
|
+
if (!original) {
|
|
286
|
+
if (colorRow) {
|
|
287
|
+
colorRow.style.display = 'none';
|
|
288
|
+
}
|
|
289
|
+
colorKey = null;
|
|
290
|
+
return;
|
|
291
|
+
}
|
|
292
|
+
if (!colorRow) {
|
|
293
|
+
colorRow = document.createElement('div');
|
|
294
|
+
Object.assign(colorRow.style, { display: 'flex', gap: '4px', justifyContent: 'center' });
|
|
295
|
+
pickerCard.insertBefore(colorRow, pickerRow.nextSibling ?? pickerCard.children[2] ?? null);
|
|
296
|
+
for (let c = 0; c < Colors.COLORS; c += 1) {
|
|
297
|
+
const button = el('button', { width: '44px', height: '44px', boxSizing: 'border-box', flex: 'none', padding: '6px', borderRadius: '50%', border: '2px solid transparent', cursor: 'pointer', touchAction: 'pan-y' }, colorRow);
|
|
298
|
+
button.setAttribute('aria-label', `Colour: ${c + 1}`);
|
|
299
|
+
button.addEventListener('click', (event) => {
|
|
300
|
+
event.stopPropagation();
|
|
301
|
+
onColor(c);
|
|
302
|
+
});
|
|
303
|
+
colorButtons.push(button);
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
colorRow.style.display = 'flex';
|
|
307
|
+
colorButtons.forEach((button, c) => {
|
|
308
|
+
button.style.background = c === 0 ? original : palette.colors[c - 1][0];
|
|
309
|
+
button.style.borderColor = c === wornColor ? '#f2c94c' : 'rgba(255,255,255,0.4)';
|
|
310
|
+
button.setAttribute('aria-pressed', String(c === wornColor));
|
|
311
|
+
});
|
|
312
|
+
colorKey = key;
|
|
313
|
+
}
|
|
175
314
|
const pickerToggle = el('button', { padding: '8px 14px', borderRadius: '18px', border: '1px solid rgba(255,255,255,0.4)', background: 'rgba(20,16,12,0.72)', color: '#fff', font: 'inherit', cursor: 'pointer' }, picker);
|
|
176
315
|
pickerToggle.textContent = 'Character';
|
|
177
316
|
// Graphics: Auto / Low / High, under the characters, in a deck that has
|
|
@@ -203,6 +342,7 @@ export function makeChrome({ onBack, onAvatar, avatarCount, onPerson = () => {},
|
|
|
203
342
|
// conversation is open. Keys typed here are the panel's, not the game's.
|
|
204
343
|
let talkHandlers = { open() {}, send() {}, end() {} };
|
|
205
344
|
const talkButton = el('button', { position: 'absolute', bottom: 'max(64px, calc(env(safe-area-inset-bottom) + 54px))', left: '50%', transform: 'translateX(-50%)', pointerEvents: 'auto', padding: '10px 18px', borderRadius: '22px', border: '1px solid rgba(255,255,255,0.45)', background: 'rgba(20,16,12,0.8)', color: '#fff', font: 'inherit', display: 'none', cursor: 'pointer' }, root);
|
|
345
|
+
overPicker.push(talkButton);
|
|
206
346
|
talkButton.addEventListener('pointerdown', (event) => {
|
|
207
347
|
event.stopPropagation();
|
|
208
348
|
talkHandlers.open();
|
|
@@ -217,14 +357,64 @@ export function makeChrome({ onBack, onAvatar, avatarCount, onPerson = () => {},
|
|
|
217
357
|
talkHandlers.end();
|
|
218
358
|
});
|
|
219
359
|
const panelLog = el('div', { maxHeight: '28vh', overflowY: 'auto', display: 'flex', flexDirection: 'column', gap: '4px', fontSize: '14px', fontWeight: '500' }, panel);
|
|
360
|
+
// v1.46: the mind is answering; reduced motion keeps a plain ellipsis.
|
|
361
|
+
const typingStyle = el('style', {}, root);
|
|
362
|
+
typingStyle.textContent = `
|
|
363
|
+
@keyframes hub-npc-dot { 0%, 80%, 100% { opacity: .35; } 40% { opacity: 1; } }
|
|
364
|
+
.hub-npc-typing span { animation: hub-npc-dot 1.2s infinite; }
|
|
365
|
+
.hub-npc-typing span:nth-child(2) { animation-delay: .2s; }
|
|
366
|
+
.hub-npc-typing span:nth-child(3) { animation-delay: .4s; }
|
|
367
|
+
@media (prefers-reduced-motion: reduce) {
|
|
368
|
+
.hub-npc-typing span { animation: none; display: none; }
|
|
369
|
+
.hub-npc-typing::after { content: '…'; }
|
|
370
|
+
}
|
|
371
|
+
`;
|
|
372
|
+
let panelTyping = null;
|
|
373
|
+
let panelMind = false;
|
|
374
|
+
let panelOpening = null;
|
|
375
|
+
const dropTyping = () => {
|
|
376
|
+
panelTyping?.remove();
|
|
377
|
+
panelTyping = null;
|
|
378
|
+
};
|
|
379
|
+
// The questions are made only while there are some to offer.
|
|
380
|
+
let panelAsks = null;
|
|
381
|
+
let asksHandler = null;
|
|
382
|
+
// The row is taken out again, not hidden: the panel of a conversation with
|
|
383
|
+
// no questions has the nodes it always had.
|
|
384
|
+
const dropAsks = () => {
|
|
385
|
+
panelAsks?.remove();
|
|
386
|
+
panelAsks = null;
|
|
387
|
+
asksHandler = null;
|
|
388
|
+
};
|
|
220
389
|
// Not a <form>: castle.xyz plays a deck in a frame sandboxed without
|
|
221
390
|
// `allow-forms`, where a form's submission (Enter, or a submit button) is
|
|
222
391
|
// blocked before its submit event fires, so nothing would ever be said.
|
|
223
392
|
const panelForm = el('div', { display: 'flex', gap: '6px', margin: '0' }, panel);
|
|
393
|
+
// Chat words, not an account: no autofill or saved suggestions (Chrome
|
|
394
|
+
// offered emails on a bare field).
|
|
395
|
+
const chatField = (input, name) => {
|
|
396
|
+
input.type = 'text';
|
|
397
|
+
input.name = name;
|
|
398
|
+
input.autocomplete = 'off';
|
|
399
|
+
input.inputMode = 'text';
|
|
400
|
+
input.setAttribute('autocapitalize', 'sentences');
|
|
401
|
+
input.spellcheck = true;
|
|
402
|
+
};
|
|
224
403
|
const panelInput = el('input', { flex: '1', minWidth: '0', padding: '8px 10px', borderRadius: '8px', border: '1px solid rgba(255,255,255,0.3)', background: 'rgba(255,255,255,0.1)', color: '#fff', font: '500 15px system-ui, sans-serif' }, panelForm);
|
|
404
|
+
chatField(panelInput, 'say');
|
|
225
405
|
panelInput.maxLength = 280;
|
|
226
406
|
panelInput.placeholder = 'Say something…';
|
|
227
407
|
panelInput.enterKeyHint = 'send';
|
|
408
|
+
const setTalkTyping = (allowed) => {
|
|
409
|
+
const wasHidden = panelForm.style.display === 'none';
|
|
410
|
+
panelForm.style.display = allowed ? 'flex' : 'none';
|
|
411
|
+
if (!allowed) {
|
|
412
|
+
panelInput.blur();
|
|
413
|
+
dropAsks();
|
|
414
|
+
} else if (wasHidden && globalThis.matchMedia?.('(pointer: fine)').matches && !(globalThis.navigator?.maxTouchPoints > 0)) {
|
|
415
|
+
panelInput.focus({ preventScroll: true });
|
|
416
|
+
}
|
|
417
|
+
};
|
|
228
418
|
const panelSend = el('button', { padding: '8px 14px', borderRadius: '8px', border: 'none', background: '#e9c48f', color: '#2b2118', font: '700 14px system-ui, sans-serif', cursor: 'pointer' }, panelForm);
|
|
229
419
|
panelSend.type = 'button';
|
|
230
420
|
panelSend.textContent = 'Say';
|
|
@@ -282,6 +472,7 @@ export function makeChrome({ onBack, onAvatar, avatarCount, onPerson = () => {},
|
|
|
282
472
|
let sitHandler = () => {};
|
|
283
473
|
const emoteBottom = 'max(146px, calc(env(safe-area-inset-bottom) + 136px))';
|
|
284
474
|
const emoteButton = el('button', { position: 'absolute', right: '20px', bottom: emoteBottom, width: '52px', height: '52px', borderRadius: '26px', pointerEvents: 'auto', border: '2px solid rgba(255,255,255,0.5)', background: 'rgba(20,16,12,0.78)', color: '#fff', font: '24px system-ui, sans-serif', display: 'none', cursor: 'pointer', touchAction: 'manipulation', userSelect: 'none', padding: '0' }, root);
|
|
475
|
+
overPicker.push(emoteButton);
|
|
285
476
|
emoteButton.textContent = '☺';
|
|
286
477
|
emoteButton.setAttribute('aria-label', 'Emote');
|
|
287
478
|
const emoteRow = el('div', { position: 'absolute', right: '80px', bottom: emoteBottom, display: 'none', gap: '6px', pointerEvents: 'auto', padding: '4px', borderRadius: '28px', background: 'rgba(20,16,12,0.78)' }, root);
|
|
@@ -290,8 +481,10 @@ export function makeChrome({ onBack, onAvatar, avatarCount, onPerson = () => {},
|
|
|
290
481
|
let emotesKey = '';
|
|
291
482
|
const setEmotesOpen = (open) => {
|
|
292
483
|
emotesOpen = open;
|
|
484
|
+
showCompanionBadge();
|
|
293
485
|
emoteRow.style.display = open ? 'flex' : 'none';
|
|
294
486
|
};
|
|
487
|
+
shutRound.push(() => setEmotesOpen(false));
|
|
295
488
|
emoteButton.addEventListener('pointerdown', (event) => {
|
|
296
489
|
event.stopPropagation();
|
|
297
490
|
event.preventDefault();
|
|
@@ -302,6 +495,7 @@ export function makeChrome({ onBack, onAvatar, avatarCount, onPerson = () => {},
|
|
|
302
495
|
// the feed of what was just said, small, above the dock.
|
|
303
496
|
let sayHandler = () => {};
|
|
304
497
|
const sayButton = el('button', { position: 'absolute', right: '20px', bottom: 'max(206px, calc(env(safe-area-inset-bottom) + 196px))', width: '52px', height: '52px', borderRadius: '26px', pointerEvents: 'auto', border: '2px solid rgba(255,255,255,0.5)', background: 'rgba(20,16,12,0.78)', color: '#fff', font: '22px system-ui, sans-serif', display: 'none', cursor: 'pointer', touchAction: 'manipulation', userSelect: 'none', padding: '0' }, root);
|
|
498
|
+
overPicker.push(sayButton);
|
|
305
499
|
sayButton.textContent = '💬';
|
|
306
500
|
sayButton.setAttribute('aria-label', 'Quick chat');
|
|
307
501
|
const sayCard = el('div', { position: 'absolute', right: '80px', bottom: 'max(146px, calc(env(safe-area-inset-bottom) + 136px))', width: 'min(70vw, 236px)', display: 'none', flexDirection: 'column', gap: '6px', pointerEvents: 'auto', padding: '8px', borderRadius: '14px', background: 'rgba(20,16,12,0.88)', boxShadow: '0 4px 14px rgba(0,0,0,0.45)' }, root);
|
|
@@ -312,15 +506,17 @@ export function makeChrome({ onBack, onAvatar, avatarCount, onPerson = () => {},
|
|
|
312
506
|
let sayNote = null;
|
|
313
507
|
const setSayOpen = (open) => {
|
|
314
508
|
sayOpen = open;
|
|
509
|
+
showCompanionBadge();
|
|
315
510
|
sayCard.style.display = open ? 'flex' : 'none';
|
|
316
511
|
};
|
|
512
|
+
shutRound.push(() => setSayOpen(false));
|
|
317
513
|
sayButton.addEventListener('pointerdown', (event) => {
|
|
318
514
|
event.stopPropagation();
|
|
319
515
|
event.preventDefault();
|
|
320
516
|
setSayOpen(!sayOpen);
|
|
321
517
|
setEmotesOpen(false);
|
|
322
518
|
});
|
|
323
|
-
const feed = el('div', { position: 'absolute', left: '10px', bottom: 'max(70px, calc(env(safe-area-inset-bottom) + 60px))', maxWidth: '62vw', display: 'flex', flexDirection: 'column', gap: '2px', font: '500 12px/1.3 system-ui, sans-serif', textShadow:
|
|
519
|
+
const feed = el('div', { position: 'absolute', left: '10px', bottom: 'max(70px, calc(env(safe-area-inset-bottom) + 60px))', maxWidth: '62vw', display: 'flex', flexDirection: 'column', gap: '2px', font: '500 12px/1.3 system-ui, sans-serif', textShadow: BARE_TEXT_SHADOW, opacity: '0.92' }, root);
|
|
324
520
|
let feedKey = '';
|
|
325
521
|
const sitButton = el('button', { position: 'absolute', bottom: 'max(112px, calc(env(safe-area-inset-bottom) + 102px))', left: '50%', transform: 'translateX(-50%)', pointerEvents: 'auto', padding: '10px 22px', borderRadius: '22px', border: '1px solid rgba(255,255,255,0.45)', background: 'rgba(20,16,12,0.8)', color: '#fff', font: 'inherit', display: 'none', cursor: 'pointer', touchAction: 'manipulation' }, root);
|
|
326
522
|
sitButton.addEventListener('pointerdown', (event) => {
|
|
@@ -344,13 +540,17 @@ export function makeChrome({ onBack, onAvatar, avatarCount, onPerson = () => {},
|
|
|
344
540
|
doorsList.addEventListener('pointerdown', (event) => event.stopPropagation());
|
|
345
541
|
let doorsOpen = false;
|
|
346
542
|
let doorsKey = '';
|
|
543
|
+
// The "Stuck?" row's press (v1.33); never called in a deck without it.
|
|
544
|
+
let stuckRowPick = () => {};
|
|
347
545
|
function closeDoors() {
|
|
348
546
|
doorsOpen = false;
|
|
547
|
+
showCompanionBadge();
|
|
349
548
|
doorsList.style.display = 'none';
|
|
350
549
|
}
|
|
351
550
|
doorsButton.addEventListener('pointerdown', (event) => {
|
|
352
551
|
event.stopPropagation();
|
|
353
552
|
doorsOpen = !doorsOpen;
|
|
553
|
+
showCompanionBadge();
|
|
354
554
|
aboveDock(doorsList);
|
|
355
555
|
doorsList.style.display = doorsOpen ? 'flex' : 'none';
|
|
356
556
|
closePeople();
|
|
@@ -365,15 +565,24 @@ export function makeChrome({ onBack, onAvatar, avatarCount, onPerson = () => {},
|
|
|
365
565
|
let peopleKey = '';
|
|
366
566
|
function closePeople() {
|
|
367
567
|
peopleOpen = false;
|
|
568
|
+
showCompanionBadge();
|
|
368
569
|
peopleList.style.display = 'none';
|
|
369
570
|
}
|
|
370
571
|
peopleButton.addEventListener('pointerdown', (event) => {
|
|
371
572
|
event.stopPropagation();
|
|
372
573
|
peopleOpen = !peopleOpen;
|
|
574
|
+
showCompanionBadge();
|
|
373
575
|
aboveDock(peopleList);
|
|
374
576
|
peopleList.style.display = peopleOpen ? 'flex' : 'none';
|
|
375
577
|
closeDoors();
|
|
376
578
|
});
|
|
579
|
+
let companionBadge = null;
|
|
580
|
+
function showCompanionBadge() {
|
|
581
|
+
if (companionBadge) {companionBadge.style.display = talkOpen || pickerOpen || peopleOpen || doorsOpen || sayOpen || emotesOpen ? 'none' : 'block';}
|
|
582
|
+
}
|
|
583
|
+
let lockLift = 0;
|
|
584
|
+
const cornerBottoms = new Map([picker, grabButton, emoteButton, emoteRow, sayButton, sayCard].map((node) => [node, node.style.bottom]));
|
|
585
|
+
|
|
377
586
|
const smallButton = (parent, text, primary) => {
|
|
378
587
|
const button = el('button', { padding: '5px 12px', borderRadius: '12px', border: primary ? 'none' : '1px solid rgba(255,255,255,0.35)', background: primary ? '#e9c48f' : 'transparent', color: primary ? '#2b2118' : '#fff', font: '700 13px system-ui, sans-serif', cursor: 'pointer' }, parent);
|
|
379
588
|
button.textContent = text;
|
|
@@ -450,17 +659,22 @@ export function makeChrome({ onBack, onAvatar, avatarCount, onPerson = () => {},
|
|
|
450
659
|
}
|
|
451
660
|
const peopleRows = new Map();
|
|
452
661
|
|
|
453
|
-
// Pointers to friends out of sight (a town): a small chip over a friend far
|
|
454
|
-
// off, or at the screen's edge with an arrow when they are off screen.
|
|
455
|
-
const pointers = el('div', { position: 'absolute', inset: '0' }, root);
|
|
456
|
-
const pointerNodes = new Map();
|
|
457
|
-
|
|
458
662
|
// A question put to the player (v1.10): an invitation to a party, a door
|
|
459
663
|
// their party wants to go through. One at a time, under the HUD.
|
|
460
664
|
const askCard = el('div', { position: 'absolute', top: 'max(92px, calc(env(safe-area-inset-top) + 80px))', left: '50%', transform: 'translateX(-50%)', width: 'min(86vw, 320px)', boxSizing: 'border-box', pointerEvents: 'auto', display: 'none', alignItems: 'center', gap: '8px', padding: '8px 10px', borderRadius: '12px', background: 'rgba(20,16,12,0.9)', boxShadow: '0 4px 14px rgba(0,0,0,0.45)', fontSize: '14px' }, root);
|
|
461
665
|
askCard.addEventListener('pointerdown', (event) => event.stopPropagation());
|
|
462
666
|
let askKey = '';
|
|
463
667
|
let askNow = null;
|
|
668
|
+
function heartButton(parent, door, hearted) {
|
|
669
|
+
const button = smallButton(parent, hearted ? '♥' : '♡', false);
|
|
670
|
+
button.style.flex = 'none';
|
|
671
|
+
button.setAttribute('aria-label', hearted ? 'Remove heart' : 'Heart this game');
|
|
672
|
+
button.setAttribute('aria-pressed', String(hearted));
|
|
673
|
+
button.addEventListener('pointerdown', (event) => {
|
|
674
|
+
event.stopPropagation();
|
|
675
|
+
onHeart(door);
|
|
676
|
+
});
|
|
677
|
+
}
|
|
464
678
|
// Standing by someone who is not in the player's party: invite them.
|
|
465
679
|
let nearHandler = () => {};
|
|
466
680
|
const nearButton = el('button', { position: 'absolute', bottom: 'max(160px, calc(env(safe-area-inset-bottom) + 150px))', left: '50%', transform: 'translateX(-50%)', pointerEvents: 'auto', padding: '6px 14px', borderRadius: '16px', border: '1px solid rgba(255,255,255,0.4)', background: 'rgba(20,16,12,0.78)', color: '#fff', font: '600 13px system-ui, sans-serif', display: 'none', cursor: 'pointer', touchAction: 'manipulation', maxWidth: '80vw', overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap' }, root);
|
|
@@ -470,10 +684,515 @@ export function makeChrome({ onBack, onAvatar, avatarCount, onPerson = () => {},
|
|
|
470
684
|
nearHandler();
|
|
471
685
|
});
|
|
472
686
|
|
|
687
|
+
// "Stuck?" (v1.33, `stuck.js`): a chip at the bottom centre, over the invite
|
|
688
|
+
// button's row, between the dock on the left and the round buttons on the
|
|
689
|
+
// right (never wider than leaves them clear: its words wrap). That is where
|
|
690
|
+
// it hangs; where it is drawn is `placeStuckChip`'s. Built on the first
|
|
691
|
+
// `stuckPrompt` with words, so a deck without `hub.stuck` has no node of it.
|
|
692
|
+
let stuckChip = null;
|
|
693
|
+
let stuckHandler = () => {};
|
|
694
|
+
let stuckShift = 'translateX(-50%)';
|
|
695
|
+
// Where the chip hangs while it is asked for (null otherwise): the room a
|
|
696
|
+
// toast leaves it, whether or not it could be drawn this frame.
|
|
697
|
+
let stuckSpot = null;
|
|
698
|
+
const shownRect = (node) => {
|
|
699
|
+
if (!node || node.style.display === 'none') {
|
|
700
|
+
return null;
|
|
701
|
+
}
|
|
702
|
+
const r = node.getBoundingClientRect();
|
|
703
|
+
return r.width > 0 && r.height > 0 ? { left: r.left, right: r.right, top: r.top, bottom: r.bottom } : null;
|
|
704
|
+
};
|
|
705
|
+
// Measured only while a toast is up, on every setToast (said each frame, so
|
|
706
|
+
// a resize or a turned stage is met by the next one) and again after the
|
|
707
|
+
// chip is asked for. Everything a player taps is in its way, wherever it
|
|
708
|
+
// hangs (`toastBand`); the chip by the spot it is asked for at
|
|
709
|
+
// (`stuckSpot`), drawn this frame or not, so the two never chase each
|
|
710
|
+
// other's last box. The boxes are read before either inset is written,
|
|
711
|
+
// and a phone's toast starts under the safe area (`toastStart`).
|
|
712
|
+
function placeToast() {
|
|
713
|
+
if (toast.style.display === 'none') {
|
|
714
|
+
return;
|
|
715
|
+
}
|
|
716
|
+
const wide = desktop();
|
|
717
|
+
const width = toast.offsetWidth;
|
|
718
|
+
const height = toast.offsetHeight;
|
|
719
|
+
const rects = [hud, askCard, back, sound?.button, sound?.card, stats, talkButton, sitButton, nearButton, panel, dock, doorsList, peopleList, picker, grabButton, emoteButton, emoteRow, sayButton, sayCard].map(shownRect).filter(Boolean);
|
|
720
|
+
if (stuckSpot) {
|
|
721
|
+
rects.push(stuckSpot);
|
|
722
|
+
}
|
|
723
|
+
const band = toastBand({ desktop: wide, viewW: window.innerWidth, viewH: window.innerHeight, width, height, rects, start: Math.max(12, toastStart.offsetTop || 0) });
|
|
724
|
+
const nextTop = wide ? '' : `${band.top}px`;
|
|
725
|
+
const nextBottom = wide ? `${band.bottom}px` : '';
|
|
726
|
+
if (toast.style.top !== nextTop) {
|
|
727
|
+
toast.style.top = nextTop;
|
|
728
|
+
}
|
|
729
|
+
if (toast.style.bottom !== nextBottom) {
|
|
730
|
+
toast.style.bottom = nextBottom;
|
|
731
|
+
}
|
|
732
|
+
}
|
|
733
|
+
// The chip is kept out from under the HUD and a question the way a clear
|
|
734
|
+
// HUD keeps labels out from under itself (`hudClear.js`): moved to just
|
|
735
|
+
// under them, never off the view -- in any place, not only one that asks
|
|
736
|
+
// for `hud.clear`, since on a short view (a phone on its side) where it
|
|
737
|
+
// hangs is where they are. Where that leaves it over another control, or
|
|
738
|
+
// no room at all, it is not drawn (`chipShift`): the Doors row is still
|
|
739
|
+
// there. The toast reserves room for an asked-for chip on desktop; the
|
|
740
|
+
// chip otherwise yields to what a player taps or reads as a card. A
|
|
741
|
+
// cabinet's card and the ribbon are read where a clear HUD's flush left them, so this runs after
|
|
742
|
+
// `flushHudClear` in a frame. What is hung on the world -- labels, speech,
|
|
743
|
+
// pointers -- is not in its way: it passes under the chip as under every
|
|
744
|
+
// other button (their layers are made before it, so it is drawn over them),
|
|
745
|
+
// and a bubble drifting across never takes the chip down. Everything is
|
|
746
|
+
// read first, then the one style is written. Only while the chip is asked
|
|
747
|
+
// for; false when it cannot be drawn.
|
|
748
|
+
function placeStuckChip() {
|
|
749
|
+
const w = stuckChip.offsetWidth;
|
|
750
|
+
const h = stuckChip.offsetHeight;
|
|
751
|
+
const left = stuckChip.offsetLeft - w / 2;
|
|
752
|
+
const top = stuckChip.offsetTop;
|
|
753
|
+
const above = [hud, askCard].map(shownRect).filter(Boolean);
|
|
754
|
+
const others = [back, toast, picker, talkButton, grabButton, emoteButton, emoteRow, sayButton, sayCard, feed, sitButton, dock, nearButton, stats, cabinet, ribbon, sound?.button, sound?.card].map(shownRect).filter(Boolean);
|
|
755
|
+
const down = chipShift({ left, right: left + w, top, bottom: top + h }, above, others, window.innerHeight);
|
|
756
|
+
if (down === null) {
|
|
757
|
+
return false;
|
|
758
|
+
}
|
|
759
|
+
const shift = down > 0 ? `translate(-50%, ${down}px)` : 'translateX(-50%)';
|
|
760
|
+
if (shift !== stuckShift) {
|
|
761
|
+
stuckShift = shift;
|
|
762
|
+
stuckChip.style.transform = shift;
|
|
763
|
+
}
|
|
764
|
+
return true;
|
|
765
|
+
}
|
|
766
|
+
function buildStuckChip() {
|
|
767
|
+
const chip = el('button', { position: 'absolute', bottom: 'max(202px, calc(env(safe-area-inset-bottom) + 192px))', left: '50%', transform: 'translateX(-50%)', pointerEvents: 'auto', padding: '9px 12px', borderRadius: '18px', border: '1px solid rgba(255,255,255,0.45)', background: 'rgba(20,16,12,0.8)', color: '#fff', font: '600 12px system-ui, sans-serif', display: 'none', cursor: 'pointer', touchAction: 'manipulation', boxSizing: 'border-box', width: 'max-content', maxWidth: 'calc(100vw - 170px)', textAlign: 'center' }, root);
|
|
768
|
+
chip.dataset.hub = 'stuck';
|
|
769
|
+
chip.addEventListener('pointerdown', (event) => {
|
|
770
|
+
event.stopPropagation();
|
|
771
|
+
event.preventDefault();
|
|
772
|
+
stuckHandler();
|
|
773
|
+
});
|
|
774
|
+
return chip;
|
|
775
|
+
}
|
|
776
|
+
|
|
777
|
+
// The sound control (a deck with `hub.soundscape`, `soundscape.js`): a small
|
|
778
|
+
// speaker button in the top right corner, clear of the HUD's 70vw and of
|
|
779
|
+
// the column of round buttons at the bottom right; a tap opens a card under
|
|
780
|
+
// it with Mute and a volume slider. Built on the first `soundControl`, so a
|
|
781
|
+
// deck without the key has no node of it.
|
|
782
|
+
let sound = null;
|
|
783
|
+
function buildSound() {
|
|
784
|
+
const top = 'max(12px, env(safe-area-inset-top))';
|
|
785
|
+
const button = el('button', { position: 'absolute', top, right: '12px', width: '40px', height: '40px', borderRadius: '20px', pointerEvents: 'auto', border: '1px solid rgba(255,255,255,0.4)', background: 'rgba(20,16,12,0.72)', color: '#fff', font: '18px system-ui, sans-serif', display: 'none', cursor: 'pointer', touchAction: 'manipulation', userSelect: 'none', padding: '0' }, root);
|
|
786
|
+
button.dataset.hub = 'sound';
|
|
787
|
+
const card = el('div', { position: 'absolute', top: `calc(${top} + 46px)`, right: '12px', width: 'min(70vw, 208px)', boxSizing: 'border-box', display: 'none', alignItems: 'center', gap: '8px', pointerEvents: 'auto', padding: '8px 10px', borderRadius: '12px', background: 'rgba(20,16,12,0.88)', boxShadow: '0 4px 14px rgba(0,0,0,0.45)' }, root);
|
|
788
|
+
card.dataset.hub = 'sound-card';
|
|
789
|
+
card.addEventListener('pointerdown', (event) => event.stopPropagation());
|
|
790
|
+
const mute = el('button', { flex: 'none', padding: '5px 10px', borderRadius: '12px', border: '1px solid rgba(255,255,255,0.35)', background: 'transparent', color: '#fff', font: '700 13px system-ui, sans-serif', cursor: 'pointer', touchAction: 'manipulation' }, card);
|
|
791
|
+
const slider = el('input', { flex: '1', minWidth: '0', height: '28px', margin: '0', accentColor: '#e9c48f', cursor: 'pointer' }, card);
|
|
792
|
+
slider.type = 'range';
|
|
793
|
+
slider.min = '0';
|
|
794
|
+
slider.max = '100';
|
|
795
|
+
slider.step = '1';
|
|
796
|
+
slider.setAttribute('aria-label', 'Volume');
|
|
797
|
+
const made = { button, card, mute, slider, open: false, key: '', handlers: { onVolume() {}, onMuted() {} }, muted: false };
|
|
798
|
+
button.addEventListener('pointerdown', (event) => {
|
|
799
|
+
event.stopPropagation();
|
|
800
|
+
event.preventDefault();
|
|
801
|
+
made.open = !made.open;
|
|
802
|
+
card.style.display = made.open ? 'flex' : 'none';
|
|
803
|
+
});
|
|
804
|
+
mute.addEventListener('pointerdown', (event) => {
|
|
805
|
+
event.stopPropagation();
|
|
806
|
+
event.preventDefault();
|
|
807
|
+
made.handlers.onMuted(!made.muted);
|
|
808
|
+
});
|
|
809
|
+
slider.addEventListener('input', () => made.handlers.onVolume(Number(slider.value) / 100));
|
|
810
|
+
// The arrow keys are the avatar's again once the slider is let go.
|
|
811
|
+
slider.addEventListener('change', () => slider.blur?.());
|
|
812
|
+
return made;
|
|
813
|
+
}
|
|
814
|
+
|
|
473
815
|
const stats = el('div', { position: 'absolute', right: '8px', top: 'max(8px, env(safe-area-inset-top))', font: '11px/1.3 ui-monospace, monospace', opacity: '0.7', textAlign: 'right', whiteSpace: 'pre' }, root);
|
|
474
816
|
|
|
817
|
+
// A clear HUD (v1.26, `hudClear.js`), in a place whose manifest asks for it
|
|
818
|
+
// (`setHudClear`). Everything below runs only then, or once as the option
|
|
819
|
+
// goes to put the HUD back as it always was: a place that never asks is
|
|
820
|
+
// drawn by the code above and below with none of this in its way.
|
|
821
|
+
let hudClear = false;
|
|
822
|
+
let hudClearDrawn = false;
|
|
823
|
+
let hudClearKey = '';
|
|
824
|
+
let hudClearRect = null;
|
|
825
|
+
const hudClearSizes = new WeakMap();
|
|
826
|
+
// The place before asked and this one does not: the styles of old, put
|
|
827
|
+
// back the moment the option goes, whether or not a HUD is drawn after.
|
|
828
|
+
function restoreHudClear() {
|
|
829
|
+
hudBig.style.fontSize = '56px';
|
|
830
|
+
for (const key of ['whiteSpace', 'overflow', 'textOverflow', 'maxWidth', 'marginLeft', 'marginRight']) {
|
|
831
|
+
hudBig.style[key] = '';
|
|
832
|
+
}
|
|
833
|
+
for (const key of ['display', 'overflow', 'webkitLineClamp', 'webkitBoxOrient']) {
|
|
834
|
+
hudText.style[key] = '';
|
|
835
|
+
}
|
|
836
|
+
hud.style.maxHeight = '';
|
|
837
|
+
hud.style.overflow = '';
|
|
838
|
+
hudClearDrawn = false;
|
|
839
|
+
hudClearKey = '';
|
|
840
|
+
hudClearRect = null;
|
|
841
|
+
hudClearPending.clear();
|
|
842
|
+
}
|
|
843
|
+
function layoutHudClear(big, text) {
|
|
844
|
+
hudClearDrawn = true;
|
|
845
|
+
const backShown = back.style.display !== 'none';
|
|
846
|
+
const key = [hudTitle.textContent, big, text, window.innerWidth, window.innerHeight, backShown ? back.textContent : ''].join('\u0001');
|
|
847
|
+
if (key === hudClearKey) {
|
|
848
|
+
return;
|
|
849
|
+
}
|
|
850
|
+
hudClearKey = key;
|
|
851
|
+
const layout = hudLayout({
|
|
852
|
+
big,
|
|
853
|
+
text,
|
|
854
|
+
viewW: window.innerWidth,
|
|
855
|
+
viewH: window.innerHeight,
|
|
856
|
+
// The big line's row is the Back button's: it keeps out of its way.
|
|
857
|
+
reserve: backShown ? back.offsetLeft + back.offsetWidth + 8 : 0,
|
|
858
|
+
});
|
|
859
|
+
hudBig.style.fontSize = `${layout.bigPx}px`;
|
|
860
|
+
hudBig.style.whiteSpace = layout.bigOneLine ? 'nowrap' : '';
|
|
861
|
+
hudBig.style.overflow = layout.bigOneLine ? 'hidden' : '';
|
|
862
|
+
hudBig.style.textOverflow = layout.bigOneLine ? 'ellipsis' : '';
|
|
863
|
+
hudBig.style.maxWidth = layout.bigMaxWidth === null ? '' : `${layout.bigMaxWidth}px`;
|
|
864
|
+
hudBig.style.marginLeft = layout.bigMaxWidth === null ? '' : 'auto';
|
|
865
|
+
hudBig.style.marginRight = layout.bigMaxWidth === null ? '' : 'auto';
|
|
866
|
+
hudText.style.display = layout.textLines === null ? '' : '-webkit-box';
|
|
867
|
+
hudText.style.overflow = layout.textLines === null ? '' : 'hidden';
|
|
868
|
+
hudText.style.webkitLineClamp = layout.textLines === null ? '' : String(layout.textLines);
|
|
869
|
+
hudText.style.webkitBoxOrient = layout.textLines === null ? '' : 'vertical';
|
|
870
|
+
hud.style.maxHeight = layout.maxHeight === null ? '' : `${layout.maxHeight}px`;
|
|
871
|
+
hud.style.overflow = layout.maxHeight === null ? '' : 'hidden';
|
|
872
|
+
if (layout.bigOneLine) {
|
|
873
|
+
// The estimate fell short of this face: shrink to what was drawn.
|
|
874
|
+
const px = fitPx(layout.bigPx, hudBig.clientWidth, hudBig.scrollWidth);
|
|
875
|
+
if (px !== layout.bigPx) {
|
|
876
|
+
hudBig.style.fontSize = `${px}px`;
|
|
877
|
+
}
|
|
878
|
+
}
|
|
879
|
+
// The box as it is drawn now; it changes only with what the key holds.
|
|
880
|
+
const r = hud.getBoundingClientRect();
|
|
881
|
+
hudClearRect = r.width > 0 && r.height > 0 ? { left: r.left, right: r.right, top: r.top, bottom: r.bottom } : null;
|
|
882
|
+
}
|
|
883
|
+
// What a frame's setters ask to be kept clear of the HUD, by group
|
|
884
|
+
// ("labels", "pointers", "cabinet", "ribbon"): each entry is [node, x, y,
|
|
885
|
+
// anchor, text] -- `node`, hung from (x, y) by `anchor` (`boxAt`), is moved
|
|
886
|
+
// to just under the HUD's box when it would lie over it, never past the
|
|
887
|
+
// bottom of the view. Nothing is measured or moved as it is asked: the
|
|
888
|
+
// whole frame is flushed once (`flushHudClear`, said by the hub system when
|
|
889
|
+
// it has drawn everything), every size that must be measured read first and
|
|
890
|
+
// only then anything moved. A write between two reads would have the
|
|
891
|
+
// browser lay the page out again for each, and a crowd of bubbles drifting
|
|
892
|
+
// sideways is measured every frame. A setter called with no flush after it
|
|
893
|
+
// is still flushed, before the browser paints (a microtask).
|
|
894
|
+
const hudClearPending = new Map();
|
|
895
|
+
let hudClearQueued = false;
|
|
896
|
+
function keepClearOfHud(group, entries) {
|
|
897
|
+
hudClearPending.set(group, entries);
|
|
898
|
+
if (!hudClearQueued) {
|
|
899
|
+
hudClearQueued = true;
|
|
900
|
+
(globalThis.queueMicrotask ?? ((fn) => Promise.resolve().then(fn)))(() => {
|
|
901
|
+
hudClearQueued = false;
|
|
902
|
+
flushHudClear();
|
|
903
|
+
});
|
|
904
|
+
}
|
|
905
|
+
}
|
|
906
|
+
function flushHudClear() {
|
|
907
|
+
if (!hudClearPending.size) {
|
|
908
|
+
return;
|
|
909
|
+
}
|
|
910
|
+
const groups = [...hudClearPending.values()];
|
|
911
|
+
hudClearPending.clear();
|
|
912
|
+
const rect = hudClear && hud.style.display !== 'none' ? hudClearRect : null;
|
|
913
|
+
if (!rect) {
|
|
914
|
+
return;
|
|
915
|
+
}
|
|
916
|
+
const moves = [];
|
|
917
|
+
for (const entries of groups) {
|
|
918
|
+
for (const [node, x, y, anchor, text] of entries) {
|
|
919
|
+
// One since hidden or taken away is left alone.
|
|
920
|
+
if (!node || node.style.display === 'none' || !Number.isFinite(x) || !Number.isFinite(y)) {
|
|
921
|
+
continue;
|
|
922
|
+
}
|
|
923
|
+
// Its size is measured once for each `text` it shows -- and, for a
|
|
924
|
+
// bubble that wraps by the room to its right (speech with no width
|
|
925
|
+
// of its own), again whenever it moves sideways.
|
|
926
|
+
const wraps = node.style.whiteSpace === 'normal' && node.style.width !== 'max-content';
|
|
927
|
+
const key = [text, node.style.fontSize, node.style.maxWidth, node.style.padding, window.innerWidth, wraps ? node.style.left : ''].join('\u0001');
|
|
928
|
+
let box = hudClearSizes.get(node);
|
|
929
|
+
if (!box || box.key !== key) {
|
|
930
|
+
box = { key, w: node.offsetWidth, h: node.offsetHeight };
|
|
931
|
+
hudClearSizes.set(node, box);
|
|
932
|
+
}
|
|
933
|
+
const down = pushBelow(boxAt(x, y, box.w, box.h, anchor), rect, undefined, window.innerHeight);
|
|
934
|
+
if (down > 0) {
|
|
935
|
+
moves.push([node, y + down]);
|
|
936
|
+
}
|
|
937
|
+
}
|
|
938
|
+
}
|
|
939
|
+
for (const [node, top] of moves) {
|
|
940
|
+
node.style.top = `${top}px`;
|
|
941
|
+
}
|
|
942
|
+
}
|
|
943
|
+
|
|
944
|
+
// v1.74: made only when an opted-in place offers chips.
|
|
945
|
+
let actionChips = null, actionKey = '', actionHandler = null, actionListeners = null;
|
|
946
|
+
function clearActions() {
|
|
947
|
+
actionListeners?.abort();
|
|
948
|
+
actionChips?.remove();
|
|
949
|
+
actionChips = actionListeners = actionHandler = null;
|
|
950
|
+
actionKey = '';
|
|
951
|
+
}
|
|
952
|
+
|
|
953
|
+
// v1.75: only allocated for an opted-in prompt. The field is the only
|
|
954
|
+
// DOM node that ever holds an answer, and it is wiped on every close.
|
|
955
|
+
let textAsk = null;
|
|
956
|
+
function closeTextAsk() {
|
|
957
|
+
if (!textAsk?.card) {
|
|
958
|
+
return;
|
|
959
|
+
}
|
|
960
|
+
textAsk.listeners.abort();
|
|
961
|
+
textAsk.input.value = '';
|
|
962
|
+
textAsk.input.blur();
|
|
963
|
+
textAsk.shield.remove();
|
|
964
|
+
textAsk.card = textAsk.shield = textAsk.input = textAsk.listeners = null;
|
|
965
|
+
textAsk.onOpen?.(false);
|
|
966
|
+
textAsk.onOpen = textAsk.cancel = null;
|
|
967
|
+
}
|
|
968
|
+
function clearTextAsk() {
|
|
969
|
+
closeTextAsk();
|
|
970
|
+
textAsk = null;
|
|
971
|
+
}
|
|
972
|
+
|
|
973
|
+
// v1.79: only an opted-in offer creates this bottom sheet or its CSS.
|
|
974
|
+
let placeMenu = null;
|
|
975
|
+
function closeMenu() {
|
|
976
|
+
if (!placeMenu?.sheet) {return;}
|
|
977
|
+
placeMenu.listeners.abort();
|
|
978
|
+
for (const timer of placeMenu.timers) { clearTimeout(timer); }
|
|
979
|
+
placeMenu.sheet.remove();
|
|
980
|
+
placeMenu.css.remove();
|
|
981
|
+
placeMenu.sheet = placeMenu.css = placeMenu.listeners = null;
|
|
982
|
+
placeMenu.onOpen?.(false);
|
|
983
|
+
placeMenu.onOpen = placeMenu.cancel = null;
|
|
984
|
+
}
|
|
985
|
+
function clearMenu() {
|
|
986
|
+
closeMenu();
|
|
987
|
+
placeMenu = null;
|
|
988
|
+
}
|
|
989
|
+
function setMenu(offer, handler, onOpen) {
|
|
990
|
+
if (!offer) { closeMenu(); return; }
|
|
991
|
+
if (placeMenu && offer.n <= placeMenu.n) {return;}
|
|
992
|
+
closeMenu();
|
|
993
|
+
placeMenu = { n: offer.n };
|
|
994
|
+
const spec = offer.spec;
|
|
995
|
+
if (!spec) {return;}
|
|
996
|
+
if (Object.hasOwn(spec, 'face')) {placeMenu.face = spec.face;}
|
|
997
|
+
const height = Object.hasOwn(spec, 'face') ? 40 : 55;
|
|
998
|
+
const listeners = new AbortController(), signal = listeners.signal, timers = new Set();
|
|
999
|
+
// The same column, padding, corners and shadow as the Doors/chat panels.
|
|
1000
|
+
// Token fallbacks use their existing palette when no tokens are installed.
|
|
1001
|
+
const sheet = el('div', { position: 'absolute', left: '50%', bottom: '0', transform: 'translateX(-50%)', width: 'min(100%, 720px)', maxHeight: `${height}vh`, boxSizing: 'border-box', overflow: 'hidden', pointerEvents: 'auto', display: 'flex', flexDirection: 'column', gap: '6px', padding: '12px', paddingBottom: 'max(12px, env(safe-area-inset-bottom))', borderRadius: '12px 12px 0 0', background: 'var(--castle-surface-3, rgba(20,16,12,0.88))', color: 'var(--castle-text-primary, #fff)', boxShadow: '0 4px 14px rgba(0,0,0,0.45)', zIndex: '9' }, root);
|
|
1002
|
+
sheet.className = 'hub-menu-sheet';
|
|
1003
|
+
sheet.dataset.hub = 'menu';
|
|
1004
|
+
sheet.setAttribute('role', 'dialog');
|
|
1005
|
+
sheet.setAttribute('aria-label', spec.title);
|
|
1006
|
+
const css = el('style', {}, sheet);
|
|
1007
|
+
css.textContent = `
|
|
1008
|
+
.hub-menu-tile { color: inherit; font: inherit; border: 1px solid var(--castle-border-2, rgba(255,255,255,.4)); background: var(--castle-surface-4, rgba(255,255,255,.1)); border-radius: 8px; }
|
|
1009
|
+
.hub-menu-tile:not(:disabled) { cursor: pointer; }
|
|
1010
|
+
.hub-menu-tile:not(:disabled):active, .hub-menu-tile.is-pressed { background: var(--castle-surface-5, rgba(255,255,255,.18)); transform: scale(.96); }
|
|
1011
|
+
@media (hover: hover) { .hub-menu-tile:not(:disabled):hover { border-color: var(--castle-text-primary, #fff); } }
|
|
1012
|
+
@media (prefers-reduced-motion: reduce) { .hub-menu-tile:not(:disabled):active, .hub-menu-tile.is-pressed { transform: none; } }
|
|
1013
|
+
@media (max-width: 600px) { .hub-menu-grid { grid-template-columns: repeat(4, minmax(64px, 1fr)) !important; } }
|
|
1014
|
+
@media (max-width: 340px) { .hub-menu-grid { grid-template-columns: repeat(3, minmax(64px, 1fr)) !important; } }
|
|
1015
|
+
@supports (height: 1dvh) { .hub-menu-sheet { max-height: ${height}dvh !important; } }
|
|
1016
|
+
`;
|
|
1017
|
+
for (const type of ['pointerdown', 'pointermove', 'pointerup', 'mousedown', 'wheel', 'contextmenu', 'keydown', 'keyup']) {
|
|
1018
|
+
sheet.addEventListener(type, (event) => event.stopPropagation(), { signal });
|
|
1019
|
+
}
|
|
1020
|
+
const cancel = () => {
|
|
1021
|
+
if (!placeMenu?.sheet) {return;}
|
|
1022
|
+
closeMenu();
|
|
1023
|
+
handler('close', offer.n);
|
|
1024
|
+
};
|
|
1025
|
+
globalThis.addEventListener?.('keydown', (event) => {
|
|
1026
|
+
if (event.key === 'Escape' || event.key === 'BrowserBack') {
|
|
1027
|
+
event.preventDefault(); event.stopImmediatePropagation(); cancel();
|
|
1028
|
+
}
|
|
1029
|
+
}, { capture: true, signal });
|
|
1030
|
+
const row = el('div', { display: 'flex', alignItems: 'center', gap: '8px', flexShrink: '0' }, sheet);
|
|
1031
|
+
el('div', { flex: '1', overflowWrap: 'anywhere' }, row).textContent = spec.title;
|
|
1032
|
+
const close = smallButton(row, '×', false);
|
|
1033
|
+
close.type = 'button';
|
|
1034
|
+
Object.assign(close.style, { minWidth: '44px', minHeight: '44px', touchAction: 'manipulation' });
|
|
1035
|
+
close.setAttribute('aria-label', 'Close');
|
|
1036
|
+
close.addEventListener('pointerdown', (event) => event.preventDefault(), { signal });
|
|
1037
|
+
close.addEventListener('click', () => { close.blur(); cancel(); }, { signal });
|
|
1038
|
+
if (spec.note) {el('div', { fontSize: '13px', color: 'var(--castle-text-secondary, #fff)', overflowWrap: 'anywhere', flexShrink: '0' }, sheet).textContent = spec.note;}
|
|
1039
|
+
const scroll = el('div', { overflowY: 'auto', minHeight: '0', overscrollBehavior: 'contain', touchAction: 'pan-y' }, sheet);
|
|
1040
|
+
for (const section of spec.sections) {
|
|
1041
|
+
el('div', { fontSize: '13px', margin: '8px 0', color: 'var(--castle-text-secondary, #fff)' }, scroll).textContent = section.title;
|
|
1042
|
+
const grid = el('div', { display: 'grid', gridTemplateColumns: 'repeat(auto-fill, minmax(64px, 1fr))', gap: '8px' }, scroll);
|
|
1043
|
+
grid.className = 'hub-menu-grid';
|
|
1044
|
+
for (const item of section.items) {
|
|
1045
|
+
const tile = el('button', { position: 'relative', aspectRatio: '1', minWidth: '64px', minHeight: '64px', padding: '6px', overflow: 'hidden', display: 'flex', flexDirection: 'column', alignItems: 'center', justifyContent: 'center', gap: '4px', touchAction: 'manipulation', overflowWrap: 'anywhere' }, grid);
|
|
1046
|
+
tile.className = 'hub-menu-tile'; tile.type = 'button'; tile.disabled = spec.readOnly === true;
|
|
1047
|
+
tile.dataset.id = item.id;
|
|
1048
|
+
tile.setAttribute('aria-label', item.label);
|
|
1049
|
+
tile.setAttribute('aria-pressed', item.on === true ? 'true' : 'false');
|
|
1050
|
+
if (item.on) {
|
|
1051
|
+
tile.style.outline = '2px solid var(--castle-text-primary, #fff)';
|
|
1052
|
+
tile.style.outlineOffset = '-3px';
|
|
1053
|
+
el('span', { position: 'absolute', top: '2px', right: '4px', fontSize: '12px' }, tile).textContent = '✓';
|
|
1054
|
+
}
|
|
1055
|
+
const swatch = el('span', { width: '28px', height: '28px', flexShrink: '0', borderRadius: item.icon ? '0' : '6px', background: item.color ?? 'var(--castle-text-primary, #fff)' }, tile);
|
|
1056
|
+
if (item.icon) {
|
|
1057
|
+
swatch.style.maskImage = swatch.style.webkitMaskImage = menuIcon(item.icon);
|
|
1058
|
+
swatch.style.maskSize = swatch.style.webkitMaskSize = 'contain';
|
|
1059
|
+
swatch.style.maskRepeat = swatch.style.webkitMaskRepeat = 'no-repeat';
|
|
1060
|
+
}
|
|
1061
|
+
swatch.setAttribute('aria-hidden', 'true');
|
|
1062
|
+
el('span', { fontSize: '12px', lineHeight: '1.15', maxHeight: '2.3em', overflow: 'hidden' }, tile).textContent = item.label;
|
|
1063
|
+
if (!tile.disabled) {
|
|
1064
|
+
tile.addEventListener('pointerdown', (event) => event.preventDefault(), { signal });
|
|
1065
|
+
tile.addEventListener('click', () => {
|
|
1066
|
+
if (!placeMenu?.sheet) {return;}
|
|
1067
|
+
tile.blur();
|
|
1068
|
+
tile.className = 'hub-menu-tile is-pressed';
|
|
1069
|
+
const timer = setTimeout(() => { tile.className = 'hub-menu-tile'; timers.delete(timer); }, 120);
|
|
1070
|
+
timers.add(timer);
|
|
1071
|
+
handler(item.id, offer.n);
|
|
1072
|
+
}, { signal });
|
|
1073
|
+
}
|
|
1074
|
+
}
|
|
1075
|
+
}
|
|
1076
|
+
Object.assign(placeMenu, { sheet, css, listeners, timers, onOpen, cancel });
|
|
1077
|
+
onOpen?.(true);
|
|
1078
|
+
}
|
|
1079
|
+
|
|
475
1080
|
return {
|
|
476
|
-
|
|
1081
|
+
setMenu, clearMenu,
|
|
1082
|
+
cancelMenu: () => placeMenu?.cancel?.(),
|
|
1083
|
+
menuOpen: () => !!placeMenu?.sheet,
|
|
1084
|
+
menuFace: () => placeMenu?.sheet ? placeMenu.face : undefined,
|
|
1085
|
+
setTextAsk(spec, handler, onOpen) {
|
|
1086
|
+
if (!spec) {
|
|
1087
|
+
closeTextAsk();
|
|
1088
|
+
return;
|
|
1089
|
+
}
|
|
1090
|
+
if (textAsk && spec.n <= textAsk.n) {
|
|
1091
|
+
return;
|
|
1092
|
+
}
|
|
1093
|
+
closeTextAsk();
|
|
1094
|
+
textAsk = { n: spec.n };
|
|
1095
|
+
if (spec.id === null) {
|
|
1096
|
+
return;
|
|
1097
|
+
}
|
|
1098
|
+
const listeners = new AbortController(), signal = listeners.signal;
|
|
1099
|
+
// Like the decor panel's world surface: gestures belong to the card,
|
|
1100
|
+
// never the canvas underneath it. No surface exists while it is closed.
|
|
1101
|
+
// It is drawn over every other control of the chrome, dimmed, so nothing
|
|
1102
|
+
// sits on the card or looks tappable through it.
|
|
1103
|
+
const shield = el('div', { position: 'absolute', inset: '0', zIndex: '10', background: 'rgba(0,0,0,0.35)', pointerEvents: 'auto', touchAction: 'none' }, root);
|
|
1104
|
+
for (const type of ['pointerdown', 'pointermove', 'pointerup', 'wheel', 'contextmenu', 'keydown', 'keyup', 'keypress']) {
|
|
1105
|
+
shield.addEventListener(type, (event) => {
|
|
1106
|
+
event.stopPropagation();
|
|
1107
|
+
if (event.target === shield) {
|
|
1108
|
+
event.preventDefault();
|
|
1109
|
+
}
|
|
1110
|
+
}, { signal, passive: false });
|
|
1111
|
+
}
|
|
1112
|
+
const card = el('div', { position: 'fixed', left: '50%', transform: 'translateX(-50%)', width: 'min(90vw, 320px)', boxSizing: 'border-box', pointerEvents: 'auto', display: 'flex', flexDirection: 'column', gap: '10px', padding: '14px', borderRadius: '12px', background: '#17120e', boxShadow: '0 4px 14px rgba(0,0,0,0.45)', fontSize: '14px' }, shield);
|
|
1113
|
+
card.setAttribute('role', 'dialog');
|
|
1114
|
+
card.setAttribute('aria-label', spec.title);
|
|
1115
|
+
const place = () => {
|
|
1116
|
+
const view = window.visualViewport;
|
|
1117
|
+
// Stay in the visible viewport as the phone keyboard rises.
|
|
1118
|
+
const bottom = view ? window.innerHeight - view.height - view.offsetTop : 0;
|
|
1119
|
+
card.style.bottom = `max(${bottom + 24}px, calc(env(safe-area-inset-bottom) + 24px))`;
|
|
1120
|
+
};
|
|
1121
|
+
place();
|
|
1122
|
+
window.visualViewport?.addEventListener('resize', place, { signal });
|
|
1123
|
+
window.visualViewport?.addEventListener('scroll', place, { signal });
|
|
1124
|
+
for (const type of ['pointerdown', 'mousedown', 'keydown', 'keyup']) {
|
|
1125
|
+
card.addEventListener(type, (event) => event.stopPropagation(), { signal });
|
|
1126
|
+
}
|
|
1127
|
+
el('div', { fontWeight: '600' }, card).textContent = spec.title;
|
|
1128
|
+
const input = el('input', { width: '100%', boxSizing: 'border-box', minHeight: '44px', padding: '8px 10px', borderRadius: '8px', border: '1px solid rgba(255,255,255,0.35)', background: 'rgba(255,255,255,0.1)', color: '#fff', font: '16px system-ui, sans-serif' }, card);
|
|
1129
|
+
input.type = 'text';
|
|
1130
|
+
// DOM maxlength counts UTF-16 units; the input handler limits code points.
|
|
1131
|
+
input.maxLength = 2 * spec.max;
|
|
1132
|
+
input.autocomplete = 'off';
|
|
1133
|
+
input.setAttribute('autocorrect', 'off');
|
|
1134
|
+
input.spellcheck = false;
|
|
1135
|
+
input.setAttribute('autocapitalize', 'words');
|
|
1136
|
+
input.setAttribute('aria-label', spec.title);
|
|
1137
|
+
const row = el('div', { display: 'flex', justifyContent: 'flex-end', gap: '8px' }, card);
|
|
1138
|
+
const ok = smallButton(row, 'OK', true), cancel = smallButton(row, 'Cancel', false);
|
|
1139
|
+
for (const button of [ok, cancel]) {
|
|
1140
|
+
button.type = 'button';
|
|
1141
|
+
button.style.minHeight = '44px';
|
|
1142
|
+
button.style.minWidth = '64px';
|
|
1143
|
+
button.style.touchAction = 'manipulation';
|
|
1144
|
+
}
|
|
1145
|
+
ok.disabled = true;
|
|
1146
|
+
ok.style.opacity = '0.45';
|
|
1147
|
+
const changed = () => {
|
|
1148
|
+
if (!input.composing) {
|
|
1149
|
+
input.value = Array.from(input.value).slice(0, spec.max).join('');
|
|
1150
|
+
}
|
|
1151
|
+
ok.disabled = input.composing || !validPrivateText(input.value, spec.max);
|
|
1152
|
+
ok.style.opacity = ok.disabled ? '0.45' : '';
|
|
1153
|
+
};
|
|
1154
|
+
input.addEventListener('compositionstart', () => { input.composing = true; ok.disabled = true; ok.style.opacity = '0.45'; }, { signal });
|
|
1155
|
+
input.addEventListener('compositionend', () => { input.composing = false; changed(); }, { signal });
|
|
1156
|
+
input.addEventListener('input', changed, { signal });
|
|
1157
|
+
const answer = (cancelled) => {
|
|
1158
|
+
if (!textAsk?.card || (!cancelled && (input.composing || !validPrivateText(input.value, spec.max)))) {
|
|
1159
|
+
return;
|
|
1160
|
+
}
|
|
1161
|
+
const text = cancelled ? null : input.value;
|
|
1162
|
+
closeTextAsk();
|
|
1163
|
+
handler(spec.id, spec.n, text);
|
|
1164
|
+
};
|
|
1165
|
+
ok.addEventListener('click', () => answer(false), { signal });
|
|
1166
|
+
cancel.addEventListener('click', () => answer(true), { signal });
|
|
1167
|
+
input.addEventListener('keydown', (event) => {
|
|
1168
|
+
event.stopPropagation();
|
|
1169
|
+
if (event.isComposing || event.keyCode === 229) {
|
|
1170
|
+
return;
|
|
1171
|
+
}
|
|
1172
|
+
if (event.key === 'Enter') {
|
|
1173
|
+
event.preventDefault();
|
|
1174
|
+
answer(false);
|
|
1175
|
+
}
|
|
1176
|
+
}, { signal });
|
|
1177
|
+
Object.assign(textAsk, { card, shield, input, listeners, onOpen, cancel: () => answer(true) });
|
|
1178
|
+
onOpen?.(true);
|
|
1179
|
+
input.focus();
|
|
1180
|
+
},
|
|
1181
|
+
clearTextAsk,
|
|
1182
|
+
cancelTextAsk: () => textAsk?.cancel?.(),
|
|
1183
|
+
textAskOpen: () => !!textAsk?.card,
|
|
1184
|
+
textAskPending: (spec) => !!spec && spec.id !== null && (!textAsk || spec.n > textAsk.n),
|
|
1185
|
+
setCover(alpha, text, line = '') {
|
|
1186
|
+
if (line && !coverLine) {
|
|
1187
|
+
coverLine = el('div', { marginTop: '12px', width: 'min(84vw, 420px)', textAlign: 'center', overflowWrap: 'anywhere', fontSize: '12px', lineHeight: '1.5', color: '#e9c48f', opacity: '0.85' }, cover);
|
|
1188
|
+
}
|
|
1189
|
+
if (coverLine) {
|
|
1190
|
+
if (coverLine.textContent !== line) {
|
|
1191
|
+
coverLine.textContent = line;
|
|
1192
|
+
}
|
|
1193
|
+
coverLine.style.display = line ? 'block' : 'none';
|
|
1194
|
+
cover.style.flexDirection = line ? 'column' : '';
|
|
1195
|
+
}
|
|
477
1196
|
cover.style.opacity = String(alpha);
|
|
478
1197
|
cover.style.pointerEvents = alpha > 0.05 ? 'auto' : 'none';
|
|
479
1198
|
if (text !== undefined && coverText.textContent !== text) {
|
|
@@ -487,6 +1206,104 @@ export function makeChrome({ onBack, onAvatar, avatarCount, onPerson = () => {},
|
|
|
487
1206
|
back.textContent = text;
|
|
488
1207
|
}
|
|
489
1208
|
},
|
|
1209
|
+
setActions(items, handler, canAct, n) {
|
|
1210
|
+
if (!items?.length) {
|
|
1211
|
+
clearActions();
|
|
1212
|
+
return;
|
|
1213
|
+
}
|
|
1214
|
+
actionHandler = handler;
|
|
1215
|
+
const key = JSON.stringify([items, n]);
|
|
1216
|
+
if (key !== actionKey) {
|
|
1217
|
+
clearActions();
|
|
1218
|
+
actionHandler = handler;
|
|
1219
|
+
actionKey = key;
|
|
1220
|
+
actionListeners = new AbortController();
|
|
1221
|
+
actionChips = el('div', { position: 'absolute', right: '12px', display: 'none', flexDirection: 'column-reverse', alignItems: 'flex-end', gap: '6px', maxWidth: 'calc(100vw - 24px)', pointerEvents: 'none' }, root);
|
|
1222
|
+
actionChips.addEventListener('pointerdown', (event) => event.stopPropagation(), { signal: actionListeners.signal });
|
|
1223
|
+
for (const item of items.slice(0, 3)) {
|
|
1224
|
+
const chip = el('button', { border: '0', borderRadius: '22px', minHeight: '44px', padding: '12px 20px', font: '600 16px/1.2 system-ui, sans-serif', color: '#26222b', background: '#f4c66c', cursor: 'pointer', touchAction: 'manipulation', pointerEvents: 'auto', maxWidth: '100%', overflowWrap: 'anywhere' }, actionChips);
|
|
1225
|
+
chip.type = 'button';
|
|
1226
|
+
chip.tabIndex = -1;
|
|
1227
|
+
chip.textContent = item.label;
|
|
1228
|
+
const pointer = (event) => {
|
|
1229
|
+
event.preventDefault();
|
|
1230
|
+
event.stopPropagation();
|
|
1231
|
+
};
|
|
1232
|
+
chip.addEventListener('pointerdown', pointer, { signal: actionListeners.signal });
|
|
1233
|
+
chip.addEventListener('mousedown', pointer, { signal: actionListeners.signal });
|
|
1234
|
+
for (const type of ['keydown', 'keyup']) {
|
|
1235
|
+
chip.addEventListener(type, pointer, { signal: actionListeners.signal });
|
|
1236
|
+
}
|
|
1237
|
+
chip.addEventListener('click', (event) => {
|
|
1238
|
+
event.stopPropagation();
|
|
1239
|
+
chip.blur();
|
|
1240
|
+
if (actionChips && actionChips.style.display !== 'none') {
|
|
1241
|
+
onChip?.();
|
|
1242
|
+
actionHandler?.(item.id, n);
|
|
1243
|
+
}
|
|
1244
|
+
}, { signal: actionListeners.signal });
|
|
1245
|
+
}
|
|
1246
|
+
}
|
|
1247
|
+
const show = canAct && !pickerOpen && !sayOpen && !emotesOpen && !peopleOpen && !doorsOpen && !talkOpen;
|
|
1248
|
+
actionChips.style.display = show ? 'flex' : 'none';
|
|
1249
|
+
if (!show) {
|
|
1250
|
+
return;
|
|
1251
|
+
}
|
|
1252
|
+
// Decor mounts a z=3 layer here, with its entry button first. Measure
|
|
1253
|
+
// that button only when its layer is drawn, never the full-view layer.
|
|
1254
|
+
const decor = [...root.children].find((node) => node.style.zIndex === '3');
|
|
1255
|
+
const decorButton = decor?.style.display !== 'none' ? decor?.children[0] : null;
|
|
1256
|
+
const column = [grabButton, emoteButton, sayButton, sitButton].map(shownRect).filter(Boolean);
|
|
1257
|
+
const controls = [picker, talkButton, dock, nearButton, stuckChip, decorButton].map(shownRect).filter(Boolean).concat(column);
|
|
1258
|
+
const above = [hud, askCard, back, sound?.button, sound?.card].map(shownRect).filter(Boolean);
|
|
1259
|
+
const overlaps = (a, b) => a.left < b.right && a.right > b.left;
|
|
1260
|
+
const chips = [...actionChips.children];
|
|
1261
|
+
// Restore chips trimmed by a previous frame before trying both positions.
|
|
1262
|
+
for (const chip of chips) {
|
|
1263
|
+
chip.style.display = '';
|
|
1264
|
+
}
|
|
1265
|
+
const place = (right, initialBottom) => {
|
|
1266
|
+
actionChips.style.right = `${right}px`;
|
|
1267
|
+
actionChips.style.maxWidth = `${Math.max(0, window.innerWidth - right - 12)}px`;
|
|
1268
|
+
actionChips.style.bottom = initialBottom;
|
|
1269
|
+
const box = actionChips.getBoundingClientRect();
|
|
1270
|
+
let bottom = window.innerHeight - box.bottom;
|
|
1271
|
+
for (const r of controls) {
|
|
1272
|
+
if (overlaps(r, box)) {
|
|
1273
|
+
bottom = Math.max(bottom, window.innerHeight - r.top + 12);
|
|
1274
|
+
}
|
|
1275
|
+
}
|
|
1276
|
+
actionChips.style.bottom = `${bottom}px`;
|
|
1277
|
+
const placed = actionChips.getBoundingClientRect();
|
|
1278
|
+
return placed.left >= 12 && placed.top >= 12 && placed.bottom <= window.innerHeight - 12
|
|
1279
|
+
&& !above.some((r) => overlaps(r, placed) && r.bottom + 12 > placed.top);
|
|
1280
|
+
};
|
|
1281
|
+
// Identity determines which controls bound the stack from above, even
|
|
1282
|
+
// when a short frame puts speech or Grab in the top half of the view.
|
|
1283
|
+
const right = window.innerWidth - Math.min(window.innerWidth - 12, ...column.map((r) => r.left)) + 12;
|
|
1284
|
+
for (let count = chips.length; count > 0; count -= 1) {
|
|
1285
|
+
// Trimming can narrow the stack enough to clear a HUD or decor
|
|
1286
|
+
// obstacle in the right column, so retry it before the fallback.
|
|
1287
|
+
if (place(12, 'max(132px, calc(env(safe-area-inset-bottom) + 122px))') || place(right, '12px')) {
|
|
1288
|
+
return;
|
|
1289
|
+
}
|
|
1290
|
+
// column-reverse puts the first offer at the bottom: trim from the top.
|
|
1291
|
+
chips[count - 1].style.display = 'none';
|
|
1292
|
+
}
|
|
1293
|
+
actionChips.style.display = 'none';
|
|
1294
|
+
},
|
|
1295
|
+
clearActions,
|
|
1296
|
+
// v1.67: called only in a decor place; the tray uses the same chrome root.
|
|
1297
|
+
decorRoot() {
|
|
1298
|
+
return root;
|
|
1299
|
+
},
|
|
1300
|
+
setDecorating(on) {
|
|
1301
|
+
hud.style.visibility = on ? 'hidden' : '';
|
|
1302
|
+
picker.style.visibility = on ? 'hidden' : '';
|
|
1303
|
+
back.style.zIndex = on ? '4' : '';
|
|
1304
|
+
back.style.top = on ? 'auto' : 'max(12px, env(safe-area-inset-top))';
|
|
1305
|
+
back.style.bottom = on ? 'max(196px, calc(env(safe-area-inset-bottom) + 186px))' : '';
|
|
1306
|
+
},
|
|
490
1307
|
setHud(spec, timerSeconds) {
|
|
491
1308
|
if (!spec) {
|
|
492
1309
|
hud.style.display = 'none';
|
|
@@ -498,12 +1315,65 @@ export function makeChrome({ onBack, onAvatar, avatarCount, onPerson = () => {},
|
|
|
498
1315
|
hudBig.textContent = big;
|
|
499
1316
|
hudBig.style.display = big ? 'block' : 'none';
|
|
500
1317
|
hudText.textContent = spec.text ?? '';
|
|
1318
|
+
if (hudClear) {
|
|
1319
|
+
layoutHudClear(big, spec.text ?? '');
|
|
1320
|
+
}
|
|
501
1321
|
},
|
|
1322
|
+
// Whether this place asks for a clear HUD (`hud.clear`, v1.26). Said each
|
|
1323
|
+
// frame before `setHud`; never said true, nothing of it is drawn.
|
|
1324
|
+
setHudClear(on) {
|
|
1325
|
+
hudClear = on === true;
|
|
1326
|
+
if (!hudClear && hudClearDrawn) {
|
|
1327
|
+
restoreHudClear();
|
|
1328
|
+
}
|
|
1329
|
+
if (!hudClear) {
|
|
1330
|
+
hudClearPending.clear();
|
|
1331
|
+
}
|
|
1332
|
+
},
|
|
1333
|
+
// The end of a frame's drawing in a place with a clear HUD: everything
|
|
1334
|
+
// the setters above asked to be kept clear of it is measured, then moved.
|
|
1335
|
+
// Nothing asked (a place without the option): nothing read or written.
|
|
1336
|
+
flushHudClear,
|
|
502
1337
|
// `items` is [{ id, x, y, text, speech, npc, color }] in CSS pixels (a
|
|
503
1338
|
// `color` is a player's mark); anything not
|
|
504
1339
|
// listed is removed.
|
|
1340
|
+
// The HUD's box that this frame's flush will move labels out from under
|
|
1341
|
+
// (v1.26), or null when nothing will be moved: no clear HUD asked for, or
|
|
1342
|
+
// none drawn. For v1.43's rule, which must judge where labels end up.
|
|
1343
|
+
hudClearBox() {
|
|
1344
|
+
return hudClear && hud.style.display !== 'none' ? hudClearRect : null;
|
|
1345
|
+
},
|
|
1346
|
+
// How big a label with these words is drawn, `{ w, h }` in CSS pixels
|
|
1347
|
+
// (v1.43, for a deck whose labels are kept apart: `labelsNear.js`).
|
|
1348
|
+
// Measured once for each text in a node of its own outside the chrome's
|
|
1349
|
+
// root, made on the first call: a deck that never asks has no such node.
|
|
1350
|
+
measureLabel(text, speech = false, npc = false) {
|
|
1351
|
+
const key = `${speech ? (npc ? 'n' : 's') : 'l'}${desktop() ? 'd' : 'm'}${window.innerWidth}|${text}`;
|
|
1352
|
+
let size = labelSizes.get(key);
|
|
1353
|
+
if (!size) {
|
|
1354
|
+
labelMeasure ??= el('div', { position: 'fixed', left: '-10000px', top: '0', visibility: 'hidden', pointerEvents: 'none', font: '600 15px/1.3 system-ui, sans-serif', padding: '4px 10px', whiteSpace: 'nowrap', fontSize: '14px' });
|
|
1355
|
+
const m = labelMeasure.style;
|
|
1356
|
+
m.whiteSpace = speech ? 'normal' : 'nowrap';
|
|
1357
|
+
m.width = speech ? 'max-content' : 'auto';
|
|
1358
|
+
m.maxWidth = !speech ? 'none' : npc && desktop() ? 'min(62vw, 320px)' : '62vw';
|
|
1359
|
+
m.fontSize = speech ? '13px' : '14px';
|
|
1360
|
+
m.fontWeight = speech ? '500' : '600';
|
|
1361
|
+
labelMeasure.textContent = text;
|
|
1362
|
+
size = { w: labelMeasure.offsetWidth, h: labelMeasure.offsetHeight };
|
|
1363
|
+
if (labelSizes.size > 400) {
|
|
1364
|
+
labelSizes.clear();
|
|
1365
|
+
}
|
|
1366
|
+
labelSizes.set(key, size);
|
|
1367
|
+
}
|
|
1368
|
+
return size;
|
|
1369
|
+
},
|
|
505
1370
|
setLabels(items) {
|
|
506
1371
|
const seen = new Set();
|
|
1372
|
+
// The top chrome an emote's emoji is kept from under (`emoteBubble.js`),
|
|
1373
|
+
// read once a call and only when an emote is drawn.
|
|
1374
|
+
let bands = null;
|
|
1375
|
+
// An emote put on its head: id -> the bottom it was put at.
|
|
1376
|
+
const emoteAt = new Map();
|
|
507
1377
|
for (const item of items) {
|
|
508
1378
|
seen.add(item.id);
|
|
509
1379
|
let node = labelNodes.get(item.id);
|
|
@@ -514,19 +1384,27 @@ export function makeChrome({ onBack, onAvatar, avatarCount, onPerson = () => {},
|
|
|
514
1384
|
// An NPC's line is kept on screen: a reply over one at the edge of the
|
|
515
1385
|
// view would otherwise be cut off mid-sentence. Other labels are
|
|
516
1386
|
// placed as they always were.
|
|
1387
|
+
// v1.43: an item that comes with its `box` (`labelsNear.js` `labelBox`:
|
|
1388
|
+
// measured for these words, kept on the screen, moved from under a
|
|
1389
|
+
// clear HUD) is put exactly there and moved by nothing after, so what
|
|
1390
|
+
// is drawn is what the rule judged. No other item has one.
|
|
517
1391
|
let x = item.x;
|
|
518
|
-
if (item.
|
|
1392
|
+
if (item.box) {
|
|
1393
|
+
x = (item.box.left + item.box.right) / 2;
|
|
1394
|
+
} else if (item.npc) {
|
|
519
1395
|
const half = node.offsetWidth / 2;
|
|
520
1396
|
x = Math.min(Math.max(item.x, half + 6), window.innerWidth - half - 6);
|
|
521
1397
|
}
|
|
522
1398
|
node.style.left = `${x}px`;
|
|
523
|
-
node.style.top = `${item.y}px`;
|
|
1399
|
+
node.style.top = `${item.box ? item.box.bottom : item.y}px`;
|
|
524
1400
|
if (item.speech) {
|
|
525
1401
|
node.style.background = 'rgba(255,250,240,0.94)';
|
|
526
1402
|
node.style.color = '#2b2118';
|
|
527
1403
|
node.style.whiteSpace = 'normal';
|
|
528
|
-
if (item.npc) {
|
|
529
|
-
// Its own width, not what is left of the screen to its right
|
|
1404
|
+
if (item.npc || item.box) {
|
|
1405
|
+
// Its own width, not what is left of the screen to its right
|
|
1406
|
+
// (v1.43: so is any line that comes with its box, which was
|
|
1407
|
+
// measured that way).
|
|
530
1408
|
node.style.width = 'max-content';
|
|
531
1409
|
}
|
|
532
1410
|
node.style.maxWidth = item.npc && desktop() ? 'min(62vw, 320px)' : '62vw';
|
|
@@ -537,7 +1415,9 @@ export function makeChrome({ onBack, onAvatar, avatarCount, onPerson = () => {},
|
|
|
537
1415
|
// An emote's emoji over a player: large, on nothing.
|
|
538
1416
|
node.dataset.emote = '1';
|
|
539
1417
|
node.style.background = 'transparent';
|
|
540
|
-
node.style.fontSize = '
|
|
1418
|
+
node.style.fontSize = '42px';
|
|
1419
|
+
// The glyph's own box, so it sits on the head it was put over.
|
|
1420
|
+
node.style.lineHeight = '1';
|
|
541
1421
|
node.style.padding = '0';
|
|
542
1422
|
node.style.textShadow = '0 2px 4px rgba(0,0,0,0.5)';
|
|
543
1423
|
}
|
|
@@ -556,6 +1436,38 @@ export function makeChrome({ onBack, onAvatar, avatarCount, onPerson = () => {},
|
|
|
556
1436
|
if (node.textContent !== item.text) {
|
|
557
1437
|
node.textContent = item.text;
|
|
558
1438
|
}
|
|
1439
|
+
if (item.emote && !item.box) {
|
|
1440
|
+
// An emote's emoji sits on its head (`emoteBubble.js`): just above
|
|
1441
|
+
// it, or beside it where above is off the view or under the top
|
|
1442
|
+
// chrome, and never under the top chrome. A clear HUD moves what is
|
|
1443
|
+
// under its own box (`keepClearOfHud` below).
|
|
1444
|
+
bands ??= [hud, askCard, back, sound?.button].map(shownRect).filter(Boolean);
|
|
1445
|
+
// An emoji's size is its glyph's at a fixed font size: measured once
|
|
1446
|
+
// per emoji, not read back after this frame's writes.
|
|
1447
|
+
let size = emoteSizes.get(item.text);
|
|
1448
|
+
if (!size) {
|
|
1449
|
+
size = { w: node.offsetWidth, h: node.offsetHeight };
|
|
1450
|
+
emoteSizes.set(item.text, size);
|
|
1451
|
+
}
|
|
1452
|
+
const { w, h } = size;
|
|
1453
|
+
let placed = null;
|
|
1454
|
+
if (item.head) {
|
|
1455
|
+
placed = placeEmoteBubble(item.head, { w, h }, hudClear ? [] : bands, { w: window.innerWidth, h: window.innerHeight }, item.lift ?? 0);
|
|
1456
|
+
} else if (!hudClear && bands.length) {
|
|
1457
|
+
const { dx, dy } = emoteBubbleShift({ left: x - w / 2, right: x + w / 2, top: item.y - h, bottom: item.y }, bands, window.innerWidth);
|
|
1458
|
+
placed = dx !== 0 || dy !== 0 ? { left: x - w / 2 + dx, right: x + w / 2 + dx, top: item.y - h + dy, bottom: item.y + dy } : null;
|
|
1459
|
+
}
|
|
1460
|
+
// A head off the view: no bubble. Any other is shown again.
|
|
1461
|
+
const visibility = item.head && !placed ? 'hidden' : '';
|
|
1462
|
+
if ((node.style.visibility || '') !== visibility) {
|
|
1463
|
+
node.style.visibility = visibility;
|
|
1464
|
+
}
|
|
1465
|
+
if (placed) {
|
|
1466
|
+
node.style.left = `${(placed.left + placed.right) / 2}px`;
|
|
1467
|
+
node.style.top = `${placed.bottom}px`;
|
|
1468
|
+
emoteAt.set(item.id, placed.bottom);
|
|
1469
|
+
}
|
|
1470
|
+
}
|
|
559
1471
|
}
|
|
560
1472
|
for (const [id, node] of labelNodes) {
|
|
561
1473
|
if (!seen.has(id)) {
|
|
@@ -563,6 +1475,16 @@ export function makeChrome({ onBack, onAvatar, avatarCount, onPerson = () => {},
|
|
|
563
1475
|
labelNodes.delete(id);
|
|
564
1476
|
}
|
|
565
1477
|
}
|
|
1478
|
+
if (hudClear) {
|
|
1479
|
+
keepClearOfHud(
|
|
1480
|
+
'labels',
|
|
1481
|
+
// One with its `box` is already where it stays.
|
|
1482
|
+
items.filter((item) => !item.box).map((item) => {
|
|
1483
|
+
const node = labelNodes.get(item.id);
|
|
1484
|
+
return [node, parseFloat(node.style.left), emoteAt.get(item.id) ?? item.y, 'bottom', item.text];
|
|
1485
|
+
}),
|
|
1486
|
+
);
|
|
1487
|
+
}
|
|
566
1488
|
},
|
|
567
1489
|
// `item` is { id, rev, card, x, y, opacity } in CSS pixels, or null for no
|
|
568
1490
|
// card; `imageOf(value)` is a picture's `src`, or null for none.
|
|
@@ -586,6 +1508,9 @@ export function makeChrome({ onBack, onAvatar, avatarCount, onPerson = () => {},
|
|
|
586
1508
|
const half = cabinet.offsetWidth / 2;
|
|
587
1509
|
cabinet.style.left = `${Math.min(Math.max(item.x, half + 6), window.innerWidth - half - 6)}px`;
|
|
588
1510
|
cabinet.style.top = `${Math.max(item.y, cabinet.offsetHeight + 6)}px`;
|
|
1511
|
+
if (hudClear) {
|
|
1512
|
+
keepClearOfHud('cabinet', [[cabinet, parseFloat(cabinet.style.left), parseFloat(cabinet.style.top), 'bottom', cabinetKey]]);
|
|
1513
|
+
}
|
|
589
1514
|
// A board the player asked for is read whole, wherever they stand by it.
|
|
590
1515
|
cabinet.style.opacity = String(open ? 1 : item.opacity);
|
|
591
1516
|
},
|
|
@@ -600,21 +1525,44 @@ export function makeChrome({ onBack, onAvatar, avatarCount, onPerson = () => {},
|
|
|
600
1525
|
if (ribbon.textContent !== text) {
|
|
601
1526
|
ribbon.textContent = text;
|
|
602
1527
|
}
|
|
1528
|
+
if (hudClear) {
|
|
1529
|
+
keepClearOfHud('ribbon', [[ribbon, pos.x, pos.y, 'bottom', text]]);
|
|
1530
|
+
}
|
|
603
1531
|
},
|
|
604
|
-
setToast(text) {
|
|
605
|
-
|
|
1532
|
+
setToast(text, { wrap = false } = {}) {
|
|
1533
|
+
if (text && wrap) {
|
|
1534
|
+
if (!toastWrap) {
|
|
1535
|
+
toastWrap = { maxWidth: toast.style.maxWidth, overflowWrap: toast.style.overflowWrap, textAlign: toast.style.textAlign };
|
|
1536
|
+
Object.assign(toast.style, { maxWidth: 'min(90vw, 480px)', overflowWrap: 'anywhere', textAlign: 'center' });
|
|
1537
|
+
}
|
|
1538
|
+
} else if (toastWrap) {
|
|
1539
|
+
Object.assign(toast.style, toastWrap);
|
|
1540
|
+
toastWrap = null;
|
|
1541
|
+
}
|
|
1542
|
+
const display = text ? 'block' : 'none';
|
|
1543
|
+
if (toast.style.display !== display) {
|
|
1544
|
+
toast.style.display = display;
|
|
1545
|
+
}
|
|
606
1546
|
if (text && toast.textContent !== text) {
|
|
607
1547
|
toast.textContent = text;
|
|
608
1548
|
}
|
|
1549
|
+
placeToast();
|
|
609
1550
|
},
|
|
610
|
-
showPicker(show, selected) {
|
|
1551
|
+
showPicker(show, selected, colors) {
|
|
1552
|
+
showColors(selected, colors);
|
|
611
1553
|
picker.style.display = show ? 'flex' : 'none';
|
|
612
1554
|
if (!show) {
|
|
613
1555
|
setPickerOpen(false);
|
|
614
1556
|
}
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
1557
|
+
// Asked every frame: written only when the character worn changes.
|
|
1558
|
+
if (selected !== pickerSelected) {
|
|
1559
|
+
pickerSelected = selected;
|
|
1560
|
+
pickerButtons.forEach((button, i) => {
|
|
1561
|
+
button.style.borderColor = i === selected ? '#f2c94c' : 'rgba(255,255,255,0.4)';
|
|
1562
|
+
button.style.background = i === selected ? 'rgba(242,201,76,0.22)' : 'rgba(20,16,12,0.7)';
|
|
1563
|
+
button.setAttribute('aria-pressed', String(i === selected));
|
|
1564
|
+
});
|
|
1565
|
+
}
|
|
618
1566
|
},
|
|
619
1567
|
// The Graphics row: `mode` is the one picked ('auto', 'low' or 'high').
|
|
620
1568
|
setGraphics(mode, onPick) {
|
|
@@ -662,6 +1610,9 @@ export function makeChrome({ onBack, onAvatar, avatarCount, onPerson = () => {},
|
|
|
662
1610
|
event.stopPropagation();
|
|
663
1611
|
event.preventDefault();
|
|
664
1612
|
setEmotesOpen(false);
|
|
1613
|
+
if (onChip) {
|
|
1614
|
+
onChip();
|
|
1615
|
+
}
|
|
665
1616
|
emoteHandler(id);
|
|
666
1617
|
});
|
|
667
1618
|
}
|
|
@@ -681,6 +1632,12 @@ export function makeChrome({ onBack, onAvatar, avatarCount, onPerson = () => {},
|
|
|
681
1632
|
if (key === sayKey && sayNote && chat && sayNote.textContent !== (chat.note ?? '')) {
|
|
682
1633
|
sayNote.textContent = chat.note ?? '';
|
|
683
1634
|
}
|
|
1635
|
+
// The field's own words (a deck with cues, v1.23): rewritten in place
|
|
1636
|
+
// too. A chat part that names none keeps 'Message…'.
|
|
1637
|
+
if (key === sayKey && sayInput && chat?.placeholder && sayInput.placeholder !== chat.placeholder) {
|
|
1638
|
+
sayInput.placeholder = chat.placeholder;
|
|
1639
|
+
sayInput.setAttribute('aria-label', chat.label ?? chat.placeholder);
|
|
1640
|
+
}
|
|
684
1641
|
if (key === sayKey) {
|
|
685
1642
|
return;
|
|
686
1643
|
}
|
|
@@ -691,6 +1648,9 @@ export function makeChrome({ onBack, onAvatar, avatarCount, onPerson = () => {},
|
|
|
691
1648
|
event.stopPropagation();
|
|
692
1649
|
event.preventDefault();
|
|
693
1650
|
setSayOpen(false);
|
|
1651
|
+
if (onChip) {
|
|
1652
|
+
onChip();
|
|
1653
|
+
}
|
|
694
1654
|
sayHandler(what);
|
|
695
1655
|
});
|
|
696
1656
|
const row = el('div', { display: 'flex', justifyContent: 'space-between' }, sayCard);
|
|
@@ -717,8 +1677,12 @@ export function makeChrome({ onBack, onAvatar, avatarCount, onPerson = () => {},
|
|
|
717
1677
|
sayNote.textContent = chat.note ?? '';
|
|
718
1678
|
const line = el('div', { display: 'flex', gap: '6px', opacity: chat.input ? '1' : '0.5' }, sayCard);
|
|
719
1679
|
const input = el('input', { flex: '1', minWidth: '0', padding: '7px 9px', borderRadius: '8px', border: '1px solid rgba(255,255,255,0.3)', background: 'rgba(255,255,255,0.1)', color: '#fff', font: '500 14px system-ui, sans-serif' }, line);
|
|
1680
|
+
chatField(input, 'message');
|
|
720
1681
|
input.maxLength = 200;
|
|
721
|
-
input.placeholder = 'Message…';
|
|
1682
|
+
input.placeholder = chat.placeholder ?? 'Message…';
|
|
1683
|
+
if (chat.placeholder) {
|
|
1684
|
+
input.setAttribute('aria-label', chat.label ?? chat.placeholder);
|
|
1685
|
+
}
|
|
722
1686
|
// Shown even when it cannot be used, so chat can be found; the note says why.
|
|
723
1687
|
input.disabled = !chat.input;
|
|
724
1688
|
input.enterKeyHint = 'send';
|
|
@@ -814,52 +1778,201 @@ export function makeChrome({ onBack, onAvatar, avatarCount, onPerson = () => {},
|
|
|
814
1778
|
grabButton.style.color = text === 'Throw' ? '#2b2118' : '#fff';
|
|
815
1779
|
}
|
|
816
1780
|
},
|
|
1781
|
+
talkRect: () => shownRect(panel),
|
|
1782
|
+
// Only companion places call this layout pass; keyless decks keep their CSS.
|
|
1783
|
+
layoutCompanion(parent) {
|
|
1784
|
+
const lock = parent?.querySelector?.('button[aria-label^="Shift lock"]');
|
|
1785
|
+
const rect = shownRect(lock);
|
|
1786
|
+
const lift = rect && lock.style.visibility !== 'hidden' ? rect.bottom - rect.top + 8 : 0;
|
|
1787
|
+
if (lift === lockLift) {return;}
|
|
1788
|
+
lockLift = lift;
|
|
1789
|
+
for (const [node, bottom] of cornerBottoms) {node.style.bottom = lift ? `calc(${bottom} + ${lift}px)` : bottom;}
|
|
1790
|
+
for (const unit of ['vh', 'dvh']) {pickerCard.style.maxHeight = `calc(100${unit} - ${76 + lift}px - env(safe-area-inset-top) - env(safe-area-inset-bottom))`;}
|
|
1791
|
+
},
|
|
1792
|
+
setCompanionBadge(show, name, onOpen) {
|
|
1793
|
+
if (!show) {
|
|
1794
|
+
companionBadge?.remove();
|
|
1795
|
+
companionBadge = null;
|
|
1796
|
+
delete this.companionBadge;
|
|
1797
|
+
return;
|
|
1798
|
+
}
|
|
1799
|
+
if (!companionBadge) {
|
|
1800
|
+
companionBadge = el('button', { width: '44px', height: '44px', flex: '0 0 44px', boxSizing: 'border-box', padding: '8px', borderRadius: '50%', border: '1px solid rgba(255,255,255,0.4)', background: 'rgba(20,16,12,0.72)', cursor: 'pointer', pointerEvents: 'auto', touchAction: 'manipulation' }, dock);
|
|
1801
|
+
companionBadge.innerHTML = '<svg viewBox="0 0 28 28" width="26" height="26" aria-hidden="true"><path fill="#fff6e6" d="M3 6l11 5L24 3l-5 13-7 6-2-8z"/><path fill="#e8743b" d="M14 11l5 5-7 6 2-11zM19 16l7 1-6 3z"/></svg>';
|
|
1802
|
+
companionBadge.addEventListener('pointerdown', (event) => {
|
|
1803
|
+
event.stopPropagation();
|
|
1804
|
+
companionBadge.openCompanion?.();
|
|
1805
|
+
});
|
|
1806
|
+
this.companionBadge = companionBadge;
|
|
1807
|
+
}
|
|
1808
|
+
companionBadge.openCompanion = onOpen;
|
|
1809
|
+
companionBadge.setAttribute('aria-label', `Chat with ${name}`);
|
|
1810
|
+
showCompanionBadge();
|
|
1811
|
+
},
|
|
1812
|
+
// A 44 px hit area over the private follower; created only for chat.
|
|
1813
|
+
setCompanionTalk(screen, name, onOpen) {
|
|
1814
|
+
if (!screen || talkOpen || pickerOpen || peopleOpen || doorsOpen || sayOpen || emotesOpen) {
|
|
1815
|
+
this.companionTalkButton?.remove();
|
|
1816
|
+
delete this.companionTalkButton;
|
|
1817
|
+
return;
|
|
1818
|
+
}
|
|
1819
|
+
if (!this.companionTalkButton) {
|
|
1820
|
+
const button = el('button', { position: 'absolute', width: '44px', height: '44px', transform: 'translate(-50%, -50%)', pointerEvents: 'auto', background: 'transparent', border: 'none', padding: '0', cursor: 'pointer' }, root);
|
|
1821
|
+
button.addEventListener('pointerdown', (event) => {
|
|
1822
|
+
event.stopPropagation();
|
|
1823
|
+
button.openCompanion?.();
|
|
1824
|
+
});
|
|
1825
|
+
this.companionTalkButton = button;
|
|
1826
|
+
}
|
|
1827
|
+
this.companionTalkButton.openCompanion = onOpen;
|
|
1828
|
+
this.companionTalkButton.style.left = `${screen.x}px`;
|
|
1829
|
+
this.companionTalkButton.style.top = `${screen.y}px`;
|
|
1830
|
+
this.companionTalkButton.setAttribute('aria-label', `Chat with ${name}`);
|
|
1831
|
+
// Never over a control: a tap there is the control's.
|
|
1832
|
+
const controls = [picker, grabButton, emoteButton, sayButton, talkButton, sitButton, sound?.button, back, hud, askCard, actionChips].map(shownRect).filter(Boolean);
|
|
1833
|
+
const covers = controls.some((r) => r.left < screen.x + 22 && r.right > screen.x - 22 && r.top < screen.y + 22 && r.bottom > screen.y - 22);
|
|
1834
|
+
this.companionTalkButton.style.display = covers ? 'none' : 'block';
|
|
1835
|
+
},
|
|
817
1836
|
// The Talk button, for the NPC named, or hidden.
|
|
818
|
-
talkPrompt(name) {
|
|
1837
|
+
talkPrompt(name, mind = false) {
|
|
819
1838
|
const show = Boolean(name) && !talkOpen;
|
|
820
1839
|
talkButton.style.display = show ? 'block' : 'none';
|
|
821
|
-
|
|
1840
|
+
// A mind's button names it by first name: "Chat with Biscuit", not the
|
|
1841
|
+
// whole "Biscuit, the puppy" in three lines on a phone.
|
|
1842
|
+
const text = show ? (mind ? `Chat with ${name.split(',')[0].trim() || name}` : `Talk to ${name}`) : '';
|
|
822
1843
|
if (show && talkButton.textContent !== text) {
|
|
823
1844
|
talkButton.textContent = text;
|
|
824
1845
|
}
|
|
825
1846
|
},
|
|
826
|
-
openTalk(name) {
|
|
1847
|
+
openTalk(name, { mind = false, canType = true } = {}) {
|
|
827
1848
|
talkOpen = true;
|
|
1849
|
+
showCompanionBadge();
|
|
1850
|
+
panelMind = mind;
|
|
828
1851
|
panelName.textContent = name;
|
|
1852
|
+
dropTyping();
|
|
829
1853
|
panelLog.replaceChildren();
|
|
1854
|
+
panelOpening = null;
|
|
1855
|
+
dropAsks();
|
|
1856
|
+
panelInput.value = '';
|
|
1857
|
+
panelInput.placeholder = mind ? `Ask ${name.split(',')[0].trim()} anything…` : 'Say something…';
|
|
1858
|
+
panelSend.disabled = false;
|
|
1859
|
+
panelSend.style.opacity = '1';
|
|
1860
|
+
panelSend.textContent = 'Say';
|
|
830
1861
|
panel.style.display = 'flex';
|
|
831
1862
|
talkButton.style.display = 'none';
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
if (globalThis.matchMedia?.('(pointer: fine)').matches) {
|
|
835
|
-
panelInput.focus({ preventScroll: true });
|
|
836
|
-
}
|
|
1863
|
+
panelForm.style.display = 'none';
|
|
1864
|
+
setTalkTyping(canType);
|
|
837
1865
|
},
|
|
838
1866
|
closeTalk() {
|
|
839
1867
|
talkOpen = false;
|
|
1868
|
+
showCompanionBadge();
|
|
1869
|
+
panelOpening = null;
|
|
840
1870
|
panel.style.display = 'none';
|
|
841
1871
|
panelInput.blur();
|
|
1872
|
+
dropAsks();
|
|
1873
|
+
dropTyping();
|
|
1874
|
+
},
|
|
1875
|
+
talkTyping: setTalkTyping,
|
|
1876
|
+
// A refused re-attach keeps the unsent question for the next open.
|
|
1877
|
+
talkDraft(text) {
|
|
1878
|
+
if (text !== undefined) {
|
|
1879
|
+
panelInput.value = text;
|
|
1880
|
+
}
|
|
1881
|
+
return panelInput.value;
|
|
1882
|
+
},
|
|
1883
|
+
// v1.47: replace the opening in place; questions and later lines stay put.
|
|
1884
|
+
talkOpening(text) {
|
|
1885
|
+
if (talkOpen && panelOpening) {
|
|
1886
|
+
panelOpening.textContent = text;
|
|
1887
|
+
}
|
|
1888
|
+
},
|
|
1889
|
+
// v1.46: a mind's chips sit below its field; an empty list removes them.
|
|
1890
|
+
talkAsks(asks, onAsk) {
|
|
1891
|
+
const list = Array.isArray(asks) ? asks.slice(0, 3) : [];
|
|
1892
|
+
if (!list.length) {
|
|
1893
|
+
dropAsks();
|
|
1894
|
+
return;
|
|
1895
|
+
}
|
|
1896
|
+
if (!panelAsks) {
|
|
1897
|
+
panelAsks = el('div', { display: 'none', flexWrap: 'wrap', gap: '6px' }, panel);
|
|
1898
|
+
if (!panelMind) {
|
|
1899
|
+
panel.insertBefore(panelAsks, panelForm);
|
|
1900
|
+
}
|
|
1901
|
+
}
|
|
1902
|
+
panelAsks.replaceChildren();
|
|
1903
|
+
asksHandler = onAsk;
|
|
1904
|
+
if (panelMind) {
|
|
1905
|
+
el('span', { fontSize: '12px', opacity: '0.7', flexBasis: '100%' }, panelAsks).textContent = 'or try:';
|
|
1906
|
+
}
|
|
1907
|
+
for (const ask of list) {
|
|
1908
|
+
const chip = el('button', { pointerEvents: 'auto', maxWidth: '100%', overflowWrap: 'anywhere', padding: '6px 11px', borderRadius: '14px', border: '1px solid rgba(233,196,143,0.7)', background: 'rgba(233,196,143,0.14)', color: '#f5dfbd', font: '600 13px/1.25 system-ui, sans-serif', textAlign: 'left', cursor: 'pointer' }, panelAsks);
|
|
1909
|
+
chip.type = 'button';
|
|
1910
|
+
chip.textContent = ask;
|
|
1911
|
+
chip.addEventListener('pointerdown', (event) => {
|
|
1912
|
+
event.stopPropagation();
|
|
1913
|
+
event.preventDefault();
|
|
1914
|
+
if (onChip) {
|
|
1915
|
+
onChip();
|
|
1916
|
+
}
|
|
1917
|
+
asksHandler?.(ask);
|
|
1918
|
+
});
|
|
1919
|
+
}
|
|
1920
|
+
panelAsks.style.display = 'flex';
|
|
842
1921
|
},
|
|
843
1922
|
// `note`, when given, is a small caption under the line (a scripted reply).
|
|
844
1923
|
talkLine(who, text, note = null) {
|
|
1924
|
+
// v1.35: where the log was before this line: at its end, or scrolled
|
|
1925
|
+
// up by the player to read something earlier.
|
|
1926
|
+
const atEnd = panelLog.scrollHeight - panelLog.scrollTop - panelLog.clientHeight <= TALK_END_PX;
|
|
1927
|
+
if (who === 'them') {
|
|
1928
|
+
dropTyping();
|
|
1929
|
+
}
|
|
845
1930
|
const line = el('div', { alignSelf: who === 'me' ? 'flex-end' : 'flex-start', maxWidth: '85%', padding: '5px 9px', borderRadius: '10px', background: who === 'me' ? 'rgba(233,196,143,0.25)' : 'rgba(255,250,240,0.94)', color: who === 'me' ? '#fff' : '#2b2118' }, panelLog);
|
|
846
1931
|
line.textContent = text;
|
|
1932
|
+
if (who === 'them' && panelLog.childElementCount === 1) {
|
|
1933
|
+
panelOpening = line;
|
|
1934
|
+
}
|
|
847
1935
|
if (note) {
|
|
848
1936
|
el('div', { fontSize: '11px', fontStyle: 'italic', opacity: '0.65', marginTop: '2px' }, line).textContent = note;
|
|
849
1937
|
}
|
|
850
|
-
|
|
1938
|
+
if (who === 'me') {
|
|
1939
|
+
// The player's own words: they have just sent them, show them.
|
|
1940
|
+
panelLog.scrollTop = panelLog.scrollHeight;
|
|
1941
|
+
} else if (atEnd) {
|
|
1942
|
+
// A reply is read from its first word: its top at the top of what
|
|
1943
|
+
// shows (the end of the log when the whole reply fits, as the
|
|
1944
|
+
// browser stops there). A player reading further up is left there.
|
|
1945
|
+
panelLog.scrollTop = line.offsetTop - panelLog.offsetTop;
|
|
1946
|
+
}
|
|
851
1947
|
},
|
|
852
1948
|
talkWaiting(waiting) {
|
|
853
1949
|
panelSend.disabled = waiting;
|
|
854
1950
|
panelSend.style.opacity = waiting ? '0.5' : '1';
|
|
855
1951
|
panelSend.textContent = waiting ? '…' : 'Say';
|
|
1952
|
+
if (!waiting) {
|
|
1953
|
+
dropTyping();
|
|
1954
|
+
} else if (talkOpen && panelMind && !panelTyping) {
|
|
1955
|
+
const atEnd = panelLog.scrollHeight - panelLog.scrollTop - panelLog.clientHeight <= TALK_END_PX;
|
|
1956
|
+
panelTyping = el('div', { alignSelf: 'flex-start', display: 'flex', gap: '3px', padding: '5px 9px', borderRadius: '10px', background: 'rgba(255,250,240,0.94)', color: '#2b2118' }, panelLog);
|
|
1957
|
+
panelTyping.className = 'hub-npc-typing';
|
|
1958
|
+
panelTyping.setAttribute('role', 'status');
|
|
1959
|
+
panelTyping.setAttribute('aria-label', `${panelName.textContent} is typing`);
|
|
1960
|
+
for (let i = 0; i < 3; i++) {
|
|
1961
|
+
el('span', {}, panelTyping).textContent = '•';
|
|
1962
|
+
}
|
|
1963
|
+
if (atEnd) {
|
|
1964
|
+
panelLog.scrollTop = panelLog.scrollHeight;
|
|
1965
|
+
}
|
|
1966
|
+
}
|
|
856
1967
|
},
|
|
857
1968
|
talkFocused() {
|
|
858
1969
|
return document.activeElement === panelInput;
|
|
859
1970
|
},
|
|
860
1971
|
// `doors` is [{ id, title }] to offer, or null for none; `goText` is the
|
|
861
|
-
// word on each one's button ("Go", or "Go together" in a party).
|
|
862
|
-
|
|
1972
|
+
// word on each one's button ("Go", or "Go together" in a party). `stuck`
|
|
1973
|
+
// (v1.33, a deck with `hub.stuck`) is `{ where, onPick }`, a "Stuck?" row
|
|
1974
|
+
// over the doors that goes back to the place's arrival; null for none.
|
|
1975
|
+
setDoors(doors, goText = 'Go', stuck = null, yours = null) {
|
|
863
1976
|
const show = Array.isArray(doors) && doors.length > 0;
|
|
864
1977
|
doorsButton.style.display = show ? 'block' : 'none';
|
|
865
1978
|
if (!show) {
|
|
@@ -867,23 +1980,53 @@ export function makeChrome({ onBack, onAvatar, avatarCount, onPerson = () => {},
|
|
|
867
1980
|
doorsKey = '';
|
|
868
1981
|
return;
|
|
869
1982
|
}
|
|
870
|
-
const
|
|
1983
|
+
const yourRows = yours?.rows?.slice(0, desktop() ? 5 : 3) ?? [];
|
|
1984
|
+
const yourKey = yours ? JSON.stringify([yourRows, yours.hearts ?? null]) : '';
|
|
1985
|
+
const key = `${yourKey}${goText}#${doors.map((d) => `${d.id}:${d.title ?? ''}:${d.featured ? 'f' : ''}${d.solo ? 's' : ''}${d.need ?? ''}`).join('|')}${stuck ? `#stuck:${stuck.where}` : ''}`;
|
|
1986
|
+
if (stuck) {
|
|
1987
|
+
stuckRowPick = stuck.onPick;
|
|
1988
|
+
}
|
|
871
1989
|
if (key === doorsKey) {
|
|
872
1990
|
return;
|
|
873
1991
|
}
|
|
874
1992
|
doorsKey = key;
|
|
875
1993
|
doorsList.replaceChildren();
|
|
876
|
-
|
|
1994
|
+
if (stuck) {
|
|
1995
|
+
const row = el('div', { display: 'flex', alignItems: 'center', gap: '8px', paddingBottom: '6px', borderBottom: '1px solid rgba(255,255,255,0.18)' }, doorsList);
|
|
1996
|
+
row.dataset.hub = 'stuck-row';
|
|
1997
|
+
const words = el('div', { flex: '1', minWidth: '0' }, row);
|
|
1998
|
+
el('div', { overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap' }, words).textContent = 'Stuck?';
|
|
1999
|
+
el('div', { fontSize: '11px', fontWeight: '500', opacity: '0.7', overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap' }, words).textContent = stuck.where;
|
|
2000
|
+
const go = smallButton(row, 'Go', false);
|
|
2001
|
+
go.style.flex = 'none';
|
|
2002
|
+
go.setAttribute('aria-label', `Stuck? ${stuck.where}`);
|
|
2003
|
+
go.addEventListener('pointerdown', (event) => {
|
|
2004
|
+
event.stopPropagation();
|
|
2005
|
+
closeDoors();
|
|
2006
|
+
stuckRowPick();
|
|
2007
|
+
});
|
|
2008
|
+
}
|
|
2009
|
+
if (yourRows.length) {
|
|
2010
|
+
el('div', { fontSize: '13px', opacity: '0.8' }, doorsList).textContent = 'Your games';
|
|
2011
|
+
}
|
|
2012
|
+
const listed = [...yourRows.map((r) => ({ ...doors.find((d) => d.id === r.door), title: r.title, line: r.line, yours: true })), ...doors];
|
|
2013
|
+
for (const [index, door] of listed.entries()) {
|
|
2014
|
+
if (index === yourRows.length && yourRows.length) {
|
|
2015
|
+
el('div', { fontSize: '13px', opacity: '0.8', borderTop: '1px solid rgba(255,255,255,0.18)', paddingTop: '8px' }, doorsList).textContent = 'All doors';
|
|
2016
|
+
}
|
|
877
2017
|
const row = el('div', { display: 'flex', alignItems: 'center', gap: '8px' }, doorsList);
|
|
878
2018
|
// The title on a line of its own, with one short word under it on what
|
|
879
2019
|
// the door takes (a solo game, how many it needs): beside the button
|
|
880
2020
|
// they squeezed the title to a few letters.
|
|
881
2021
|
const words = el('div', { flex: '1', minWidth: '0' }, row);
|
|
882
2022
|
const name = el('div', { overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap' }, words);
|
|
883
|
-
name.textContent = `${door.featured ? '★ ' : ''}${door.title ?? door.id}`;
|
|
884
|
-
const takes = door.solo ? 'solo' : door.need ? `needs ${door.need}` : '';
|
|
2023
|
+
name.textContent = `${door.featured && !door.yours ? '★ ' : ''}${door.title ?? door.id}`;
|
|
2024
|
+
const takes = door.yours ? door.line : door.solo ? 'solo' : door.need ? `needs ${door.need}` : '';
|
|
885
2025
|
if (takes) {
|
|
886
|
-
el('div', { fontSize: '11px', fontWeight: '500', opacity: '0.7' }, words).textContent = takes;
|
|
2026
|
+
el('div', { fontSize: '11px', fontWeight: '500', opacity: '0.7', ...(door.yours ? { overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap' } : {}) }, words).textContent = takes;
|
|
2027
|
+
}
|
|
2028
|
+
if (yours?.hearts) {
|
|
2029
|
+
heartButton(row, door.id, yours.hearts.includes(door.id));
|
|
887
2030
|
}
|
|
888
2031
|
const go = el('button', { padding: '5px 12px', borderRadius: '12px', border: 'none', background: '#e9c48f', color: '#2b2118', font: '700 13px system-ui, sans-serif', cursor: 'pointer' }, row);
|
|
889
2032
|
// A party cannot go together through a door that takes one player.
|
|
@@ -892,6 +2035,9 @@ export function makeChrome({ onBack, onAvatar, avatarCount, onPerson = () => {},
|
|
|
892
2035
|
go.addEventListener('pointerdown', (event) => {
|
|
893
2036
|
event.stopPropagation();
|
|
894
2037
|
closeDoors();
|
|
2038
|
+
if (onChip) {
|
|
2039
|
+
onChip();
|
|
2040
|
+
}
|
|
895
2041
|
onJumpDoor(door);
|
|
896
2042
|
});
|
|
897
2043
|
}
|
|
@@ -946,6 +2092,12 @@ export function makeChrome({ onBack, onAvatar, avatarCount, onPerson = () => {},
|
|
|
946
2092
|
// the friend themself. Anything not listed is removed.
|
|
947
2093
|
setPointers(items) {
|
|
948
2094
|
const seen = new Set();
|
|
2095
|
+
// The round buttons an edge chip is kept beside, never under (v1.38: a
|
|
2096
|
+
// chip at the right edge had half its words under the chat button).
|
|
2097
|
+
// Read once a call, and only when there is an edge chip.
|
|
2098
|
+
const buttons = items.some((item) => item.angle !== null && item.angle !== undefined)
|
|
2099
|
+
? [sayButton, emoteButton, grabButton, sound?.button].map(shownRect).filter(Boolean)
|
|
2100
|
+
: [];
|
|
949
2101
|
for (const item of items) {
|
|
950
2102
|
seen.add(item.id);
|
|
951
2103
|
let node = pointerNodes.get(item.id);
|
|
@@ -967,10 +2119,30 @@ export function makeChrome({ onBack, onAvatar, avatarCount, onPerson = () => {},
|
|
|
967
2119
|
}
|
|
968
2120
|
// Kept whole on screen; over a friend it sits above their head.
|
|
969
2121
|
const half = node.chip.offsetWidth / 2;
|
|
970
|
-
|
|
2122
|
+
let x = Math.min(Math.max(item.x, half + 6), window.innerWidth - half - 6);
|
|
2123
|
+
let y = item.y;
|
|
2124
|
+
if (edge && buttons.length) {
|
|
2125
|
+
// The buttons stand in a column at the edge. A chip over any of them
|
|
2126
|
+
// goes to the left of them all; one too wide for that goes over the
|
|
2127
|
+
// whole column it lies across, or under it with no room over. So no
|
|
2128
|
+
// move away from one button can put it on another.
|
|
2129
|
+
const tall = node.chip.offsetHeight / 2;
|
|
2130
|
+
const across = (r) => x + half > r.left - 4 && x - half < r.right + 4;
|
|
2131
|
+
if (buttons.some((r) => across(r) && y + tall > r.top && y - tall < r.bottom)) {
|
|
2132
|
+
const left = Math.min(...buttons.map((r) => r.left)) - 6 - half;
|
|
2133
|
+
if (left >= half + 6) {
|
|
2134
|
+
x = left;
|
|
2135
|
+
} else {
|
|
2136
|
+
const column = buttons.filter(across);
|
|
2137
|
+
const over = Math.min(...column.map((r) => r.top)) - 6 - tall;
|
|
2138
|
+
y = over >= tall + 6 ? over : Math.max(...column.map((r) => r.bottom)) + 6 + tall;
|
|
2139
|
+
}
|
|
2140
|
+
}
|
|
2141
|
+
}
|
|
971
2142
|
node.chip.style.transform = edge ? 'translate(-50%, -50%)' : 'translate(-50%, -100%)';
|
|
972
2143
|
node.chip.style.left = `${x}px`;
|
|
973
|
-
node.chip.style.top = `${
|
|
2144
|
+
node.chip.style.top = `${y}px`;
|
|
2145
|
+
node.y = y;
|
|
974
2146
|
}
|
|
975
2147
|
for (const [id, node] of pointerNodes) {
|
|
976
2148
|
if (!seen.has(id)) {
|
|
@@ -978,6 +2150,16 @@ export function makeChrome({ onBack, onAvatar, avatarCount, onPerson = () => {},
|
|
|
978
2150
|
pointerNodes.delete(id);
|
|
979
2151
|
}
|
|
980
2152
|
}
|
|
2153
|
+
if (hudClear) {
|
|
2154
|
+
keepClearOfHud(
|
|
2155
|
+
'pointers',
|
|
2156
|
+
items.map((item) => {
|
|
2157
|
+
const chip = pointerNodes.get(item.id).chip;
|
|
2158
|
+
const edge = item.angle !== null && item.angle !== undefined;
|
|
2159
|
+
return [chip, parseFloat(chip.style.left), pointerNodes.get(item.id).y, edge ? 'center' : 'bottom', `${edge ? '>' : ''}${item.text}`];
|
|
2160
|
+
}),
|
|
2161
|
+
);
|
|
2162
|
+
}
|
|
981
2163
|
},
|
|
982
2164
|
// `ask` is { key, text, yes, no } (the words and the two buttons'), or
|
|
983
2165
|
// null for none; an answer goes to `onAsk(ask, true | false)`.
|
|
@@ -989,7 +2171,21 @@ export function makeChrome({ onBack, onAvatar, avatarCount, onPerson = () => {},
|
|
|
989
2171
|
}
|
|
990
2172
|
askKey = ask.key;
|
|
991
2173
|
askCard.replaceChildren();
|
|
992
|
-
|
|
2174
|
+
if (ask.kind === 'yours') {
|
|
2175
|
+
askCard.style.width = 'min(94vw, 420px)';
|
|
2176
|
+
} else if (askCard.style.width !== 'min(86vw, 320px)') {
|
|
2177
|
+
askCard.style.width = 'min(86vw, 320px)';
|
|
2178
|
+
}
|
|
2179
|
+
if (ask.kind === 'yours') {
|
|
2180
|
+
const words = el('div', { flex: '1', minWidth: '0', fontWeight: '600', overflow: 'hidden' }, askCard);
|
|
2181
|
+
el('div', { overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap' }, words).textContent = ask.text;
|
|
2182
|
+
el('div', { fontSize: '11px', fontWeight: '500', opacity: '0.7', overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap' }, words).textContent = ask.line;
|
|
2183
|
+
if (typeof ask.heart === 'boolean') {
|
|
2184
|
+
heartButton(askCard, ask.door, ask.heart);
|
|
2185
|
+
}
|
|
2186
|
+
} else {
|
|
2187
|
+
el('div', { flex: '1', minWidth: '0', fontWeight: '600' }, askCard).textContent = ask.text;
|
|
2188
|
+
}
|
|
993
2189
|
for (const [text, answer] of [[ask.yes, true], [ask.no, false]]) {
|
|
994
2190
|
smallButton(askCard, text, answer).addEventListener('pointerdown', (event) => {
|
|
995
2191
|
event.stopPropagation();
|
|
@@ -1011,6 +2207,83 @@ export function makeChrome({ onBack, onAvatar, avatarCount, onPerson = () => {},
|
|
|
1011
2207
|
}
|
|
1012
2208
|
}
|
|
1013
2209
|
},
|
|
2210
|
+
// The "Stuck?" chip (v1.33): its words, or null to hide it; a press calls
|
|
2211
|
+
// `handler`. Never over an open card or list, like the invite button, and
|
|
2212
|
+
// never over the HUD, a question, another control, a cabinet's card or
|
|
2213
|
+
// the ribbon (`placeStuckChip`). Said last in a frame: after the other
|
|
2214
|
+
// setters and after `flushHudClear`, whose final boxes it is placed by.
|
|
2215
|
+
stuckPrompt(text, handler) {
|
|
2216
|
+
if (!text && !stuckChip) {
|
|
2217
|
+
return;
|
|
2218
|
+
}
|
|
2219
|
+
stuckChip ??= buildStuckChip();
|
|
2220
|
+
if (text) {
|
|
2221
|
+
stuckHandler = handler;
|
|
2222
|
+
if (stuckChip.textContent !== text) {
|
|
2223
|
+
stuckChip.textContent = text;
|
|
2224
|
+
}
|
|
2225
|
+
}
|
|
2226
|
+
const show = Boolean(text) && !sayOpen && !emotesOpen && !peopleOpen && !doorsOpen && !talkOpen;
|
|
2227
|
+
if (show && stuckChip.style.display !== 'block') {
|
|
2228
|
+
// Laid out before it is measured; nothing is painted in between.
|
|
2229
|
+
stuckChip.style.display = 'block';
|
|
2230
|
+
}
|
|
2231
|
+
// The toast leaves the chip's spot clear before the chip looks for the
|
|
2232
|
+
// toast, by where it hangs and not by whether it is drawn.
|
|
2233
|
+
const was = stuckSpot;
|
|
2234
|
+
if (show) {
|
|
2235
|
+
const w = stuckChip.offsetWidth;
|
|
2236
|
+
const x = stuckChip.offsetLeft;
|
|
2237
|
+
const y = stuckChip.offsetTop;
|
|
2238
|
+
const h = stuckChip.offsetHeight;
|
|
2239
|
+
stuckSpot = was && was.left === x - w / 2 && was.right === x + w / 2 && was.top === y && was.bottom === y + h ? was : { left: x - w / 2, right: x + w / 2, top: y, bottom: y + h };
|
|
2240
|
+
} else {
|
|
2241
|
+
stuckSpot = null;
|
|
2242
|
+
}
|
|
2243
|
+
if (stuckSpot !== was) {
|
|
2244
|
+
placeToast();
|
|
2245
|
+
}
|
|
2246
|
+
if (!show || !placeStuckChip()) {
|
|
2247
|
+
stuckChip.style.display = 'none';
|
|
2248
|
+
}
|
|
2249
|
+
},
|
|
2250
|
+
// The sound control (a deck with `hub.soundscape`): `show` whether the
|
|
2251
|
+
// button is up, `state` `{ volume, muted }` (0 to 1), `handlers`
|
|
2252
|
+
// `{ onVolume(0..1), onMuted(bool) }`. Never called in a deck without the
|
|
2253
|
+
// key, and nothing of it exists until it is.
|
|
2254
|
+
soundControl(show, state, handlers) {
|
|
2255
|
+
if (!show && !sound) {
|
|
2256
|
+
return;
|
|
2257
|
+
}
|
|
2258
|
+
sound ??= buildSound();
|
|
2259
|
+
sound.handlers = handlers ?? sound.handlers;
|
|
2260
|
+
const percent = Math.round((state?.volume ?? 0) * 100);
|
|
2261
|
+
const muted = state?.muted === true;
|
|
2262
|
+
const key = `${show ? 1 : 0}|${muted ? 1 : 0}|${percent}|${stats.textContent ? 1 : 0}`;
|
|
2263
|
+
if (key === sound.key) {
|
|
2264
|
+
return;
|
|
2265
|
+
}
|
|
2266
|
+
sound.key = key;
|
|
2267
|
+
sound.muted = muted;
|
|
2268
|
+
if (!show) {
|
|
2269
|
+
sound.open = false;
|
|
2270
|
+
sound.card.style.display = 'none';
|
|
2271
|
+
}
|
|
2272
|
+
sound.button.style.display = show ? 'block' : 'none';
|
|
2273
|
+
// Under the frame-rate readout where that is up (`?hubstats`).
|
|
2274
|
+
const top = stats.textContent ? `${stats.offsetTop + stats.offsetHeight + 6}px` : 'max(12px, env(safe-area-inset-top))';
|
|
2275
|
+
sound.button.style.top = top;
|
|
2276
|
+
sound.card.style.top = `calc(${top} + 46px)`;
|
|
2277
|
+
const quiet = muted || percent === 0;
|
|
2278
|
+
sound.button.textContent = quiet ? '🔇' : '🔊';
|
|
2279
|
+
sound.button.setAttribute('aria-label', quiet ? 'Sound: off' : `Sound: ${percent}%`);
|
|
2280
|
+
sound.mute.textContent = muted ? 'Unmute' : 'Mute';
|
|
2281
|
+
sound.slider.style.opacity = muted ? '0.5' : '1';
|
|
2282
|
+
// Not while the player drags it: the value is theirs then.
|
|
2283
|
+
if (document.activeElement !== sound.slider && sound.slider.value !== String(percent)) {
|
|
2284
|
+
sound.slider.value = String(percent);
|
|
2285
|
+
}
|
|
2286
|
+
},
|
|
1014
2287
|
// Whether the People list is open (its rows' places are asked for then).
|
|
1015
2288
|
peopleOpen: () => peopleOpen,
|
|
1016
2289
|
setStats(text) {
|
|
@@ -1020,8 +2293,19 @@ export function makeChrome({ onBack, onAvatar, avatarCount, onPerson = () => {},
|
|
|
1020
2293
|
}
|
|
1021
2294
|
},
|
|
1022
2295
|
dispose() {
|
|
2296
|
+
if (placeMenu) {clearMenu();}
|
|
2297
|
+
if (textAsk) {
|
|
2298
|
+
clearTextAsk();
|
|
2299
|
+
}
|
|
2300
|
+
if (actionChips) {
|
|
2301
|
+
clearActions();
|
|
2302
|
+
}
|
|
2303
|
+
if (hudClearDrawn) {
|
|
2304
|
+
restoreHudClear();
|
|
2305
|
+
}
|
|
1023
2306
|
unguardKeys();
|
|
1024
2307
|
desktopQuery?.removeEventListener?.('change', layoutPanel);
|
|
2308
|
+
labelMeasure?.remove();
|
|
1025
2309
|
root.remove();
|
|
1026
2310
|
},
|
|
1027
2311
|
};
|