@songsid/agend 2.4.0-beta.15 → 2.4.0-beta.17
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/accounts-profiles.d.ts +1 -1
- package/dist/accounts-view.d.ts +3 -0
- package/dist/accounts-view.js.map +1 -1
- package/dist/auth-api.js +6 -0
- package/dist/auth-api.js.map +1 -1
- package/dist/backend/claude-code.d.ts +15 -1
- package/dist/backend/claude-code.js +64 -8
- package/dist/backend/claude-code.js.map +1 -1
- package/dist/backend/kiro.js +6 -1
- package/dist/backend/kiro.js.map +1 -1
- package/dist/backend/types.d.ts +8 -0
- package/dist/backend/types.js.map +1 -1
- package/dist/backend-command.d.ts +4 -2
- package/dist/backend-command.js +3 -0
- package/dist/backend-command.js.map +1 -1
- package/dist/browser-backend-signins.d.ts +1 -0
- package/dist/browser-backend-signins.js +3 -1
- package/dist/browser-backend-signins.js.map +1 -1
- package/dist/build-provenance.json +1 -1
- package/dist/classic-channel-manager.d.ts +1 -0
- package/dist/classic-channel-manager.js +4 -1
- package/dist/classic-channel-manager.js.map +1 -1
- package/dist/claude-credential-change.d.ts +22 -0
- package/dist/claude-credential-change.js +47 -0
- package/dist/claude-credential-change.js.map +1 -0
- package/dist/claude-credential-launch.d.ts +63 -0
- package/dist/claude-credential-launch.js +315 -0
- package/dist/claude-credential-launch.js.map +1 -0
- package/dist/claude-credential-runner.d.ts +1 -0
- package/dist/claude-credential-runner.js +56 -0
- package/dist/claude-credential-runner.js.map +1 -0
- package/dist/claude-credential-vault.d.ts +57 -0
- package/dist/claude-credential-vault.js +277 -0
- package/dist/claude-credential-vault.js.map +1 -0
- package/dist/claude-request-observation.d.ts +7 -0
- package/dist/claude-request-observation.js +26 -0
- package/dist/claude-request-observation.js.map +1 -0
- package/dist/claude-setup-token-transport.d.ts +9 -0
- package/dist/claude-setup-token-transport.js +82 -0
- package/dist/claude-setup-token-transport.js.map +1 -0
- package/dist/claude-setup-token.d.ts +51 -0
- package/dist/claude-setup-token.js +83 -0
- package/dist/claude-setup-token.js.map +1 -0
- package/dist/cli-audited.js +15 -12
- package/dist/cli-audited.js.map +1 -1
- package/dist/command-report.d.ts +11 -0
- package/dist/command-report.js +2 -0
- package/dist/command-report.js.map +1 -0
- package/dist/config-validator.js +9 -0
- package/dist/config-validator.js.map +1 -1
- package/dist/config.js +4 -2
- package/dist/config.js.map +1 -1
- package/dist/daemon.d.ts +5 -0
- package/dist/daemon.js +65 -3
- package/dist/daemon.js.map +1 -1
- package/dist/fleet-level-config.d.ts +1 -1
- package/dist/fleet-level-config.js +1 -0
- package/dist/fleet-level-config.js.map +1 -1
- package/dist/fleet-manager.d.ts +53 -2
- package/dist/fleet-manager.js +511 -22
- package/dist/fleet-manager.js.map +1 -1
- package/dist/general-knowledge/skills/web-appearance/SKILL.md +4 -1
- package/dist/general-knowledge/skills/web-dashboard/SKILL.md +25 -6
- package/dist/host-monitoring-config.d.ts +15 -0
- package/dist/host-monitoring-config.js +36 -0
- package/dist/host-monitoring-config.js.map +1 -0
- package/dist/host-monitoring-history-files.d.ts +2 -0
- package/dist/host-monitoring-history-files.js +16 -0
- package/dist/host-monitoring-history-files.js.map +1 -0
- package/dist/host-monitoring-history-policy.d.ts +55 -0
- package/dist/host-monitoring-history-policy.js +93 -0
- package/dist/host-monitoring-history-policy.js.map +1 -0
- package/dist/host-monitoring-history-store.d.ts +52 -0
- package/dist/host-monitoring-history-store.js +176 -0
- package/dist/host-monitoring-history-store.js.map +1 -0
- package/dist/host-monitoring-history-worker.d.ts +1 -0
- package/dist/host-monitoring-history-worker.js +50 -0
- package/dist/host-monitoring-history-worker.js.map +1 -0
- package/dist/host-monitoring-history.d.ts +71 -0
- package/dist/host-monitoring-history.js +265 -0
- package/dist/host-monitoring-history.js.map +1 -0
- package/dist/host-monitoring-platform.d.ts +73 -0
- package/dist/host-monitoring-platform.js +273 -0
- package/dist/host-monitoring-platform.js.map +1 -0
- package/dist/host-monitoring-runtime.d.ts +34 -0
- package/dist/host-monitoring-runtime.js +80 -0
- package/dist/host-monitoring-runtime.js.map +1 -0
- package/dist/host-monitoring-settings-store.d.ts +5 -0
- package/dist/host-monitoring-settings-store.js +49 -0
- package/dist/host-monitoring-settings-store.js.map +1 -0
- package/dist/host-monitoring.d.ts +106 -0
- package/dist/host-monitoring.js +157 -0
- package/dist/host-monitoring.js.map +1 -0
- package/dist/hub/group-policy/resources.d.ts +1 -1
- package/dist/instance-config-impact.js +1 -1
- package/dist/instance-config-impact.js.map +1 -1
- package/dist/instructions.js +1 -0
- package/dist/instructions.js.map +1 -1
- package/dist/locale.d.ts +2 -0
- package/dist/locale.js +13 -1
- package/dist/locale.js.map +1 -1
- package/dist/office-share-page.js +1 -1
- package/dist/office-share-page.js.map +1 -1
- package/dist/profile-signins.d.ts +1 -0
- package/dist/profile-signins.js +3 -1
- package/dist/profile-signins.js.map +1 -1
- package/dist/public-web-gateway.js +6 -0
- package/dist/public-web-gateway.js.map +1 -1
- package/dist/public-web-link.d.ts +21 -2
- package/dist/public-web-link.js +22 -2
- package/dist/public-web-link.js.map +1 -1
- package/dist/runtime-cli-install.js +17 -16
- package/dist/runtime-cli-install.js.map +1 -1
- package/dist/settings-api.d.ts +15 -0
- package/dist/settings-api.js +154 -8
- package/dist/settings-api.js.map +1 -1
- package/dist/settings-baseline.d.ts +1 -0
- package/dist/settings-baseline.js +5 -4
- package/dist/settings-baseline.js.map +1 -1
- package/dist/settings-change.js +10 -0
- package/dist/settings-change.js.map +1 -1
- package/dist/settings-effect.d.ts +2 -0
- package/dist/settings-effect.js +15 -1
- package/dist/settings-effect.js.map +1 -1
- package/dist/topic-commands.d.ts +7 -1
- package/dist/topic-commands.js +98 -88
- package/dist/topic-commands.js.map +1 -1
- package/dist/transcript-monitor.d.ts +1 -0
- package/dist/transcript-monitor.js +18 -0
- package/dist/transcript-monitor.js.map +1 -1
- package/dist/types.d.ts +2 -0
- package/dist/ui/accounts-view.js +16 -8
- package/dist/ui/backend-signin.js +3 -1
- package/dist/ui/chat-commands.js +2 -0
- package/dist/ui/chat-popout-transport.js +49 -19
- package/dist/ui/chat-popout.js +15 -1
- package/dist/ui/chat-store.js +1 -1
- package/dist/ui/claude-credentials.js +123 -0
- package/dist/ui/claude-setup-token.js +36 -0
- package/dist/ui/contact-auth-client.js +7 -2
- package/dist/ui/contact-auth-strings.js +45 -14
- package/dist/ui/contact-authorizations.js +47 -26
- package/dist/ui/contact-needs.js +4 -4
- package/dist/ui/fleet-canvas.js +3 -2
- package/dist/ui/fleet-office-card.js +414 -41
- package/dist/ui/fleet-office-dialogue.js +3 -3
- package/dist/ui/fleet-office-pack.d.ts +67 -1
- package/dist/ui/fleet-office-pack.js +412 -18
- package/dist/ui/fleet-office-play.js +401 -3
- package/dist/ui/fleet-office-skin.js +133 -21
- package/dist/ui/fleet-office-store.js +41 -0
- package/dist/ui/fleet-office-zones.js +34 -9
- package/dist/ui/fleet-office.js +513 -62
- package/dist/ui/host-health-model.js +42 -0
- package/dist/ui/host-health.js +74 -0
- package/dist/ui/office-share-page.js +5 -1
- package/dist/ui/panel-chat.js +146 -46
- package/dist/ui/panel-fleet.js +24 -11
- package/dist/ui/panel-hub.js +5 -1
- package/dist/ui/panel-settings.js +5 -4
- package/dist/ui/preview-popout.js +134 -0
- package/dist/ui/reply-file-preview.js +1 -1
- package/dist/ui/search-dialog.js +8 -1
- package/dist/ui/settings-capabilities.js +2 -0
- package/dist/ui/settings-host-monitoring.js +69 -0
- package/dist/ui/settings-registry.js +4 -1
- package/dist/ui/settings-shared.js +3 -2
- package/dist/ui/shared/accounts.css +8 -4
- package/dist/ui/shared/agent-sheet.js +5 -2
- package/dist/ui/shared/app-route.js +1 -1
- package/dist/ui/shared/app.css +248 -27
- package/dist/ui/shared/app.js +8 -1
- package/dist/ui/shared/chat-strings.js +10 -4
- package/dist/ui/shared/chat-thread.js +42 -10
- package/dist/ui/shared/info-tip.js +64 -0
- package/dist/ui/shared/instance-nav.js +47 -5
- package/dist/ui/shared/jump-idle.js +36 -0
- package/dist/ui/shared/office-dialogue.css +12 -0
- package/dist/ui/shared/preview-panel.js +44 -18
- package/dist/ui/shared/preview-popout.css +11 -0
- package/dist/ui/shared/theme.js +15 -1
- package/dist/ui/shared/ui-menu.js +17 -11
- package/dist/ui/shared/usage-dialog.js +9 -34
- package/dist/ui/shared/view-strings.js +2 -0
- package/dist/usage/i18n-keys.d.ts +1 -1
- package/dist/usage/i18n-keys.js +1 -1
- package/dist/usage/i18n-keys.js.map +1 -1
- package/dist/usage/providers.d.ts +1 -0
- package/dist/usage/providers.js +14 -1
- package/dist/usage/providers.js.map +1 -1
- package/dist/usage/usage-api.js +5 -2
- package/dist/usage/usage-api.js.map +1 -1
- package/dist/web-api.d.ts +6 -1
- package/dist/web-api.js +83 -9
- package/dist/web-api.js.map +1 -1
- package/dist/web-chat-history.d.ts +7 -1
- package/dist/web-chat-history.js +19 -3
- package/dist/web-chat-history.js.map +1 -1
- package/dist/web-claude-credentials.d.ts +31 -0
- package/dist/web-claude-credentials.js +138 -0
- package/dist/web-claude-credentials.js.map +1 -0
- package/dist/web-commands.d.ts +5 -2
- package/dist/web-commands.js +4 -2
- package/dist/web-commands.js.map +1 -1
- package/dist/web-office-skins.d.ts +7 -2
- package/dist/web-office-skins.js +42 -16
- package/dist/web-office-skins.js.map +1 -1
- package/dist/web-session.d.ts +20 -1
- package/dist/web-session.js +27 -0
- package/dist/web-session.js.map +1 -1
- package/dist/web-shell-routes.d.ts +1 -1
- package/dist/web-shell-routes.js +1 -1
- package/dist/web-shell-routes.js.map +1 -1
- package/dist/web-terminal.d.ts +4 -0
- package/dist/web-terminal.js +16 -1
- package/dist/web-terminal.js.map +1 -1
- package/package.json +1 -1
package/dist/ui/fleet-office.js
CHANGED
|
@@ -60,6 +60,7 @@
|
|
|
60
60
|
// (inline ticks wrapped the bar at ~10). The offices and the interval are kept per browser; playing starts on enter
|
|
61
61
|
// and on reload. Space pauses, ← / → (and N / P, media keys) step; Pause and Next on the bar and in fullscreen.
|
|
62
62
|
// Edit offices and Edit layout wait. A share link does not offer it.
|
|
63
|
+
import { assetUrl } from "/assets/asset-url.js";
|
|
63
64
|
import { html, useEffect, useLayoutEffect, useMemo, useRef, useState } from "/assets/app-html.js";
|
|
64
65
|
import { appStore } from "/assets/app-store.js";
|
|
65
66
|
import { t, lang, register } from "/assets/app-i18n.js";
|
|
@@ -71,18 +72,18 @@ import { hits, needle } from "./fleet-canvas-layout.js";
|
|
|
71
72
|
import { AUTO_ID, LOBBY, autoLayout, backingScale, coatOf, createFlights, customLayout, deskAt, desksOf, filterOk, lampOf, layoutOk, lightOf, membersOf,
|
|
72
73
|
officePose, officeRooms, signOf, workOn } from "./fleet-office-model.js";
|
|
73
74
|
import { BUILT_IN_SKINS, CHAR_DEPTH, DEFAULT_PAL, PICTURE_SKINS, bubbleBox, pixelSkin, loadBuiltInSkin, loadPackSkin, modeOf, skinFor, tagBox, tagFootprint } from "./fleet-office-skin.js";
|
|
74
|
-
import { CALLING, activeFurniture, bubbleAt, hiddenBy, bubbleRank, NIGHT, WANDER, createMail, createWalkers, isNight, linesFor, npcKey, personAt, placeBubbles, thinBubbles, walkTargets, zonesLayout } from "./fleet-office-zones.js";
|
|
75
|
+
import { CALLING, activeFurniture, bubbleAt, hiddenBy, bubbleRank, NIGHT, WANDER, createMail, createWalkers, isNight, linesFor, npcKey, personAt, placeBubbles, routeStaysInArea, thinBubbles, walkTargets, zonesLayout } from "./fleet-office-zones.js";
|
|
75
76
|
import { actsOk, createOfficeStore } from "./fleet-office-store.js";
|
|
76
77
|
import { badgeOf, fixedOf, mergeLevels } from "./fleet-office-levels.js";
|
|
77
78
|
import { OfficeCard, cardModel } from "./fleet-office-card.js";
|
|
78
|
-
import { PLAY, createHold, playAllowed, pruneReactions, reactionAt } from "./fleet-office-play.js";
|
|
79
|
+
import { PLAY, applySeatDrop, clampDropForArea, createHold, createSnackDrag, createSnacks, findSeatDropTarget, playAllowed, pruneReactions, reactionAt, scatterWords, seatDropTargets } from "./fleet-office-play.js";
|
|
79
80
|
import { POLL_MS } from "./fleet-traffic.js";
|
|
80
81
|
import { OfficeEditor, officeForSave } from "./fleet-office-editor.js";
|
|
81
82
|
import { LayoutEditor, handlesOf } from "./fleet-office-layout.js";
|
|
82
83
|
import { ShareButton } from "./office-share-dialog.js";
|
|
83
84
|
import { Dialog } from "/assets/ui-dialog.js";
|
|
84
85
|
import { DLG, boxColours, boxLayout, createDialogue, createFaces, drawBox, fitBox, messageOf, onBox, pickFront, portraitSrc, stageOf, talkOf, wrap } from "./fleet-office-dialogue.js";
|
|
85
|
-
import { applyOverrides, fitNight, fitSeatFor, stripBox } from "./fleet-office-pack.js";
|
|
86
|
+
import { applyOverrides, createClipClocks, fitNight, fitSeatFor, packMaxFps, snackLabel, stripBox } from "./fleet-office-pack.js";
|
|
86
87
|
import { ALL_ID, LOBBY_TILE, OV, createCrossFlights, cropToRooms, fromTile, inTile, labelAt, lobbyNodes, overviewOk, tileAt, tileBox, tileLayout, visibleTiles } from "./fleet-office-overview.js";
|
|
87
88
|
import { CAROUSEL_ID, INTERVALS, carouselHeld, carouselIdsOk, carouselKey, carouselOk, intervalOk, nextIndex, prevIndex } from "./fleet-office-carousel.js";
|
|
88
89
|
import { centreOn, gestureState, gestures, miniPoint, toScreen, toWorld, wheelFactor, zoomKey, zoomTo } from "./fleet-canvas-view.js";
|
|
@@ -115,9 +116,11 @@ register("orgo", {
|
|
|
115
116
|
officesInCarousel: "Offices in the carousel",
|
|
116
117
|
officesCount: "Carousel {0}/{1} offices ▾", selectAll: "Select all", selectNone: "Select none",
|
|
117
118
|
dialogue: "Dialogue", dialogueTitle: "When a person messages someone here, show their words and the reply in a box at the bottom (this browser only)",
|
|
118
|
-
dlgWorking: "Working…", dlgSomeone: "Someone", dlgHeardShare: "Sent {0} a message.", dlgAnsweredShare: "Replied.", dlgFile: "(sent a file)", dlgSays: "{0}: {1}",
|
|
119
|
+
dlgOpenChat: "Open the agent’s chat in a new window", dlgWorking: "Working…", dlgSomeone: "Someone", dlgHeardShare: "Sent {0} a message.", dlgAnsweredShare: "Replied.", dlgFile: "(sent a file)", dlgSays: "{0}: {1}",
|
|
119
120
|
dlgBox: "Dialogue: {0}. Click for their card, double-click for their chat.",
|
|
120
121
|
zones: "Go to an area", zoneAll: "Whole office", zoneN: "{0} {1}",
|
|
122
|
+
snacks: "Snacks", snackFeed: "Feed {0}", snackPlace: "Place here",
|
|
123
|
+
snackArm: "{0}: drag onto someone to feed, or onto the floor to place; click to select",
|
|
121
124
|
},
|
|
122
125
|
"zh-TW": {
|
|
123
126
|
label: "辦公室:每個 team 是一間房間,每個 Agent 一張桌子;General 和未加入 team 的 Agent 在大廳。拖曳平移;滾輪、雙指、+ 和 − 縮放,0 顯示整個場景,F 切換全螢幕。",
|
|
@@ -144,9 +147,11 @@ register("orgo", {
|
|
|
144
147
|
officesInCarousel: "輪播的辦公室",
|
|
145
148
|
officesCount: "輪播 {0}/{1} 間 ▾", selectAll: "全選", selectNone: "全不選",
|
|
146
149
|
dialogue: "對話框", dialogueTitle: "有人傳訊息給這裡的成員時,在下方的對話框顯示訊息與回覆(只限這個瀏覽器)",
|
|
147
|
-
dlgWorking: "處理中…", dlgSomeone: "有人", dlgHeardShare: "傳了一則訊息給 {0}。", dlgAnsweredShare: "已回覆。", dlgFile: "(傳了一個檔案)", dlgSays: "{0}:{1}",
|
|
150
|
+
dlgOpenChat: "在新視窗開啟這個 Agent 的聊天", dlgWorking: "處理中…", dlgSomeone: "有人", dlgHeardShare: "傳了一則訊息給 {0}。", dlgAnsweredShare: "已回覆。", dlgFile: "(傳了一個檔案)", dlgSays: "{0}:{1}",
|
|
148
151
|
dlgBox: "對話框:{0}。點一下看資料卡,點兩下開啟聊天。",
|
|
149
152
|
zones: "移到區域", zoneAll: "總覽", zoneN: "{0} {1}",
|
|
153
|
+
snacks: "零食", snackFeed: "餵給 {0}", snackPlace: "放在這裡",
|
|
154
|
+
snackArm: "{0}:拖到成員身上餵食,或放到空地讓閒置成員過來搶;點一下可選取",
|
|
150
155
|
},
|
|
151
156
|
});
|
|
152
157
|
const to = (k, ...v) => t(`orgo.${k}`, ...v);
|
|
@@ -453,12 +458,26 @@ function paintLayers(p, env, ls, tagsOff = false) {
|
|
|
453
458
|
});
|
|
454
459
|
return { ls, tagsOff, back, front };
|
|
455
460
|
}
|
|
461
|
+
/** Final painted bubbles, topmost first; touch adds a 44 CSS-pixel target without changing the drawing. */
|
|
462
|
+
export function officeBubbleAt(hits, x, y, minSize = 0) {
|
|
463
|
+
const reversed = [...hits].reverse();
|
|
464
|
+
const exact = reversed.find(({ box: b }) => x >= b.x && y >= b.y && x <= b.x + b.w && y <= b.y + b.h);
|
|
465
|
+
if (exact || !minSize) return exact || null;
|
|
466
|
+
let nearest = null, distance = Infinity;
|
|
467
|
+
for (const hit of reversed) {
|
|
468
|
+
const b = hit.box, dx = x - b.x - b.w / 2, dy = y - b.y - b.h / 2;
|
|
469
|
+
if (Math.abs(dx) <= Math.max(minSize, b.w) / 2 && Math.abs(dy) <= Math.max(minSize, b.h) / 2 && dx * dx + dy * dy < distance) {
|
|
470
|
+
nearest = hit; distance = dx * dx + dy * dy;
|
|
471
|
+
}
|
|
472
|
+
}
|
|
473
|
+
return nearest;
|
|
474
|
+
}
|
|
456
475
|
/**
|
|
457
476
|
* One frame of a scene at `ms` (0: still), a logical unit `a` bitmap px, its origin at (ox, oy); `hot`: the desk key
|
|
458
477
|
* hovered (its name tag shows even in a crowd); `tagsOff` (#2554: a tile too small to read them): the name tags show
|
|
459
478
|
* only for the one hovered and the Find box's matches. Whether anything in it is moving (in the air, or someone walking).
|
|
460
479
|
*/
|
|
461
|
-
export function drawPart(ctx, p, a, ox, oy, ms, still, hot, env, tagsOff = false, defer = null) {
|
|
480
|
+
export function drawPart(ctx, p, a, ox, oy, ms, still, hot, env, tagsOff = false, defer = null, bubbleHits = null) {
|
|
462
481
|
const sk = p.skin;
|
|
463
482
|
const ls = layerScale(a, p.L.width, p.L.height);
|
|
464
483
|
if (!p.layers || p.layers.ls !== ls || p.layers.tagsOff !== tagsOff) p.layers = paintLayers(p, env, ls, tagsOff);
|
|
@@ -476,6 +495,18 @@ export function drawPart(ctx, p, a, ox, oy, ms, still, hot, env, tagsOff = false
|
|
|
476
495
|
// y (a tie: the item first, the person in front); furniture over them; things in the air; the pack's foreground
|
|
477
496
|
// (door frames, pillars, table fronts); then what must stay readable: crowd counts and name tags (bubbles below).
|
|
478
497
|
const t = ms > 0 ? ms : now(), live = furnitureAt(p, t);
|
|
498
|
+
const draggedHeld = p.hold ? p.hold.held() : null;
|
|
499
|
+
const heldName = draggedHeld ? draggedHeld.name : null;
|
|
500
|
+
if (!still && ms > 0 && p.snacks) {
|
|
501
|
+
const snackHidden = heldName ? new Map(live.hidden).set(heldName, "__held__") : live.hidden;
|
|
502
|
+
const changed = p.snacks.step(t, {
|
|
503
|
+
desks: p.desks, walkers: p.walkers, hidden: snackHidden, ownArea: !!p.ownArea,
|
|
504
|
+
areas: p.L.areas, graph: p.L, snacksById: p.snacksById,
|
|
505
|
+
charEatOf: (n) => (sk.eatStrip ? sk.eatStrip(n) : null),
|
|
506
|
+
onClaim: p.onSnackClaim,
|
|
507
|
+
});
|
|
508
|
+
if (changed && typeof p.onSnacksChanged === "function") p.onSnacksChanged();
|
|
509
|
+
}
|
|
479
510
|
const people = p.desks.map((d) => {
|
|
480
511
|
const at = p.walkers.at(d.node.name, t) || { ...d.seat, walking: false };
|
|
481
512
|
if (at.walking) walking = true;
|
|
@@ -483,26 +514,102 @@ export function drawPart(ctx, p, a, ox, oy, ms, still, hot, env, tagsOff = false
|
|
|
483
514
|
}).sort((x, y) => x.at.y - y.at.y);
|
|
484
515
|
const furniture = strollFurniture(p.night ? nightFurniture(sk.pack.furniture) : sk.pack.furniture, (k) => p.walkers.at(k, t));
|
|
485
516
|
if (furniture.some((f) => f.walking)) walking = true;
|
|
486
|
-
const
|
|
517
|
+
const placedSnacks = p.snacks ? p.snacks.placedList() : [];
|
|
518
|
+
const band = [...furniture.filter((f) => f.depth === "y").map((f) => ({ y: f.y, k: 0, f })),
|
|
519
|
+
...placedSnacks.map((sn) => ({ y: sn.y, k: 0.5, sn })),
|
|
520
|
+
...people.map((q) => ({ y: q.at.y, k: 1, p: q })),
|
|
487
521
|
...(p.ghosts ? ghostsOf(sk.pack, people).map((g) => ({ y: g.y, k: 1, g })) : []),
|
|
488
522
|
// #2665: by day, each item's night place too (at night the items are there already).
|
|
489
523
|
...(p.ghosts && !p.night ? nightGhostsOf(sk.pack).map((n) => ({ y: n.y, k: 1, n })) : [])]
|
|
490
524
|
.sort((x, y) => x.y - y.y || x.k - y.k);
|
|
525
|
+
// M-3432 (#4255) & M-3445 (#4266): draw drop-target rings above the floor layer only, never over furniture or characters.
|
|
526
|
+
const drop = p.snackDrop && p.snackDrop.current;
|
|
527
|
+
if (drop && drop.kind === "place") {
|
|
528
|
+
ctx.save();
|
|
529
|
+
ctx.fillStyle = "rgba(0, 0, 0, 0.16)";
|
|
530
|
+
ctx.beginPath(); ctx.ellipse(drop.x, drop.y, 16, 7, 0, 0, Math.PI * 2); ctx.fill();
|
|
531
|
+
ctx.strokeStyle = env.pal.accent; ctx.lineWidth = 1.5; ctx.setLineDash([4, 3]);
|
|
532
|
+
ctx.beginPath(); ctx.ellipse(drop.x, drop.y, 16, 7, 0, 0, Math.PI * 2); ctx.stroke();
|
|
533
|
+
ctx.restore();
|
|
534
|
+
} else if (drop && drop.kind === "feed") {
|
|
535
|
+
const target = people.find((q) => q.look.name === drop.name && !live.hidden.has(q.look.name));
|
|
536
|
+
if (target) {
|
|
537
|
+
ctx.save();
|
|
538
|
+
ctx.fillStyle = env.pal.accentDim;
|
|
539
|
+
ctx.beginPath(); ctx.ellipse(target.at.x, target.at.y, 24, 10, 0, 0, Math.PI * 2); ctx.fill();
|
|
540
|
+
ctx.strokeStyle = env.pal.accent; ctx.lineWidth = 2;
|
|
541
|
+
ctx.beginPath(); ctx.ellipse(target.at.x, target.at.y, 24, 10, 0, 0, Math.PI * 2); ctx.stroke();
|
|
542
|
+
ctx.restore();
|
|
543
|
+
}
|
|
544
|
+
}
|
|
545
|
+
const seatDrop = heldName && p.seatDrop ? p.seatDrop.current : null;
|
|
546
|
+
if (seatDrop && seatDrop.name === heldName && Array.isArray(seatDrop.targets)) {
|
|
547
|
+
for (const st of seatDrop.targets) {
|
|
548
|
+
if (st.current) continue;
|
|
549
|
+
const isHover = !!seatDrop.hover && seatDrop.hover.area === st.area && seatDrop.hover.slot === st.slot;
|
|
550
|
+
ctx.save();
|
|
551
|
+
if (isHover) {
|
|
552
|
+
ctx.fillStyle = env.pal.accentDim;
|
|
553
|
+
ctx.beginPath(); ctx.ellipse(st.x, st.y, 26, 11, 0, 0, Math.PI * 2); ctx.fill();
|
|
554
|
+
ctx.strokeStyle = "rgba(0, 0, 0, 0.38)"; ctx.lineWidth = 4.5;
|
|
555
|
+
ctx.beginPath(); ctx.ellipse(st.x, st.y, 26, 11, 0, 0, Math.PI * 2); ctx.stroke();
|
|
556
|
+
ctx.strokeStyle = env.pal.accent; ctx.lineWidth = 2.5;
|
|
557
|
+
ctx.beginPath(); ctx.ellipse(st.x, st.y, 26, 11, 0, 0, Math.PI * 2); ctx.stroke();
|
|
558
|
+
} else {
|
|
559
|
+
ctx.globalAlpha = 0.9;
|
|
560
|
+
ctx.fillStyle = env.pal.accentDim;
|
|
561
|
+
ctx.beginPath(); ctx.ellipse(st.x, st.y, 22, 10, 0, 0, Math.PI * 2); ctx.fill();
|
|
562
|
+
ctx.strokeStyle = "rgba(0, 0, 0, 0.35)"; ctx.lineWidth = 3.5;
|
|
563
|
+
ctx.beginPath(); ctx.ellipse(st.x, st.y, 22, 10, 0, 0, Math.PI * 2); ctx.stroke();
|
|
564
|
+
ctx.strokeStyle = env.pal.accent; ctx.lineWidth = 2; ctx.setLineDash([5, 3]);
|
|
565
|
+
ctx.beginPath(); ctx.ellipse(st.x, st.y, 22, 10, 0, 0, Math.PI * 2); ctx.stroke();
|
|
566
|
+
}
|
|
567
|
+
ctx.restore();
|
|
568
|
+
}
|
|
569
|
+
}
|
|
491
570
|
for (const f of furniture) if (f.depth !== "y" && f.depth < CHAR_DEPTH) sk.drawFurniture(ctx, f, f.asleep || live.active.has(f.id), ms, env);
|
|
492
571
|
for (const it of post) if (it.t === 0) sk.drawProp(ctx, it, ms, env); // a letter on the floor: under the people
|
|
493
|
-
|
|
572
|
+
let heldPerson = null;
|
|
573
|
+
for (const { f, p: q, g, n, sn } of band) {
|
|
494
574
|
if (f) { sk.drawFurniture(ctx, f, f.asleep || live.active.has(f.id), ms, env); continue; }
|
|
575
|
+
if (sn) {
|
|
576
|
+
const sdef = p.snacksById && p.snacksById.get(sn.snackId);
|
|
577
|
+
if (sdef && sk.drawSnack) {
|
|
578
|
+
ctx.save();
|
|
579
|
+
ctx.fillStyle = "rgba(0, 0, 0, 0.22)";
|
|
580
|
+
ctx.beginPath(); ctx.ellipse(sn.x, sn.y + 1, Math.max(8, Math.round(sdef.sprite.dw * 0.38)), 4, 0, 0, Math.PI * 2); ctx.fill();
|
|
581
|
+
ctx.restore();
|
|
582
|
+
sk.drawSnack(ctx, sdef.sprite, ms, sn.x, sn.y, env, `sn:${sn.id}`);
|
|
583
|
+
}
|
|
584
|
+
continue;
|
|
585
|
+
}
|
|
495
586
|
if (n) { ctx.save(); ctx.globalAlpha = GHOST_ALPHA; sk.drawFurniture(ctx, n, true, 0, env); ctx.restore(); continue; }
|
|
496
587
|
if (g) { ctx.save(); ctx.globalAlpha = GHOST_ALPHA; sk.drawCharacter(ctx, { x: g.x - 44, y: g.y - 53, w: 88, h: 53, seat: g }, g.look, 0, env); ctx.restore(); continue; }
|
|
588
|
+
if (heldName && q.look.name === heldName) { heldPerson = q; continue; } // M-3445 (#4267): drawn lifted on top below
|
|
497
589
|
if (live.hidden.has(q.look.name)) continue; // #2698: drawn as the item (never while walking)
|
|
498
590
|
const box = { ...q.d, x: q.at.x - 44, y: q.at.y - 53, w: 88, h: 53, seat: { x: q.at.x, y: q.at.y } };
|
|
499
|
-
// An agent's own pose (office_set, #2578) while its act lasts and nothing calls it; walking is walking.
|
|
591
|
+
// An agent's own pose (office_set, #2578) while its act lasts and nothing calls it; walking is walking; M-3432: eating when fed.
|
|
500
592
|
const posed = actPosed(p, q.look);
|
|
501
|
-
const
|
|
593
|
+
const eating = !q.at.walking && p.snacks && ms > 0 ? p.snacks.eatingOf(q.look.name, t) : null;
|
|
594
|
+
const canEat = !!eating && !CALLING.has(q.look.state) && !ASLEEP.has(q.look.state) && !q.look.night;
|
|
595
|
+
const look = q.at.walking ? { ...q.look, pose: "walk", heading: q.at.heading }
|
|
596
|
+
: canEat ? { ...posed, pose: "eat", basePose: posed.pose } : posed;
|
|
502
597
|
sk.drawCharacter(ctx, box, look, ms, env);
|
|
503
|
-
if (
|
|
598
|
+
if (canEat && eating.snackId && p.snacksById && sk.drawSnack) {
|
|
599
|
+
const sdef = p.snacksById.get(eating.snackId);
|
|
600
|
+
if (sdef && sdef.eat) sk.drawSnack(ctx, sdef.eat, Math.max(0, t - eating.t0), q.at.x, q.at.y, env);
|
|
601
|
+
}
|
|
602
|
+
if (!q.at.walking || (p.snacks && ms > 0 && p.snacks.scatterOf(q.look.name, t))) {
|
|
603
|
+
speakers.push({ look: q.look, ...speakerAt(sk, look, q.at), area: q.d.area });
|
|
604
|
+
}
|
|
504
605
|
}
|
|
505
606
|
for (const f of furniture) if (f.depth !== "y" && f.depth >= CHAR_DEPTH) sk.drawFurniture(ctx, f, f.asleep || live.active.has(f.id), ms, env);
|
|
607
|
+
// M-3445 (#4267): the character currently being dragged renders lifted above furniture and other characters in its `dragged` pose.
|
|
608
|
+
if (heldPerson) {
|
|
609
|
+
const box = { ...heldPerson.d, x: heldPerson.at.x - 44, y: heldPerson.at.y - 53, w: 88, h: 53, seat: { x: heldPerson.at.x, y: heldPerson.at.y } };
|
|
610
|
+
const posed = actPosed(p, heldPerson.look);
|
|
611
|
+
sk.drawCharacter(ctx, box, { ...posed, pose: "dragged", basePose: posed.pose }, ms, env);
|
|
612
|
+
}
|
|
506
613
|
for (const it of up) sk.drawProp(ctx, it, ms, env);
|
|
507
614
|
for (const it of post) if (it.t > 0) sk.drawProp(ctx, it, ms, env);
|
|
508
615
|
if (sk.drawForeground) sk.drawForeground(ctx, p.L, env);
|
|
@@ -517,7 +624,7 @@ export function drawPart(ctx, p, a, ox, oy, ms, still, hot, env, tagsOff = false
|
|
|
517
624
|
const taken = [];
|
|
518
625
|
const touches = (b) => taken.some((o) => b.x < o.x + o.w && o.x < b.x + b.w && b.y < o.y + o.h && o.y < b.y + b.h);
|
|
519
626
|
for (const q of people) {
|
|
520
|
-
if (live.hidden.has(q.look.name) || !tagged(q)) continue;
|
|
627
|
+
if ((live.hidden.has(q.look.name) && q.look.name !== heldName) || !tagged(q)) continue;
|
|
521
628
|
sk.drawTag(ctx, q.at.x, q.at.y, q.look, env);
|
|
522
629
|
const box = tagBox(ctx, q.at.x, q.at.y, q.look.label);
|
|
523
630
|
tags.push(box); taken.push(tagFootprint(ctx, box, q.look.badge));
|
|
@@ -528,7 +635,7 @@ export function drawPart(ctx, p, a, ox, oy, ms, still, hot, env, tagsOff = false
|
|
|
528
635
|
// kept on the scene (`heldTags`): hitPart hits each person on theirs, past the picture's edge too (#2699 review).
|
|
529
636
|
const held = [];
|
|
530
637
|
for (const f of furniture) {
|
|
531
|
-
const on = people.filter((q) => live.hidden.get(q.look.name) === f.id);
|
|
638
|
+
const on = people.filter((q) => live.hidden.get(q.look.name) === f.id && q.look.name !== heldName);
|
|
532
639
|
if (!on.length) {
|
|
533
640
|
if (!tagsOff && f.label) {
|
|
534
641
|
const nl = npcLook(p, f), box = tagBox(ctx, f.x, f.y, nl.label);
|
|
@@ -613,16 +720,27 @@ export function drawPart(ctx, p, a, ox, oy, ms, still, hot, env, tagsOff = false
|
|
|
613
720
|
const packSays = ra ? linesFor(reacting.get(sp.look.name).kind, p.lang, sk.pack, null, sp.look.name) : [];
|
|
614
721
|
const raSays = ra ? (packSays.length ? packSays[Math.floor(reacting.get(sp.look.name).t0) % packSays.length] : ra.say) : null;
|
|
615
722
|
const own = raSays ? raSays : actLive(act, says, Date.now(), p.actSeen) && act.say ? act.say : null;
|
|
616
|
-
const
|
|
617
|
-
|
|
723
|
+
const sc = !own && p.snacks && ms > 0 ? p.snacks.scatterOf(sp.look.name, t0) : null;
|
|
724
|
+
const scText = sc ? scatterWords(p.lang) : null;
|
|
725
|
+
const b = own ? { text: own, shown: [...own].length }
|
|
726
|
+
: scText ? { text: scText, shown: [...scText].length }
|
|
727
|
+
: bubbleAt(sp.look.name, says, ms, linesFor(says, p.lang, sk.pack, p.lines, sp.look.name)); // #3681: theirs, their set's, the pack's
|
|
728
|
+
if (b) bubbles.push({ key: sp.look.name, area: sp.area, state: sp.look.state, calling: CALLING.has(sp.look.state), rank: own ? 0 : scText ? 1 : bubbleRank(sp.look.state), shown: b.shown, ...(raSays ? { keep: true } : {}),
|
|
618
729
|
box: bubbleBox(ctx, sp.x, sp.y, b.text), tail: { x: sp.x, y: sp.y }, sp, b });
|
|
619
730
|
}
|
|
620
731
|
// A crowded area speaks less (thinBubbles: calls, then work, a few at most); no bubble covers a name tag. `defer`
|
|
621
732
|
// (All offices): drawn after every tile, unclipped, so a bubble at a tile's edge is whole.
|
|
622
733
|
const placed = placeBubbles(thinBubbles(bubbles, p.zones ? p.L.over : null), 22, tags);
|
|
623
|
-
const say = () => { T(); for (const { sp, b, dy } of placed)
|
|
734
|
+
const say = () => { T(); for (const { sp, b, dy } of placed) {
|
|
735
|
+
const text = [...b.text].slice(0, b.shown).join("");
|
|
736
|
+
sk.drawBubble(ctx, sp.x, sp.y, text, env, -dy);
|
|
737
|
+
if (bubbleHits && text) {
|
|
738
|
+
const box = bubbleBox(ctx, sp.x, sp.y, text, -dy);
|
|
739
|
+
bubbleHits.push({ name: sp.look.name, box: { x: ox + box.x * a, y: oy + box.y * a, w: box.w * a, h: box.h * a } });
|
|
740
|
+
}
|
|
741
|
+
} };
|
|
624
742
|
if (defer) defer.push(say); else say();
|
|
625
|
-
return walking || up.length > 0 || p.flights.size() > 0 || post.some((it) => it.t > 0) || rising.length > 0 || !!reacting;
|
|
743
|
+
return walking || up.length > 0 || p.flights.size() > 0 || post.some((it) => it.t > 0) || rising.length > 0 || !!reacting || (!!p.snacks && p.snacks.active(t0)) || !!(p.snackDrop && p.snackDrop.current) || !!(p.hold && p.hold.held());
|
|
626
744
|
}
|
|
627
745
|
/**
|
|
628
746
|
* #2661: an NPC's name tag (a furniture item's label) — with the title a pack pins on it (`levels.fixed` by its id),
|
|
@@ -720,9 +838,17 @@ export function OfficeKey({ pal }) {
|
|
|
720
838
|
* `opening` the office it opens on (the share's), instead of the one this browser chose last; #2861: `talk` the share's
|
|
721
839
|
* conversations (its /state's: who heard or answered a person, when — never what was said), instead of the stream's.
|
|
722
840
|
*/
|
|
841
|
+
function ensureDialogueStyle() {
|
|
842
|
+
const doc = globalThis.document;
|
|
843
|
+
if (!doc?.head || doc.querySelector('link[data-office-dialogue-css="1"]')) return;
|
|
844
|
+
const link = doc.createElement("link"); link.rel = "stylesheet";
|
|
845
|
+
link.href = assetUrl("/assets/office-dialogue.css");
|
|
846
|
+
link.setAttribute("data-office-dialogue-css", "1"); doc.head.appendChild(link);
|
|
847
|
+
}
|
|
723
848
|
export function Office({ view, traffic, q = "", lease, onOpen, assetUrl, assetImage, opening, talk, more = false, onMore = null, live = null, onLive = null }) {
|
|
724
849
|
// M-3253: on a phone the page above (fleet-canvas.js) puts a ⋯ in its bar: `more` is that sheet open, `onMore(open)`;
|
|
725
850
|
// `live` / `onLive` its Live toggle, which moves into the sheet. Without one (a share link's page) the bar stays.
|
|
851
|
+
useLayoutEffect(ensureDialogueStyle, []);
|
|
726
852
|
const phone = useOfficePhone(), compact = phone && typeof onMore === "function";
|
|
727
853
|
const store = useMemo(() => createOfficeStore(lease ? { fetch: (path, o) => lease.fetch(path, o) } : {}), [lease]);
|
|
728
854
|
const [stored, setStored] = useState([]);
|
|
@@ -765,6 +891,12 @@ export function Office({ view, traffic, q = "", lease, onOpen, assetUrl, assetIm
|
|
|
765
891
|
const dlg = useMemo(createDialogue, []);
|
|
766
892
|
const faces = useMemo(() => createFaces(), []);
|
|
767
893
|
const [dlgSay, setDlgSay] = useState("");
|
|
894
|
+
const [dlgVisible, setDlgVisible] = useState(false);
|
|
895
|
+
const dlgVisibleRef = useRef(false);
|
|
896
|
+
const showDialogueDock = (visible) => {
|
|
897
|
+
if (dlgVisibleRef.current !== visible) { dlgVisibleRef.current = visible; setDlgVisible(visible); }
|
|
898
|
+
};
|
|
899
|
+
const dialogueCanvasRef = useRef(null);
|
|
768
900
|
const [dlgHot, setDlgHot] = useState(false);
|
|
769
901
|
const dlgRef = useRef(null), dlgShown = useRef(null), dlgLines = useRef(new Map()), talkSeen = useRef(new Set());
|
|
770
902
|
const [nightNow, setNightNow] = useState(() => isNight());
|
|
@@ -799,6 +931,8 @@ export function Office({ view, traffic, q = "", lease, onOpen, assetUrl, assetIm
|
|
|
799
931
|
const flights = useMemo(() => createFlights(), []);
|
|
800
932
|
const walkers = useMemo(() => createWalkers(), []);
|
|
801
933
|
const seatsRef = useRef(new Map()); // the zones layout's last seats: kept where they can be
|
|
934
|
+
const seatPrefsRef = useRef({}), seatKeyRef = useRef(""), seatDropRef = useRef(null);
|
|
935
|
+
const [seatRev, setSeatRev] = useState(0);
|
|
802
936
|
// #2554: All offices' tiles keep their own: seats (by tile and style), walkers and flights (by tile); and the items
|
|
803
937
|
// flying between tiles.
|
|
804
938
|
const tileSeats = useRef(new Map()), tileWalkers = useRef(new Map()), tileFlights = useRef(new Map());
|
|
@@ -1066,17 +1200,30 @@ export function Office({ view, traffic, q = "", lease, onOpen, assetUrl, assetIm
|
|
|
1066
1200
|
// While Edit layout is open: a faint figure on every seat, in the pose its area is for (#2558), so a seat is placed by
|
|
1067
1201
|
// what will stand, sit or lie there, not by a dot.
|
|
1068
1202
|
const ghosts = zones && !!layout && !layoutStale;
|
|
1203
|
+
const shared = talk !== undefined || typeof onOpen !== "function";
|
|
1204
|
+
// What a view and per-device seat choices are kept for: the office and its style (All offices: its own key).
|
|
1205
|
+
const officeKey = overview ? `${ALL_ID}@tiles` : `${custom ? custom.id : AUTO_ID}@${baseSkin.id}`;
|
|
1069
1206
|
const keep = (n) => !(hideAsleep && ASLEEP.has(n.state));
|
|
1070
1207
|
const single = useMemo(() => {
|
|
1071
1208
|
if (overview) return { rooms: [], width: 1, height: 1 }; // All offices: the tiles below
|
|
1072
1209
|
const all = custom ? membersOf(custom, view) : [...new Map(officeRooms(view, filter).flatMap((r) => r.nodes).map((n) => [n.name, n])).values()];
|
|
1073
1210
|
const nodes = all.filter(keep);
|
|
1074
|
-
if (zones) {
|
|
1211
|
+
if (zones) {
|
|
1212
|
+
const skKey = shared ? "" : officeKey;
|
|
1213
|
+
if (seatKeyRef.current !== skKey) {
|
|
1214
|
+
seatKeyRef.current = skKey;
|
|
1215
|
+
seatsRef.current = new Map();
|
|
1216
|
+
seatPrefsRef.current = skKey ? store.seats(skKey) : {};
|
|
1217
|
+
}
|
|
1218
|
+
const z = zonesLayout(skin.pack, nodes, seatsRef.current, { night, seatPrefs: skKey ? seatPrefsRef.current : null });
|
|
1219
|
+
seatsRef.current = z.seats;
|
|
1220
|
+
return z;
|
|
1221
|
+
}
|
|
1075
1222
|
// The desks wrap at the stage's width at the scale they open on (desksK: a pixel level near one CSS px a unit).
|
|
1076
1223
|
const deskW = Math.max(240, Math.floor(width / desksK(ratio)));
|
|
1077
1224
|
if (!custom) return autoLayout(officeRooms(view, filter).map((r) => (hideAsleep ? { ...r, nodes: r.nodes.filter(keep) } : r)), { width: deskW });
|
|
1078
1225
|
return officeScene(custom, nodes, skin, false, deskW);
|
|
1079
|
-
}, [overview, view, filter, custom, width, ratio, skin, hideAsleep, night]);
|
|
1226
|
+
}, [overview, view, filter, custom, width, ratio, skin, hideAsleep, night, seatRev, officeKey, shared]);
|
|
1080
1227
|
// ── #2554: All offices' tiles — each stored office (then the lobby: whoever is in no office) laid out as its own view
|
|
1081
1228
|
// lays it out, in its own style (desks wrap at a cell's width), with its own seats, walkers and flights ──
|
|
1082
1229
|
const lobbyAll = useMemo(() => (overview ? lobbyNodes(stored, view) : []), [overview, stored, view]);
|
|
@@ -1124,11 +1271,27 @@ export function Office({ view, traffic, q = "", lease, onOpen, assetUrl, assetIm
|
|
|
1124
1271
|
const visitMemo = useMemo(() => ({ claims: new Map(), idle: null }), [skin]);
|
|
1125
1272
|
// M-3293: play — never on a share link's page (no onOpen there, or its own `talk`), with reduced motion, in All
|
|
1126
1273
|
// offices, the carousel or Edit layout. `hold`: the person picked up (carried where the pointer is, walked back from
|
|
1127
|
-
// where they are dropped
|
|
1128
|
-
const shared = talk !== undefined || typeof onOpen !== "function";
|
|
1274
|
+
// where they are dropped, or seated on another seat in their area: M-3445 #4266/#4267); `reacts`: pats and feeds showing.
|
|
1129
1275
|
const play = playAllowed({ on: playOn, still, zones, overview, layout: !!layout, shared }) && !carouselPick;
|
|
1130
1276
|
const hold = useMemo(() => createHold(), []), reacts = useRef(new Map()), walkNow = useRef(null), holdTimer = useRef(null);
|
|
1131
|
-
|
|
1277
|
+
// M-3432 (#4255): custom snacks from the active skin pack (client-local, only when play is enabled).
|
|
1278
|
+
const snacks = useMemo(() => createSnacks(), []);
|
|
1279
|
+
const snackDragCtrl = useMemo(() => createSnackDrag(), []);
|
|
1280
|
+
const packSnacks = useMemo(() => (skin && skin.pack && Array.isArray(skin.pack.snacks) ? skin.pack.snacks : []), [skin]);
|
|
1281
|
+
const snacksById = useMemo(() => new Map(packSnacks.map((s) => [s.id, s])), [packSnacks]);
|
|
1282
|
+
const showSnacks = play && packSnacks.length > 0;
|
|
1283
|
+
const [armedSnack, setArmedSnack] = useState(null);
|
|
1284
|
+
const [snackDrag, setSnackDrag] = useState(null);
|
|
1285
|
+
const snackDropRef = useRef(null), snackGhostRef = useRef(null), snackGhostPosRef = useRef(null), snackTrayRef = useRef(null), snackSwallowRef = useRef(false);
|
|
1286
|
+
const snackCtxRef = useRef({ showSnacks: false, officeKey: "", styleKey: "" });
|
|
1287
|
+
const onSnackClaim = (winner) => {
|
|
1288
|
+
reacts.current.set(winner, { kind: "feed", t0: now() });
|
|
1289
|
+
if (store.tellOn(winner)) void store.tell(winner, "feed");
|
|
1290
|
+
loop.current?.wake();
|
|
1291
|
+
};
|
|
1292
|
+
useEffect(() => { if (!play) { const wasHeld = !!hold.held(); snackDragCtrl.retire(); hold.cancel(); seatDropRef.current = null; reacts.current.clear(); snacks.clear(); snackDropRef.current = null; setArmedSnack(null); setSnackDrag(null); if (wasHeld) walkNow.current?.(); } }, [play]);
|
|
1293
|
+
useEffect(() => { if (!showSnacks) { snackDragCtrl.retire(); snackDropRef.current = null; setArmedSnack(null); setSnackDrag(null); } }, [showSnacks]);
|
|
1294
|
+
useEffect(() => () => { snackDragCtrl.retire(); }, []);
|
|
1132
1295
|
useEffect(() => {
|
|
1133
1296
|
if (!zones || overview) return undefined;
|
|
1134
1297
|
const go = () => {
|
|
@@ -1136,6 +1299,7 @@ export function Office({ view, traffic, q = "", lease, onOpen, assetUrl, assetIm
|
|
|
1136
1299
|
// An act's walk; not someone in bed for the night (#2568: bedtime wins, as for mail).
|
|
1137
1300
|
for (const d of desksOf(L)) { const a = actsHere.get(d.node.name), at = !d.night && actLive(a, d.node.state, Date.now(), actSeen.current) ? actTarget(a, L, walkers, t) : null; if (at) to.set(d.node.name, at); }
|
|
1138
1301
|
for (const [name, at] of mail.targets(L, t)) to.set(name, at);
|
|
1302
|
+
for (const [name, at] of snacks.targets(t)) to.set(name, at);
|
|
1139
1303
|
const held = hold.held(); // M-3293: carried: where the pointer is, no walk
|
|
1140
1304
|
if (held) to.set(held.name, held.at);
|
|
1141
1305
|
walkers.sync(to, t, L, still);
|
|
@@ -1167,8 +1331,8 @@ export function Office({ view, traffic, q = "", lease, onOpen, assetUrl, assetIm
|
|
|
1167
1331
|
const touched = useRef(false), fitted = useRef(false), drag = useRef(gestureState());
|
|
1168
1332
|
const miniViewRef = useRef(null), miniRef = useRef(null), overlayEl = useRef(null), tipDeskRef = useRef(null), pctRef = useRef(null);
|
|
1169
1333
|
const labelEls = useRef(new Map()); // #2554: the tiles' labels (tile key → element)
|
|
1170
|
-
|
|
1171
|
-
|
|
1334
|
+
snackCtxRef.current = { showSnacks, officeKey, styleKey };
|
|
1335
|
+
useEffect(() => { snackDragCtrl.retire(); hold.cancel(); seatDropRef.current = null; snacks.clear(); snackDropRef.current = null; setArmedSnack(null); setSnackDrag(null); }, [officeKey, styleKey]);
|
|
1172
1336
|
const keyRef = useRef(officeKey), saveTimer = useRef(0);
|
|
1173
1337
|
// The fit mode (Fit: contain; Fill: cover), kept per office and style like the view.
|
|
1174
1338
|
const [fitRev, setFitRev] = useState(0);
|
|
@@ -1205,7 +1369,7 @@ export function Office({ view, traffic, q = "", lease, onOpen, assetUrl, assetIm
|
|
|
1205
1369
|
const v = view0(), sz = sizeRef.current;
|
|
1206
1370
|
const w = c.walks ? walkers.at(c.name, now()) : null;
|
|
1207
1371
|
const pt = w ? { x: w.x, y: w.y - 52, r: 16 } : { x: c.box.x + c.box.w / 2, y: c.box.y, r: (c.box.w / 2) * v.k };
|
|
1208
|
-
const p = toScreen(v, pt.x, pt.y), cw = 320, ch = el.offsetHeight || 260, gap = 12 + (w ? pt.r : pt.r);
|
|
1372
|
+
const p = toScreen(v, pt.x, pt.y), cw = el.offsetWidth || 320, ch = el.offsetHeight || 260, gap = 12 + (w ? pt.r : pt.r);
|
|
1209
1373
|
let x = p.x + gap;
|
|
1210
1374
|
if (x + cw > sz.w - 8) x = p.x - gap - cw;
|
|
1211
1375
|
x = Math.max(8, Math.min(x, sz.w - cw - 8));
|
|
@@ -1400,6 +1564,8 @@ export function Office({ view, traffic, q = "", lease, onOpen, assetUrl, assetIm
|
|
|
1400
1564
|
// or the zoom changes, never on a pan); each frame draws the matte, the layers, the people and the items in the air ──
|
|
1401
1565
|
const scene = useRef(null);
|
|
1402
1566
|
const loop = useRef(null);
|
|
1567
|
+
const clipClocks = useRef(null);
|
|
1568
|
+
if (!clipClocks.current) clipClocks.current = createClipClocks();
|
|
1403
1569
|
// The matte around the scene: the pack's own, else its background's edge (sampled once), else the skin's (tokens);
|
|
1404
1570
|
// All offices: the dashboard's background (each tile is its own scene).
|
|
1405
1571
|
const matte = overview ? pal.bg : (skin.pack && skin.pack.matte) || sampledMatte(skin.backdrop) || (skin.matte ? skin.matte({ pal, mode }) : pal.bg);
|
|
@@ -1415,16 +1581,22 @@ export function Office({ view, traffic, q = "", lease, onOpen, assetUrl, assetIm
|
|
|
1415
1581
|
cv.style.setProperty("width", `${BW / ratio}px`);
|
|
1416
1582
|
cv.style.setProperty("height", `${BH / ratio}px`);
|
|
1417
1583
|
const env = { pal, mode, labels: { lobby: to("lobbyRoom"), closed: to("closed"), areas: { desks: to("area_desks"), lounge: to("area_lounge"), alert: to("area_alert"), nap: to("area_nap") } } };
|
|
1418
|
-
const
|
|
1584
|
+
const maxPackFps = overview
|
|
1585
|
+
? Math.max(0, ...tiles.map((tl) => packMaxFps(tl.skin && tl.skin.pack)))
|
|
1586
|
+
: packMaxFps(skin && skin.pack);
|
|
1587
|
+
const fps = Math.max(FPS, Math.min(30, Math.ceil(maxPackFps)));
|
|
1588
|
+
const base = { ctx, ratio, BW, BH, matte, env, fps, dirty: true };
|
|
1419
1589
|
if (overview) {
|
|
1420
1590
|
// Each tile a scene of its own, where the overview puts it (arranged.tiles, in the same order).
|
|
1421
1591
|
const parts = tiles.map((tl, i) => ({ ...partOf(tl.L, tileLooks[i], tl.skin, tl.zones, tl.walkers, tl.flights), night, key: tl.key, prefix: tl.prefix, tile: arranged.tiles[i], ups: ups.current, levelsOn: !!(lv && lv.enabled), levels: wordsOf(tl.skin) }));
|
|
1422
1592
|
scene.current = { ...base, overview: true, parts, lay: arranged };
|
|
1423
1593
|
} else {
|
|
1424
|
-
scene.current = { ...base, overview: false, part: { ...partOf(L, looks, skin, zones, walkers, flights), ghosts, night, mail, acts: actsHere, actSeen: actSeen.current, ups: ups.current, levelsOn: !!(lv && lv.enabled), levels: wordsOf(skin), reacts: reacts.current
|
|
1594
|
+
scene.current = { ...base, overview: false, part: { ...partOf(L, looks, skin, zones, walkers, flights), ghosts, night, mail, acts: actsHere, actSeen: actSeen.current, ups: ups.current, levelsOn: !!(lv && lv.enabled), levels: wordsOf(skin), reacts: reacts.current,
|
|
1595
|
+
hold: play ? hold : null, seatDrop: seatDropRef,
|
|
1596
|
+
snacks: play ? snacks : null, snacksById, ownArea, snackDrop: snackDropRef, onSnackClaim, onSnacksChanged: () => walkNow.current?.() } };
|
|
1425
1597
|
}
|
|
1426
1598
|
if (still) draw(0); else loop.current?.wake();
|
|
1427
|
-
}, [L, looks, skin, pal, size.w, size.h, ratio, matte, overview, tiles, tileLooks, arranged, ghosts, night, mail, actsHere, lv, wordsOf]);
|
|
1599
|
+
}, [L, looks, skin, pal, size.w, size.h, ratio, matte, overview, tiles, tileLooks, arranged, ghosts, night, mail, actsHere, lv, wordsOf, play, snacksById, ownArea]);
|
|
1428
1600
|
|
|
1429
1601
|
/** One frame at `ms` (0: still); whether anything is moving (in the air, or someone walking). */
|
|
1430
1602
|
function draw(ms) {
|
|
@@ -1432,13 +1604,22 @@ export function Office({ view, traffic, q = "", lease, onOpen, assetUrl, assetIm
|
|
|
1432
1604
|
if (!s) return false;
|
|
1433
1605
|
placeCard();
|
|
1434
1606
|
const { ctx, BW, BH, env } = s;
|
|
1607
|
+
s.bubbleHits = [];
|
|
1608
|
+
const seenClips = ms > 0 ? new Set() : null;
|
|
1609
|
+
const clocked = (prefix) => (seenClips
|
|
1610
|
+
? { ...env, clock: (k, st, t) => { const fk = `${prefix}${k}`; seenClips.add(fk); return clipClocks.current.elapsed(fk, st, t); } }
|
|
1611
|
+
: env);
|
|
1435
1612
|
// The view in bitmap px: a logical unit is `a` px (a whole number at a pixel level), the origin on a whole px.
|
|
1436
1613
|
const v = view0(), a = v.k * s.ratio, ox = Math.round(v.x * s.ratio), oy = Math.round(v.y * s.ratio);
|
|
1437
1614
|
ctx.setTransform(1, 0, 0, 1, 0, 0);
|
|
1438
1615
|
ctx.clearRect(0, 0, BW, BH);
|
|
1439
1616
|
ctx.fillStyle = s.matte; ctx.fillRect(0, 0, BW, BH);
|
|
1440
1617
|
ctx.imageSmoothingEnabled = false;
|
|
1441
|
-
if (!s.overview) {
|
|
1618
|
+
if (!s.overview) {
|
|
1619
|
+
const moved = drawPart(ctx, s.part, a, ox, oy, ms, still, tipNow.current, clocked(""), false, null, s.bubbleHits);
|
|
1620
|
+
if (seenClips) clipClocks.current.prune(seenClips);
|
|
1621
|
+
return drawDialogue(ctx, s, ms) || moved;
|
|
1622
|
+
}
|
|
1442
1623
|
// All offices: each tile on screen drawn as its own view, scaled into it and clipped to it; one off screen is not
|
|
1443
1624
|
// drawn (its flights still land). Then a frame round each tile, and the items flying between tiles.
|
|
1444
1625
|
const hot = tipNow.current, on = new Set(visibleTiles(s.lay, v, sizeRef.current).map((tt) => tt.key)), said = [];
|
|
@@ -1450,7 +1631,7 @@ export function Office({ view, traffic, q = "", lease, onOpen, assetUrl, assetIm
|
|
|
1450
1631
|
ctx.save();
|
|
1451
1632
|
ctx.setTransform(1, 0, 0, 1, 0, 0);
|
|
1452
1633
|
ctx.beginPath(); ctx.rect(tx, ty, tw, th); ctx.clip();
|
|
1453
|
-
if (drawPart(ctx, p, a * tt.s, tx, ty, ms, still, hot && hot.startsWith(p.prefix) ? hot.slice(p.prefix.length) : null,
|
|
1634
|
+
if (drawPart(ctx, p, a * tt.s, tx, ty, ms, still, hot && hot.startsWith(p.prefix) ? hot.slice(p.prefix.length) : null, clocked(p.prefix), v.k * tt.s < TAG_MIN_K, said, s.bubbleHits)) moving = true;
|
|
1454
1635
|
ctx.restore();
|
|
1455
1636
|
ctx.setTransform(1, 0, 0, 1, 0, 0);
|
|
1456
1637
|
ctx.strokeStyle = env.pal.border; ctx.lineWidth = 1;
|
|
@@ -1460,11 +1641,13 @@ export function Office({ view, traffic, q = "", lease, onOpen, assetUrl, assetIm
|
|
|
1460
1641
|
const up = still ? [] : cross.frame(ms, s.parts);
|
|
1461
1642
|
// Each drawn by its sender's tile's skin (#2562: their own prop, else that pack's for its kind), at that tile's scale;
|
|
1462
1643
|
// a sender in no tile drawn: the built-in item, in overview units.
|
|
1644
|
+
const crossEnv = clocked("x:");
|
|
1463
1645
|
for (const it of up) {
|
|
1464
1646
|
const from = senderTile(s.parts, it.from);
|
|
1465
|
-
if (from) { ctx.setTransform(a * from.tile.s, 0, 0, a * from.tile.s, ox, oy); from.skin.drawProp(ctx, { ...it, x: it.x / from.tile.s, y: it.y / from.tile.s }, ms,
|
|
1466
|
-
else { ctx.setTransform(a, 0, 0, a, ox, oy); skinFor("pixel").drawProp(ctx, it, ms,
|
|
1647
|
+
if (from) { ctx.setTransform(a * from.tile.s, 0, 0, a * from.tile.s, ox, oy); from.skin.drawProp(ctx, { ...it, x: it.x / from.tile.s, y: it.y / from.tile.s }, ms, crossEnv); }
|
|
1648
|
+
else { ctx.setTransform(a, 0, 0, a, ox, oy); skinFor("pixel").drawProp(ctx, it, ms, crossEnv); }
|
|
1467
1649
|
}
|
|
1650
|
+
if (seenClips) clipClocks.current.prune(seenClips);
|
|
1468
1651
|
return drawDialogue(ctx, s, ms) || moving || up.length > 0 || cross.size() > 0;
|
|
1469
1652
|
}
|
|
1470
1653
|
/**
|
|
@@ -1472,15 +1655,25 @@ export function Office({ view, traffic, q = "", lease, onOpen, assetUrl, assetIm
|
|
|
1472
1655
|
* awake (pickFront), with their faces (the pack's portraits; else the agent's avatar, else initials), the speaker's
|
|
1473
1656
|
* words typed out, the agent's line while it works and "+N". Nothing at all while it is off. Whether it moves.
|
|
1474
1657
|
*/
|
|
1475
|
-
function drawDialogue(
|
|
1658
|
+
function drawDialogue(_mapCtx, s, ms) {
|
|
1476
1659
|
const d = dlgRef.current;
|
|
1477
|
-
if (!d) { dlgShown.current = null; return false; }
|
|
1660
|
+
if (!d) { dlgShown.current = null; showDialogueDock(false); return false; }
|
|
1478
1661
|
const t = ms > 0 ? ms : now();
|
|
1479
1662
|
const { front, more } = pickFront(dlg.list(), (n) => d.who.has(n), (n) => d.who.get(n).look?.pose === "paused");
|
|
1480
|
-
if (!front) { dlgShown.current = null; return false; }
|
|
1481
|
-
const who = d.who.get(front.instance), node = who.node
|
|
1663
|
+
if (!front) { dlgShown.current = null; showDialogueDock(false); return false; }
|
|
1664
|
+
const who = d.who.get(front.instance), node = who.node;
|
|
1482
1665
|
const stage = stageOf(front, t, node.state === "working", still);
|
|
1483
|
-
if (stage.done) { dlgShown.current = null; return false; }
|
|
1666
|
+
if (stage.done) { dlgShown.current = null; showDialogueDock(false); return false; }
|
|
1667
|
+
showDialogueDock(true);
|
|
1668
|
+
const cv = dialogueCanvasRef.current;
|
|
1669
|
+
if (!cv) return false; // layout commit mounts the dock, then its effect paints even with reduced motion
|
|
1670
|
+
const dw = cv.clientWidth || sizeRef.current.w, dh = cv.clientHeight || (phone ? 160 : 180), L0 = boxLayout(dw, dh);
|
|
1671
|
+
const BW = Math.max(1, Math.floor(dw * s.ratio)), BH = Math.max(1, Math.floor(dh * s.ratio));
|
|
1672
|
+
if (cv.width !== BW) cv.width = BW;
|
|
1673
|
+
if (cv.height !== BH) cv.height = BH;
|
|
1674
|
+
const ctx = cv.getContext("2d");
|
|
1675
|
+
if (!ctx) return false;
|
|
1676
|
+
ctx.setTransform(1, 0, 0, 1, 0, 0); ctx.clearRect(0, 0, BW, BH);
|
|
1484
1677
|
const skinOf = who.skin, pack = skinOf && skinOf.pack;
|
|
1485
1678
|
const pic = (src) => (src && skinOf && typeof skinOf.picture === "function" ? skinOf.picture(src, dlgWake) : null);
|
|
1486
1679
|
const agentName = nodeText(node).primary;
|
|
@@ -1518,27 +1711,38 @@ export function Office({ view, traffic, q = "", lease, onOpen, assetUrl, assetIm
|
|
|
1518
1711
|
dlgShown.current = { L, stage, key: who.key, name: front.instance };
|
|
1519
1712
|
const frameSrc = pack && pack.dialogBox && pack.dialogBox.frame, frameIm = frameSrc ? pic(frameSrc) : null;
|
|
1520
1713
|
return drawBox(ctx, {
|
|
1521
|
-
|
|
1714
|
+
// A short landscape dock keeps the name and words; decorative faces need headroom above the box.
|
|
1715
|
+
L, stage, left: dh >= 144 ? personFace() : null, right: dh < 144 || stage.phase === "heard" ? null : agentFace(),
|
|
1522
1716
|
name: answered ? agentName : front.person ? front.person.name || to("dlgSomeone") : to("dlgSomeone"),
|
|
1523
1717
|
lines, status: status ? `${agentName} · ${status}` : null, more,
|
|
1524
1718
|
colours: boxColours(pack && pack.dialogBox, s.env.pal), frame: frameIm ? { im: frameIm, slice: pack.dialogBox.slice || 8, k: pack.scale || 2 } : null,
|
|
1525
1719
|
}, t, { ...s.env, still });
|
|
1526
1720
|
}
|
|
1721
|
+
// A newly mounted dock must paint even when reduced motion leaves the map loop asleep.
|
|
1722
|
+
useLayoutEffect(() => {
|
|
1723
|
+
if (!dialogueOn || !dlgVisible) return;
|
|
1724
|
+
if (scene.current) drawDialogue(scene.current.ctx, scene.current, still ? 0 : now());
|
|
1725
|
+
if (!still) loop.current?.wake();
|
|
1726
|
+
}, [dialogueOn, dlgVisible, dlgSay, width, phone, ratio]);
|
|
1727
|
+
|
|
1527
1728
|
// The loop: drawing only when the frame (FPS) changed or something is in the air; stopped while the tab is hidden,
|
|
1528
1729
|
// gone with the view. Office review: while something walks or flies, one requestAnimationFrame per display frame (the
|
|
1529
1730
|
// motion is smooth); when nothing moves, the poses change at most FPS times a second, so the loop sleeps (a timer)
|
|
1530
1731
|
// until the next frame's start instead of waking at the display's rate only to find nothing to draw.
|
|
1531
1732
|
useEffect(() => {
|
|
1532
1733
|
if (still || typeof requestAnimationFrame !== "function") return undefined;
|
|
1533
|
-
let raf = 0, timer = 0, last = -1, air = true, gone = false;
|
|
1734
|
+
let raf = 0, timer = 0, last = -1, lastFps = FPS, air = true, gone = false;
|
|
1534
1735
|
const tick = () => {
|
|
1535
1736
|
raf = 0;
|
|
1536
1737
|
if (gone || globalThis.document?.hidden || !scene.current) return;
|
|
1537
|
-
const
|
|
1538
|
-
|
|
1738
|
+
const fps = scene.current.fps || FPS;
|
|
1739
|
+
const ms = now(), frame = Math.floor((ms / 1000) * fps); // the clock the trips started on
|
|
1740
|
+
if (scene.current.dirty || frame !== last || fps !== lastFps || air) { scene.current.dirty = false; last = frame; lastFps = fps; air = draw(ms); }
|
|
1539
1741
|
if (air) { raf = requestAnimationFrame(tick); return; }
|
|
1540
|
-
const wait = Math.max(1, Math.ceil(((frame + 1) * 1000) /
|
|
1541
|
-
|
|
1742
|
+
const wait = Math.max(1, Math.ceil(((frame + 1) * 1000) / fps - ms)); // until the next frame starts
|
|
1743
|
+
if (fps > FPS && wait <= 16) { raf = requestAnimationFrame(tick); return; }
|
|
1744
|
+
const sleep = fps > FPS ? Math.max(1, wait - 14) : wait;
|
|
1745
|
+
timer = setTimeout(() => { timer = 0; if (!gone && !raf) raf = requestAnimationFrame(tick); }, sleep);
|
|
1542
1746
|
};
|
|
1543
1747
|
const wake = () => {
|
|
1544
1748
|
air = true;
|
|
@@ -1611,12 +1815,24 @@ export function Office({ view, traffic, q = "", lease, onOpen, assetUrl, assetIm
|
|
|
1611
1815
|
pinch: (from, to) => { raw.current = Math.min(OK_MAX, Math.max(OK_MIN, raw.current * (to.dist / from.dist))); setView(pinchOffice(view0(), from, to, raw.current)); } });
|
|
1612
1816
|
/** Where a drag pans: the canvas, and Edit layout's overlay off its handles (the controls, the bar and the list: never). */
|
|
1613
1817
|
const onScene = (el) => !!el && (el === canvasRef.current || (typeof el.closest === "function" && !!el.closest(".ol-svg") && !el.closest(".ol-handle")));
|
|
1614
|
-
/** M-3293
|
|
1818
|
+
/** M-3293 / M-3445: update the floor-level seat drop targets while carrying `h` ({ name, at }). */
|
|
1819
|
+
const updateSeatDrop = (h) => {
|
|
1820
|
+
if (!h || !zones || !skin || !skin.pack) { seatDropRef.current = null; return; }
|
|
1821
|
+
const ds = desksOf(L);
|
|
1822
|
+
seatDropRef.current = {
|
|
1823
|
+
name: h.name,
|
|
1824
|
+
targets: seatDropTargets(skin.pack, ds, h.name),
|
|
1825
|
+
hover: findSeatDropTarget(skin.pack, ds, h.name, h.at),
|
|
1826
|
+
};
|
|
1827
|
+
};
|
|
1828
|
+
/** M-3293 / M-3445: someone picked up — enters `dragged` pose under the pointer, highlights valid seats in their area. */
|
|
1615
1829
|
const pickedUp = (pointerId) => {
|
|
1616
1830
|
const h = hold.held();
|
|
1617
1831
|
if (!h) return;
|
|
1618
1832
|
// Captured only now: a press that stays a click must reach the canvas (its card), which a capture would take away.
|
|
1619
1833
|
try { stageRef.current.setPointerCapture(pointerId); } catch { /* gone */ }
|
|
1834
|
+
snacks.cancel(h.name);
|
|
1835
|
+
updateSeatDrop(h);
|
|
1620
1836
|
walkers.place(h.name, h.at); drag.current.swallow = true;
|
|
1621
1837
|
setTip(null); setCard(null); loop.current?.wake();
|
|
1622
1838
|
};
|
|
@@ -1634,24 +1850,60 @@ export function Office({ view, traffic, q = "", lease, onOpen, assetUrl, assetIm
|
|
|
1634
1850
|
g.down(e);
|
|
1635
1851
|
if (drag.current.pts.size === 2) raw.current = view0().k; // a pinch starts from the zoom shown
|
|
1636
1852
|
};
|
|
1637
|
-
/** M-3293: while a press may pick someone up it is theirs (no pan); once held it carries them; a finger that moved first pans. */
|
|
1853
|
+
/** M-3293 / M-3445: while a press may pick someone up it is theirs (no pan); once held it carries them; a finger that moved first pans. */
|
|
1638
1854
|
const onStageMove = (e) => {
|
|
1639
1855
|
if (hold.state()) {
|
|
1640
1856
|
const w = pointOf(e), was = hold.state();
|
|
1641
1857
|
const st = w ? hold.move(e.pointerId, w.x, w.y, now(), e.clientX, e.clientY) : hold.state();
|
|
1642
|
-
if (st === "held") {
|
|
1858
|
+
if (st === "held") {
|
|
1859
|
+
if (was !== "held") pickedUp(e.pointerId);
|
|
1860
|
+
else { const h = hold.held(); updateSeatDrop(h); walkers.place(h.name, h.at); loop.current?.wake(); }
|
|
1861
|
+
return;
|
|
1862
|
+
}
|
|
1643
1863
|
if (st === "maybe" || st === "press") return;
|
|
1644
|
-
if (st === "pan") { clearTimeout(holdTimer.current); hold.cancel(); }
|
|
1864
|
+
if (st === "pan") { clearTimeout(holdTimer.current); hold.cancel(); seatDropRef.current = null; }
|
|
1645
1865
|
}
|
|
1646
1866
|
g.move(e);
|
|
1647
1867
|
};
|
|
1868
|
+
/** M-3445 (#4266): settle a dragged character onto a valid seat in their area (or clamp/walk back to their seat). */
|
|
1869
|
+
const finishHoldDrop = (r, commitSeat) => {
|
|
1870
|
+
seatDropRef.current = null;
|
|
1871
|
+
if (!r) return;
|
|
1872
|
+
const ds = desksOf(L);
|
|
1873
|
+
const target = commitSeat && zones && skin && skin.pack ? findSeatDropTarget(skin.pack, ds, r.name, r.at) : null;
|
|
1874
|
+
if (target) {
|
|
1875
|
+
if (!target.current) {
|
|
1876
|
+
const res = applySeatDrop({ pack: skin.pack, desks: ds, seats: seatsRef.current, prefs: seatPrefsRef.current, name: r.name, target });
|
|
1877
|
+
seatsRef.current = res.seats;
|
|
1878
|
+
seatPrefsRef.current = res.prefs;
|
|
1879
|
+
if (!shared) store.saveSeats(officeKey, res.prefs);
|
|
1880
|
+
if (res.swapped) {
|
|
1881
|
+
const occPos = walkers.at(res.swapped.name, now()) || { x: target.x, y: target.y };
|
|
1882
|
+
if (ownArea && !routeStaysInArea(occPos, res.swapped.seat, L, target.area, null)) {
|
|
1883
|
+
walkers.place(res.swapped.name, res.swapped.seat);
|
|
1884
|
+
}
|
|
1885
|
+
}
|
|
1886
|
+
walkers.place(r.name, { x: target.x, y: target.y });
|
|
1887
|
+
setSeatRev((n) => n + 1);
|
|
1888
|
+
} else {
|
|
1889
|
+
walkers.place(r.name, { x: target.x, y: target.y });
|
|
1890
|
+
walkNow.current?.();
|
|
1891
|
+
}
|
|
1892
|
+
} else {
|
|
1893
|
+
const d = ds.find((x) => x && x.node && x.node.name === r.name);
|
|
1894
|
+
const landAt = ownArea && d ? clampDropForArea(r.at, d.seat, L, d.area) : r.at;
|
|
1895
|
+
walkers.place(r.name, landAt);
|
|
1896
|
+
walkNow.current?.();
|
|
1897
|
+
}
|
|
1898
|
+
loop.current?.wake();
|
|
1899
|
+
};
|
|
1648
1900
|
const onStageUp = (e) => {
|
|
1649
1901
|
clearTimeout(holdTimer.current);
|
|
1650
1902
|
const r = hold.up(e.pointerId);
|
|
1651
|
-
if (r) {
|
|
1903
|
+
if (r) { finishHoldDrop(r, true); drag.current.swallow = true; setTimeout(() => { if (!drag.current.pts.size) drag.current.swallow = false; }, 0); }
|
|
1652
1904
|
g.up(e);
|
|
1653
1905
|
};
|
|
1654
|
-
const onStageCancel = (e) => { clearTimeout(holdTimer.current); const r = hold.up(e.pointerId);
|
|
1906
|
+
const onStageCancel = (e) => { clearTimeout(holdTimer.current); const r = hold.up(e.pointerId); finishHoldDrop(r, false); g.up(e); };
|
|
1655
1907
|
const onWheel = (e) => {
|
|
1656
1908
|
if (!onScene(e.target) && !(typeof e.target?.closest === "function" && e.target.closest(".ol-handle, .oo-tile-label"))) return;
|
|
1657
1909
|
e.preventDefault();
|
|
@@ -1661,6 +1913,14 @@ export function Office({ view, traffic, q = "", lease, onOpen, assetUrl, assetIm
|
|
|
1661
1913
|
};
|
|
1662
1914
|
const onKeyDown = (e) => {
|
|
1663
1915
|
if (e.defaultPrevented) return; // Edit layout's handles move with the arrows
|
|
1916
|
+
if (e.key === "Escape" && hold.held()) {
|
|
1917
|
+
e.preventDefault();
|
|
1918
|
+
clearTimeout(holdTimer.current);
|
|
1919
|
+
const h = hold.held();
|
|
1920
|
+
hold.cancel();
|
|
1921
|
+
finishHoldDrop(h, false);
|
|
1922
|
+
return;
|
|
1923
|
+
}
|
|
1664
1924
|
const tag = e.target && e.target.tagName;
|
|
1665
1925
|
if (tag === "INPUT" || tag === "SELECT" || tag === "TEXTAREA") return;
|
|
1666
1926
|
const z = zoomKey(e);
|
|
@@ -1680,12 +1940,29 @@ export function Office({ view, traffic, q = "", lease, onOpen, assetUrl, assetIm
|
|
|
1680
1940
|
};
|
|
1681
1941
|
/** #2861: the dialogue box under a pointer event ({ key, name }: its agent), or null. */
|
|
1682
1942
|
const dlgAt = (e) => {
|
|
1683
|
-
const b = dlgShown.current, r =
|
|
1943
|
+
const b = dlgShown.current, r = dialogueCanvasRef.current ? dialogueCanvasRef.current.getBoundingClientRect() : null;
|
|
1684
1944
|
return b && r && onBox(b.L, b.stage, e.clientX - r.left, e.clientY - r.top) ? b : null;
|
|
1685
1945
|
};
|
|
1946
|
+
// Use the painted prefix and final displaced position, including bubbles outside an overview tile.
|
|
1947
|
+
const bubbleAtEvent = (e) => {
|
|
1948
|
+
// An armed snack owns map taps until the existing placement/feed action consumes it.
|
|
1949
|
+
if (shared || !onOpen || showSnacks && armedSnack) return null;
|
|
1950
|
+
const s = scene.current, r = canvasRef.current?.getBoundingClientRect();
|
|
1951
|
+
if (!s || !r) return null;
|
|
1952
|
+
const hit = officeBubbleAt(s.bubbleHits || [], (e.clientX - r.left) * s.ratio, (e.clientY - r.top) * s.ratio, lastType.current === "touch" ? 44 * s.ratio : 0);
|
|
1953
|
+
return hit && people.some(d => d.node.i && d.node.name === hit.name) ? hit : null;
|
|
1954
|
+
};
|
|
1955
|
+
const openDialogue = (e) => {
|
|
1956
|
+
if (shared || !onOpen || !dlgShown.current || e.detail > 1) return;
|
|
1957
|
+
if (e.type === "keydown") {
|
|
1958
|
+
if (e.repeat || e.key !== "Enter" && e.key !== " ") return;
|
|
1959
|
+
e.preventDefault();
|
|
1960
|
+
}
|
|
1961
|
+
setCard(null); open(dlgShown.current.name);
|
|
1962
|
+
};
|
|
1686
1963
|
const onMove = (e) => {
|
|
1687
|
-
if (e.pointerType === "touch" || g.busy()) return;
|
|
1688
|
-
const onDlg = !!dlgAt(e);
|
|
1964
|
+
if (e.pointerType === "touch" || g.busy() || snackDrag || snackDropRef.current) return;
|
|
1965
|
+
const onDlg = !!dlgAt(e) || !!bubbleAtEvent(e);
|
|
1689
1966
|
if (onDlg !== dlgHot) setDlgHot(onDlg);
|
|
1690
1967
|
const d = onDlg ? null : deskOf(e); const key = d ? d.key : null; if (key !== tip) setTip(key);
|
|
1691
1968
|
};
|
|
@@ -1710,9 +1987,145 @@ export function Office({ view, traffic, q = "", lease, onOpen, assetUrl, assetIm
|
|
|
1710
1987
|
});
|
|
1711
1988
|
return nearestPerson(list, w.x, w.y, TAP_R / Math.max(OK_MIN, view0().k));
|
|
1712
1989
|
};
|
|
1990
|
+
/** M-3432 (#4255): feed an awake person a snack (plays eat animation + hearts + feed bubble + optional Tell). */
|
|
1991
|
+
const feedPerson = (name, snack, at) => {
|
|
1992
|
+
const t = now();
|
|
1993
|
+
snacks.feed(name, snack, { x: at.x, y: at.y, t, charEatStrip: skin.eatStrip ? skin.eatStrip(name) : null });
|
|
1994
|
+
reacts.current.set(name, { kind: "feed", t0: t });
|
|
1995
|
+
if (store.tellOn(name)) void store.tell(name, "feed");
|
|
1996
|
+
walkNow.current?.();
|
|
1997
|
+
loop.current?.wake();
|
|
1998
|
+
};
|
|
1999
|
+
/** M-3432 (#4255): drop a snack on the floor so nearby idle characters race to it. */
|
|
2000
|
+
const placeSnackAt = (snack, at) => {
|
|
2001
|
+
const t = now();
|
|
2002
|
+
const hidden = scene.current && scene.current.part ? furnitureAt(scene.current.part, t).hidden : null;
|
|
2003
|
+
snacks.place(snack, at, t, { desks: desksOf(L), walkers, hidden, ownArea, areas: L.areas, graph: L });
|
|
2004
|
+
walkNow.current?.();
|
|
2005
|
+
loop.current?.wake();
|
|
2006
|
+
};
|
|
2007
|
+
/** M-3432 (#4255): classify a pointer position while dragging a snack (awake person → feed, floor → place, tray/asleep/outside → cancel). */
|
|
2008
|
+
const snackTargetOf = (e) => {
|
|
2009
|
+
const tray = snackTrayRef.current;
|
|
2010
|
+
if (tray && typeof tray.getBoundingClientRect === "function") {
|
|
2011
|
+
const tr = tray.getBoundingClientRect();
|
|
2012
|
+
if (e.clientX >= tr.left && e.clientX <= tr.right && e.clientY >= tr.top && e.clientY <= tr.bottom) return null;
|
|
2013
|
+
}
|
|
2014
|
+
const st = stageRef.current;
|
|
2015
|
+
if (st && typeof st.getBoundingClientRect === "function") {
|
|
2016
|
+
const sr = st.getBoundingClientRect();
|
|
2017
|
+
if (e.clientX < sr.left || e.clientX > sr.right || e.clientY < sr.top || e.clientY > sr.bottom) return null;
|
|
2018
|
+
}
|
|
2019
|
+
const d = deskOf(e) || (e.pointerType === "touch" ? nearOf(e) : null);
|
|
2020
|
+
if (d && d.node && d.node.i) {
|
|
2021
|
+
if (ASLEEP.has(d.node.state) || d.night) return null;
|
|
2022
|
+
const at = (zones && walkers.at(d.node.name, now())) || d.seat || { x: d.x + d.w / 2, y: d.y + d.h };
|
|
2023
|
+
return { kind: "feed", name: d.node.name, label: nodeText(d.node).primary, x: at.x, y: at.y };
|
|
2024
|
+
}
|
|
2025
|
+
const w = pointOf(e);
|
|
2026
|
+
if (!w || w.x < 0 || w.x > L.width || w.y < 0 || w.y > L.height) return null;
|
|
2027
|
+
return { kind: "place", x: w.x, y: w.y };
|
|
2028
|
+
};
|
|
2029
|
+
/** M-3432 (#4255): drag a snack from the tray onto a character or empty floor; a short tap is left to onClick (tap-to-arm). */
|
|
2030
|
+
const onSnackDown = (snack, e) => {
|
|
2031
|
+
if (!showSnacks || e.isPrimary === false || (e.pointerType === "mouse" && e.button !== 0)) return;
|
|
2032
|
+
e.stopPropagation();
|
|
2033
|
+
const startOffice = officeKey, startStyle = styleKey;
|
|
2034
|
+
let lastKey = "";
|
|
2035
|
+
const moveGhost = (cx, cy) => {
|
|
2036
|
+
const sr = stageRef.current ? stageRef.current.getBoundingClientRect() : null;
|
|
2037
|
+
if (!sr) return;
|
|
2038
|
+
const gx = Math.round(cx - sr.left + 12), gy = Math.round(cy - sr.top - 40);
|
|
2039
|
+
snackGhostPosRef.current = { x: gx, y: gy };
|
|
2040
|
+
const gh = snackGhostRef.current;
|
|
2041
|
+
if (gh && gh.style) gh.style.setProperty("transform", `translate(${gx}px, ${gy}px)`);
|
|
2042
|
+
};
|
|
2043
|
+
const swallowClick = () => {
|
|
2044
|
+
snackSwallowRef.current = true;
|
|
2045
|
+
setTimeout(() => { snackSwallowRef.current = false; }, 0);
|
|
2046
|
+
};
|
|
2047
|
+
snackDragCtrl.start({
|
|
2048
|
+
pid: e.pointerId,
|
|
2049
|
+
sx: e.clientX,
|
|
2050
|
+
sy: e.clientY,
|
|
2051
|
+
slop: PLAY.SLOP,
|
|
2052
|
+
onMove: (ev, { starting }) => {
|
|
2053
|
+
if (starting) { setCard(null); setTip(null); }
|
|
2054
|
+
ev.preventDefault();
|
|
2055
|
+
if (tipNow.current) setTip(null);
|
|
2056
|
+
moveGhost(ev.clientX, ev.clientY);
|
|
2057
|
+
const drop = snackTargetOf(ev);
|
|
2058
|
+
snackDropRef.current = drop;
|
|
2059
|
+
const k = drop ? `${drop.kind}:${drop.name || ""}` : "";
|
|
2060
|
+
if (starting || k !== lastKey) {
|
|
2061
|
+
lastKey = k;
|
|
2062
|
+
setSnackDrag({ snack, kind: drop ? drop.kind : null, label: drop && drop.kind === "feed" ? drop.label : "" });
|
|
2063
|
+
}
|
|
2064
|
+
loop.current?.wake();
|
|
2065
|
+
return drop;
|
|
2066
|
+
},
|
|
2067
|
+
onCommit: (drop) => {
|
|
2068
|
+
snackDropRef.current = null;
|
|
2069
|
+
setSnackDrag(null);
|
|
2070
|
+
swallowClick();
|
|
2071
|
+
const cur = snackCtxRef.current;
|
|
2072
|
+
if (cur.showSnacks && cur.officeKey === startOffice && cur.styleKey === startStyle) {
|
|
2073
|
+
if (drop.kind === "feed") feedPerson(drop.name, snack, { x: drop.x, y: drop.y });
|
|
2074
|
+
else if (drop.kind === "place") placeSnackAt(snack, { x: drop.x, y: drop.y });
|
|
2075
|
+
setArmedSnack(null);
|
|
2076
|
+
}
|
|
2077
|
+
loop.current?.wake();
|
|
2078
|
+
},
|
|
2079
|
+
onCancel: ({ dragging }) => {
|
|
2080
|
+
snackDropRef.current = null;
|
|
2081
|
+
setSnackDrag(null);
|
|
2082
|
+
if (dragging) swallowClick();
|
|
2083
|
+
loop.current?.wake();
|
|
2084
|
+
},
|
|
2085
|
+
});
|
|
2086
|
+
};
|
|
2087
|
+
useEffect(() => {
|
|
2088
|
+
if (!armedSnack) return undefined;
|
|
2089
|
+
const onEsc = (e) => { if (e.key === "Escape" && !e.defaultPrevented) { e.preventDefault(); setArmedSnack(null); } };
|
|
2090
|
+
globalThis.document?.addEventListener?.("keydown", onEsc, true);
|
|
2091
|
+
return () => globalThis.document?.removeEventListener?.("keydown", onEsc, true);
|
|
2092
|
+
}, [armedSnack]);
|
|
2093
|
+
const paintSnackIcon = (st, pxSize = 28) => (cv) => {
|
|
2094
|
+
const g = cv && typeof cv.getContext === "function" ? cv.getContext("2d") : null;
|
|
2095
|
+
if (!g || !st || !skin || typeof skin.drawSnackIcon !== "function") return;
|
|
2096
|
+
const r = deviceRatio(), S = pxSize;
|
|
2097
|
+
if (cv.width !== Math.round(S * r) || cv.height !== Math.round(S * r)) { cv.width = Math.round(S * r); cv.height = Math.round(S * r); }
|
|
2098
|
+
g.setTransform(r, 0, 0, r, 0, 0); g.clearRect(0, 0, S, S);
|
|
2099
|
+
skin.drawSnackIcon(g, st, S);
|
|
2100
|
+
};
|
|
1713
2101
|
const onClick = (e) => {
|
|
1714
2102
|
const box = dlgAt(e);
|
|
2103
|
+
const bubble = bubbleAtEvent(e);
|
|
2104
|
+
if ((box || bubble) && !shared && onOpen) {
|
|
2105
|
+
if (!(e.detail > 1)) { setCard(null); open((box || bubble).name); }
|
|
2106
|
+
return;
|
|
2107
|
+
}
|
|
1715
2108
|
if (box) { focusPerson(box.key); return; }
|
|
2109
|
+
if (showSnacks && armedSnack) {
|
|
2110
|
+
const snack = snacksById.get(armedSnack);
|
|
2111
|
+
if (snack) {
|
|
2112
|
+
const hit = deskOf(e) || (lastType.current === "touch" ? nearOf(e) : null);
|
|
2113
|
+
if (hit && hit.node && hit.node.i) {
|
|
2114
|
+
if (!ASLEEP.has(hit.node.state) && !hit.night) {
|
|
2115
|
+
const at = (zones && walkers.at(hit.node.name, now())) || hit.seat || { x: hit.x + hit.w / 2, y: hit.y + hit.h };
|
|
2116
|
+
feedPerson(hit.node.name, snack, at);
|
|
2117
|
+
}
|
|
2118
|
+
setArmedSnack(null);
|
|
2119
|
+
return;
|
|
2120
|
+
}
|
|
2121
|
+
const w = pointOf(e);
|
|
2122
|
+
if (w && w.x >= 0 && w.x <= L.width && w.y >= 0 && w.y <= L.height) {
|
|
2123
|
+
placeSnackAt(snack, w);
|
|
2124
|
+
setArmedSnack(null);
|
|
2125
|
+
return;
|
|
2126
|
+
}
|
|
2127
|
+
}
|
|
2128
|
+
}
|
|
1716
2129
|
const d = deskOf(e) || (lastType.current === "touch" ? nearOf(e) : null);
|
|
1717
2130
|
if (!d || !d.node.i) { setTip(null); setCard(null); return; }
|
|
1718
2131
|
if (lastType.current === "touch") setTip(null);
|
|
@@ -1722,7 +2135,7 @@ export function Office({ view, traffic, q = "", lease, onOpen, assetUrl, assetIm
|
|
|
1722
2135
|
// All offices: a double-click on a tile (off its people) opens that office; the lobby is no office.
|
|
1723
2136
|
const onDblClick = (e) => {
|
|
1724
2137
|
const box = dlgAt(e);
|
|
1725
|
-
if (box
|
|
2138
|
+
if (box || bubbleAtEvent(e)) return; // the first click already opened it
|
|
1726
2139
|
const s = scene.current, w = pointOf(e), hit = deskOf(e);
|
|
1727
2140
|
if (hit && hit.node.i) { setCard(null); open(hit.node.name); return; } // #2661: a person's chat, past the card
|
|
1728
2141
|
if (!overview || !s || !s.overview || !w || hit) return;
|
|
@@ -1831,12 +2244,12 @@ export function Office({ view, traffic, q = "", lease, onOpen, assetUrl, assetIm
|
|
|
1831
2244
|
setView(centreOn({ ...v, k }, size, at.x, at.y));
|
|
1832
2245
|
};
|
|
1833
2246
|
/** The card's picture: the person's idle frame in the office's style (pack strip or built-in figure). */
|
|
1834
|
-
const drawAvatar = (cv) => {
|
|
2247
|
+
const drawAvatar = (cv, sizePx = 56) => {
|
|
1835
2248
|
const s = scene.current, c = cardOf;
|
|
1836
2249
|
const g = cv && cv.getContext ? cv.getContext("2d") : null;
|
|
1837
2250
|
if (!g || !c || !s || !c.skin || !c.look) return;
|
|
1838
|
-
const r = deviceRatio(), W = 56;
|
|
1839
|
-
if (cv.width !== W * r) { cv.width = W * r; cv.height = W * r; }
|
|
2251
|
+
const r = deviceRatio(), W = Number(sizePx) || 56;
|
|
2252
|
+
if (cv.width !== Math.round(W * r) || cv.height !== Math.round(W * r)) { cv.width = Math.round(W * r); cv.height = Math.round(W * r); }
|
|
1840
2253
|
g.setTransform(1, 0, 0, 1, 0, 0); g.clearRect(0, 0, cv.width, cv.height); g.imageSmoothingEnabled = false;
|
|
1841
2254
|
const look = { ...c.look, pose: "idle", dim: false, match: false, badge: null, notag: true, free: true, work: 0, sign: null };
|
|
1842
2255
|
const at = { x: 0, y: 0 }, b = c.skin.charBox ? c.skin.charBox(look, at) : null, box = b || { x: -16, y: -48, w: 32, h: 48 };
|
|
@@ -1909,7 +2322,7 @@ export function Office({ view, traffic, q = "", lease, onOpen, assetUrl, assetIm
|
|
|
1909
2322
|
${canLayout ? html`<button type="button" class="btn btn-sm oo-layout" onClick=${openLayout}>${t("orgl.edit")}</button>` : null}
|
|
1910
2323
|
${canShare ? html`<${ShareButton} offices=${stored} current=${overview ? "all" : custom ? custom.id : null} disabled=${!!layout}
|
|
1911
2324
|
get=${lease ? (path, o) => lease.fetch(path, o) : undefined} />` : null}`;
|
|
1912
|
-
return html`<div class=${`oo${fs ? ` fs ${fs}` : ""}${compact ? " phone" : ""}`} ref=${ooRef}>
|
|
2325
|
+
return html`<div class=${`oo${fs ? ` fs ${fs}` : ""}${compact ? " phone" : ""}${dlgVisible ? " has-dialogue" : ""}`} ref=${ooRef}>
|
|
1913
2326
|
${compact ? null : html`<div class="oo-bar">${barItems}</div>`}
|
|
1914
2327
|
${compact && more ? html`<${Dialog} title=${to("office")} cls="oo-sheet" onClose=${closeMore}>
|
|
1915
2328
|
<div class="oo-sheet-tiles">
|
|
@@ -1948,8 +2361,23 @@ export function Office({ view, traffic, q = "", lease, onOpen, assetUrl, assetIm
|
|
|
1948
2361
|
where: [cardOf.office || (custom ? custom.name : to("allOffice")), cardOf.area].filter(Boolean).join(" · ") })}
|
|
1949
2362
|
avatar=${drawAvatar} sheet=${phone || size.w < SHEET_W} place=${(el) => { cardEl.current = el; placeCard(); }}
|
|
1950
2363
|
onChat=${onOpen ? () => { const n = cardOf.node.name; setCard(null); open(n); } : null} onFind=${findCard} onClose=${closeCard}
|
|
1951
|
-
onReact=${play ? (kind) => {
|
|
1952
|
-
|
|
2364
|
+
onReact=${play ? (kind) => {
|
|
2365
|
+
const n = cardOf.node.name;
|
|
2366
|
+
if (kind === "feed" && !ASLEEP.has(cardOf.node.state) && !cardOf.box.night) {
|
|
2367
|
+
const sn = (armedSnack && snacksById.get(armedSnack)) || packSnacks[0] || null;
|
|
2368
|
+
if (sn || (skin.eatStrip && skin.eatStrip(n))) {
|
|
2369
|
+
const at = (zones && walkers.at(n, now())) || cardOf.box.seat || { x: cardOf.box.x + cardOf.box.w / 2, y: cardOf.box.y + cardOf.box.h };
|
|
2370
|
+
snacks.feed(n, sn, { x: at.x, y: at.y, t: now(), charEatStrip: skin.eatStrip ? skin.eatStrip(n) : null });
|
|
2371
|
+
walkNow.current?.();
|
|
2372
|
+
}
|
|
2373
|
+
}
|
|
2374
|
+
reacts.current.set(n, { kind, t0: now() }); loop.current?.wake(); if (store.tellOn(n)) void store.tell(n, kind);
|
|
2375
|
+
} : null}
|
|
2376
|
+
tell=${play ? { on: store.tellOn(cardOf.node.name), set: (v) => { store.saveTell(cardOf.node.name, v); setTellRev((x) => x + 1); } } : null}
|
|
2377
|
+
packCard=${cardOf.skin?.pack?.card || null}
|
|
2378
|
+
picture=${typeof cardOf.skin?.picture === "function" ? cardOf.skin.picture : null}
|
|
2379
|
+
portrait=${cardOf.skin?.pack ? portraitSrc(cardOf.skin.pack, { agent: cardOf.node.name, state: cardOf.node.state }) : null}
|
|
2380
|
+
packScale=${cardOf.skin?.pack?.scale || 2} />` : null}
|
|
1953
2381
|
<ul class="oo-desks" aria-label=${to("desks")}>${people.map((d) => {
|
|
1954
2382
|
const nt = nodeText(d.node), cap = caption(officePose(d.node.state), d.node.state), where = d.office ? ` · ${d.office}` : "";
|
|
1955
2383
|
return html`<li key=${d.key}>${d.node.i
|
|
@@ -1966,9 +2394,24 @@ export function Office({ view, traffic, q = "", lease, onOpen, assetUrl, assetIm
|
|
|
1966
2394
|
title=${to("fillTitle")} onClick=${toggleFill}>${to("fill")}</button>
|
|
1967
2395
|
<button type="button" class="icon-btn oo-fs" aria-label=${to(fs ? "exitFullscreen" : "fullscreen")} title=${to(fs ? "exitFullscreen" : "fullscreen")} onClick=${toggleFs}><${Icon} name=${fs ? "fullscreenexit" : "fullscreen"} size=${16} /></button>
|
|
1968
2396
|
</div>
|
|
1969
|
-
${
|
|
1970
|
-
|
|
1971
|
-
|
|
2397
|
+
${showSnacks ? html`<div ref=${snackTrayRef} class="oo-snacks" role="toolbar" aria-label=${to("snacks")}>
|
|
2398
|
+
${packSnacks.map((sn) => {
|
|
2399
|
+
const lb = snackLabel(sn, lang());
|
|
2400
|
+
return html`<button key=${sn.id} type="button" class="icon-btn oo-snack" data-snack=${sn.id}
|
|
2401
|
+
aria-label=${to("snackArm", lb)} title=${lb} aria-pressed=${armedSnack === sn.id ? "true" : "false"}
|
|
2402
|
+
onPointerDown=${(e) => onSnackDown(sn, e)}
|
|
2403
|
+
onClick=${(e) => { e.stopPropagation(); if (snackSwallowRef.current) return; setArmedSnack((cur) => (cur === sn.id ? null : sn.id)); }}>
|
|
2404
|
+
<canvas class="oo-snack-icon" width="28" height="28" aria-hidden="true" ref=${paintSnackIcon(sn.sprite, 28)}></canvas>
|
|
2405
|
+
</button>`;
|
|
2406
|
+
})}
|
|
2407
|
+
</div>` : null}
|
|
2408
|
+
${snackDrag ? html`<div class="oo-snack-ghost" aria-hidden="true" ref=${(el) => {
|
|
2409
|
+
snackGhostRef.current = el;
|
|
2410
|
+
if (el && el.style && snackGhostPosRef.current) el.style.setProperty("transform", `translate(${snackGhostPosRef.current.x}px, ${snackGhostPosRef.current.y}px)`);
|
|
2411
|
+
}}>
|
|
2412
|
+
<canvas class="oo-snack-icon" width="28" height="28" ref=${paintSnackIcon(snackDrag.snack.sprite, 28)}></canvas>
|
|
2413
|
+
${snackDrag.kind === "feed" ? html`<span class="oo-snack-hint">${to("snackFeed", snackDrag.label)}</span>`
|
|
2414
|
+
: snackDrag.kind === "place" ? html`<span class="oo-snack-hint">${to("snackPlace")}</span>` : null}
|
|
1972
2415
|
</div>` : null}
|
|
1973
2416
|
${fs ? html`<div class="oo-fs-bar">${officeSelect("oo-fs-office")}${carChrome()}</div>` : null}
|
|
1974
2417
|
<svg ref=${miniRef} class="oc-mini oo-mini" viewBox=${`0 0 ${Math.max(1, L.width)} ${Math.max(1, L.height)}`} aria-hidden="true" onClick=${onMini}>
|
|
@@ -1980,5 +2423,13 @@ export function Office({ view, traffic, q = "", lease, onOpen, assetUrl, assetIm
|
|
|
1980
2423
|
<rect ref=${miniViewRef} class="oc-mini-view oo-mini-view" />
|
|
1981
2424
|
</svg>
|
|
1982
2425
|
</div>
|
|
2426
|
+
${zoneList.length ? html`<div class="oo-zone-pills" role="group" aria-label=${to("zones")}>
|
|
2427
|
+
<button type="button" class="btn btn-sm oo-zone-all" onClick=${() => fit()}>${to("zoneAll")}</button>
|
|
2428
|
+
${zoneList.map((z) => html`<button key=${z.key} type="button" class="btn btn-sm oo-zone" data-area=${z.key} onClick=${() => toZone(z)}>${to("zoneN", areaName(z.key), z.n)}</button>`)}
|
|
2429
|
+
</div>` : null}
|
|
2430
|
+
${dialogueOn && dlgVisible ? html`<canvas class="oo-dialogue-canvas" ref=${dialogueCanvasRef}
|
|
2431
|
+
role=${onOpen && !shared ? "button" : "img"} tabindex=${onOpen && !shared ? "0" : null}
|
|
2432
|
+
aria-label=${onOpen && !shared ? to("dlgOpenChat") : dlgSay} title=${onOpen && !shared ? to("dlgOpenChat") : null}
|
|
2433
|
+
onClick=${openDialogue} onKeyDown=${openDialogue}></canvas>` : null}
|
|
1983
2434
|
</div>`;
|
|
1984
2435
|
}
|