BlueGit

timfa questward

Hide craft dye controls on non-tailor stations.

CSS display:flex was overriding the hidden attribute on material/dye controls, so furnace and other stations showed Choose dye; keep dyeing tailor-only on client and server.

timfa Tim Falken · pushed by timfa

Authored 2026-08-27 · 2 months ago

Hash
b7733356c8adb4c4fd778edd59906c317112e8bb
Parent
678fbba5
4 files changed +34 −17
client/index.html +6 −6
@@ -245,12 +245,12 @@
245 245 <span>Material</span>
246 246 <select id="craft-material-tier"></select>
247 247 </label>
248 <div id="craft-dye-controls" class="craft-tailor-dye" hidden>
249 <span>Dye (optional)</span>
250 <button id="craft-dye-pick" type="button">Choose dye…</button>
251 <button id="craft-dye-clear" type="button" hidden>Clear dye</button>
252 <img id="craft-dye-preview" alt="" hidden>
253 </div>
248 </div>
249 <div id="craft-dye-controls" class="craft-tailor-dye" hidden>
250 <span>Dye (optional)</span>
251 <button id="craft-dye-pick" type="button">Choose dye…</button>
252 <button id="craft-dye-clear" type="button" hidden>Clear dye</button>
253 <img id="craft-dye-preview" alt="" hidden>
254 254 </div>
255 255 <div class="craft-output">
256 256 <img id="craft-output-img" alt="">
@@ -245,12 +245,12 @@
245 <span>Material</span>
245 <span>Material</span>
246 <select id="craft-material-tier"></select>
246 <select id="craft-material-tier"></select>
247 </label>
247 </label>
248 <div id="craft-dye-controls" class="craft-tailor-dye" hidden>
248 </div>
249 <span>Dye (optional)</span>
249 <div id="craft-dye-controls" class="craft-tailor-dye" hidden>
250 <button id="craft-dye-pick" type="button">Choose dye…</button>
250 <span>Dye (optional)</span>
251 <button id="craft-dye-clear" type="button" hidden>Clear dye</button>
251 <button id="craft-dye-pick" type="button">Choose dye…</button>
252 <img id="craft-dye-preview" alt="" hidden>
252 <button id="craft-dye-clear" type="button" hidden>Clear dye</button>
253 </div>
253 <img id="craft-dye-preview" alt="" hidden>
254 </div>
254 </div>
255 <div class="craft-output">
255 <div class="craft-output">
256 <img id="craft-output-img" alt="">
256 <img id="craft-output-img" alt="">
client/src/play/crafting.js +15 −11
@@ -90,7 +90,12 @@ export function initCrafting ({
90 90 renderRecipeGrid();
91 91 renderDetail();
92 92 });
93 dyePickBtn?.addEventListener("click", () => openDyePicker());
93 dyePickBtn?.addEventListener("click", () =>
94 {
95 if (!isTailorStation())
96 { return; }
97 openDyePicker();
98 });
94 99 dyeClearBtn?.addEventListener("click", () =>
95 100 {
96 101 dyeSlotIndex = null;
@@ -119,11 +124,6 @@ export function initCrafting ({
119 124 return stationId === CraftingStationId.craftingBench;
120 125 }
121 126
122 function isCraftingBenchStation ()
123 {
124 return stationId === CraftingStationId.craftingBench;
125 }
126
127 127 function isSpinningWheelStation ()
128 128 {
129 129 return stationId === CraftingStationId.spinningWheel;
@@ -356,6 +356,13 @@ export function initCrafting ({
356 356
357 357 function renderDetail ()
358 358 {
359 if (materialControls)
360 { materialControls.hidden = !usesMaterialDropdown(); }
361 if (!isTailorStation())
362 { dyeSlotIndex = null; }
363 if (dyeControls)
364 { dyeControls.hidden = !isTailorStation(); }
365
359 366 const recipe = activeRecipe();
360 367 if (!recipe)
361 368 {
@@ -366,11 +373,6 @@ export function initCrafting ({
366 373 detailEmpty.hidden = true;
367 374 detailBody.hidden = false;
368 375
369 if (materialControls)
370 { materialControls.hidden = !usesMaterialDropdown(); }
371 if (dyeControls)
372 { dyeControls.hidden = !isTailorStation(); }
373
374 376 const outputStack = {
375 377 itemId: recipe.output.itemId,
376 378 quantity: Math.max(1, recipe.output.quantity | 0 || 1),
@@ -499,6 +501,8 @@ export function initCrafting ({
499 501
500 502 function openDyePicker ()
501 503 {
504 if (!isTailorStation())
505 { return; }
502 506 const slots = getInventorySlots?.() ?? [];
503 507 dyeGrid.replaceChildren();
504 508 let found = false;
@@ -90,7 +90,12 @@ export function initCrafting ({
90 renderRecipeGrid();
90 renderRecipeGrid();
91 renderDetail();
91 renderDetail();
92 });
92 });
93 dyePickBtn?.addEventListener("click", () => openDyePicker());
93 dyePickBtn?.addEventListener("click", () =>
94 {
95 if (!isTailorStation())
96 { return; }
97 openDyePicker();
98 });
94 dyeClearBtn?.addEventListener("click", () =>
99 dyeClearBtn?.addEventListener("click", () =>
95 {
100 {
96 dyeSlotIndex = null;
101 dyeSlotIndex = null;
@@ -119,11 +124,6 @@ export function initCrafting ({
119 return stationId === CraftingStationId.craftingBench;
124 return stationId === CraftingStationId.craftingBench;
120 }
125 }
121
126
122 function isCraftingBenchStation ()
123 {
124 return stationId === CraftingStationId.craftingBench;
125 }
126
127 function isSpinningWheelStation ()
127 function isSpinningWheelStation ()
128 {
128 {
129 return stationId === CraftingStationId.spinningWheel;
129 return stationId === CraftingStationId.spinningWheel;
@@ -356,6 +356,13 @@ export function initCrafting ({
356
356
357 function renderDetail ()
357 function renderDetail ()
358 {
358 {
359 if (materialControls)
360 { materialControls.hidden = !usesMaterialDropdown(); }
361 if (!isTailorStation())
362 { dyeSlotIndex = null; }
363 if (dyeControls)
364 { dyeControls.hidden = !isTailorStation(); }
365
359 const recipe = activeRecipe();
366 const recipe = activeRecipe();
360 if (!recipe)
367 if (!recipe)
361 {
368 {
@@ -366,11 +373,6 @@ export function initCrafting ({
366 detailEmpty.hidden = true;
373 detailEmpty.hidden = true;
367 detailBody.hidden = false;
374 detailBody.hidden = false;
368
375
369 if (materialControls)
370 { materialControls.hidden = !usesMaterialDropdown(); }
371 if (dyeControls)
372 { dyeControls.hidden = !isTailorStation(); }
373
374 const outputStack = {
376 const outputStack = {
375 itemId: recipe.output.itemId,
377 itemId: recipe.output.itemId,
376 quantity: Math.max(1, recipe.output.quantity | 0 || 1),
378 quantity: Math.max(1, recipe.output.quantity | 0 || 1),
@@ -499,6 +501,8 @@ export function initCrafting ({
499
501
500 function openDyePicker ()
502 function openDyePicker ()
501 {
503 {
504 if (!isTailorStation())
505 { return; }
502 const slots = getInventorySlots?.() ?? [];
506 const slots = getInventorySlots?.() ?? [];
503 dyeGrid.replaceChildren();
507 dyeGrid.replaceChildren();
504 let found = false;
508 let found = false;
client/ui/play.css +6 −0
@@ -1094,6 +1094,9 @@ a { color: #d4c48a; }
1094 1094 padding-bottom: 0.5rem;
1095 1095 border-bottom: 1px solid #2c3340;
1096 1096 }
1097 .craft-material-controls[hidden] {
1098 display: none !important;
1099 }
1097 1100
1098 1101 .craft-material-field {
1099 1102 display: flex;
@@ -1118,6 +1121,9 @@ a { color: #d4c48a; }
1118 1121 font-size: 0.85rem;
1119 1122 color: #c8c2b4;
1120 1123 }
1124 .craft-tailor-dye[hidden] {
1125 display: none !important;
1126 }
1121 1127
1122 1128 .craft-tailor-dye img {
1123 1129 width: 28px;
@@ -1094,6 +1094,9 @@ a { color: #d4c48a; }
1094 padding-bottom: 0.5rem;
1094 padding-bottom: 0.5rem;
1095 border-bottom: 1px solid #2c3340;
1095 border-bottom: 1px solid #2c3340;
1096}
1096}
1097.craft-material-controls[hidden] {
1098 display: none !important;
1099}
1097
1100
1098.craft-material-field {
1101.craft-material-field {
1099 display: flex;
1102 display: flex;
@@ -1118,6 +1121,9 @@ a { color: #d4c48a; }
1118 font-size: 0.85rem;
1121 font-size: 0.85rem;
1119 color: #c8c2b4;
1122 color: #c8c2b4;
1120}
1123}
1124.craft-tailor-dye[hidden] {
1125 display: none !important;
1126}
1121
1127
1122.craft-tailor-dye img {
1128.craft-tailor-dye img {
1123 width: 28px;
1129 width: 28px;
server/src/crafting/service.js +7 −0
@@ -148,6 +148,8 @@ export function startCraft (world, sessionId, characterId, stationId, recipeId,
148 148 let dyeSlotIndex = null;
149 149 if (recipe.tailorTemplate)
150 150 {
151 if (stationId !== CraftingStationId.tailorBench)
152 { throw userError("That garment can only be made at a tailor's bench."); }
151 153 const dyeIdx = options.dyeSlotIndex;
152 154 let dyeStack = null;
153 155 if (dyeIdx != null && dyeIdx >= 0)
@@ -164,6 +166,11 @@ export function startCraft (world, sessionId, characterId, stationId, recipeId,
164 166 { throw userError(resolved.reason); }
165 167 recipe = resolved.recipe;
166 168 }
169 else if (options.dyeSlotIndex != null)
170 {
171 // Dye is tailor-only; ignore client-supplied dye on other stations.
172 dyeSlotIndex = null;
173 }
167 174
168 175 if (!canStartCraft(inventory?.slots ?? [], recipe, level, { dyeSlotIndex }))
169 176 {
@@ -148,6 +148,8 @@ export function startCraft (world, sessionId, characterId, stationId, recipeId,
148 let dyeSlotIndex = null;
148 let dyeSlotIndex = null;
149 if (recipe.tailorTemplate)
149 if (recipe.tailorTemplate)
150 {
150 {
151 if (stationId !== CraftingStationId.tailorBench)
152 { throw userError("That garment can only be made at a tailor's bench."); }
151 const dyeIdx = options.dyeSlotIndex;
153 const dyeIdx = options.dyeSlotIndex;
152 let dyeStack = null;
154 let dyeStack = null;
153 if (dyeIdx != null && dyeIdx >= 0)
155 if (dyeIdx != null && dyeIdx >= 0)
@@ -164,6 +166,11 @@ export function startCraft (world, sessionId, characterId, stationId, recipeId,
164 { throw userError(resolved.reason); }
166 { throw userError(resolved.reason); }
165 recipe = resolved.recipe;
167 recipe = resolved.recipe;
166 }
168 }
169 else if (options.dyeSlotIndex != null)
170 {
171 // Dye is tailor-only; ignore client-supplied dye on other stations.
172 dyeSlotIndex = null;
173 }
167
174
168 if (!canStartCraft(inventory?.slots ?? [], recipe, level, { dyeSlotIndex }))
175 if (!canStartCraft(inventory?.slots ?? [], recipe, level, { dyeSlotIndex }))
169 {
176 {