BlueGit

timfa questward

Share clothing shirt sprites and improve spawner equip picking.

Move cloth-shirt art into clothing/, raise play zoom floor to 2x, and replace humanoid equip dropdowns with a slot-filtered item picker.

timfa Tim Falken · pushed by timfa

Authored 2026-08-26 · 2 months ago

Hash
c39b627a52a7fdff3703c0b8d6fce2303a7c131a
Parent
940628bd
8 files changed +157 −51
client/assets/items/cloth-shirt/cloth-shirt-equip.png client/assets/items/clothing/shirt-equip.png renamed +0 −0
client/assets/items/cloth-shirt/cloth-shirt.png client/assets/items/clothing/shirt.png renamed +0 −0
client/scripts/write-placeholder-assets.mjs +2 −2
@@ -38,14 +38,14 @@ solid(join(root, "items", "paper", "paper.png"), [232, 224, 196, 255]);
38 38 solid(join(root, "items", "apple", "apple.png"), [196, 48, 48, 255]);
39 39 solid(join(root, "items", "stick", "stick.png"), [140, 92, 44, 255]);
40 40 solid(join(root, "items", "blank-cheque", "blank-cheque.png"), [168, 214, 168, 255]);
41 solid(join(root, "items", "cloth-shirt", "cloth-shirt.png"), [72, 112, 176, 255]);
41 solid(join(root, "items", "clothing", "shirt.png"), [72, 112, 176, 255]);
42 42 solid(join(root, "blocks", "spawner", "spawner.png"), [168, 64, 196, 255], [80, 20, 96, 255]);
43 43 solid(join(root, "blocks", "bank", "bank.png"), [212, 176, 72, 255], [96, 72, 16, 255]);
44 44 solid(join(root, "blocks", "church-altar", "church-altar.png"), [210, 210, 220, 255], [76, 72, 88, 255]);
45 45 solid(join(root, "mobs", "deer", "deer.png"), [120, 78, 42, 255]);
46 46 solid(join(root, "mobs", "rat", "rat.png"), [96, 88, 72, 255], [40, 36, 28, 255]);
47 47 overlay(join(root, "items", "stick", "stick-equip.png"), [150, 98, 46, 230]);
48 overlay(join(root, "items", "cloth-shirt", "cloth-shirt-equip.png"), [72, 112, 176, 230]);
48 overlay(join(root, "items", "clothing", "shirt-equip.png"), [72, 112, 176, 230]);
49 49 solid(join(root, "items", "lantern", "lantern.png"), [180, 120, 40, 255]);
50 50 solid(join(root, "items", "bones", "bones.png"), [218, 210, 180, 255], [92, 84, 68, 255]);
51 51 solid(join(root, "items", "skull", "skull.png"), [205, 198, 170, 255], [80, 72, 60, 255]);
@@ -38,14 +38,14 @@ solid(join(root, "items", "paper", "paper.png"), [232, 224, 196, 255]);
38solid(join(root, "items", "apple", "apple.png"), [196, 48, 48, 255]);
38solid(join(root, "items", "apple", "apple.png"), [196, 48, 48, 255]);
39solid(join(root, "items", "stick", "stick.png"), [140, 92, 44, 255]);
39solid(join(root, "items", "stick", "stick.png"), [140, 92, 44, 255]);
40solid(join(root, "items", "blank-cheque", "blank-cheque.png"), [168, 214, 168, 255]);
40solid(join(root, "items", "blank-cheque", "blank-cheque.png"), [168, 214, 168, 255]);
41solid(join(root, "items", "cloth-shirt", "cloth-shirt.png"), [72, 112, 176, 255]);
41solid(join(root, "items", "clothing", "shirt.png"), [72, 112, 176, 255]);
42solid(join(root, "blocks", "spawner", "spawner.png"), [168, 64, 196, 255], [80, 20, 96, 255]);
42solid(join(root, "blocks", "spawner", "spawner.png"), [168, 64, 196, 255], [80, 20, 96, 255]);
43solid(join(root, "blocks", "bank", "bank.png"), [212, 176, 72, 255], [96, 72, 16, 255]);
43solid(join(root, "blocks", "bank", "bank.png"), [212, 176, 72, 255], [96, 72, 16, 255]);
44solid(join(root, "blocks", "church-altar", "church-altar.png"), [210, 210, 220, 255], [76, 72, 88, 255]);
44solid(join(root, "blocks", "church-altar", "church-altar.png"), [210, 210, 220, 255], [76, 72, 88, 255]);
45solid(join(root, "mobs", "deer", "deer.png"), [120, 78, 42, 255]);
45solid(join(root, "mobs", "deer", "deer.png"), [120, 78, 42, 255]);
46solid(join(root, "mobs", "rat", "rat.png"), [96, 88, 72, 255], [40, 36, 28, 255]);
46solid(join(root, "mobs", "rat", "rat.png"), [96, 88, 72, 255], [40, 36, 28, 255]);
47overlay(join(root, "items", "stick", "stick-equip.png"), [150, 98, 46, 230]);
47overlay(join(root, "items", "stick", "stick-equip.png"), [150, 98, 46, 230]);
48overlay(join(root, "items", "cloth-shirt", "cloth-shirt-equip.png"), [72, 112, 176, 230]);
48overlay(join(root, "items", "clothing", "shirt-equip.png"), [72, 112, 176, 230]);
49solid(join(root, "items", "lantern", "lantern.png"), [180, 120, 40, 255]);
49solid(join(root, "items", "lantern", "lantern.png"), [180, 120, 40, 255]);
50solid(join(root, "items", "bones", "bones.png"), [218, 210, 180, 255], [92, 84, 68, 255]);
50solid(join(root, "items", "bones", "bones.png"), [218, 210, 180, 255], [92, 84, 68, 255]);
51solid(join(root, "items", "skull", "skull.png"), [205, 198, 170, 255], [80, 72, 60, 255]);
51solid(join(root, "items", "skull", "skull.png"), [205, 198, 170, 255], [80, 72, 60, 255]);
client/src/editor/tileConfigModal.js +123 −45
@@ -9,17 +9,27 @@ import {
9 9 isCentralExchangeSpawner
10 10 } from "/shared/definitions/mobs.js";
11 11 import { centralExchangeStaffCount } from "/shared/market/exchange.js";
12 import { ItemId, itemDefinition, EQUIPMENT_SLOT } from "/shared/definitions/items.js";
12 import { ITEM_DEFINITIONS, itemDefinition } from "/shared/definitions/items.js";
13 13 import { EQUIPMENT_SLOTS } from "/shared/items/inventory.js";
14 14 import { listNpcShopSellableItems } from "/shared/shop/pricing.js";
15 15
16 const EQUIP_PRESETS = Object.freeze([
17 { itemId: ItemId.clothShirt, slot: EQUIPMENT_SLOT.chest },
18 { itemId: ItemId.stick, slot: EQUIPMENT_SLOT.weapon },
19 { itemId: ItemId.bronzePickaxe, slot: EQUIPMENT_SLOT.weapon },
20 { itemId: ItemId.bronzeAxe, slot: EQUIPMENT_SLOT.weapon },
21 { itemId: ItemId.lantern, slot: EQUIPMENT_SLOT.offhand }
22 ]);
16 /** Items that can be worn in a given equipment slot. */
17 export function listEquippableItemsForSlot (slot)
18 {
19 const out = [];
20 for (const def of Object.values(ITEM_DEFINITIONS))
21 {
22 if (!def?.equipment || def.equipment.slot !== slot)
23 { continue; }
24 out.push({
25 itemId: def.itemId,
26 key: def.key ?? String(def.itemId),
27 displayName: def.displayName ?? `Item ${def.itemId}`
28 });
29 }
30 out.sort((a, b) => a.displayName.localeCompare(b.displayName));
31 return out;
32 }
23 33
24 34 export function initTileConfigModal ({ onSave, onRemove })
25 35 {
@@ -29,12 +39,17 @@ export function initTileConfigModal ({ onSave, onRemove })
29 39 const title = document.getElementById("tile-config-title");
30 40 const itemSearchBackdrop = document.getElementById("shop-item-search-backdrop");
31 41 const itemSearchModal = document.getElementById("shop-item-search-modal");
42 const itemSearchTitle = itemSearchModal?.querySelector("h2") ?? null;
32 43 const itemSearchInput = document.getElementById("shop-item-search-input");
33 44 const itemSearchResults = document.getElementById("shop-item-search-results");
34 45 let open = false;
35 46 let context = null;
36 47 /** @type {{ itemId: number, quantity: number }[]} */
37 48 let sellsDraft = [];
49 /** @type {Record<string, number|null>} */
50 let equipmentDraft = {};
51 /** @type {{ kind: "sells" } | { kind: "equip", slot: string } | null} */
52 let itemSearchMode = null;
38 53
39 54 function show (visible)
40 55 {
@@ -50,38 +65,65 @@ export function initTileConfigModal ({ onSave, onRemove })
50 65
51 66 function closeItemSearch ()
52 67 {
68 itemSearchMode = null;
53 69 if (itemSearchBackdrop)
54 70 { itemSearchBackdrop.hidden = true; }
55 71 if (itemSearchModal)
56 72 { itemSearchModal.hidden = true; }
57 73 }
58 74
59 function openItemSearch ()
75 function openSellItemSearch ()
76 {
77 itemSearchMode = { kind: "sells" };
78 openItemSearch("Add shop stock");
79 }
80
81 function openEquipItemSearch (slot)
82 {
83 itemSearchMode = { kind: "equip", slot };
84 openItemSearch(`Equip ${slot}`);
85 }
86
87 function openItemSearch (heading)
60 88 {
61 89 if (!itemSearchBackdrop || !itemSearchModal || !itemSearchInput)
62 90 { return; }
91 if (itemSearchTitle)
92 { itemSearchTitle.textContent = heading ?? "Choose item"; }
63 93 itemSearchInput.value = "";
94 itemSearchInput.placeholder = itemSearchMode?.kind === "equip"
95 ? "Search equipment…"
96 : "Search items…";
64 97 renderItemSearchResults("");
65 98 itemSearchBackdrop.hidden = false;
66 99 itemSearchModal.hidden = false;
67 100 itemSearchInput.focus();
68 101 }
69 102
103 function candidateItems ()
104 {
105 if (itemSearchMode?.kind === "equip")
106 { return listEquippableItemsForSlot(itemSearchMode.slot); }
107 return listNpcShopSellableItems();
108 }
109
70 110 function renderItemSearchResults (query)
71 111 {
72 112 if (!itemSearchResults)
73 113 { return; }
74 114 itemSearchResults.innerHTML = "";
75 115 const q = String(query ?? "").trim().toLowerCase();
76 const taken = new Set(sellsDraft.map((line) => line.itemId));
77 const matches = listNpcShopSellableItems().filter((item) =>
116 const taken = itemSearchMode?.kind === "sells"
117 ? new Set(sellsDraft.map((line) => line.itemId))
118 : null;
119 const matches = candidateItems().filter((item) =>
78 120 {
79 if (taken.has(item.itemId))
121 if (taken?.has(item.itemId))
80 122 { return false; }
81 123 if (!q)
82 124 { return true; }
83 125 return item.displayName.toLowerCase().includes(q) || item.key.toLowerCase().includes(q);
84 }).slice(0, 80);
126 }).slice(0, 120);
85 127 if (!matches.length)
86 128 {
87 129 itemSearchResults.textContent = "No matching items.";
@@ -95,8 +137,16 @@ export function initTileConfigModal ({ onSave, onRemove })
95 137 row.textContent = item.displayName;
96 138 row.addEventListener("click", () =>
97 139 {
98 sellsDraft.push({ itemId: item.itemId, quantity: 0 });
99 renderSellsList();
140 if (itemSearchMode?.kind === "equip")
141 {
142 equipmentDraft[itemSearchMode.slot] = item.itemId;
143 renderEquipmentRows();
144 }
145 else
146 {
147 sellsDraft.push({ itemId: item.itemId, quantity: 0 });
148 renderSellsList();
149 }
100 150 closeItemSearch();
101 151 });
102 152 itemSearchResults.append(row);
@@ -149,6 +199,42 @@ export function initTileConfigModal ({ onSave, onRemove })
149 199 }
150 200 }
151 201
202 function renderEquipmentRows ()
203 {
204 const list = form.querySelector("[data-equipment-list]");
205 if (!list)
206 { return; }
207 list.innerHTML = "";
208 for (const slot of EQUIPMENT_SLOTS)
209 {
210 const itemId = equipmentDraft[slot] ?? null;
211 const def = itemId ? itemDefinition(itemId) : null;
212 const row = document.createElement("div");
213 row.className = "spawner-equip-row";
214 const label = document.createElement("span");
215 label.className = "spawner-equip-slot";
216 label.textContent = slot;
217 const name = document.createElement("span");
218 name.className = "spawner-equip-name";
219 name.textContent = def?.displayName ?? "(none)";
220 const pick = document.createElement("button");
221 pick.type = "button";
222 pick.textContent = "Choose…";
223 pick.addEventListener("click", () => openEquipItemSearch(slot));
224 const clear = document.createElement("button");
225 clear.type = "button";
226 clear.textContent = "Clear";
227 clear.disabled = itemId == null;
228 clear.addEventListener("click", () =>
229 {
230 equipmentDraft[slot] = null;
231 renderEquipmentRows();
232 });
233 row.append(label, name, pick, clear);
234 list.append(row);
235 }
236 }
237
152 238 function renderHumanoidFields (config)
153 239 {
154 240 const wrap = document.createElement("div");
@@ -169,13 +255,27 @@ export function initTileConfigModal ({ onSave, onRemove })
169 255 field("Sex", sexSelect("sex", config.sex))
170 256 );
171 257 }
258
259 const equipHeader = document.createElement("div");
260 equipHeader.className = "spawner-sells-header";
261 const equipTitle = document.createElement("strong");
262 equipTitle.textContent = "Equipment";
263 equipHeader.append(equipTitle);
264 wrap.append(equipHeader);
265
266 const equipList = document.createElement("div");
267 equipList.className = "spawner-equip-list";
268 equipList.dataset.equipmentList = "1";
269 wrap.append(equipList);
270
271 equipmentDraft = {};
172 272 for (const slot of EQUIPMENT_SLOTS)
173 273 {
174 wrap.append(field(
175 `Equip ${slot}`,
176 equipSelect(`equipment.${slot}`, slot, config.equipment?.[slot] ?? null)
177 ));
274 const raw = config.equipment?.[slot];
275 equipmentDraft[slot] = raw != null && raw !== "" ? Number(raw) || null : null;
178 276 }
277 queueMicrotask(() => renderEquipmentRows());
278
179 279 if (!exchange)
180 280 {
181 281 wrap.append(field("Hidden discount (0–1)", numberInput("hiddenDiscount", config.hiddenDiscount ?? 0.9, 0.01, 1, 0.01)));
@@ -188,7 +288,7 @@ export function initTileConfigModal ({ onSave, onRemove })
188 288 addBtn.type = "button";
189 289 addBtn.textContent = "+";
190 290 addBtn.title = "Add item";
191 addBtn.addEventListener("click", () => openItemSearch());
291 addBtn.addEventListener("click", () => openSellItemSearch());
192 292 sellsHeader.append(sellsTitle, addBtn);
193 293 wrap.append(sellsHeader);
194 294
@@ -232,6 +332,7 @@ export function initTileConfigModal ({ onSave, onRemove })
232 332 if (!isHumanoidMob(mobTypeId))
233 333 {
234 334 sellsDraft = [];
335 equipmentDraft = {};
235 336 return;
236 337 }
237 338 form.append(renderHumanoidFields(config ?? normalizeSpawnerConfig({
@@ -301,8 +402,8 @@ export function initTileConfigModal ({ onSave, onRemove })
301 402 const equipment = {};
302 403 for (const slot of EQUIPMENT_SLOTS)
303 404 {
304 const raw = data.get(`equipment.${slot}`);
305 equipment[slot] = raw ? Number(raw) : null;
405 const raw = equipmentDraft[slot];
406 equipment[slot] = raw != null && raw !== "" ? Number(raw) || null : null;
306 407 }
307 408 onSave?.(context, normalizeSpawnerConfig({
308 409 mobTypeId: String(data.get("mobTypeId") || "deer"),
@@ -380,29 +481,6 @@ function sexSelect (name, value)
380 481 return select;
381 482 }
382 483
383 function equipSelect (name, slot, value)
384 {
385 const select = document.createElement("select");
386 select.name = name;
387 const none = document.createElement("option");
388 none.value = "";
389 none.textContent = "(none)";
390 select.append(none);
391 for (const preset of EQUIP_PRESETS)
392 {
393 if (preset.slot !== slot)
394 { continue; }
395 const def = itemDefinition(preset.itemId);
396 const option = document.createElement("option");
397 option.value = String(preset.itemId);
398 option.textContent = def?.displayName ?? String(preset.itemId);
399 if (preset.itemId === value)
400 { option.selected = true; }
401 select.append(option);
402 }
403 return select;
404 }
405
406 484 function mobSelect (name, value)
407 485 {
408 486 const select = document.createElement("select");
@@ -9,17 +9,27 @@ import {
9 isCentralExchangeSpawner
9 isCentralExchangeSpawner
10} from "/shared/definitions/mobs.js";
10} from "/shared/definitions/mobs.js";
11import { centralExchangeStaffCount } from "/shared/market/exchange.js";
11import { centralExchangeStaffCount } from "/shared/market/exchange.js";
12import { ItemId, itemDefinition, EQUIPMENT_SLOT } from "/shared/definitions/items.js";
12import { ITEM_DEFINITIONS, itemDefinition } from "/shared/definitions/items.js";
13import { EQUIPMENT_SLOTS } from "/shared/items/inventory.js";
13import { EQUIPMENT_SLOTS } from "/shared/items/inventory.js";
14import { listNpcShopSellableItems } from "/shared/shop/pricing.js";
14import { listNpcShopSellableItems } from "/shared/shop/pricing.js";
15
15
16const EQUIP_PRESETS = Object.freeze([
16/** Items that can be worn in a given equipment slot. */
17 { itemId: ItemId.clothShirt, slot: EQUIPMENT_SLOT.chest },
17export function listEquippableItemsForSlot (slot)
18 { itemId: ItemId.stick, slot: EQUIPMENT_SLOT.weapon },
18{
19 { itemId: ItemId.bronzePickaxe, slot: EQUIPMENT_SLOT.weapon },
19 const out = [];
20 { itemId: ItemId.bronzeAxe, slot: EQUIPMENT_SLOT.weapon },
20 for (const def of Object.values(ITEM_DEFINITIONS))
21 { itemId: ItemId.lantern, slot: EQUIPMENT_SLOT.offhand }
21 {
22]);
22 if (!def?.equipment || def.equipment.slot !== slot)
23 { continue; }
24 out.push({
25 itemId: def.itemId,
26 key: def.key ?? String(def.itemId),
27 displayName: def.displayName ?? `Item ${def.itemId}`
28 });
29 }
30 out.sort((a, b) => a.displayName.localeCompare(b.displayName));
31 return out;
32}
23
33
24export function initTileConfigModal ({ onSave, onRemove })
34export function initTileConfigModal ({ onSave, onRemove })
25{
35{
@@ -29,12 +39,17 @@ export function initTileConfigModal ({ onSave, onRemove })
29 const title = document.getElementById("tile-config-title");
39 const title = document.getElementById("tile-config-title");
30 const itemSearchBackdrop = document.getElementById("shop-item-search-backdrop");
40 const itemSearchBackdrop = document.getElementById("shop-item-search-backdrop");
31 const itemSearchModal = document.getElementById("shop-item-search-modal");
41 const itemSearchModal = document.getElementById("shop-item-search-modal");
42 const itemSearchTitle = itemSearchModal?.querySelector("h2") ?? null;
32 const itemSearchInput = document.getElementById("shop-item-search-input");
43 const itemSearchInput = document.getElementById("shop-item-search-input");
33 const itemSearchResults = document.getElementById("shop-item-search-results");
44 const itemSearchResults = document.getElementById("shop-item-search-results");
34 let open = false;
45 let open = false;
35 let context = null;
46 let context = null;
36 /** @type {{ itemId: number, quantity: number }[]} */
47 /** @type {{ itemId: number, quantity: number }[]} */
37 let sellsDraft = [];
48 let sellsDraft = [];
49 /** @type {Record<string, number|null>} */
50 let equipmentDraft = {};
51 /** @type {{ kind: "sells" } | { kind: "equip", slot: string } | null} */
52 let itemSearchMode = null;
38
53
39 function show (visible)
54 function show (visible)
40 {
55 {
@@ -50,38 +65,65 @@ export function initTileConfigModal ({ onSave, onRemove })
50
65
51 function closeItemSearch ()
66 function closeItemSearch ()
52 {
67 {
68 itemSearchMode = null;
53 if (itemSearchBackdrop)
69 if (itemSearchBackdrop)
54 { itemSearchBackdrop.hidden = true; }
70 { itemSearchBackdrop.hidden = true; }
55 if (itemSearchModal)
71 if (itemSearchModal)
56 { itemSearchModal.hidden = true; }
72 { itemSearchModal.hidden = true; }
57 }
73 }
58
74
59 function openItemSearch ()
75 function openSellItemSearch ()
76 {
77 itemSearchMode = { kind: "sells" };
78 openItemSearch("Add shop stock");
79 }
80
81 function openEquipItemSearch (slot)
82 {
83 itemSearchMode = { kind: "equip", slot };
84 openItemSearch(`Equip ${slot}`);
85 }
86
87 function openItemSearch (heading)
60 {
88 {
61 if (!itemSearchBackdrop || !itemSearchModal || !itemSearchInput)
89 if (!itemSearchBackdrop || !itemSearchModal || !itemSearchInput)
62 { return; }
90 { return; }
91 if (itemSearchTitle)
92 { itemSearchTitle.textContent = heading ?? "Choose item"; }
63 itemSearchInput.value = "";
93 itemSearchInput.value = "";
94 itemSearchInput.placeholder = itemSearchMode?.kind === "equip"
95 ? "Search equipment…"
96 : "Search items…";
64 renderItemSearchResults("");
97 renderItemSearchResults("");
65 itemSearchBackdrop.hidden = false;
98 itemSearchBackdrop.hidden = false;
66 itemSearchModal.hidden = false;
99 itemSearchModal.hidden = false;
67 itemSearchInput.focus();
100 itemSearchInput.focus();
68 }
101 }
69
102
103 function candidateItems ()
104 {
105 if (itemSearchMode?.kind === "equip")
106 { return listEquippableItemsForSlot(itemSearchMode.slot); }
107 return listNpcShopSellableItems();
108 }
109
70 function renderItemSearchResults (query)
110 function renderItemSearchResults (query)
71 {
111 {
72 if (!itemSearchResults)
112 if (!itemSearchResults)
73 { return; }
113 { return; }
74 itemSearchResults.innerHTML = "";
114 itemSearchResults.innerHTML = "";
75 const q = String(query ?? "").trim().toLowerCase();
115 const q = String(query ?? "").trim().toLowerCase();
76 const taken = new Set(sellsDraft.map((line) => line.itemId));
116 const taken = itemSearchMode?.kind === "sells"
77 const matches = listNpcShopSellableItems().filter((item) =>
117 ? new Set(sellsDraft.map((line) => line.itemId))
118 : null;
119 const matches = candidateItems().filter((item) =>
78 {
120 {
79 if (taken.has(item.itemId))
121 if (taken?.has(item.itemId))
80 { return false; }
122 { return false; }
81 if (!q)
123 if (!q)
82 { return true; }
124 { return true; }
83 return item.displayName.toLowerCase().includes(q) || item.key.toLowerCase().includes(q);
125 return item.displayName.toLowerCase().includes(q) || item.key.toLowerCase().includes(q);
84 }).slice(0, 80);
126 }).slice(0, 120);
85 if (!matches.length)
127 if (!matches.length)
86 {
128 {
87 itemSearchResults.textContent = "No matching items.";
129 itemSearchResults.textContent = "No matching items.";
@@ -95,8 +137,16 @@ export function initTileConfigModal ({ onSave, onRemove })
95 row.textContent = item.displayName;
137 row.textContent = item.displayName;
96 row.addEventListener("click", () =>
138 row.addEventListener("click", () =>
97 {
139 {
98 sellsDraft.push({ itemId: item.itemId, quantity: 0 });
140 if (itemSearchMode?.kind === "equip")
99 renderSellsList();
141 {
142 equipmentDraft[itemSearchMode.slot] = item.itemId;
143 renderEquipmentRows();
144 }
145 else
146 {
147 sellsDraft.push({ itemId: item.itemId, quantity: 0 });
148 renderSellsList();
149 }
100 closeItemSearch();
150 closeItemSearch();
101 });
151 });
102 itemSearchResults.append(row);
152 itemSearchResults.append(row);
@@ -149,6 +199,42 @@ export function initTileConfigModal ({ onSave, onRemove })
149 }
199 }
150 }
200 }
151
201
202 function renderEquipmentRows ()
203 {
204 const list = form.querySelector("[data-equipment-list]");
205 if (!list)
206 { return; }
207 list.innerHTML = "";
208 for (const slot of EQUIPMENT_SLOTS)
209 {
210 const itemId = equipmentDraft[slot] ?? null;
211 const def = itemId ? itemDefinition(itemId) : null;
212 const row = document.createElement("div");
213 row.className = "spawner-equip-row";
214 const label = document.createElement("span");
215 label.className = "spawner-equip-slot";
216 label.textContent = slot;
217 const name = document.createElement("span");
218 name.className = "spawner-equip-name";
219 name.textContent = def?.displayName ?? "(none)";
220 const pick = document.createElement("button");
221 pick.type = "button";
222 pick.textContent = "Choose…";
223 pick.addEventListener("click", () => openEquipItemSearch(slot));
224 const clear = document.createElement("button");
225 clear.type = "button";
226 clear.textContent = "Clear";
227 clear.disabled = itemId == null;
228 clear.addEventListener("click", () =>
229 {
230 equipmentDraft[slot] = null;
231 renderEquipmentRows();
232 });
233 row.append(label, name, pick, clear);
234 list.append(row);
235 }
236 }
237
152 function renderHumanoidFields (config)
238 function renderHumanoidFields (config)
153 {
239 {
154 const wrap = document.createElement("div");
240 const wrap = document.createElement("div");
@@ -169,13 +255,27 @@ export function initTileConfigModal ({ onSave, onRemove })
169 field("Sex", sexSelect("sex", config.sex))
255 field("Sex", sexSelect("sex", config.sex))
170 );
256 );
171 }
257 }
258
259 const equipHeader = document.createElement("div");
260 equipHeader.className = "spawner-sells-header";
261 const equipTitle = document.createElement("strong");
262 equipTitle.textContent = "Equipment";
263 equipHeader.append(equipTitle);
264 wrap.append(equipHeader);
265
266 const equipList = document.createElement("div");
267 equipList.className = "spawner-equip-list";
268 equipList.dataset.equipmentList = "1";
269 wrap.append(equipList);
270
271 equipmentDraft = {};
172 for (const slot of EQUIPMENT_SLOTS)
272 for (const slot of EQUIPMENT_SLOTS)
173 {
273 {
174 wrap.append(field(
274 const raw = config.equipment?.[slot];
175 `Equip ${slot}`,
275 equipmentDraft[slot] = raw != null && raw !== "" ? Number(raw) || null : null;
176 equipSelect(`equipment.${slot}`, slot, config.equipment?.[slot] ?? null)
177 ));
178 }
276 }
277 queueMicrotask(() => renderEquipmentRows());
278
179 if (!exchange)
279 if (!exchange)
180 {
280 {
181 wrap.append(field("Hidden discount (0–1)", numberInput("hiddenDiscount", config.hiddenDiscount ?? 0.9, 0.01, 1, 0.01)));
281 wrap.append(field("Hidden discount (0–1)", numberInput("hiddenDiscount", config.hiddenDiscount ?? 0.9, 0.01, 1, 0.01)));
@@ -188,7 +288,7 @@ export function initTileConfigModal ({ onSave, onRemove })
188 addBtn.type = "button";
288 addBtn.type = "button";
189 addBtn.textContent = "+";
289 addBtn.textContent = "+";
190 addBtn.title = "Add item";
290 addBtn.title = "Add item";
191 addBtn.addEventListener("click", () => openItemSearch());
291 addBtn.addEventListener("click", () => openSellItemSearch());
192 sellsHeader.append(sellsTitle, addBtn);
292 sellsHeader.append(sellsTitle, addBtn);
193 wrap.append(sellsHeader);
293 wrap.append(sellsHeader);
194
294
@@ -232,6 +332,7 @@ export function initTileConfigModal ({ onSave, onRemove })
232 if (!isHumanoidMob(mobTypeId))
332 if (!isHumanoidMob(mobTypeId))
233 {
333 {
234 sellsDraft = [];
334 sellsDraft = [];
335 equipmentDraft = {};
235 return;
336 return;
236 }
337 }
237 form.append(renderHumanoidFields(config ?? normalizeSpawnerConfig({
338 form.append(renderHumanoidFields(config ?? normalizeSpawnerConfig({
@@ -301,8 +402,8 @@ export function initTileConfigModal ({ onSave, onRemove })
301 const equipment = {};
402 const equipment = {};
302 for (const slot of EQUIPMENT_SLOTS)
403 for (const slot of EQUIPMENT_SLOTS)
303 {
404 {
304 const raw = data.get(`equipment.${slot}`);
405 const raw = equipmentDraft[slot];
305 equipment[slot] = raw ? Number(raw) : null;
406 equipment[slot] = raw != null && raw !== "" ? Number(raw) || null : null;
306 }
407 }
307 onSave?.(context, normalizeSpawnerConfig({
408 onSave?.(context, normalizeSpawnerConfig({
308 mobTypeId: String(data.get("mobTypeId") || "deer"),
409 mobTypeId: String(data.get("mobTypeId") || "deer"),
@@ -380,29 +481,6 @@ function sexSelect (name, value)
380 return select;
481 return select;
381}
482}
382
483
383function equipSelect (name, slot, value)
384{
385 const select = document.createElement("select");
386 select.name = name;
387 const none = document.createElement("option");
388 none.value = "";
389 none.textContent = "(none)";
390 select.append(none);
391 for (const preset of EQUIP_PRESETS)
392 {
393 if (preset.slot !== slot)
394 { continue; }
395 const def = itemDefinition(preset.itemId);
396 const option = document.createElement("option");
397 option.value = String(preset.itemId);
398 option.textContent = def?.displayName ?? String(preset.itemId);
399 if (preset.itemId === value)
400 { option.selected = true; }
401 select.append(option);
402 }
403 return select;
404}
405
406function mobSelect (name, value)
484function mobSelect (name, value)
407{
485{
408 const select = document.createElement("select");
486 const select = document.createElement("select");
client/src/render/worldView.js +1 −1
@@ -527,7 +527,7 @@ export class WorldView
527 527 return matches;
528 528 }
529 529
530 setZoom (zoom, limits = { min: 1, max: 4 })
530 setZoom (zoom, limits = { min: 2, max: 4 })
531 531 {
532 532 const min = limits.min ?? 1;
533 533 const max = limits.max ?? 4;
@@ -527,7 +527,7 @@ export class WorldView
527 return matches;
527 return matches;
528 }
528 }
529
529
530 setZoom (zoom, limits = { min: 1, max: 4 })
530 setZoom (zoom, limits = { min: 2, max: 4 })
531 {
531 {
532 const min = limits.min ?? 1;
532 const min = limits.min ?? 1;
533 const max = limits.max ?? 4;
533 const max = limits.max ?? 4;
client/ui/editor.css +25 −0
@@ -495,6 +495,31 @@ label { display: block; margin: 0.4rem 0; }
495 495 white-space: nowrap;
496 496 }
497 497
498 .spawner-equip-list {
499 display: flex;
500 flex-direction: column;
501 gap: 0.35rem;
502 }
503
504 .spawner-equip-row {
505 display: grid;
506 grid-template-columns: 4.5rem 1fr auto auto;
507 gap: 0.4rem;
508 align-items: center;
509 }
510
511 .spawner-equip-slot {
512 text-transform: capitalize;
513 color: #9aa3b2;
514 font-size: 0.85rem;
515 }
516
517 .spawner-equip-name {
518 overflow: hidden;
519 text-overflow: ellipsis;
520 white-space: nowrap;
521 }
522
498 523 .spawner-buys-row {
499 524 display: flex;
500 525 align-items: center;
@@ -495,6 +495,31 @@ label { display: block; margin: 0.4rem 0; }
495 white-space: nowrap;
495 white-space: nowrap;
496}
496}
497
497
498.spawner-equip-list {
499 display: flex;
500 flex-direction: column;
501 gap: 0.35rem;
502}
503
504.spawner-equip-row {
505 display: grid;
506 grid-template-columns: 4.5rem 1fr auto auto;
507 gap: 0.4rem;
508 align-items: center;
509}
510
511.spawner-equip-slot {
512 text-transform: capitalize;
513 color: #9aa3b2;
514 font-size: 0.85rem;
515}
516
517.spawner-equip-name {
518 overflow: hidden;
519 text-overflow: ellipsis;
520 white-space: nowrap;
521}
522
498.spawner-buys-row {
523.spawner-buys-row {
499 display: flex;
524 display: flex;
500 align-items: center;
525 align-items: center;
server/tests/inventory.test.js +1 −1
@@ -108,7 +108,7 @@ test("equip uses the item key-equip sprite for appearance layers", () =>
108 108 });
109 109 harness.simulation.step();
110 110 const view = harness.simulation.entityRecord(entityId);
111 assert.ok(view.layers.some((layer) => layer.sprite === "item:cloth-shirt:cloth-shirt:equip"));
111 assert.ok(view.layers.some((layer) => layer.sprite === "item:clothing:shirt:equip"));
112 112 }
113 113 finally
114 114 { harness.close(); }
@@ -108,7 +108,7 @@ test("equip uses the item key-equip sprite for appearance layers", () =>
108 });
108 });
109 harness.simulation.step();
109 harness.simulation.step();
110 const view = harness.simulation.entityRecord(entityId);
110 const view = harness.simulation.entityRecord(entityId);
111 assert.ok(view.layers.some((layer) => layer.sprite === "item:cloth-shirt:cloth-shirt:equip"));
111 assert.ok(view.layers.some((layer) => layer.sprite === "item:clothing:shirt:equip"));
112 }
112 }
113 finally
113 finally
114 { harness.close(); }
114 { harness.close(); }
shared/definitions/items.js +5 −2
@@ -161,16 +161,19 @@ export const ITEM_DEFINITIONS = Object.freeze({
161 161 itemId: ItemId.clothShirt,
162 162 key: "cloth-shirt",
163 163 displayName: "Cloth shirt",
164 description: "A placeholder shirt worn on the chest.",
164 description: "A simple cloth shirt. Shared clothing/shirt art (tintable).",
165 165 seedValue: 8,
166 166 stackable: false,
167 167 maxStackSize: 1,
168 168 uniqueInstance: false,
169 169 category: "finished",
170 iconKey: "clothing",
171 defaultState: "shirt",
170 172 equipment: Object.freeze({
171 173 slot: EQUIPMENT_SLOT.chest,
172 174 tier: MaterialTier.bronze,
173 kind: EquipmentKind.clothArmour
175 kind: EquipmentKind.clothArmour,
176 equipSprite: equipImageName("item", "clothing", "shirt")
174 177 })
175 178 }),
176 179 [ItemId.coins]: Object.freeze({
@@ -161,16 +161,19 @@ export const ITEM_DEFINITIONS = Object.freeze({
161 itemId: ItemId.clothShirt,
161 itemId: ItemId.clothShirt,
162 key: "cloth-shirt",
162 key: "cloth-shirt",
163 displayName: "Cloth shirt",
163 displayName: "Cloth shirt",
164 description: "A placeholder shirt worn on the chest.",
164 description: "A simple cloth shirt. Shared clothing/shirt art (tintable).",
165 seedValue: 8,
165 seedValue: 8,
166 stackable: false,
166 stackable: false,
167 maxStackSize: 1,
167 maxStackSize: 1,
168 uniqueInstance: false,
168 uniqueInstance: false,
169 category: "finished",
169 category: "finished",
170 iconKey: "clothing",
171 defaultState: "shirt",
170 equipment: Object.freeze({
172 equipment: Object.freeze({
171 slot: EQUIPMENT_SLOT.chest,
173 slot: EQUIPMENT_SLOT.chest,
172 tier: MaterialTier.bronze,
174 tier: MaterialTier.bronze,
173 kind: EquipmentKind.clothArmour
175 kind: EquipmentKind.clothArmour,
176 equipSprite: equipImageName("item", "clothing", "shirt")
174 })
177 })
175 }),
178 }),
176 [ItemId.coins]: Object.freeze({
179 [ItemId.coins]: Object.freeze({