@adatechnology/game-test-room 0.5.0 → 0.6.0

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/index.d.ts CHANGED
@@ -62,6 +62,10 @@ interface InspectInfo {
62
62
  progress: number;
63
63
  }>;
64
64
  note?: string;
65
+ /** Thumbnail of the aimed item (`TestRoomItem.thumbnail`). */
66
+ thumbnail?: string;
67
+ /** Author and licence of the thumbnail (`TestRoomItem.thumbnailCredit`). */
68
+ thumbnailCredit?: string;
65
69
  distance: number;
66
70
  }
67
71
  interface HudState {
@@ -145,6 +149,10 @@ interface TestRoomItem {
145
149
  impl?: (root: THREE_NS.Object3D, id: string) => DestructibleImpl;
146
150
  /** Use animations the item brings (see `TestRoom.playAnimation`). Part poses move the child of the built object named after the part id. */
147
151
  animations?: AnimationClipSpec[];
152
+ /** Picture for the catalogue, the search results and the aimed-item label: an image URL or inline `<svg…>` markup (see `TestableItem.thumbnail`). */
153
+ thumbnail?: string;
154
+ /** Author and licence of the thumbnail, shown as the tooltip of the picture in the inspector. */
155
+ thumbnailCredit?: string;
148
156
  }
149
157
  interface TestRoomOptions {
150
158
  THREE: ThreeNamespace;
@@ -25576,6 +25576,10 @@ void main() {
25576
25576
  .tr-search{width:100%;margin:0 0 6px;padding:5px 8px;border-radius:5px;border:1px solid #3a404c;background:#0f1116;color:#e8eaee;font:inherit}
25577
25577
  .tr-search::placeholder{color:#7d8594}
25578
25578
  .tr-item small{color:#7d8594;margin-left:4px}
25579
+ .tr-thumb{display:block;width:100%;height:26px;background:currentColor;-webkit-mask:var(--tr-thumb) center/contain no-repeat;mask:var(--tr-thumb) center/contain no-repeat}
25580
+ .tr-item{min-width:0}
25581
+ .tr-item .tr-btn.has-thumb{display:flex;flex-direction:column;gap:3px;min-width:0}.tr-item .tr-btn.has-thumb .tr-name{overflow:hidden;text-overflow:ellipsis}
25582
+ .tr-insp .tr-thumb{width:140px;height:28px;margin-bottom:3px}
25579
25583
  .tr-empty{color:#9aa3b2;padding:4px 2px;grid-column:1/-1}
25580
25584
  .tr-cross{position:absolute;left:50%;top:50%;width:18px;height:18px;margin:-9px 0 0 -9px}
25581
25585
  .tr-cross:before,.tr-cross:after{content:"";position:absolute;background:#fff;opacity:.85;box-shadow:0 0 2px #000}
@@ -25641,6 +25645,17 @@ void main() {
25641
25645
  if (text !== void 0) e.textContent = text;
25642
25646
  return e;
25643
25647
  };
25648
+ var thumbSource = (thumbnail) => {
25649
+ const source = thumbnail.trim().startsWith("<") ? `data:image/svg+xml,${encodeURIComponent(thumbnail.trim())}` : thumbnail.trim();
25650
+ return source.replace(/["\\\n\r]/g, (char) => encodeURIComponent(char));
25651
+ };
25652
+ var thumb = (thumbnail, credit) => {
25653
+ const e = mk2("span", "tr-thumb");
25654
+ if (credit) e.title = credit;
25655
+ else e.setAttribute("aria-hidden", "true");
25656
+ e.style.setProperty("--tr-thumb", `url("${thumbSource(thumbnail)}")`);
25657
+ return e;
25658
+ };
25644
25659
  function createUi(o) {
25645
25660
  const { t } = o;
25646
25661
  const style = mk2("style");
@@ -25794,7 +25809,8 @@ void main() {
25794
25809
  if (!found.length) items.appendChild(mk2("div", "tr-empty", t("ui.no_results")));
25795
25810
  for (const { item: it, group } of found) {
25796
25811
  const wrap = mk2("div", "tr-item");
25797
- const b = mk2("button", "tr-btn", it.name);
25812
+ const b = mk2("button", it.thumbnail ? "tr-btn has-thumb" : "tr-btn", it.thumbnail ? void 0 : it.name);
25813
+ if (it.thumbnail) b.append(thumb(it.thumbnail), mk2("span", "tr-name", it.name));
25798
25814
  if (searching) b.appendChild(mk2("small", void 0, group));
25799
25815
  b.type = "button";
25800
25816
  b.title = it.note ?? it.name;
@@ -25953,6 +25969,7 @@ void main() {
25953
25969
  insp.appendChild(mk2("div", void 0, t("ui.aim_at_something")));
25954
25970
  return;
25955
25971
  }
25972
+ if (i.thumbnail) insp.appendChild(thumb(i.thumbnail, i.thumbnailCredit));
25956
25973
  insp.appendChild(mk2("div", "t", `${i.object} \u203A ${i.part}`));
25957
25974
  insp.appendChild(row(t("ins.material"), i.material));
25958
25975
  insp.appendChild(row(t("ins.status"), i.status + (i.burning ? ` \xB7 ${t("ins.burning")}` : "")));
@@ -27324,6 +27341,8 @@ void main() {
27324
27341
  stress: ext.stress,
27325
27342
  joints,
27326
27343
  note: e?.item?.note,
27344
+ thumbnail: e?.item?.thumbnail,
27345
+ thumbnailCredit: e?.item?.thumbnailCredit,
27327
27346
  distance: r.distance
27328
27347
  };
27329
27348
  };
@@ -27723,7 +27742,9 @@ void main() {
27723
27742
  fluid: ti.fluid,
27724
27743
  weapon: ti.weapon,
27725
27744
  impl: ti.impl,
27726
- animations: ti.animations
27745
+ animations: ti.animations,
27746
+ thumbnail: ti.thumbnail,
27747
+ thumbnailCredit: ti.thumbnailCredit
27727
27748
  };
27728
27749
  catalogMap.set(item.id, item);
27729
27750
  const at = catalog.findIndex((c) => c.id === item.id);