minecraft-inventory 0.1.34 → 0.1.36
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/package.json
CHANGED
|
@@ -54,8 +54,6 @@ export function Slot({
|
|
|
54
54
|
setPKeyActive,
|
|
55
55
|
focusedSlot,
|
|
56
56
|
setFocusedSlot,
|
|
57
|
-
mobilePickAmount,
|
|
58
|
-
setMobilePickAmount,
|
|
59
57
|
dragEndedRef,
|
|
60
58
|
noPlaceholders,
|
|
61
59
|
} = useInventoryContext()
|
|
@@ -351,34 +349,19 @@ export function Slot({
|
|
|
351
349
|
[isMobile, disabled, heldItem, sendAction, index, pKeyActive, setPKeyActive, focusedSlot, setFocusedSlot, onClickOverride, cancelLongPress, mobileMenuOpen],
|
|
352
350
|
)
|
|
353
351
|
|
|
354
|
-
const
|
|
352
|
+
const handleMobilePickAll = useCallback(() => {
|
|
355
353
|
setMobileMenuOpen(false)
|
|
356
354
|
setShowTooltip(false)
|
|
357
355
|
setFocusedSlot(index)
|
|
358
|
-
sendAction({ type: 'click', slotIndex: index, button: '
|
|
356
|
+
sendAction({ type: 'click', slotIndex: index, button: 'left', mode: 'normal' })
|
|
359
357
|
}, [sendAction, index, setFocusedSlot])
|
|
360
358
|
|
|
361
|
-
const
|
|
362
|
-
if (!item) return
|
|
363
|
-
const input = window.prompt(`Pick amount (max ${item.count}):`, String(mobilePickAmount))
|
|
364
|
-
const amount = parseInt(input ?? '', 10)
|
|
365
|
-
if (isNaN(amount) || amount <= 0) return
|
|
366
|
-
setMobilePickAmount(amount)
|
|
359
|
+
const handleMobilePickHalf = useCallback(() => {
|
|
367
360
|
setMobileMenuOpen(false)
|
|
368
361
|
setShowTooltip(false)
|
|
369
362
|
setFocusedSlot(index)
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
// Pick all: just left-click
|
|
373
|
-
sendAction({ type: 'click', slotIndex: index, button: 'left', mode: 'normal' })
|
|
374
|
-
} else {
|
|
375
|
-
// Pick up all, then put back (count - take) items one-by-one via right-click
|
|
376
|
-
sendAction({ type: 'click', slotIndex: index, button: 'left', mode: 'normal' })
|
|
377
|
-
for (let i = 0; i < item.count - take; i++) {
|
|
378
|
-
sendAction({ type: 'click', slotIndex: index, button: 'right', mode: 'normal' })
|
|
379
|
-
}
|
|
380
|
-
}
|
|
381
|
-
}, [item, mobilePickAmount, sendAction, index, setFocusedSlot, setMobilePickAmount])
|
|
363
|
+
sendAction({ type: 'click', slotIndex: index, button: 'right', mode: 'normal' })
|
|
364
|
+
}, [sendAction, index, setFocusedSlot])
|
|
382
365
|
|
|
383
366
|
const handleMobileDropOne = useCallback(() => {
|
|
384
367
|
setMobileMenuOpen(false)
|
|
@@ -537,8 +520,8 @@ export function Slot({
|
|
|
537
520
|
item={item}
|
|
538
521
|
x={mobileTouchPos.x}
|
|
539
522
|
y={mobileTouchPos.y}
|
|
523
|
+
onPickAll={handleMobilePickAll}
|
|
540
524
|
onPickHalf={handleMobilePickHalf}
|
|
541
|
-
onPickCustom={handleMobilePickCustom}
|
|
542
525
|
onDropOne={handleMobileDropOne}
|
|
543
526
|
onDropAll={handleMobileDropAll}
|
|
544
527
|
onClose={closeMobileMenu}
|
|
@@ -553,14 +536,14 @@ interface MobileSlotMenuProps {
|
|
|
553
536
|
item: ItemStack
|
|
554
537
|
x: number
|
|
555
538
|
y: number
|
|
539
|
+
onPickAll(): void
|
|
556
540
|
onPickHalf(): void
|
|
557
|
-
onPickCustom(): void
|
|
558
541
|
onDropOne(): void
|
|
559
542
|
onDropAll(): void
|
|
560
543
|
onClose(): void
|
|
561
544
|
}
|
|
562
545
|
|
|
563
|
-
function MobileSlotMenu({ item, x, y,
|
|
546
|
+
function MobileSlotMenu({ item, x, y, onPickAll, onPickHalf, onDropOne, onDropAll, onClose }: MobileSlotMenuProps) {
|
|
564
547
|
const { scale } = useScale()
|
|
565
548
|
const menuRef = useRef<HTMLDivElement>(null)
|
|
566
549
|
const [pos, setPos] = useState({ left: x, top: y })
|
|
@@ -605,11 +588,10 @@ function MobileSlotMenu({ item, x, y, onPickHalf, onPickCustom, onDropOne, onDro
|
|
|
605
588
|
<div className={styles.mobileMenuTitle}>
|
|
606
589
|
{item.displayName ?? item.name ?? `Item #${item.type}`} ×{item.count}
|
|
607
590
|
</div>
|
|
591
|
+
<button className={styles.mobileBtn} {...touchBtn(onPickAll)}>Select All ({item.count})</button>
|
|
608
592
|
<button className={styles.mobileBtn} {...touchBtn(onPickHalf)}>Pick Half ({Math.ceil(item.count / 2)})</button>
|
|
609
|
-
<button className={styles.mobileBtn} {...touchBtn(onPickCustom)}>Pick Amount…</button>
|
|
610
593
|
<button className={[styles.mobileBtn, styles.mobileBtnDanger].join(' ')} {...touchBtn(onDropOne)}>Drop One</button>
|
|
611
594
|
<button className={[styles.mobileBtn, styles.mobileBtnDanger].join(' ')} {...touchBtn(onDropAll)}>Drop All</button>
|
|
612
|
-
<button className={styles.mobileBtn} {...touchBtn(onClose)}>Cancel</button>
|
|
613
595
|
</div>
|
|
614
596
|
)
|
|
615
597
|
}
|
|
@@ -53,9 +53,6 @@ export interface InventoryContextValue {
|
|
|
53
53
|
/** Pending first digit for P-key slot number entry */
|
|
54
54
|
pKeyDigit: string
|
|
55
55
|
setPKeyDigit: (d: string) => void
|
|
56
|
-
/** Last amount entered in the mobile pick-amount prompt */
|
|
57
|
-
mobilePickAmount: number
|
|
58
|
-
setMobilePickAmount: (amount: number) => void
|
|
59
56
|
/** Ref set to true when a drag just ended; cleared on next mouseDown.
|
|
60
57
|
* Used by Slot to suppress spurious click events that fire after endDrag. */
|
|
61
58
|
dragEndedRef: React.MutableRefObject<boolean>
|
|
@@ -102,7 +99,6 @@ export function InventoryProvider({ connector, children, noDragSpread = false, n
|
|
|
102
99
|
const [pKeyActive, setPKeyActive] = useState(false)
|
|
103
100
|
const [focusedSlot, setFocusedSlot] = useState<number | null>(null)
|
|
104
101
|
const [pKeyDigit, setPKeyDigit] = useState('')
|
|
105
|
-
const [mobilePickAmount, setMobilePickAmount] = useState(1)
|
|
106
102
|
|
|
107
103
|
const connectorRef = useRef(connector)
|
|
108
104
|
connectorRef.current = connector
|
|
@@ -419,8 +415,6 @@ export function InventoryProvider({ connector, children, noDragSpread = false, n
|
|
|
419
415
|
setFocusedSlot,
|
|
420
416
|
pKeyDigit,
|
|
421
417
|
setPKeyDigit,
|
|
422
|
-
mobilePickAmount,
|
|
423
|
-
setMobilePickAmount,
|
|
424
418
|
dragEndedRef,
|
|
425
419
|
resolveEnchantmentName,
|
|
426
420
|
}
|