@songsid/agend 2.4.0-beta.15 → 2.4.0-beta.16
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 +4 -0
- package/dist/auth-api.js.map +1 -1
- package/dist/backend/claude-code.d.ts +6 -1
- package/dist/backend/claude-code.js +63 -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 +2 -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 +62 -0
- package/dist/claude-credential-launch.js +304 -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 +51 -0
- package/dist/claude-credential-vault.js +252 -0
- package/dist/claude-credential-vault.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 +7 -6
- 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 +59 -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 +39 -2
- package/dist/fleet-manager.js +383 -19
- 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 +18 -5
- package/dist/host-monitoring-config.d.ts +14 -0
- package/dist/host-monitoring-config.js +31 -0
- package/dist/host-monitoring-config.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 +2 -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/settings-api.d.ts +12 -0
- package/dist/settings-api.js +146 -7
- package/dist/settings-api.js.map +1 -1
- package/dist/settings-change.js +2 -0
- package/dist/settings-change.js.map +1 -1
- package/dist/settings-effect.js +13 -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/types.d.ts +2 -0
- package/dist/ui/accounts-view.js +12 -6
- 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 +112 -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 +262 -3
- package/dist/ui/fleet-office-skin.js +67 -20
- package/dist/ui/fleet-office-zones.js +19 -1
- package/dist/ui/fleet-office.js +393 -47
- package/dist/ui/office-share-page.js +5 -1
- package/dist/ui/panel-chat.js +47 -3
- package/dist/ui/panel-fleet.js +1 -1
- package/dist/ui/panel-settings.js +2 -1
- package/dist/ui/preview-popout.js +134 -0
- package/dist/ui/reply-file-preview.js +1 -1
- package/dist/ui/settings-host-monitoring.js +51 -0
- package/dist/ui/settings-shared.js +3 -2
- package/dist/ui/shared/app.css +211 -27
- package/dist/ui/shared/app.js +7 -1
- package/dist/ui/shared/chat-strings.js +8 -2
- package/dist/ui/shared/info-tip.js +64 -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 +11 -1
- 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 +4 -1
- package/dist/web-api.js +29 -9
- package/dist/web-api.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-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";
|
|
@@ -75,14 +76,14 @@ import { CALLING, activeFurniture, bubbleAt, hiddenBy, bubbleRank, NIGHT, WANDER
|
|
|
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, createHold, createSnackDrag, createSnacks, playAllowed, pruneReactions, reactionAt, scatterWords } 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,15 @@ 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
|
+
if (!still && ms > 0 && p.snacks) {
|
|
499
|
+
const changed = p.snacks.step(t, {
|
|
500
|
+
desks: p.desks, walkers: p.walkers, hidden: live.hidden, ownArea: !!p.ownArea,
|
|
501
|
+
areas: p.L.areas, graph: p.L, snacksById: p.snacksById,
|
|
502
|
+
charEatOf: (n) => (sk.eatStrip ? sk.eatStrip(n) : null),
|
|
503
|
+
onClaim: p.onSnackClaim,
|
|
504
|
+
});
|
|
505
|
+
if (changed && typeof p.onSnacksChanged === "function") p.onSnacksChanged();
|
|
506
|
+
}
|
|
479
507
|
const people = p.desks.map((d) => {
|
|
480
508
|
const at = p.walkers.at(d.node.name, t) || { ...d.seat, walking: false };
|
|
481
509
|
if (at.walking) walking = true;
|
|
@@ -483,24 +511,67 @@ export function drawPart(ctx, p, a, ox, oy, ms, still, hot, env, tagsOff = false
|
|
|
483
511
|
}).sort((x, y) => x.at.y - y.at.y);
|
|
484
512
|
const furniture = strollFurniture(p.night ? nightFurniture(sk.pack.furniture) : sk.pack.furniture, (k) => p.walkers.at(k, t));
|
|
485
513
|
if (furniture.some((f) => f.walking)) walking = true;
|
|
486
|
-
const
|
|
514
|
+
const placedSnacks = p.snacks ? p.snacks.placedList() : [];
|
|
515
|
+
const band = [...furniture.filter((f) => f.depth === "y").map((f) => ({ y: f.y, k: 0, f })),
|
|
516
|
+
...placedSnacks.map((sn) => ({ y: sn.y, k: 0.5, sn })),
|
|
517
|
+
...people.map((q) => ({ y: q.at.y, k: 1, p: q })),
|
|
487
518
|
...(p.ghosts ? ghostsOf(sk.pack, people).map((g) => ({ y: g.y, k: 1, g })) : []),
|
|
488
519
|
// #2665: by day, each item's night place too (at night the items are there already).
|
|
489
520
|
...(p.ghosts && !p.night ? nightGhostsOf(sk.pack).map((n) => ({ y: n.y, k: 1, n })) : [])]
|
|
490
521
|
.sort((x, y) => x.y - y.y || x.k - y.k);
|
|
522
|
+
// M-3432 (#4255): draw drop-target rings above the floor layer only, never over furniture or characters.
|
|
523
|
+
const drop = p.snackDrop && p.snackDrop.current;
|
|
524
|
+
if (drop && drop.kind === "place") {
|
|
525
|
+
ctx.save();
|
|
526
|
+
ctx.fillStyle = "rgba(0, 0, 0, 0.16)";
|
|
527
|
+
ctx.beginPath(); ctx.ellipse(drop.x, drop.y, 16, 7, 0, 0, Math.PI * 2); ctx.fill();
|
|
528
|
+
ctx.strokeStyle = env.pal.accent; ctx.lineWidth = 1.5; ctx.setLineDash([4, 3]);
|
|
529
|
+
ctx.beginPath(); ctx.ellipse(drop.x, drop.y, 16, 7, 0, 0, Math.PI * 2); ctx.stroke();
|
|
530
|
+
ctx.restore();
|
|
531
|
+
} else if (drop && drop.kind === "feed") {
|
|
532
|
+
const target = people.find((q) => q.look.name === drop.name && !live.hidden.has(q.look.name));
|
|
533
|
+
if (target) {
|
|
534
|
+
ctx.save();
|
|
535
|
+
ctx.fillStyle = env.pal.accentDim;
|
|
536
|
+
ctx.beginPath(); ctx.ellipse(target.at.x, target.at.y, 24, 10, 0, 0, Math.PI * 2); ctx.fill();
|
|
537
|
+
ctx.strokeStyle = env.pal.accent; ctx.lineWidth = 2;
|
|
538
|
+
ctx.beginPath(); ctx.ellipse(target.at.x, target.at.y, 24, 10, 0, 0, Math.PI * 2); ctx.stroke();
|
|
539
|
+
ctx.restore();
|
|
540
|
+
}
|
|
541
|
+
}
|
|
491
542
|
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
543
|
for (const it of post) if (it.t === 0) sk.drawProp(ctx, it, ms, env); // a letter on the floor: under the people
|
|
493
|
-
for (const { f, p: q, g, n } of band) {
|
|
544
|
+
for (const { f, p: q, g, n, sn } of band) {
|
|
494
545
|
if (f) { sk.drawFurniture(ctx, f, f.asleep || live.active.has(f.id), ms, env); continue; }
|
|
546
|
+
if (sn) {
|
|
547
|
+
const sdef = p.snacksById && p.snacksById.get(sn.snackId);
|
|
548
|
+
if (sdef && sk.drawSnack) {
|
|
549
|
+
ctx.save();
|
|
550
|
+
ctx.fillStyle = "rgba(0, 0, 0, 0.22)";
|
|
551
|
+
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();
|
|
552
|
+
ctx.restore();
|
|
553
|
+
sk.drawSnack(ctx, sdef.sprite, ms, sn.x, sn.y, env, `sn:${sn.id}`);
|
|
554
|
+
}
|
|
555
|
+
continue;
|
|
556
|
+
}
|
|
495
557
|
if (n) { ctx.save(); ctx.globalAlpha = GHOST_ALPHA; sk.drawFurniture(ctx, n, true, 0, env); ctx.restore(); continue; }
|
|
496
558
|
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; }
|
|
497
559
|
if (live.hidden.has(q.look.name)) continue; // #2698: drawn as the item (never while walking)
|
|
498
560
|
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.
|
|
561
|
+
// 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
562
|
const posed = actPosed(p, q.look);
|
|
501
|
-
const
|
|
563
|
+
const eating = !q.at.walking && p.snacks && ms > 0 ? p.snacks.eatingOf(q.look.name, t) : null;
|
|
564
|
+
const canEat = !!eating && !CALLING.has(q.look.state) && !ASLEEP.has(q.look.state) && !q.look.night;
|
|
565
|
+
const look = q.at.walking ? { ...q.look, pose: "walk", heading: q.at.heading }
|
|
566
|
+
: canEat ? { ...posed, pose: "eat", basePose: posed.pose } : posed;
|
|
502
567
|
sk.drawCharacter(ctx, box, look, ms, env);
|
|
503
|
-
if (
|
|
568
|
+
if (canEat && eating.snackId && p.snacksById && sk.drawSnack) {
|
|
569
|
+
const sdef = p.snacksById.get(eating.snackId);
|
|
570
|
+
if (sdef && sdef.eat) sk.drawSnack(ctx, sdef.eat, Math.max(0, t - eating.t0), q.at.x, q.at.y, env);
|
|
571
|
+
}
|
|
572
|
+
if (!q.at.walking || (p.snacks && ms > 0 && p.snacks.scatterOf(q.look.name, t))) {
|
|
573
|
+
speakers.push({ look: q.look, ...speakerAt(sk, look, q.at), area: q.d.area });
|
|
574
|
+
}
|
|
504
575
|
}
|
|
505
576
|
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);
|
|
506
577
|
for (const it of up) sk.drawProp(ctx, it, ms, env);
|
|
@@ -613,16 +684,27 @@ export function drawPart(ctx, p, a, ox, oy, ms, still, hot, env, tagsOff = false
|
|
|
613
684
|
const packSays = ra ? linesFor(reacting.get(sp.look.name).kind, p.lang, sk.pack, null, sp.look.name) : [];
|
|
614
685
|
const raSays = ra ? (packSays.length ? packSays[Math.floor(reacting.get(sp.look.name).t0) % packSays.length] : ra.say) : null;
|
|
615
686
|
const own = raSays ? raSays : actLive(act, says, Date.now(), p.actSeen) && act.say ? act.say : null;
|
|
616
|
-
const
|
|
617
|
-
|
|
687
|
+
const sc = !own && p.snacks && ms > 0 ? p.snacks.scatterOf(sp.look.name, t0) : null;
|
|
688
|
+
const scText = sc ? scatterWords(p.lang) : null;
|
|
689
|
+
const b = own ? { text: own, shown: [...own].length }
|
|
690
|
+
: scText ? { text: scText, shown: [...scText].length }
|
|
691
|
+
: 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
|
|
692
|
+
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
693
|
box: bubbleBox(ctx, sp.x, sp.y, b.text), tail: { x: sp.x, y: sp.y }, sp, b });
|
|
619
694
|
}
|
|
620
695
|
// A crowded area speaks less (thinBubbles: calls, then work, a few at most); no bubble covers a name tag. `defer`
|
|
621
696
|
// (All offices): drawn after every tile, unclipped, so a bubble at a tile's edge is whole.
|
|
622
697
|
const placed = placeBubbles(thinBubbles(bubbles, p.zones ? p.L.over : null), 22, tags);
|
|
623
|
-
const say = () => { T(); for (const { sp, b, dy } of placed)
|
|
698
|
+
const say = () => { T(); for (const { sp, b, dy } of placed) {
|
|
699
|
+
const text = [...b.text].slice(0, b.shown).join("");
|
|
700
|
+
sk.drawBubble(ctx, sp.x, sp.y, text, env, -dy);
|
|
701
|
+
if (bubbleHits && text) {
|
|
702
|
+
const box = bubbleBox(ctx, sp.x, sp.y, text, -dy);
|
|
703
|
+
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 } });
|
|
704
|
+
}
|
|
705
|
+
} };
|
|
624
706
|
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;
|
|
707
|
+
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);
|
|
626
708
|
}
|
|
627
709
|
/**
|
|
628
710
|
* #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 +802,17 @@ export function OfficeKey({ pal }) {
|
|
|
720
802
|
* `opening` the office it opens on (the share's), instead of the one this browser chose last; #2861: `talk` the share's
|
|
721
803
|
* conversations (its /state's: who heard or answered a person, when — never what was said), instead of the stream's.
|
|
722
804
|
*/
|
|
805
|
+
function ensureDialogueStyle() {
|
|
806
|
+
const doc = globalThis.document;
|
|
807
|
+
if (!doc?.head || doc.querySelector('link[data-office-dialogue-css="1"]')) return;
|
|
808
|
+
const link = doc.createElement("link"); link.rel = "stylesheet";
|
|
809
|
+
link.href = assetUrl("/assets/office-dialogue.css");
|
|
810
|
+
link.setAttribute("data-office-dialogue-css", "1"); doc.head.appendChild(link);
|
|
811
|
+
}
|
|
723
812
|
export function Office({ view, traffic, q = "", lease, onOpen, assetUrl, assetImage, opening, talk, more = false, onMore = null, live = null, onLive = null }) {
|
|
724
813
|
// M-3253: on a phone the page above (fleet-canvas.js) puts a ⋯ in its bar: `more` is that sheet open, `onMore(open)`;
|
|
725
814
|
// `live` / `onLive` its Live toggle, which moves into the sheet. Without one (a share link's page) the bar stays.
|
|
815
|
+
useLayoutEffect(ensureDialogueStyle, []);
|
|
726
816
|
const phone = useOfficePhone(), compact = phone && typeof onMore === "function";
|
|
727
817
|
const store = useMemo(() => createOfficeStore(lease ? { fetch: (path, o) => lease.fetch(path, o) } : {}), [lease]);
|
|
728
818
|
const [stored, setStored] = useState([]);
|
|
@@ -765,6 +855,12 @@ export function Office({ view, traffic, q = "", lease, onOpen, assetUrl, assetIm
|
|
|
765
855
|
const dlg = useMemo(createDialogue, []);
|
|
766
856
|
const faces = useMemo(() => createFaces(), []);
|
|
767
857
|
const [dlgSay, setDlgSay] = useState("");
|
|
858
|
+
const [dlgVisible, setDlgVisible] = useState(false);
|
|
859
|
+
const dlgVisibleRef = useRef(false);
|
|
860
|
+
const showDialogueDock = (visible) => {
|
|
861
|
+
if (dlgVisibleRef.current !== visible) { dlgVisibleRef.current = visible; setDlgVisible(visible); }
|
|
862
|
+
};
|
|
863
|
+
const dialogueCanvasRef = useRef(null);
|
|
768
864
|
const [dlgHot, setDlgHot] = useState(false);
|
|
769
865
|
const dlgRef = useRef(null), dlgShown = useRef(null), dlgLines = useRef(new Map()), talkSeen = useRef(new Set());
|
|
770
866
|
const [nightNow, setNightNow] = useState(() => isNight());
|
|
@@ -1128,7 +1224,24 @@ export function Office({ view, traffic, q = "", lease, onOpen, assetUrl, assetIm
|
|
|
1128
1224
|
const shared = talk !== undefined || typeof onOpen !== "function";
|
|
1129
1225
|
const play = playAllowed({ on: playOn, still, zones, overview, layout: !!layout, shared }) && !carouselPick;
|
|
1130
1226
|
const hold = useMemo(() => createHold(), []), reacts = useRef(new Map()), walkNow = useRef(null), holdTimer = useRef(null);
|
|
1131
|
-
|
|
1227
|
+
// M-3432 (#4255): custom snacks from the active skin pack (client-local, only when play is enabled).
|
|
1228
|
+
const snacks = useMemo(() => createSnacks(), []);
|
|
1229
|
+
const snackDragCtrl = useMemo(() => createSnackDrag(), []);
|
|
1230
|
+
const packSnacks = useMemo(() => (skin && skin.pack && Array.isArray(skin.pack.snacks) ? skin.pack.snacks : []), [skin]);
|
|
1231
|
+
const snacksById = useMemo(() => new Map(packSnacks.map((s) => [s.id, s])), [packSnacks]);
|
|
1232
|
+
const showSnacks = play && packSnacks.length > 0;
|
|
1233
|
+
const [armedSnack, setArmedSnack] = useState(null);
|
|
1234
|
+
const [snackDrag, setSnackDrag] = useState(null);
|
|
1235
|
+
const snackDropRef = useRef(null), snackGhostRef = useRef(null), snackGhostPosRef = useRef(null), snackTrayRef = useRef(null), snackSwallowRef = useRef(false);
|
|
1236
|
+
const snackCtxRef = useRef({ showSnacks: false, officeKey: "", styleKey: "" });
|
|
1237
|
+
const onSnackClaim = (winner) => {
|
|
1238
|
+
reacts.current.set(winner, { kind: "feed", t0: now() });
|
|
1239
|
+
if (store.tellOn(winner)) void store.tell(winner, "feed");
|
|
1240
|
+
loop.current?.wake();
|
|
1241
|
+
};
|
|
1242
|
+
useEffect(() => { if (!play) { snackDragCtrl.retire(); hold.cancel(); reacts.current.clear(); snacks.clear(); snackDropRef.current = null; setArmedSnack(null); setSnackDrag(null); } }, [play]);
|
|
1243
|
+
useEffect(() => { if (!showSnacks) { snackDragCtrl.retire(); snackDropRef.current = null; setArmedSnack(null); setSnackDrag(null); } }, [showSnacks]);
|
|
1244
|
+
useEffect(() => () => { snackDragCtrl.retire(); }, []);
|
|
1132
1245
|
useEffect(() => {
|
|
1133
1246
|
if (!zones || overview) return undefined;
|
|
1134
1247
|
const go = () => {
|
|
@@ -1136,6 +1249,7 @@ export function Office({ view, traffic, q = "", lease, onOpen, assetUrl, assetIm
|
|
|
1136
1249
|
// An act's walk; not someone in bed for the night (#2568: bedtime wins, as for mail).
|
|
1137
1250
|
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
1251
|
for (const [name, at] of mail.targets(L, t)) to.set(name, at);
|
|
1252
|
+
for (const [name, at] of snacks.targets(t)) to.set(name, at);
|
|
1139
1253
|
const held = hold.held(); // M-3293: carried: where the pointer is, no walk
|
|
1140
1254
|
if (held) to.set(held.name, held.at);
|
|
1141
1255
|
walkers.sync(to, t, L, still);
|
|
@@ -1169,6 +1283,8 @@ export function Office({ view, traffic, q = "", lease, onOpen, assetUrl, assetIm
|
|
|
1169
1283
|
const labelEls = useRef(new Map()); // #2554: the tiles' labels (tile key → element)
|
|
1170
1284
|
// What a view is kept for: the office and its style (All offices: its own key).
|
|
1171
1285
|
const officeKey = overview ? `${ALL_ID}@tiles` : `${custom ? custom.id : AUTO_ID}@${baseSkin.id}`;
|
|
1286
|
+
snackCtxRef.current = { showSnacks, officeKey, styleKey };
|
|
1287
|
+
useEffect(() => { snackDragCtrl.retire(); snacks.clear(); snackDropRef.current = null; setArmedSnack(null); setSnackDrag(null); }, [officeKey, styleKey]);
|
|
1172
1288
|
const keyRef = useRef(officeKey), saveTimer = useRef(0);
|
|
1173
1289
|
// The fit mode (Fit: contain; Fill: cover), kept per office and style like the view.
|
|
1174
1290
|
const [fitRev, setFitRev] = useState(0);
|
|
@@ -1205,7 +1321,7 @@ export function Office({ view, traffic, q = "", lease, onOpen, assetUrl, assetIm
|
|
|
1205
1321
|
const v = view0(), sz = sizeRef.current;
|
|
1206
1322
|
const w = c.walks ? walkers.at(c.name, now()) : null;
|
|
1207
1323
|
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);
|
|
1324
|
+
const p = toScreen(v, pt.x, pt.y), cw = el.offsetWidth || 320, ch = el.offsetHeight || 260, gap = 12 + (w ? pt.r : pt.r);
|
|
1209
1325
|
let x = p.x + gap;
|
|
1210
1326
|
if (x + cw > sz.w - 8) x = p.x - gap - cw;
|
|
1211
1327
|
x = Math.max(8, Math.min(x, sz.w - cw - 8));
|
|
@@ -1400,6 +1516,8 @@ export function Office({ view, traffic, q = "", lease, onOpen, assetUrl, assetIm
|
|
|
1400
1516
|
// or the zoom changes, never on a pan); each frame draws the matte, the layers, the people and the items in the air ──
|
|
1401
1517
|
const scene = useRef(null);
|
|
1402
1518
|
const loop = useRef(null);
|
|
1519
|
+
const clipClocks = useRef(null);
|
|
1520
|
+
if (!clipClocks.current) clipClocks.current = createClipClocks();
|
|
1403
1521
|
// The matte around the scene: the pack's own, else its background's edge (sampled once), else the skin's (tokens);
|
|
1404
1522
|
// All offices: the dashboard's background (each tile is its own scene).
|
|
1405
1523
|
const matte = overview ? pal.bg : (skin.pack && skin.pack.matte) || sampledMatte(skin.backdrop) || (skin.matte ? skin.matte({ pal, mode }) : pal.bg);
|
|
@@ -1415,16 +1533,21 @@ export function Office({ view, traffic, q = "", lease, onOpen, assetUrl, assetIm
|
|
|
1415
1533
|
cv.style.setProperty("width", `${BW / ratio}px`);
|
|
1416
1534
|
cv.style.setProperty("height", `${BH / ratio}px`);
|
|
1417
1535
|
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
|
|
1536
|
+
const maxPackFps = overview
|
|
1537
|
+
? Math.max(0, ...tiles.map((tl) => packMaxFps(tl.skin && tl.skin.pack)))
|
|
1538
|
+
: packMaxFps(skin && skin.pack);
|
|
1539
|
+
const fps = Math.max(FPS, Math.min(30, Math.ceil(maxPackFps)));
|
|
1540
|
+
const base = { ctx, ratio, BW, BH, matte, env, fps, dirty: true };
|
|
1419
1541
|
if (overview) {
|
|
1420
1542
|
// Each tile a scene of its own, where the overview puts it (arranged.tiles, in the same order).
|
|
1421
1543
|
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
1544
|
scene.current = { ...base, overview: true, parts, lay: arranged };
|
|
1423
1545
|
} 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
|
|
1546
|
+
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,
|
|
1547
|
+
snacks: play ? snacks : null, snacksById, ownArea, snackDrop: snackDropRef, onSnackClaim, onSnacksChanged: () => walkNow.current?.() } };
|
|
1425
1548
|
}
|
|
1426
1549
|
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]);
|
|
1550
|
+
}, [L, looks, skin, pal, size.w, size.h, ratio, matte, overview, tiles, tileLooks, arranged, ghosts, night, mail, actsHere, lv, wordsOf, play, snacksById, ownArea]);
|
|
1428
1551
|
|
|
1429
1552
|
/** One frame at `ms` (0: still); whether anything is moving (in the air, or someone walking). */
|
|
1430
1553
|
function draw(ms) {
|
|
@@ -1432,13 +1555,22 @@ export function Office({ view, traffic, q = "", lease, onOpen, assetUrl, assetIm
|
|
|
1432
1555
|
if (!s) return false;
|
|
1433
1556
|
placeCard();
|
|
1434
1557
|
const { ctx, BW, BH, env } = s;
|
|
1558
|
+
s.bubbleHits = [];
|
|
1559
|
+
const seenClips = ms > 0 ? new Set() : null;
|
|
1560
|
+
const clocked = (prefix) => (seenClips
|
|
1561
|
+
? { ...env, clock: (k, st, t) => { const fk = `${prefix}${k}`; seenClips.add(fk); return clipClocks.current.elapsed(fk, st, t); } }
|
|
1562
|
+
: env);
|
|
1435
1563
|
// 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
1564
|
const v = view0(), a = v.k * s.ratio, ox = Math.round(v.x * s.ratio), oy = Math.round(v.y * s.ratio);
|
|
1437
1565
|
ctx.setTransform(1, 0, 0, 1, 0, 0);
|
|
1438
1566
|
ctx.clearRect(0, 0, BW, BH);
|
|
1439
1567
|
ctx.fillStyle = s.matte; ctx.fillRect(0, 0, BW, BH);
|
|
1440
1568
|
ctx.imageSmoothingEnabled = false;
|
|
1441
|
-
if (!s.overview) {
|
|
1569
|
+
if (!s.overview) {
|
|
1570
|
+
const moved = drawPart(ctx, s.part, a, ox, oy, ms, still, tipNow.current, clocked(""), false, null, s.bubbleHits);
|
|
1571
|
+
if (seenClips) clipClocks.current.prune(seenClips);
|
|
1572
|
+
return drawDialogue(ctx, s, ms) || moved;
|
|
1573
|
+
}
|
|
1442
1574
|
// All offices: each tile on screen drawn as its own view, scaled into it and clipped to it; one off screen is not
|
|
1443
1575
|
// drawn (its flights still land). Then a frame round each tile, and the items flying between tiles.
|
|
1444
1576
|
const hot = tipNow.current, on = new Set(visibleTiles(s.lay, v, sizeRef.current).map((tt) => tt.key)), said = [];
|
|
@@ -1450,7 +1582,7 @@ export function Office({ view, traffic, q = "", lease, onOpen, assetUrl, assetIm
|
|
|
1450
1582
|
ctx.save();
|
|
1451
1583
|
ctx.setTransform(1, 0, 0, 1, 0, 0);
|
|
1452
1584
|
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,
|
|
1585
|
+
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
1586
|
ctx.restore();
|
|
1455
1587
|
ctx.setTransform(1, 0, 0, 1, 0, 0);
|
|
1456
1588
|
ctx.strokeStyle = env.pal.border; ctx.lineWidth = 1;
|
|
@@ -1460,11 +1592,13 @@ export function Office({ view, traffic, q = "", lease, onOpen, assetUrl, assetIm
|
|
|
1460
1592
|
const up = still ? [] : cross.frame(ms, s.parts);
|
|
1461
1593
|
// 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
1594
|
// a sender in no tile drawn: the built-in item, in overview units.
|
|
1595
|
+
const crossEnv = clocked("x:");
|
|
1463
1596
|
for (const it of up) {
|
|
1464
1597
|
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,
|
|
1598
|
+
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); }
|
|
1599
|
+
else { ctx.setTransform(a, 0, 0, a, ox, oy); skinFor("pixel").drawProp(ctx, it, ms, crossEnv); }
|
|
1467
1600
|
}
|
|
1601
|
+
if (seenClips) clipClocks.current.prune(seenClips);
|
|
1468
1602
|
return drawDialogue(ctx, s, ms) || moving || up.length > 0 || cross.size() > 0;
|
|
1469
1603
|
}
|
|
1470
1604
|
/**
|
|
@@ -1472,15 +1606,25 @@ export function Office({ view, traffic, q = "", lease, onOpen, assetUrl, assetIm
|
|
|
1472
1606
|
* awake (pickFront), with their faces (the pack's portraits; else the agent's avatar, else initials), the speaker's
|
|
1473
1607
|
* words typed out, the agent's line while it works and "+N". Nothing at all while it is off. Whether it moves.
|
|
1474
1608
|
*/
|
|
1475
|
-
function drawDialogue(
|
|
1609
|
+
function drawDialogue(_mapCtx, s, ms) {
|
|
1476
1610
|
const d = dlgRef.current;
|
|
1477
|
-
if (!d) { dlgShown.current = null; return false; }
|
|
1611
|
+
if (!d) { dlgShown.current = null; showDialogueDock(false); return false; }
|
|
1478
1612
|
const t = ms > 0 ? ms : now();
|
|
1479
1613
|
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
|
|
1614
|
+
if (!front) { dlgShown.current = null; showDialogueDock(false); return false; }
|
|
1615
|
+
const who = d.who.get(front.instance), node = who.node;
|
|
1482
1616
|
const stage = stageOf(front, t, node.state === "working", still);
|
|
1483
|
-
if (stage.done) { dlgShown.current = null; return false; }
|
|
1617
|
+
if (stage.done) { dlgShown.current = null; showDialogueDock(false); return false; }
|
|
1618
|
+
showDialogueDock(true);
|
|
1619
|
+
const cv = dialogueCanvasRef.current;
|
|
1620
|
+
if (!cv) return false; // layout commit mounts the dock, then its effect paints even with reduced motion
|
|
1621
|
+
const dw = cv.clientWidth || sizeRef.current.w, dh = cv.clientHeight || (phone ? 160 : 180), L0 = boxLayout(dw, dh);
|
|
1622
|
+
const BW = Math.max(1, Math.floor(dw * s.ratio)), BH = Math.max(1, Math.floor(dh * s.ratio));
|
|
1623
|
+
if (cv.width !== BW) cv.width = BW;
|
|
1624
|
+
if (cv.height !== BH) cv.height = BH;
|
|
1625
|
+
const ctx = cv.getContext("2d");
|
|
1626
|
+
if (!ctx) return false;
|
|
1627
|
+
ctx.setTransform(1, 0, 0, 1, 0, 0); ctx.clearRect(0, 0, BW, BH);
|
|
1484
1628
|
const skinOf = who.skin, pack = skinOf && skinOf.pack;
|
|
1485
1629
|
const pic = (src) => (src && skinOf && typeof skinOf.picture === "function" ? skinOf.picture(src, dlgWake) : null);
|
|
1486
1630
|
const agentName = nodeText(node).primary;
|
|
@@ -1518,27 +1662,38 @@ export function Office({ view, traffic, q = "", lease, onOpen, assetUrl, assetIm
|
|
|
1518
1662
|
dlgShown.current = { L, stage, key: who.key, name: front.instance };
|
|
1519
1663
|
const frameSrc = pack && pack.dialogBox && pack.dialogBox.frame, frameIm = frameSrc ? pic(frameSrc) : null;
|
|
1520
1664
|
return drawBox(ctx, {
|
|
1521
|
-
|
|
1665
|
+
// A short landscape dock keeps the name and words; decorative faces need headroom above the box.
|
|
1666
|
+
L, stage, left: dh >= 144 ? personFace() : null, right: dh < 144 || stage.phase === "heard" ? null : agentFace(),
|
|
1522
1667
|
name: answered ? agentName : front.person ? front.person.name || to("dlgSomeone") : to("dlgSomeone"),
|
|
1523
1668
|
lines, status: status ? `${agentName} · ${status}` : null, more,
|
|
1524
1669
|
colours: boxColours(pack && pack.dialogBox, s.env.pal), frame: frameIm ? { im: frameIm, slice: pack.dialogBox.slice || 8, k: pack.scale || 2 } : null,
|
|
1525
1670
|
}, t, { ...s.env, still });
|
|
1526
1671
|
}
|
|
1672
|
+
// A newly mounted dock must paint even when reduced motion leaves the map loop asleep.
|
|
1673
|
+
useLayoutEffect(() => {
|
|
1674
|
+
if (!dialogueOn || !dlgVisible) return;
|
|
1675
|
+
if (scene.current) drawDialogue(scene.current.ctx, scene.current, still ? 0 : now());
|
|
1676
|
+
if (!still) loop.current?.wake();
|
|
1677
|
+
}, [dialogueOn, dlgVisible, dlgSay, width, phone, ratio]);
|
|
1678
|
+
|
|
1527
1679
|
// The loop: drawing only when the frame (FPS) changed or something is in the air; stopped while the tab is hidden,
|
|
1528
1680
|
// gone with the view. Office review: while something walks or flies, one requestAnimationFrame per display frame (the
|
|
1529
1681
|
// motion is smooth); when nothing moves, the poses change at most FPS times a second, so the loop sleeps (a timer)
|
|
1530
1682
|
// until the next frame's start instead of waking at the display's rate only to find nothing to draw.
|
|
1531
1683
|
useEffect(() => {
|
|
1532
1684
|
if (still || typeof requestAnimationFrame !== "function") return undefined;
|
|
1533
|
-
let raf = 0, timer = 0, last = -1, air = true, gone = false;
|
|
1685
|
+
let raf = 0, timer = 0, last = -1, lastFps = FPS, air = true, gone = false;
|
|
1534
1686
|
const tick = () => {
|
|
1535
1687
|
raf = 0;
|
|
1536
1688
|
if (gone || globalThis.document?.hidden || !scene.current) return;
|
|
1537
|
-
const
|
|
1538
|
-
|
|
1689
|
+
const fps = scene.current.fps || FPS;
|
|
1690
|
+
const ms = now(), frame = Math.floor((ms / 1000) * fps); // the clock the trips started on
|
|
1691
|
+
if (scene.current.dirty || frame !== last || fps !== lastFps || air) { scene.current.dirty = false; last = frame; lastFps = fps; air = draw(ms); }
|
|
1539
1692
|
if (air) { raf = requestAnimationFrame(tick); return; }
|
|
1540
|
-
const wait = Math.max(1, Math.ceil(((frame + 1) * 1000) /
|
|
1541
|
-
|
|
1693
|
+
const wait = Math.max(1, Math.ceil(((frame + 1) * 1000) / fps - ms)); // until the next frame starts
|
|
1694
|
+
if (fps > FPS && wait <= 16) { raf = requestAnimationFrame(tick); return; }
|
|
1695
|
+
const sleep = fps > FPS ? Math.max(1, wait - 14) : wait;
|
|
1696
|
+
timer = setTimeout(() => { timer = 0; if (!gone && !raf) raf = requestAnimationFrame(tick); }, sleep);
|
|
1542
1697
|
};
|
|
1543
1698
|
const wake = () => {
|
|
1544
1699
|
air = true;
|
|
@@ -1680,12 +1835,29 @@ export function Office({ view, traffic, q = "", lease, onOpen, assetUrl, assetIm
|
|
|
1680
1835
|
};
|
|
1681
1836
|
/** #2861: the dialogue box under a pointer event ({ key, name }: its agent), or null. */
|
|
1682
1837
|
const dlgAt = (e) => {
|
|
1683
|
-
const b = dlgShown.current, r =
|
|
1838
|
+
const b = dlgShown.current, r = dialogueCanvasRef.current ? dialogueCanvasRef.current.getBoundingClientRect() : null;
|
|
1684
1839
|
return b && r && onBox(b.L, b.stage, e.clientX - r.left, e.clientY - r.top) ? b : null;
|
|
1685
1840
|
};
|
|
1841
|
+
// Use the painted prefix and final displaced position, including bubbles outside an overview tile.
|
|
1842
|
+
const bubbleAtEvent = (e) => {
|
|
1843
|
+
// An armed snack owns map taps until the existing placement/feed action consumes it.
|
|
1844
|
+
if (shared || !onOpen || showSnacks && armedSnack) return null;
|
|
1845
|
+
const s = scene.current, r = canvasRef.current?.getBoundingClientRect();
|
|
1846
|
+
if (!s || !r) return null;
|
|
1847
|
+
const hit = officeBubbleAt(s.bubbleHits || [], (e.clientX - r.left) * s.ratio, (e.clientY - r.top) * s.ratio, lastType.current === "touch" ? 44 * s.ratio : 0);
|
|
1848
|
+
return hit && people.some(d => d.node.i && d.node.name === hit.name) ? hit : null;
|
|
1849
|
+
};
|
|
1850
|
+
const openDialogue = (e) => {
|
|
1851
|
+
if (shared || !onOpen || !dlgShown.current || e.detail > 1) return;
|
|
1852
|
+
if (e.type === "keydown") {
|
|
1853
|
+
if (e.repeat || e.key !== "Enter" && e.key !== " ") return;
|
|
1854
|
+
e.preventDefault();
|
|
1855
|
+
}
|
|
1856
|
+
setCard(null); open(dlgShown.current.name);
|
|
1857
|
+
};
|
|
1686
1858
|
const onMove = (e) => {
|
|
1687
|
-
if (e.pointerType === "touch" || g.busy()) return;
|
|
1688
|
-
const onDlg = !!dlgAt(e);
|
|
1859
|
+
if (e.pointerType === "touch" || g.busy() || snackDrag || snackDropRef.current) return;
|
|
1860
|
+
const onDlg = !!dlgAt(e) || !!bubbleAtEvent(e);
|
|
1689
1861
|
if (onDlg !== dlgHot) setDlgHot(onDlg);
|
|
1690
1862
|
const d = onDlg ? null : deskOf(e); const key = d ? d.key : null; if (key !== tip) setTip(key);
|
|
1691
1863
|
};
|
|
@@ -1710,9 +1882,145 @@ export function Office({ view, traffic, q = "", lease, onOpen, assetUrl, assetIm
|
|
|
1710
1882
|
});
|
|
1711
1883
|
return nearestPerson(list, w.x, w.y, TAP_R / Math.max(OK_MIN, view0().k));
|
|
1712
1884
|
};
|
|
1885
|
+
/** M-3432 (#4255): feed an awake person a snack (plays eat animation + hearts + feed bubble + optional Tell). */
|
|
1886
|
+
const feedPerson = (name, snack, at) => {
|
|
1887
|
+
const t = now();
|
|
1888
|
+
snacks.feed(name, snack, { x: at.x, y: at.y, t, charEatStrip: skin.eatStrip ? skin.eatStrip(name) : null });
|
|
1889
|
+
reacts.current.set(name, { kind: "feed", t0: t });
|
|
1890
|
+
if (store.tellOn(name)) void store.tell(name, "feed");
|
|
1891
|
+
walkNow.current?.();
|
|
1892
|
+
loop.current?.wake();
|
|
1893
|
+
};
|
|
1894
|
+
/** M-3432 (#4255): drop a snack on the floor so nearby idle characters race to it. */
|
|
1895
|
+
const placeSnackAt = (snack, at) => {
|
|
1896
|
+
const t = now();
|
|
1897
|
+
const hidden = scene.current && scene.current.part ? furnitureAt(scene.current.part, t).hidden : null;
|
|
1898
|
+
snacks.place(snack, at, t, { desks: desksOf(L), walkers, hidden, ownArea, areas: L.areas, graph: L });
|
|
1899
|
+
walkNow.current?.();
|
|
1900
|
+
loop.current?.wake();
|
|
1901
|
+
};
|
|
1902
|
+
/** M-3432 (#4255): classify a pointer position while dragging a snack (awake person → feed, floor → place, tray/asleep/outside → cancel). */
|
|
1903
|
+
const snackTargetOf = (e) => {
|
|
1904
|
+
const tray = snackTrayRef.current;
|
|
1905
|
+
if (tray && typeof tray.getBoundingClientRect === "function") {
|
|
1906
|
+
const tr = tray.getBoundingClientRect();
|
|
1907
|
+
if (e.clientX >= tr.left && e.clientX <= tr.right && e.clientY >= tr.top && e.clientY <= tr.bottom) return null;
|
|
1908
|
+
}
|
|
1909
|
+
const st = stageRef.current;
|
|
1910
|
+
if (st && typeof st.getBoundingClientRect === "function") {
|
|
1911
|
+
const sr = st.getBoundingClientRect();
|
|
1912
|
+
if (e.clientX < sr.left || e.clientX > sr.right || e.clientY < sr.top || e.clientY > sr.bottom) return null;
|
|
1913
|
+
}
|
|
1914
|
+
const d = deskOf(e) || (e.pointerType === "touch" ? nearOf(e) : null);
|
|
1915
|
+
if (d && d.node && d.node.i) {
|
|
1916
|
+
if (ASLEEP.has(d.node.state) || d.night) return null;
|
|
1917
|
+
const at = (zones && walkers.at(d.node.name, now())) || d.seat || { x: d.x + d.w / 2, y: d.y + d.h };
|
|
1918
|
+
return { kind: "feed", name: d.node.name, label: nodeText(d.node).primary, x: at.x, y: at.y };
|
|
1919
|
+
}
|
|
1920
|
+
const w = pointOf(e);
|
|
1921
|
+
if (!w || w.x < 0 || w.x > L.width || w.y < 0 || w.y > L.height) return null;
|
|
1922
|
+
return { kind: "place", x: w.x, y: w.y };
|
|
1923
|
+
};
|
|
1924
|
+
/** 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). */
|
|
1925
|
+
const onSnackDown = (snack, e) => {
|
|
1926
|
+
if (!showSnacks || e.isPrimary === false || (e.pointerType === "mouse" && e.button !== 0)) return;
|
|
1927
|
+
e.stopPropagation();
|
|
1928
|
+
const startOffice = officeKey, startStyle = styleKey;
|
|
1929
|
+
let lastKey = "";
|
|
1930
|
+
const moveGhost = (cx, cy) => {
|
|
1931
|
+
const sr = stageRef.current ? stageRef.current.getBoundingClientRect() : null;
|
|
1932
|
+
if (!sr) return;
|
|
1933
|
+
const gx = Math.round(cx - sr.left + 12), gy = Math.round(cy - sr.top - 40);
|
|
1934
|
+
snackGhostPosRef.current = { x: gx, y: gy };
|
|
1935
|
+
const gh = snackGhostRef.current;
|
|
1936
|
+
if (gh && gh.style) gh.style.setProperty("transform", `translate(${gx}px, ${gy}px)`);
|
|
1937
|
+
};
|
|
1938
|
+
const swallowClick = () => {
|
|
1939
|
+
snackSwallowRef.current = true;
|
|
1940
|
+
setTimeout(() => { snackSwallowRef.current = false; }, 0);
|
|
1941
|
+
};
|
|
1942
|
+
snackDragCtrl.start({
|
|
1943
|
+
pid: e.pointerId,
|
|
1944
|
+
sx: e.clientX,
|
|
1945
|
+
sy: e.clientY,
|
|
1946
|
+
slop: PLAY.SLOP,
|
|
1947
|
+
onMove: (ev, { starting }) => {
|
|
1948
|
+
if (starting) { setCard(null); setTip(null); }
|
|
1949
|
+
ev.preventDefault();
|
|
1950
|
+
if (tipNow.current) setTip(null);
|
|
1951
|
+
moveGhost(ev.clientX, ev.clientY);
|
|
1952
|
+
const drop = snackTargetOf(ev);
|
|
1953
|
+
snackDropRef.current = drop;
|
|
1954
|
+
const k = drop ? `${drop.kind}:${drop.name || ""}` : "";
|
|
1955
|
+
if (starting || k !== lastKey) {
|
|
1956
|
+
lastKey = k;
|
|
1957
|
+
setSnackDrag({ snack, kind: drop ? drop.kind : null, label: drop && drop.kind === "feed" ? drop.label : "" });
|
|
1958
|
+
}
|
|
1959
|
+
loop.current?.wake();
|
|
1960
|
+
return drop;
|
|
1961
|
+
},
|
|
1962
|
+
onCommit: (drop) => {
|
|
1963
|
+
snackDropRef.current = null;
|
|
1964
|
+
setSnackDrag(null);
|
|
1965
|
+
swallowClick();
|
|
1966
|
+
const cur = snackCtxRef.current;
|
|
1967
|
+
if (cur.showSnacks && cur.officeKey === startOffice && cur.styleKey === startStyle) {
|
|
1968
|
+
if (drop.kind === "feed") feedPerson(drop.name, snack, { x: drop.x, y: drop.y });
|
|
1969
|
+
else if (drop.kind === "place") placeSnackAt(snack, { x: drop.x, y: drop.y });
|
|
1970
|
+
setArmedSnack(null);
|
|
1971
|
+
}
|
|
1972
|
+
loop.current?.wake();
|
|
1973
|
+
},
|
|
1974
|
+
onCancel: ({ dragging }) => {
|
|
1975
|
+
snackDropRef.current = null;
|
|
1976
|
+
setSnackDrag(null);
|
|
1977
|
+
if (dragging) swallowClick();
|
|
1978
|
+
loop.current?.wake();
|
|
1979
|
+
},
|
|
1980
|
+
});
|
|
1981
|
+
};
|
|
1982
|
+
useEffect(() => {
|
|
1983
|
+
if (!armedSnack) return undefined;
|
|
1984
|
+
const onEsc = (e) => { if (e.key === "Escape" && !e.defaultPrevented) { e.preventDefault(); setArmedSnack(null); } };
|
|
1985
|
+
globalThis.document?.addEventListener?.("keydown", onEsc, true);
|
|
1986
|
+
return () => globalThis.document?.removeEventListener?.("keydown", onEsc, true);
|
|
1987
|
+
}, [armedSnack]);
|
|
1988
|
+
const paintSnackIcon = (st, pxSize = 28) => (cv) => {
|
|
1989
|
+
const g = cv && typeof cv.getContext === "function" ? cv.getContext("2d") : null;
|
|
1990
|
+
if (!g || !st || !skin || typeof skin.drawSnackIcon !== "function") return;
|
|
1991
|
+
const r = deviceRatio(), S = pxSize;
|
|
1992
|
+
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); }
|
|
1993
|
+
g.setTransform(r, 0, 0, r, 0, 0); g.clearRect(0, 0, S, S);
|
|
1994
|
+
skin.drawSnackIcon(g, st, S);
|
|
1995
|
+
};
|
|
1713
1996
|
const onClick = (e) => {
|
|
1714
1997
|
const box = dlgAt(e);
|
|
1998
|
+
const bubble = bubbleAtEvent(e);
|
|
1999
|
+
if ((box || bubble) && !shared && onOpen) {
|
|
2000
|
+
if (!(e.detail > 1)) { setCard(null); open((box || bubble).name); }
|
|
2001
|
+
return;
|
|
2002
|
+
}
|
|
1715
2003
|
if (box) { focusPerson(box.key); return; }
|
|
2004
|
+
if (showSnacks && armedSnack) {
|
|
2005
|
+
const snack = snacksById.get(armedSnack);
|
|
2006
|
+
if (snack) {
|
|
2007
|
+
const hit = deskOf(e) || (lastType.current === "touch" ? nearOf(e) : null);
|
|
2008
|
+
if (hit && hit.node && hit.node.i) {
|
|
2009
|
+
if (!ASLEEP.has(hit.node.state) && !hit.night) {
|
|
2010
|
+
const at = (zones && walkers.at(hit.node.name, now())) || hit.seat || { x: hit.x + hit.w / 2, y: hit.y + hit.h };
|
|
2011
|
+
feedPerson(hit.node.name, snack, at);
|
|
2012
|
+
}
|
|
2013
|
+
setArmedSnack(null);
|
|
2014
|
+
return;
|
|
2015
|
+
}
|
|
2016
|
+
const w = pointOf(e);
|
|
2017
|
+
if (w && w.x >= 0 && w.x <= L.width && w.y >= 0 && w.y <= L.height) {
|
|
2018
|
+
placeSnackAt(snack, w);
|
|
2019
|
+
setArmedSnack(null);
|
|
2020
|
+
return;
|
|
2021
|
+
}
|
|
2022
|
+
}
|
|
2023
|
+
}
|
|
1716
2024
|
const d = deskOf(e) || (lastType.current === "touch" ? nearOf(e) : null);
|
|
1717
2025
|
if (!d || !d.node.i) { setTip(null); setCard(null); return; }
|
|
1718
2026
|
if (lastType.current === "touch") setTip(null);
|
|
@@ -1722,7 +2030,7 @@ export function Office({ view, traffic, q = "", lease, onOpen, assetUrl, assetIm
|
|
|
1722
2030
|
// All offices: a double-click on a tile (off its people) opens that office; the lobby is no office.
|
|
1723
2031
|
const onDblClick = (e) => {
|
|
1724
2032
|
const box = dlgAt(e);
|
|
1725
|
-
if (box
|
|
2033
|
+
if (box || bubbleAtEvent(e)) return; // the first click already opened it
|
|
1726
2034
|
const s = scene.current, w = pointOf(e), hit = deskOf(e);
|
|
1727
2035
|
if (hit && hit.node.i) { setCard(null); open(hit.node.name); return; } // #2661: a person's chat, past the card
|
|
1728
2036
|
if (!overview || !s || !s.overview || !w || hit) return;
|
|
@@ -1831,12 +2139,12 @@ export function Office({ view, traffic, q = "", lease, onOpen, assetUrl, assetIm
|
|
|
1831
2139
|
setView(centreOn({ ...v, k }, size, at.x, at.y));
|
|
1832
2140
|
};
|
|
1833
2141
|
/** The card's picture: the person's idle frame in the office's style (pack strip or built-in figure). */
|
|
1834
|
-
const drawAvatar = (cv) => {
|
|
2142
|
+
const drawAvatar = (cv, sizePx = 56) => {
|
|
1835
2143
|
const s = scene.current, c = cardOf;
|
|
1836
2144
|
const g = cv && cv.getContext ? cv.getContext("2d") : null;
|
|
1837
2145
|
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; }
|
|
2146
|
+
const r = deviceRatio(), W = Number(sizePx) || 56;
|
|
2147
|
+
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
2148
|
g.setTransform(1, 0, 0, 1, 0, 0); g.clearRect(0, 0, cv.width, cv.height); g.imageSmoothingEnabled = false;
|
|
1841
2149
|
const look = { ...c.look, pose: "idle", dim: false, match: false, badge: null, notag: true, free: true, work: 0, sign: null };
|
|
1842
2150
|
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 +2217,7 @@ export function Office({ view, traffic, q = "", lease, onOpen, assetUrl, assetIm
|
|
|
1909
2217
|
${canLayout ? html`<button type="button" class="btn btn-sm oo-layout" onClick=${openLayout}>${t("orgl.edit")}</button>` : null}
|
|
1910
2218
|
${canShare ? html`<${ShareButton} offices=${stored} current=${overview ? "all" : custom ? custom.id : null} disabled=${!!layout}
|
|
1911
2219
|
get=${lease ? (path, o) => lease.fetch(path, o) : undefined} />` : null}`;
|
|
1912
|
-
return html`<div class=${`oo${fs ? ` fs ${fs}` : ""}${compact ? " phone" : ""}`} ref=${ooRef}>
|
|
2220
|
+
return html`<div class=${`oo${fs ? ` fs ${fs}` : ""}${compact ? " phone" : ""}${dlgVisible ? " has-dialogue" : ""}`} ref=${ooRef}>
|
|
1913
2221
|
${compact ? null : html`<div class="oo-bar">${barItems}</div>`}
|
|
1914
2222
|
${compact && more ? html`<${Dialog} title=${to("office")} cls="oo-sheet" onClose=${closeMore}>
|
|
1915
2223
|
<div class="oo-sheet-tiles">
|
|
@@ -1948,8 +2256,23 @@ export function Office({ view, traffic, q = "", lease, onOpen, assetUrl, assetIm
|
|
|
1948
2256
|
where: [cardOf.office || (custom ? custom.name : to("allOffice")), cardOf.area].filter(Boolean).join(" · ") })}
|
|
1949
2257
|
avatar=${drawAvatar} sheet=${phone || size.w < SHEET_W} place=${(el) => { cardEl.current = el; placeCard(); }}
|
|
1950
2258
|
onChat=${onOpen ? () => { const n = cardOf.node.name; setCard(null); open(n); } : null} onFind=${findCard} onClose=${closeCard}
|
|
1951
|
-
onReact=${play ? (kind) => {
|
|
1952
|
-
|
|
2259
|
+
onReact=${play ? (kind) => {
|
|
2260
|
+
const n = cardOf.node.name;
|
|
2261
|
+
if (kind === "feed" && !ASLEEP.has(cardOf.node.state) && !cardOf.box.night) {
|
|
2262
|
+
const sn = (armedSnack && snacksById.get(armedSnack)) || packSnacks[0] || null;
|
|
2263
|
+
if (sn || (skin.eatStrip && skin.eatStrip(n))) {
|
|
2264
|
+
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 };
|
|
2265
|
+
snacks.feed(n, sn, { x: at.x, y: at.y, t: now(), charEatStrip: skin.eatStrip ? skin.eatStrip(n) : null });
|
|
2266
|
+
walkNow.current?.();
|
|
2267
|
+
}
|
|
2268
|
+
}
|
|
2269
|
+
reacts.current.set(n, { kind, t0: now() }); loop.current?.wake(); if (store.tellOn(n)) void store.tell(n, kind);
|
|
2270
|
+
} : null}
|
|
2271
|
+
tell=${play ? { on: store.tellOn(cardOf.node.name), set: (v) => { store.saveTell(cardOf.node.name, v); setTellRev((x) => x + 1); } } : null}
|
|
2272
|
+
packCard=${cardOf.skin?.pack?.card || null}
|
|
2273
|
+
picture=${typeof cardOf.skin?.picture === "function" ? cardOf.skin.picture : null}
|
|
2274
|
+
portrait=${cardOf.skin?.pack ? portraitSrc(cardOf.skin.pack, { agent: cardOf.node.name, state: cardOf.node.state }) : null}
|
|
2275
|
+
packScale=${cardOf.skin?.pack?.scale || 2} />` : null}
|
|
1953
2276
|
<ul class="oo-desks" aria-label=${to("desks")}>${people.map((d) => {
|
|
1954
2277
|
const nt = nodeText(d.node), cap = caption(officePose(d.node.state), d.node.state), where = d.office ? ` · ${d.office}` : "";
|
|
1955
2278
|
return html`<li key=${d.key}>${d.node.i
|
|
@@ -1966,9 +2289,24 @@ export function Office({ view, traffic, q = "", lease, onOpen, assetUrl, assetIm
|
|
|
1966
2289
|
title=${to("fillTitle")} onClick=${toggleFill}>${to("fill")}</button>
|
|
1967
2290
|
<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
2291
|
</div>
|
|
1969
|
-
${
|
|
1970
|
-
|
|
1971
|
-
|
|
2292
|
+
${showSnacks ? html`<div ref=${snackTrayRef} class="oo-snacks" role="toolbar" aria-label=${to("snacks")}>
|
|
2293
|
+
${packSnacks.map((sn) => {
|
|
2294
|
+
const lb = snackLabel(sn, lang());
|
|
2295
|
+
return html`<button key=${sn.id} type="button" class="icon-btn oo-snack" data-snack=${sn.id}
|
|
2296
|
+
aria-label=${to("snackArm", lb)} title=${lb} aria-pressed=${armedSnack === sn.id ? "true" : "false"}
|
|
2297
|
+
onPointerDown=${(e) => onSnackDown(sn, e)}
|
|
2298
|
+
onClick=${(e) => { e.stopPropagation(); if (snackSwallowRef.current) return; setArmedSnack((cur) => (cur === sn.id ? null : sn.id)); }}>
|
|
2299
|
+
<canvas class="oo-snack-icon" width="28" height="28" aria-hidden="true" ref=${paintSnackIcon(sn.sprite, 28)}></canvas>
|
|
2300
|
+
</button>`;
|
|
2301
|
+
})}
|
|
2302
|
+
</div>` : null}
|
|
2303
|
+
${snackDrag ? html`<div class="oo-snack-ghost" aria-hidden="true" ref=${(el) => {
|
|
2304
|
+
snackGhostRef.current = el;
|
|
2305
|
+
if (el && el.style && snackGhostPosRef.current) el.style.setProperty("transform", `translate(${snackGhostPosRef.current.x}px, ${snackGhostPosRef.current.y}px)`);
|
|
2306
|
+
}}>
|
|
2307
|
+
<canvas class="oo-snack-icon" width="28" height="28" ref=${paintSnackIcon(snackDrag.snack.sprite, 28)}></canvas>
|
|
2308
|
+
${snackDrag.kind === "feed" ? html`<span class="oo-snack-hint">${to("snackFeed", snackDrag.label)}</span>`
|
|
2309
|
+
: snackDrag.kind === "place" ? html`<span class="oo-snack-hint">${to("snackPlace")}</span>` : null}
|
|
1972
2310
|
</div>` : null}
|
|
1973
2311
|
${fs ? html`<div class="oo-fs-bar">${officeSelect("oo-fs-office")}${carChrome()}</div>` : null}
|
|
1974
2312
|
<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 +2318,13 @@ export function Office({ view, traffic, q = "", lease, onOpen, assetUrl, assetIm
|
|
|
1980
2318
|
<rect ref=${miniViewRef} class="oc-mini-view oo-mini-view" />
|
|
1981
2319
|
</svg>
|
|
1982
2320
|
</div>
|
|
2321
|
+
${zoneList.length ? html`<div class="oo-zone-pills" role="group" aria-label=${to("zones")}>
|
|
2322
|
+
<button type="button" class="btn btn-sm oo-zone-all" onClick=${() => fit()}>${to("zoneAll")}</button>
|
|
2323
|
+
${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>`)}
|
|
2324
|
+
</div>` : null}
|
|
2325
|
+
${dialogueOn && dlgVisible ? html`<canvas class="oo-dialogue-canvas" ref=${dialogueCanvasRef}
|
|
2326
|
+
role=${onOpen && !shared ? "button" : "img"} tabindex=${onOpen && !shared ? "0" : null}
|
|
2327
|
+
aria-label=${onOpen && !shared ? to("dlgOpenChat") : dlgSay} title=${onOpen && !shared ? to("dlgOpenChat") : null}
|
|
2328
|
+
onClick=${openDialogue} onKeyDown=${openDialogue}></canvas>` : null}
|
|
1983
2329
|
</div>`;
|
|
1984
2330
|
}
|