Replace craft batch window.prompt with an in-game quantity modal.
Craft x now uses a fixed overlay above the craft station UI, matching shop/trade quantity selectors. Co-authored-by: Cursor <cursoragent@cursor.com>
@@ -321,6 +321,20 @@
321
321
</div>
322
322
</aside>
323
323
324
<div id="craft-qty-backdrop" class="modal-backdrop" hidden></div>
325
<aside id="craft-qty-panel" hidden>
326
<header>
327
<h2>Craft quantity</h2>
328
<button id="craft-qty-close" type="button">Close</button>
329
</header>
330
<p id="craft-qty-name"></p>
331
<p id="craft-qty-hint" class="hint"></p>
332
<label class="send-row">Quantity
333
<input id="craft-qty-input" type="number" min="1" step="1" value="1">
334
</label>
335
<button id="craft-qty-confirm" type="button">Craft</button>
336
</aside>
337
324
338
<div id="dye-picker-backdrop" class="modal-backdrop" hidden></div>
325
339
<aside id="dye-picker-panel" hidden>
326
340
<header>
@@ -321,6 +321,20 @@321
</div>321
</div>322
</aside>322
</aside>323
323
324
<div id="craft-qty-backdrop" class="modal-backdrop" hidden></div>325
<aside id="craft-qty-panel" hidden>326
<header>327
<h2>Craft quantity</h2>328
<button id="craft-qty-close" type="button">Close</button>329
</header>330
<p id="craft-qty-name"></p>331
<p id="craft-qty-hint" class="hint"></p>332
<label class="send-row">Quantity333
<input id="craft-qty-input" type="number" min="1" step="1" value="1">334
</label>335
<button id="craft-qty-confirm" type="button">Craft</button>336
</aside>337
324
<div id="dye-picker-backdrop" class="modal-backdrop" hidden></div>338
<div id="dye-picker-backdrop" class="modal-backdrop" hidden></div>325
<aside id="dye-picker-panel" hidden>339
<aside id="dye-picker-panel" hidden>326
<header>340
<header>@@ -75,6 +75,13 @@ export function initCrafting ({
75
75
const dyeBackdrop = document.getElementById("dye-picker-backdrop");
76
76
const dyePanel = document.getElementById("dye-picker-panel");
77
77
const dyeGrid = document.getElementById("dye-picker-grid");
78
const qtyBackdrop = document.getElementById("craft-qty-backdrop");
79
const qtyPanel = document.getElementById("craft-qty-panel");
80
const qtyName = document.getElementById("craft-qty-name");
81
const qtyHint = document.getElementById("craft-qty-hint");
82
const qtyInput = document.getElementById("craft-qty-input");
83
const qtyConfirm = document.getElementById("craft-qty-confirm");
84
const qtyClose = document.getElementById("craft-qty-close");
78
85
79
86
let open = false;
80
87
let stationId = null;
@@ -93,7 +100,7 @@ export function initCrafting ({
93
100
document.getElementById("craft-close").addEventListener("click", () => close());
94
101
backdrop.addEventListener("click", () => close());
95
102
craftButton.addEventListener("click", () => startCraft());
96
craftBatchButton?.addEventListener("click", () => startBatchCraft());
103
craftBatchButton?.addEventListener("click", () => openBatchQtyModal());
97
104
craftBatchAllButton?.addEventListener("click", () => startCraft({ batchAll: true }));
98
105
materialTierSelect?.addEventListener("change", () =>
99
106
{
@@ -121,6 +128,22 @@ export function initCrafting ({
121
128
});
122
129
document.getElementById("dye-picker-close")?.addEventListener("click", () => closeDyePicker());
123
130
dyeBackdrop?.addEventListener("click", () => closeDyePicker());
131
qtyClose?.addEventListener("click", () => closeBatchQtyModal());
132
qtyBackdrop?.addEventListener("click", () => closeBatchQtyModal());
133
qtyConfirm?.addEventListener("click", () => confirmBatchQtyModal());
134
qtyPanel?.addEventListener("mousedown", (event) =>
135
{
136
event.stopPropagation();
137
});
138
qtyBackdrop?.addEventListener("mousedown", (event) =>
139
{
140
event.preventDefault();
141
});
142
qtyInput?.addEventListener("keydown", (event) =>
143
{
144
if (event.key === "Enter")
145
{ confirmBatchQtyModal(); }
146
});
124
147
125
148
function dyeCraftOptions ()
126
149
{
@@ -644,14 +667,68 @@ export function initCrafting ({
644
667
dyeBackdrop.hidden = true;
645
668
}
646
669
647
function startBatchCraft ()
670
function maxCraftableCount (slots, recipe)
648
671
{
649
const raw = window.prompt("How many?", "1");
650
if (raw == null)
651
{ return; }
652
const count = Number.parseInt(raw, 10);
653
if (!Number.isFinite(count) || count < 1)
672
let max = Number.POSITIVE_INFINITY;
673
for (const input of recipe?.inputs ?? [])
674
{
675
const need = input.quantity | 0;
676
if (need <= 0)
677
{ continue; }
678
max = Math.min(max, Math.floor(countItemInSlots(slots, input.itemId) / need));
679
}
680
if (!Number.isFinite(max))
681
{ return 0; }
682
return Math.max(0, max | 0);
683
}
684
685
function openBatchQtyModal ()
686
{
687
const recipe = activeRecipe();
688
if (!recipe || crafting)
654
689
{ return; }
690
const slots = getInventorySlots?.() ?? [];
691
if (!canStartCraft(slots, recipe, stationSkillLevel(), dyeCraftOptions()))
692
{
693
renderDetail();
694
return;
695
}
696
const max = Math.max(1, maxCraftableCount(slots, recipe));
697
const outStack = {
698
itemId: recipe.output.itemId,
699
quantity: Math.max(1, recipe.output.quantity | 0 || 1)
700
};
701
if (qtyName)
702
{ qtyName.textContent = itemDisplayName(outStack); }
703
if (qtyHint)
704
{ qtyHint.textContent = `Max ${formatQuantity(max)}`; }
705
if (qtyInput)
706
{
707
qtyInput.min = "1";
708
qtyInput.max = String(max);
709
qtyInput.value = "1";
710
}
711
if (qtyPanel)
712
{ qtyPanel.hidden = false; }
713
if (qtyBackdrop)
714
{ qtyBackdrop.hidden = false; }
715
qtyInput?.focus();
716
qtyInput?.select();
717
}
718
719
function closeBatchQtyModal ()
720
{
721
if (qtyPanel)
722
{ qtyPanel.hidden = true; }
723
if (qtyBackdrop)
724
{ qtyBackdrop.hidden = true; }
725
}
726
727
function confirmBatchQtyModal ()
728
{
729
const max = Math.max(1, Number(qtyInput?.max) | 0 || 1);
730
const count = Math.min(max, Math.max(1, Number(qtyInput?.value) | 0 || 1));
731
closeBatchQtyModal();
655
732
startCraft({ batchCount: count });
656
733
}
657
734
@@ -783,6 +860,7 @@ export function initCrafting ({
783
860
stopCraftAnimation();
784
861
}
785
862
closeDyePicker();
863
closeBatchQtyModal();
786
864
open = false;
787
865
stationId = null;
788
866
recipes = [];
@@ -864,6 +942,8 @@ export function initCrafting ({
864
942
{
865
943
if (!open)
866
944
{ return false; }
945
if (qtyPanel && !qtyPanel.hidden)
946
{ return true; }
867
947
if (backdrop && !backdrop.hidden)
868
948
{ return true; }
869
949
const x = GameInput.mousePosition.x;
@@ -75,6 +75,13 @@ export function initCrafting ({75
const dyeBackdrop = document.getElementById("dye-picker-backdrop");75
const dyeBackdrop = document.getElementById("dye-picker-backdrop");76
const dyePanel = document.getElementById("dye-picker-panel");76
const dyePanel = document.getElementById("dye-picker-panel");77
const dyeGrid = document.getElementById("dye-picker-grid");77
const dyeGrid = document.getElementById("dye-picker-grid");78
const qtyBackdrop = document.getElementById("craft-qty-backdrop");79
const qtyPanel = document.getElementById("craft-qty-panel");80
const qtyName = document.getElementById("craft-qty-name");81
const qtyHint = document.getElementById("craft-qty-hint");82
const qtyInput = document.getElementById("craft-qty-input");83
const qtyConfirm = document.getElementById("craft-qty-confirm");84
const qtyClose = document.getElementById("craft-qty-close");78
85
79
let open = false;86
let open = false;80
let stationId = null;87
let stationId = null;@@ -93,7 +100,7 @@ export function initCrafting ({93
document.getElementById("craft-close").addEventListener("click", () => close());100
document.getElementById("craft-close").addEventListener("click", () => close());94
backdrop.addEventListener("click", () => close());101
backdrop.addEventListener("click", () => close());95
craftButton.addEventListener("click", () => startCraft());102
craftButton.addEventListener("click", () => startCraft());96
craftBatchButton?.addEventListener("click", () => startBatchCraft());103
craftBatchButton?.addEventListener("click", () => openBatchQtyModal());97
craftBatchAllButton?.addEventListener("click", () => startCraft({ batchAll: true }));104
craftBatchAllButton?.addEventListener("click", () => startCraft({ batchAll: true }));98
materialTierSelect?.addEventListener("change", () =>105
materialTierSelect?.addEventListener("change", () =>99
{106
{@@ -121,6 +128,22 @@ export function initCrafting ({121
});128
});122
document.getElementById("dye-picker-close")?.addEventListener("click", () => closeDyePicker());129
document.getElementById("dye-picker-close")?.addEventListener("click", () => closeDyePicker());123
dyeBackdrop?.addEventListener("click", () => closeDyePicker());130
dyeBackdrop?.addEventListener("click", () => closeDyePicker());131
qtyClose?.addEventListener("click", () => closeBatchQtyModal());132
qtyBackdrop?.addEventListener("click", () => closeBatchQtyModal());133
qtyConfirm?.addEventListener("click", () => confirmBatchQtyModal());134
qtyPanel?.addEventListener("mousedown", (event) =>135
{136
event.stopPropagation();137
});138
qtyBackdrop?.addEventListener("mousedown", (event) =>139
{140
event.preventDefault();141
});142
qtyInput?.addEventListener("keydown", (event) =>143
{144
if (event.key === "Enter")145
{ confirmBatchQtyModal(); }146
});124
147
125
function dyeCraftOptions ()148
function dyeCraftOptions ()126
{149
{@@ -644,14 +667,68 @@ export function initCrafting ({644
dyeBackdrop.hidden = true;667
dyeBackdrop.hidden = true;645
}668
}646
669
647
function startBatchCraft ()670
function maxCraftableCount (slots, recipe)648
{671
{649
const raw = window.prompt("How many?", "1");672
let max = Number.POSITIVE_INFINITY;650
if (raw == null)673
for (const input of recipe?.inputs ?? [])651
{ return; }674
{652
const count = Number.parseInt(raw, 10);675
const need = input.quantity | 0;653
if (!Number.isFinite(count) || count < 1)676
if (need <= 0)677
{ continue; }678
max = Math.min(max, Math.floor(countItemInSlots(slots, input.itemId) / need));679
}680
if (!Number.isFinite(max))681
{ return 0; }682
return Math.max(0, max | 0);683
}684
685
function openBatchQtyModal ()686
{687
const recipe = activeRecipe();688
if (!recipe || crafting)654
{ return; }689
{ return; }690
const slots = getInventorySlots?.() ?? [];691
if (!canStartCraft(slots, recipe, stationSkillLevel(), dyeCraftOptions()))692
{693
renderDetail();694
return;695
}696
const max = Math.max(1, maxCraftableCount(slots, recipe));697
const outStack = {698
itemId: recipe.output.itemId,699
quantity: Math.max(1, recipe.output.quantity | 0 || 1)700
};701
if (qtyName)702
{ qtyName.textContent = itemDisplayName(outStack); }703
if (qtyHint)704
{ qtyHint.textContent = `Max ${formatQuantity(max)}`; }705
if (qtyInput)706
{707
qtyInput.min = "1";708
qtyInput.max = String(max);709
qtyInput.value = "1";710
}711
if (qtyPanel)712
{ qtyPanel.hidden = false; }713
if (qtyBackdrop)714
{ qtyBackdrop.hidden = false; }715
qtyInput?.focus();716
qtyInput?.select();717
}718
719
function closeBatchQtyModal ()720
{721
if (qtyPanel)722
{ qtyPanel.hidden = true; }723
if (qtyBackdrop)724
{ qtyBackdrop.hidden = true; }725
}726
727
function confirmBatchQtyModal ()728
{729
const max = Math.max(1, Number(qtyInput?.max) | 0 || 1);730
const count = Math.min(max, Math.max(1, Number(qtyInput?.value) | 0 || 1));731
closeBatchQtyModal();655
startCraft({ batchCount: count });732
startCraft({ batchCount: count });656
}733
}657
734
@@ -783,6 +860,7 @@ export function initCrafting ({783
stopCraftAnimation();860
stopCraftAnimation();784
}861
}785
closeDyePicker();862
closeDyePicker();863
closeBatchQtyModal();786
open = false;864
open = false;787
stationId = null;865
stationId = null;788
recipes = [];866
recipes = [];@@ -864,6 +942,8 @@ export function initCrafting ({864
{942
{865
if (!open)943
if (!open)866
{ return false; }944
{ return false; }945
if (qtyPanel && !qtyPanel.hidden)946
{ return true; }867
if (backdrop && !backdrop.hidden)947
if (backdrop && !backdrop.hidden)868
{ return true; }948
{ return true; }869
const x = GameInput.mousePosition.x;949
const x = GameInput.mousePosition.x;@@ -1344,6 +1344,33 @@ button.friend-account-name:hover {
1344
1344
margin-bottom: 0.5rem;
1345
1345
}
1346
1346
1347
/* Above #craft-panel (and dye picker) so Craft x quantity is usable. */
1348
#craft-qty-backdrop {
1349
z-index: 9;
1350
pointer-events: auto;
1351
}
1352
1353
#craft-qty-panel {
1354
position: fixed;
1355
z-index: 10;
1356
top: 50%;
1357
left: 50%;
1358
transform: translate(-50%, -50%);
1359
width: min(320px, 92vw);
1360
background: #1a1e26;
1361
border: 1px solid #2c3340;
1362
padding: 0.75rem 1rem 1rem;
1363
pointer-events: auto;
1364
}
1365
1366
#craft-qty-panel header {
1367
display: flex;
1368
justify-content: space-between;
1369
align-items: center;
1370
gap: 0.75rem;
1371
margin-bottom: 0.75rem;
1372
}
1373
1347
1374
#cauldron-panel,
1348
1375
#cauldron-pick-panel,
1349
1376
#cauldron-dye-confirm-panel {
@@ -1984,6 +2011,8 @@ button.friend-account-name:hover {
1984
2011
#bank-panel[hidden],
1985
2012
#craft-panel[hidden],
1986
2013
#craft-backdrop[hidden],
2014
#craft-qty-panel[hidden],
2015
#craft-qty-backdrop[hidden],
1987
2016
#dye-picker-panel[hidden],
1988
2017
#dye-picker-backdrop[hidden],
1989
2018
#cauldron-panel[hidden],
@@ -1344,6 +1344,33 @@ button.friend-account-name:hover {1344
margin-bottom: 0.5rem;1344
margin-bottom: 0.5rem;1345
}1345
}1346
1346
1347
/* Above #craft-panel (and dye picker) so Craft x quantity is usable. */1348
#craft-qty-backdrop {1349
z-index: 9;1350
pointer-events: auto;1351
}1352
1353
#craft-qty-panel {1354
position: fixed;1355
z-index: 10;1356
top: 50%;1357
left: 50%;1358
transform: translate(-50%, -50%);1359
width: min(320px, 92vw);1360
background: #1a1e26;1361
border: 1px solid #2c3340;1362
padding: 0.75rem 1rem 1rem;1363
pointer-events: auto;1364
}1365
1366
#craft-qty-panel header {1367
display: flex;1368
justify-content: space-between;1369
align-items: center;1370
gap: 0.75rem;1371
margin-bottom: 0.75rem;1372
}1373
1347
#cauldron-panel,1374
#cauldron-panel,1348
#cauldron-pick-panel,1375
#cauldron-pick-panel,1349
#cauldron-dye-confirm-panel {1376
#cauldron-dye-confirm-panel {@@ -1984,6 +2011,8 @@ button.friend-account-name:hover {1984
#bank-panel[hidden],2011
#bank-panel[hidden],1985
#craft-panel[hidden],2012
#craft-panel[hidden],1986
#craft-backdrop[hidden],2013
#craft-backdrop[hidden],2014
#craft-qty-panel[hidden],2015
#craft-qty-backdrop[hidden],1987
#dye-picker-panel[hidden],2016
#dye-picker-panel[hidden],1988
#dye-picker-backdrop[hidden],2017
#dye-picker-backdrop[hidden],1989
#cauldron-panel[hidden],2018
#cauldron-panel[hidden],