@rpg-engine/long-bow 0.7.70 → 0.7.72
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/components/Item/Inventory/ItemSlot.d.ts +5 -18
- package/dist/components/Item/Inventory/ItemSlotTooltips.d.ts +12 -1
- package/dist/components/Item/Inventory/context/DraggingContext.d.ts +11 -0
- package/dist/hooks/useCursorPosition.d.ts +1 -1
- package/dist/long-bow.cjs.development.js +573 -661
- package/dist/long-bow.cjs.development.js.map +1 -1
- package/dist/long-bow.cjs.production.min.js +1 -1
- package/dist/long-bow.cjs.production.min.js.map +1 -1
- package/dist/long-bow.esm.js +575 -663
- package/dist/long-bow.esm.js.map +1 -1
- package/package.json +2 -3
- package/src/components/Equipment/EquipmentSet.tsx +29 -61
- package/src/components/Item/Inventory/DraggedItem.tsx +2 -2
- package/src/components/Item/Inventory/ItemContainer.tsx +44 -68
- package/src/components/Item/Inventory/ItemSlot.tsx +451 -239
- package/src/components/Item/Inventory/ItemSlotTooltips.tsx +46 -48
- package/src/components/Item/Inventory/context/DraggingContext.tsx +26 -0
- package/src/hooks/useCursorPosition.ts +20 -29
- package/src/stories/UI/containers/ItemContainer.stories.tsx +3 -30
- package/dist/components/Item/Inventory/context/ItemSlotDraggingContext.d.ts +0 -26
- package/dist/components/Item/Inventory/context/ItemSlotTooltipContext.d.ts +0 -28
- package/dist/components/Item/Inventory/hooks/useItemSlotDragAndDrop.d.ts +0 -39
- package/src/components/Item/Inventory/context/ItemSlotDraggingContext.tsx +0 -52
- package/src/components/Item/Inventory/context/ItemSlotTooltipContext.tsx +0 -95
- package/src/components/Item/Inventory/hooks/useItemSlotDragAndDrop.ts +0 -248
|
@@ -27377,57 +27377,6 @@ var Container$8 = /*#__PURE__*/styled__default.div.withConfig({
|
|
|
27377
27377
|
componentId: "sc-dgmp04-0"
|
|
27378
27378
|
})(["position:static !important;"]);
|
|
27379
27379
|
|
|
27380
|
-
var useCursorPosition = function useCursorPosition(_ref) {
|
|
27381
|
-
var _ref$scale = _ref.scale,
|
|
27382
|
-
scale = _ref$scale === void 0 ? 1 : _ref$scale;
|
|
27383
|
-
var _useState = React.useState({
|
|
27384
|
-
x: 0,
|
|
27385
|
-
y: 0
|
|
27386
|
-
}),
|
|
27387
|
-
position = _useState[0],
|
|
27388
|
-
setPosition = _useState[1];
|
|
27389
|
-
var scalePosition = React.useCallback(function (x, y) {
|
|
27390
|
-
return {
|
|
27391
|
-
x: (x - shared.GRID_WIDTH / 2) / scale + shared.GRID_WIDTH / 2,
|
|
27392
|
-
y: (y - shared.GRID_HEIGHT / 2) / scale + shared.GRID_HEIGHT / 2
|
|
27393
|
-
};
|
|
27394
|
-
}, [scale]);
|
|
27395
|
-
var setFromEvent = React.useCallback(function (e) {
|
|
27396
|
-
var x, y;
|
|
27397
|
-
if ('touches' in e) {
|
|
27398
|
-
x = e.touches[0].clientX;
|
|
27399
|
-
y = e.touches[0].clientY;
|
|
27400
|
-
} else {
|
|
27401
|
-
x = e.clientX;
|
|
27402
|
-
y = e.clientY;
|
|
27403
|
-
}
|
|
27404
|
-
var scaledPosition = scalePosition(x, y);
|
|
27405
|
-
setPosition(scaledPosition);
|
|
27406
|
-
}, [scale, scalePosition]);
|
|
27407
|
-
var cleanup = React.useCallback(function () {
|
|
27408
|
-
setPosition({
|
|
27409
|
-
x: 0,
|
|
27410
|
-
y: 0
|
|
27411
|
-
});
|
|
27412
|
-
}, []);
|
|
27413
|
-
React.useEffect(function () {
|
|
27414
|
-
var handleEvent = function handleEvent(e) {
|
|
27415
|
-
return setFromEvent(e);
|
|
27416
|
-
};
|
|
27417
|
-
window.addEventListener('mousemove', handleEvent);
|
|
27418
|
-
window.addEventListener('touchmove', handleEvent);
|
|
27419
|
-
window.addEventListener('mouseup', cleanup);
|
|
27420
|
-
window.addEventListener('touchend', cleanup);
|
|
27421
|
-
return function () {
|
|
27422
|
-
window.removeEventListener('mousemove', handleEvent);
|
|
27423
|
-
window.removeEventListener('touchmove', handleEvent);
|
|
27424
|
-
window.removeEventListener('mouseup', cleanup);
|
|
27425
|
-
window.removeEventListener('touchend', cleanup);
|
|
27426
|
-
};
|
|
27427
|
-
}, [setFromEvent, cleanup]);
|
|
27428
|
-
return position;
|
|
27429
|
-
};
|
|
27430
|
-
|
|
27431
27380
|
var rarityColor = function rarityColor(item) {
|
|
27432
27381
|
switch (item == null ? void 0 : item.rarity) {
|
|
27433
27382
|
case shared.ItemRarities.Uncommon:
|
|
@@ -27596,306 +27545,187 @@ var ItemSlotRenderer = function ItemSlotRenderer(_ref) {
|
|
|
27596
27545
|
return React__default.createElement(React__default.Fragment, null, onRenderSlot(item));
|
|
27597
27546
|
};
|
|
27598
27547
|
|
|
27599
|
-
|
|
27600
|
-
var
|
|
27601
|
-
|
|
27602
|
-
|
|
27603
|
-
|
|
27604
|
-
|
|
27605
|
-
|
|
27606
|
-
|
|
27607
|
-
|
|
27608
|
-
position: {
|
|
27609
|
-
x: 0,
|
|
27610
|
-
y: 0
|
|
27611
|
-
},
|
|
27612
|
-
actions: []
|
|
27613
|
-
}
|
|
27614
|
-
};
|
|
27615
|
-
// Create context with default values
|
|
27616
|
-
var ItemSlotTooltipContext = /*#__PURE__*/React.createContext({
|
|
27617
|
-
itemDetails: defaultItemDetails,
|
|
27618
|
-
updateItemDetails: function updateItemDetails() {},
|
|
27619
|
-
clearItemDetails: function clearItemDetails() {}
|
|
27620
|
-
});
|
|
27621
|
-
// Provider component
|
|
27622
|
-
var ItemSlotTooltipProvider = function ItemSlotTooltipProvider(_ref) {
|
|
27623
|
-
var children = _ref.children;
|
|
27624
|
-
var _useState = React.useState(defaultItemDetails),
|
|
27625
|
-
itemDetails = _useState[0],
|
|
27626
|
-
setItemDetails = _useState[1];
|
|
27548
|
+
var RelativeListMenu = function RelativeListMenu(_ref) {
|
|
27549
|
+
var options = _ref.options,
|
|
27550
|
+
onSelected = _ref.onSelected,
|
|
27551
|
+
onOutsideClick = _ref.onOutsideClick,
|
|
27552
|
+
_ref$fontSize = _ref.fontSize,
|
|
27553
|
+
fontSize = _ref$fontSize === void 0 ? 0.8 : _ref$fontSize,
|
|
27554
|
+
pos = _ref.pos;
|
|
27555
|
+
var ref = React.useRef(null);
|
|
27556
|
+
useOutsideClick(ref, 'relative-context-menu');
|
|
27627
27557
|
React.useEffect(function () {
|
|
27628
|
-
|
|
27629
|
-
|
|
27630
|
-
|
|
27631
|
-
|
|
27632
|
-
|
|
27633
|
-
|
|
27634
|
-
|
|
27635
|
-
tooltip: _extends({}, prev.tooltip, updates.tooltip),
|
|
27636
|
-
contextMenu: _extends({}, prev.contextMenu, updates.contextMenu, {
|
|
27637
|
-
// Ensure actions are properly merged or overridden
|
|
27638
|
-
actions: (_updates$contextMenu$ = (_updates$contextMenu = updates.contextMenu) == null ? void 0 : _updates$contextMenu.actions) != null ? _updates$contextMenu$ : (_prev$contextMenu = prev.contextMenu) == null ? void 0 : _prev$contextMenu.actions
|
|
27639
|
-
})
|
|
27640
|
-
});
|
|
27558
|
+
document.addEventListener('clickOutside', function (event) {
|
|
27559
|
+
var e = event;
|
|
27560
|
+
if (e.detail.id === 'relative-context-menu') {
|
|
27561
|
+
if (onOutsideClick) {
|
|
27562
|
+
onOutsideClick();
|
|
27563
|
+
}
|
|
27564
|
+
}
|
|
27641
27565
|
});
|
|
27566
|
+
return function () {
|
|
27567
|
+
document.removeEventListener('clickOutside', function (_e) {});
|
|
27568
|
+
};
|
|
27642
27569
|
}, []);
|
|
27643
|
-
|
|
27644
|
-
|
|
27645
|
-
|
|
27646
|
-
|
|
27647
|
-
|
|
27648
|
-
|
|
27649
|
-
|
|
27650
|
-
clearItemDetails: clearItemDetails
|
|
27570
|
+
return React__default.createElement(ModalPortal, null, React__default.createElement(Container$9, Object.assign({
|
|
27571
|
+
fontSize: fontSize,
|
|
27572
|
+
ref: ref
|
|
27573
|
+
}, pos), React__default.createElement("ul", {
|
|
27574
|
+
className: "rpgui-list-imp",
|
|
27575
|
+
style: {
|
|
27576
|
+
overflow: 'hidden'
|
|
27651
27577
|
}
|
|
27652
|
-
},
|
|
27578
|
+
}, options.map(function (params, index) {
|
|
27579
|
+
return React__default.createElement(ListElement$2, {
|
|
27580
|
+
key: (params == null ? void 0 : params.id) || index,
|
|
27581
|
+
onPointerDown: function onPointerDown() {
|
|
27582
|
+
onSelected(params == null ? void 0 : params.id);
|
|
27583
|
+
}
|
|
27584
|
+
}, (params == null ? void 0 : params.text) || 'No text');
|
|
27585
|
+
}))));
|
|
27653
27586
|
};
|
|
27654
|
-
|
|
27655
|
-
|
|
27656
|
-
|
|
27587
|
+
var Container$9 = /*#__PURE__*/styled__default.div.withConfig({
|
|
27588
|
+
displayName: "RelativeListMenu__Container",
|
|
27589
|
+
componentId: "sc-7hohf-0"
|
|
27590
|
+
})(["position:absolute;top:", "px;left:", "px;display:flex;flex-direction:column;width:max-content;justify-content:start;align-items:flex-start;li{font-size:", "em;}"], function (props) {
|
|
27591
|
+
return props.y;
|
|
27592
|
+
}, function (props) {
|
|
27593
|
+
return props.x;
|
|
27594
|
+
}, function (props) {
|
|
27595
|
+
return props.fontSize;
|
|
27596
|
+
});
|
|
27597
|
+
var ListElement$2 = /*#__PURE__*/styled__default.li.withConfig({
|
|
27598
|
+
displayName: "RelativeListMenu__ListElement",
|
|
27599
|
+
componentId: "sc-7hohf-1"
|
|
27600
|
+
})(["margin-right:0.5rem;"]);
|
|
27601
|
+
|
|
27602
|
+
var MobileItemTooltip = function MobileItemTooltip(_ref) {
|
|
27603
|
+
var item = _ref.item,
|
|
27604
|
+
atlasIMG = _ref.atlasIMG,
|
|
27605
|
+
atlasJSON = _ref.atlasJSON,
|
|
27606
|
+
closeTooltip = _ref.closeTooltip,
|
|
27607
|
+
equipmentSet = _ref.equipmentSet,
|
|
27608
|
+
_ref$scale = _ref.scale,
|
|
27609
|
+
scale = _ref$scale === void 0 ? 1 : _ref$scale,
|
|
27610
|
+
options = _ref.options,
|
|
27611
|
+
onSelected = _ref.onSelected;
|
|
27612
|
+
var ref = React.useRef(null);
|
|
27613
|
+
var handleFadeOut = function handleFadeOut() {
|
|
27614
|
+
var _ref$current;
|
|
27615
|
+
(_ref$current = ref.current) == null ? void 0 : _ref$current.classList.add('fadeOut');
|
|
27616
|
+
};
|
|
27617
|
+
return React__default.createElement(ModalPortal, null, React__default.createElement(Container$a, {
|
|
27618
|
+
ref: ref,
|
|
27619
|
+
onTouchEnd: function onTouchEnd() {
|
|
27620
|
+
handleFadeOut();
|
|
27621
|
+
setTimeout(function () {
|
|
27622
|
+
closeTooltip();
|
|
27623
|
+
}, 100);
|
|
27624
|
+
},
|
|
27625
|
+
scale: scale
|
|
27626
|
+
}, React__default.createElement(ItemInfoDisplay, {
|
|
27627
|
+
item: item,
|
|
27628
|
+
atlasIMG: atlasIMG,
|
|
27629
|
+
atlasJSON: atlasJSON,
|
|
27630
|
+
equipmentSet: equipmentSet,
|
|
27631
|
+
isMobile: true
|
|
27632
|
+
}), React__default.createElement(OptionsContainer, null, options == null ? void 0 : options.map(function (option) {
|
|
27633
|
+
return React__default.createElement(Option, {
|
|
27634
|
+
key: option.id,
|
|
27635
|
+
onTouchEnd: function onTouchEnd() {
|
|
27636
|
+
handleFadeOut();
|
|
27637
|
+
setTimeout(function () {
|
|
27638
|
+
onSelected == null ? void 0 : onSelected(option.id);
|
|
27639
|
+
closeTooltip();
|
|
27640
|
+
}, 100);
|
|
27641
|
+
}
|
|
27642
|
+
}, option.text);
|
|
27643
|
+
}))));
|
|
27657
27644
|
};
|
|
27645
|
+
var Container$a = /*#__PURE__*/styled__default.div.withConfig({
|
|
27646
|
+
displayName: "MobileItemTooltip__Container",
|
|
27647
|
+
componentId: "sc-ku4p1j-0"
|
|
27648
|
+
})(["position:absolute;z-index:100;left:0;top:0;width:100vw;height:100vh;background-color:rgba(0 0 0 / 0.5);display:flex;justify-content:center;align-items:center;gap:0.5rem;transition:opacity 0.08s;animation:fadeIn 0.1s forwards;@keyframes fadeIn{0%{opacity:0;}100%{opacity:0.92;}}@keyframes fadeOut{0%{opacity:0.92;}100%{opacity:0;}}&.fadeOut{animation:fadeOut 0.1s forwards;}@media (max-width:640px){flex-direction:column;}"]);
|
|
27649
|
+
var OptionsContainer = /*#__PURE__*/styled__default.div.withConfig({
|
|
27650
|
+
displayName: "MobileItemTooltip__OptionsContainer",
|
|
27651
|
+
componentId: "sc-ku4p1j-1"
|
|
27652
|
+
})(["display:flex;flex-direction:column;gap:0.5rem;flex-wrap:wrap;@media (max-width:640px){flex-direction:row;justify-content:center;}"]);
|
|
27653
|
+
var Option = /*#__PURE__*/styled__default.button.withConfig({
|
|
27654
|
+
displayName: "MobileItemTooltip__Option",
|
|
27655
|
+
componentId: "sc-ku4p1j-2"
|
|
27656
|
+
})(["padding:1rem;background-color:#333;color:white;border:none;border-radius:3px;width:8rem;transition:background-color 0.1s;&:hover{background-color:#555;}@media (max-width:640px){padding:1rem 0.5rem;}"]);
|
|
27658
27657
|
|
|
27659
|
-
var
|
|
27660
|
-
|
|
27661
|
-
|
|
27662
|
-
|
|
27663
|
-
|
|
27664
|
-
|
|
27665
|
-
|
|
27666
|
-
|
|
27667
|
-
|
|
27658
|
+
var ItemSlotToolTips = function ItemSlotToolTips(_ref) {
|
|
27659
|
+
var isTooltipVisible = _ref.isTooltipVisible,
|
|
27660
|
+
isFocused = _ref.isFocused,
|
|
27661
|
+
isContextMenuVisible = _ref.isContextMenuVisible,
|
|
27662
|
+
isContextMenuDisabled = _ref.isContextMenuDisabled,
|
|
27663
|
+
item = _ref.item,
|
|
27664
|
+
contextActions = _ref.contextActions,
|
|
27665
|
+
contextMenuPosition = _ref.contextMenuPosition,
|
|
27666
|
+
dragScale = _ref.dragScale,
|
|
27667
|
+
setIsContextMenuVisible = _ref.setIsContextMenuVisible,
|
|
27668
|
+
setIsTooltipMobileVisible = _ref.setIsTooltipMobileVisible,
|
|
27669
|
+
isTooltipMobileVisible = _ref.isTooltipMobileVisible,
|
|
27670
|
+
_onSelected = _ref.onSelected,
|
|
27671
|
+
atlasIMG = _ref.atlasIMG,
|
|
27672
|
+
atlasJSON = _ref.atlasJSON,
|
|
27673
|
+
equipmentSet = _ref.equipmentSet;
|
|
27674
|
+
return React__default.createElement(React__default.Fragment, null, isTooltipVisible && item && !isFocused && React__default.createElement(ItemTooltip, {
|
|
27675
|
+
item: item,
|
|
27676
|
+
atlasIMG: atlasIMG,
|
|
27677
|
+
atlasJSON: atlasJSON,
|
|
27678
|
+
equipmentSet: equipmentSet
|
|
27679
|
+
}), isTooltipMobileVisible && item && React__default.createElement(MobileItemTooltip, {
|
|
27680
|
+
item: item,
|
|
27681
|
+
atlasIMG: atlasIMG,
|
|
27682
|
+
atlasJSON: atlasJSON,
|
|
27683
|
+
equipmentSet: equipmentSet,
|
|
27684
|
+
closeTooltip: function closeTooltip() {
|
|
27685
|
+
setIsTooltipMobileVisible(false);
|
|
27668
27686
|
},
|
|
27669
|
-
|
|
27670
|
-
|
|
27671
|
-
|
|
27687
|
+
scale: dragScale,
|
|
27688
|
+
options: contextActions,
|
|
27689
|
+
onSelected: function onSelected(optionId) {
|
|
27690
|
+
setIsContextMenuVisible(false);
|
|
27691
|
+
if (item) {
|
|
27692
|
+
_onSelected == null ? void 0 : _onSelected(optionId, item);
|
|
27693
|
+
}
|
|
27694
|
+
}
|
|
27695
|
+
}), !isContextMenuDisabled && isContextMenuVisible && contextActions && React__default.createElement(RelativeListMenu, {
|
|
27696
|
+
options: contextActions,
|
|
27697
|
+
onSelected: function onSelected(optionId) {
|
|
27698
|
+
setIsContextMenuVisible(false);
|
|
27699
|
+
if (item) {
|
|
27700
|
+
_onSelected == null ? void 0 : _onSelected(optionId, item);
|
|
27701
|
+
}
|
|
27702
|
+
},
|
|
27703
|
+
onOutsideClick: function onOutsideClick() {
|
|
27704
|
+
setIsContextMenuVisible(false);
|
|
27705
|
+
},
|
|
27706
|
+
pos: contextMenuPosition
|
|
27707
|
+
}));
|
|
27708
|
+
};
|
|
27709
|
+
|
|
27710
|
+
var DraggingContext = /*#__PURE__*/React.createContext({
|
|
27711
|
+
item: null,
|
|
27712
|
+
setDraggingItem: function setDraggingItem() {}
|
|
27672
27713
|
});
|
|
27673
|
-
var
|
|
27714
|
+
var useDragging = function useDragging() {
|
|
27715
|
+
return React.useContext(DraggingContext);
|
|
27716
|
+
};
|
|
27717
|
+
var DraggingProvider = function DraggingProvider(_ref) {
|
|
27674
27718
|
var children = _ref.children;
|
|
27675
27719
|
var _useState = React.useState(null),
|
|
27676
27720
|
item = _useState[0],
|
|
27677
27721
|
setDraggingItem = _useState[1];
|
|
27678
|
-
|
|
27679
|
-
isFocused: false,
|
|
27680
|
-
wasDragged: false,
|
|
27681
|
-
position: {
|
|
27682
|
-
x: 0,
|
|
27683
|
-
y: 0
|
|
27684
|
-
},
|
|
27685
|
-
dropPosition: null
|
|
27686
|
-
}),
|
|
27687
|
-
dragState = _useState2[0],
|
|
27688
|
-
setDragState = _useState2[1];
|
|
27689
|
-
return React__default.createElement(ItemSlotDraggingContext.Provider, {
|
|
27722
|
+
return React__default.createElement(DraggingContext.Provider, {
|
|
27690
27723
|
value: {
|
|
27691
27724
|
item: item,
|
|
27692
|
-
setDraggingItem: setDraggingItem
|
|
27693
|
-
dragState: dragState,
|
|
27694
|
-
setDragState: setDragState
|
|
27725
|
+
setDraggingItem: setDraggingItem
|
|
27695
27726
|
}
|
|
27696
27727
|
}, children);
|
|
27697
27728
|
};
|
|
27698
|
-
var useItemSlotDragging = function useItemSlotDragging() {
|
|
27699
|
-
return React.useContext(ItemSlotDraggingContext);
|
|
27700
|
-
};
|
|
27701
|
-
|
|
27702
|
-
var useItemSlotDragAndDrop = function useItemSlotDragAndDrop(_ref) {
|
|
27703
|
-
var isDepotSystem = _ref.isDepotSystem,
|
|
27704
|
-
item = _ref.item,
|
|
27705
|
-
onDrop = _ref.onDrop,
|
|
27706
|
-
onDragEnd = _ref.onDragEnd,
|
|
27707
|
-
checkIfItemCanBeMoved = _ref.checkIfItemCanBeMoved,
|
|
27708
|
-
checkIfItemShouldDragEnd = _ref.checkIfItemShouldDragEnd,
|
|
27709
|
-
setItemShortcut = _ref.setItemShortcut,
|
|
27710
|
-
isSelectingShortcut = _ref.isSelectingShortcut,
|
|
27711
|
-
onDragStart = _ref.onDragStart,
|
|
27712
|
-
onPointerDown = _ref.onPointerDown,
|
|
27713
|
-
containerType = _ref.containerType,
|
|
27714
|
-
slotIndex = _ref.slotIndex,
|
|
27715
|
-
openQuantitySelector = _ref.openQuantitySelector,
|
|
27716
|
-
isContextMenuDisabled = _ref.isContextMenuDisabled;
|
|
27717
|
-
var dragContainer = React.useRef(null);
|
|
27718
|
-
var _useItemSlotDragging = useItemSlotDragging(),
|
|
27719
|
-
draggingItem = _useItemSlotDragging.item,
|
|
27720
|
-
setDraggingItem = _useItemSlotDragging.setDraggingItem,
|
|
27721
|
-
dragState = _useItemSlotDragging.dragState,
|
|
27722
|
-
setDragState = _useItemSlotDragging.setDragState;
|
|
27723
|
-
var _useItemSlotTooltip = useItemSlotTooltip(),
|
|
27724
|
-
updateItemDetails = _useItemSlotTooltip.updateItemDetails,
|
|
27725
|
-
itemDetails = _useItemSlotTooltip.itemDetails;
|
|
27726
|
-
React.useEffect(function () {
|
|
27727
|
-
setDragState(function (prev) {
|
|
27728
|
-
return _extends({}, prev, {
|
|
27729
|
-
position: {
|
|
27730
|
-
x: 0,
|
|
27731
|
-
y: 0
|
|
27732
|
-
},
|
|
27733
|
-
isFocused: false
|
|
27734
|
-
});
|
|
27735
|
-
});
|
|
27736
|
-
}, [item, isDepotSystem, setDragState]);
|
|
27737
|
-
React.useEffect(function () {
|
|
27738
|
-
if (onDrop && item && dragState.dropPosition) {
|
|
27739
|
-
onDrop(item, dragState.dropPosition);
|
|
27740
|
-
setDragState(function (prev) {
|
|
27741
|
-
return _extends({}, prev, {
|
|
27742
|
-
dropPosition: null
|
|
27743
|
-
});
|
|
27744
|
-
});
|
|
27745
|
-
}
|
|
27746
|
-
}, [dragState.dropPosition, item, onDrop]);
|
|
27747
|
-
var getContainerBounds = React.useCallback(function () {
|
|
27748
|
-
var container = dragContainer.current;
|
|
27749
|
-
if (!container) return {
|
|
27750
|
-
left: 0,
|
|
27751
|
-
top: 0,
|
|
27752
|
-
right: 0,
|
|
27753
|
-
bottom: 0
|
|
27754
|
-
};
|
|
27755
|
-
var rect = container.getBoundingClientRect();
|
|
27756
|
-
return {
|
|
27757
|
-
left: rect.left,
|
|
27758
|
-
top: rect.top,
|
|
27759
|
-
right: window.innerWidth - rect.right,
|
|
27760
|
-
bottom: window.innerHeight - rect.bottom
|
|
27761
|
-
};
|
|
27762
|
-
}, []);
|
|
27763
|
-
var resetDragState = React.useCallback(function () {
|
|
27764
|
-
console.log('RESET_DRAG_STATE!');
|
|
27765
|
-
setDragState(function (prev) {
|
|
27766
|
-
return _extends({}, prev, {
|
|
27767
|
-
wasDragged: false,
|
|
27768
|
-
isFocused: false,
|
|
27769
|
-
position: {
|
|
27770
|
-
x: 0,
|
|
27771
|
-
y: 0
|
|
27772
|
-
}
|
|
27773
|
-
});
|
|
27774
|
-
});
|
|
27775
|
-
setDraggingItem(null);
|
|
27776
|
-
// Reset tooltip visibility
|
|
27777
|
-
updateItemDetails({
|
|
27778
|
-
tooltip: {
|
|
27779
|
-
visible: false,
|
|
27780
|
-
mobileVisible: false
|
|
27781
|
-
}
|
|
27782
|
-
});
|
|
27783
|
-
}, [updateItemDetails, setDragState]);
|
|
27784
|
-
var handleSuccessfulDrag = React.useCallback(function (quantity) {
|
|
27785
|
-
console.log('HANDLE_SUCCESSFUL_DRAG!');
|
|
27786
|
-
resetDragState();
|
|
27787
|
-
if (quantity !== -1 && item) {
|
|
27788
|
-
onDragEnd == null ? void 0 : onDragEnd(quantity);
|
|
27789
|
-
}
|
|
27790
|
-
}, [item, onDragEnd, resetDragState]);
|
|
27791
|
-
var onDraggableStart = React.useCallback(function () {
|
|
27792
|
-
console.log('ON_DRAGGABLE_START!');
|
|
27793
|
-
if (!item || isSelectingShortcut) return;
|
|
27794
|
-
if (onDragStart && containerType) {
|
|
27795
|
-
onDragStart(item, slotIndex, containerType);
|
|
27796
|
-
}
|
|
27797
|
-
if (!draggingItem && item) {
|
|
27798
|
-
console.log('!!! SETTING DRAGGING ITEM ', item._id);
|
|
27799
|
-
setDraggingItem(item);
|
|
27800
|
-
}
|
|
27801
|
-
}, [item, isSelectingShortcut, onDragStart, containerType, slotIndex]);
|
|
27802
|
-
var onDraggableProgress = React.useCallback(function (_e, data) {
|
|
27803
|
-
console.log('ON_DRAGGABLE_PROGRESS!');
|
|
27804
|
-
var _dragState$position = dragState.position,
|
|
27805
|
-
x = _dragState$position.x,
|
|
27806
|
-
y = _dragState$position.y;
|
|
27807
|
-
if (Math.abs(data.x - x) > 5 || Math.abs(data.y - y) > 5) {
|
|
27808
|
-
setDragState(function (prev) {
|
|
27809
|
-
return _extends({}, prev, {
|
|
27810
|
-
wasDragged: true,
|
|
27811
|
-
isFocused: true
|
|
27812
|
-
});
|
|
27813
|
-
});
|
|
27814
|
-
}
|
|
27815
|
-
}, [dragState.position, draggingItem, item, setDraggingItem, setDragState]);
|
|
27816
|
-
var onDraggableStop = React.useCallback(function (e, data) {
|
|
27817
|
-
console.log('ON_DRAGGABLE_STOP!');
|
|
27818
|
-
var target = e.target;
|
|
27819
|
-
if (!target) return;
|
|
27820
|
-
target.classList.remove('react-draggable-dragging');
|
|
27821
|
-
if (target != null && target.id.includes('shortcutSetter') && setItemShortcut && item) {
|
|
27822
|
-
var index = parseInt(target.id.split('_')[1]);
|
|
27823
|
-
if (!isNaN(index)) {
|
|
27824
|
-
setItemShortcut(item, index);
|
|
27825
|
-
}
|
|
27826
|
-
}
|
|
27827
|
-
if (dragState.wasDragged && item && !isSelectingShortcut) {
|
|
27828
|
-
var classes = Array.from(target.classList);
|
|
27829
|
-
var isOutsideDrop = classes.some(function (elm) {
|
|
27830
|
-
return elm.includes('rpgui-content');
|
|
27831
|
-
}) || classes.length === 0;
|
|
27832
|
-
if (isOutsideDrop) {
|
|
27833
|
-
setDragState(function (prev) {
|
|
27834
|
-
return _extends({}, prev, {
|
|
27835
|
-
dropPosition: {
|
|
27836
|
-
x: data.x,
|
|
27837
|
-
y: data.y
|
|
27838
|
-
}
|
|
27839
|
-
});
|
|
27840
|
-
});
|
|
27841
|
-
}
|
|
27842
|
-
setDragState(function (prev) {
|
|
27843
|
-
return _extends({}, prev, {
|
|
27844
|
-
wasDragged: false
|
|
27845
|
-
});
|
|
27846
|
-
});
|
|
27847
|
-
setTimeout(function () {
|
|
27848
|
-
if (checkIfItemCanBeMoved != null && checkIfItemCanBeMoved() && (!checkIfItemShouldDragEnd || checkIfItemShouldDragEnd())) {
|
|
27849
|
-
if (item.stackQty && item.stackQty !== 1 && openQuantitySelector) {
|
|
27850
|
-
openQuantitySelector(item.stackQty, handleSuccessfulDrag);
|
|
27851
|
-
} else {
|
|
27852
|
-
handleSuccessfulDrag(item.stackQty);
|
|
27853
|
-
}
|
|
27854
|
-
} else {
|
|
27855
|
-
resetDragState();
|
|
27856
|
-
}
|
|
27857
|
-
}, 50);
|
|
27858
|
-
} else if (item) {
|
|
27859
|
-
var isTouch = e.type === 'touchend';
|
|
27860
|
-
console.log("Debug: \n isTouch: " + isTouch + ",\n isSelectingShortcut: " + isSelectingShortcut + ",\n draggingItem: " + draggingItem + ",\n dragginState: " + JSON.stringify(dragState) + "\n ");
|
|
27861
|
-
if (!isContextMenuDisabled && isTouch && !isSelectingShortcut) {
|
|
27862
|
-
updateItemDetails({
|
|
27863
|
-
item: item,
|
|
27864
|
-
tooltip: {
|
|
27865
|
-
mobileVisible: true
|
|
27866
|
-
}
|
|
27867
|
-
});
|
|
27868
|
-
} else if (!isContextMenuDisabled && !isSelectingShortcut && !isTouch) {
|
|
27869
|
-
var _itemDetails$contextM;
|
|
27870
|
-
var event = e;
|
|
27871
|
-
updateItemDetails({
|
|
27872
|
-
item: item,
|
|
27873
|
-
contextMenu: {
|
|
27874
|
-
visible: !(itemDetails != null && (_itemDetails$contextM = itemDetails.contextMenu) != null && _itemDetails$contextM.visible),
|
|
27875
|
-
position: {
|
|
27876
|
-
x: event.clientX - 10,
|
|
27877
|
-
y: event.clientY - 5
|
|
27878
|
-
}
|
|
27879
|
-
}
|
|
27880
|
-
});
|
|
27881
|
-
}
|
|
27882
|
-
onPointerDown == null ? void 0 : onPointerDown(item.type, containerType != null ? containerType : null, item);
|
|
27883
|
-
}
|
|
27884
|
-
console.log('setting draggingItem to null');
|
|
27885
|
-
setDraggingItem(null);
|
|
27886
|
-
}, [dragState.wasDragged, item, isSelectingShortcut, checkIfItemCanBeMoved, checkIfItemShouldDragEnd, openQuantitySelector, handleSuccessfulDrag, resetDragState, isContextMenuDisabled, onPointerDown, containerType, setItemShortcut]);
|
|
27887
|
-
return {
|
|
27888
|
-
dragContainer: dragContainer,
|
|
27889
|
-
dragState: dragState,
|
|
27890
|
-
draggingItem: draggingItem,
|
|
27891
|
-
setDraggingItem: setDraggingItem,
|
|
27892
|
-
getContainerBounds: getContainerBounds,
|
|
27893
|
-
onDraggableStart: onDraggableStart,
|
|
27894
|
-
onDraggableProgress: onDraggableProgress,
|
|
27895
|
-
onDraggableStop: onDraggableStop,
|
|
27896
|
-
resetItem: resetDragState
|
|
27897
|
-
};
|
|
27898
|
-
};
|
|
27899
27729
|
|
|
27900
27730
|
var generateContextMenuListOptions = function generateContextMenuListOptions(actionsByTypeList) {
|
|
27901
27731
|
var contextMenu = actionsByTypeList.map(function (action) {
|
|
@@ -28034,14 +27864,15 @@ var EquipmentSlotSpriteByType = {
|
|
|
28034
27864
|
RightHand: 'shields/plate-shield.png',
|
|
28035
27865
|
Accessory: 'ranged-weapons/arrow.png'
|
|
28036
27866
|
};
|
|
28037
|
-
var ItemSlot = /*#__PURE__*/
|
|
27867
|
+
var ItemSlot = /*#__PURE__*/mobxReactLite.observer(function (_ref) {
|
|
28038
27868
|
var slotIndex = _ref.slotIndex,
|
|
28039
27869
|
item = _ref.item,
|
|
28040
27870
|
containerType = _ref.itemContainerType,
|
|
28041
27871
|
slotSpriteMask = _ref.slotSpriteMask,
|
|
28042
27872
|
_onMouseOver = _ref.onMouseOver,
|
|
28043
|
-
|
|
27873
|
+
_onMouseOut = _ref.onMouseOut,
|
|
28044
27874
|
onPointerDown = _ref.onPointerDown,
|
|
27875
|
+
_onSelected = _ref.onSelected,
|
|
28045
27876
|
atlasJSON = _ref.atlasJSON,
|
|
28046
27877
|
atlasIMG = _ref.atlasIMG,
|
|
28047
27878
|
_ref$isContextMenuDis = _ref.isContextMenuDisabled,
|
|
@@ -28052,102 +27883,292 @@ var ItemSlot = /*#__PURE__*/React__default.memo( /*#__PURE__*/mobxReactLite.obse
|
|
|
28052
27883
|
onDrop = _ref.onOutsideDrop,
|
|
28053
27884
|
checkIfItemCanBeMoved = _ref.checkIfItemCanBeMoved,
|
|
28054
27885
|
openQuantitySelector = _ref.openQuantitySelector,
|
|
27886
|
+
checkIfItemShouldDragEnd = _ref.checkIfItemShouldDragEnd,
|
|
28055
27887
|
dragScale = _ref.dragScale,
|
|
28056
27888
|
isSelectingShortcut = _ref.isSelectingShortcut,
|
|
27889
|
+
equipmentSet = _ref.equipmentSet,
|
|
28057
27890
|
setItemShortcut = _ref.setItemShortcut,
|
|
28058
27891
|
isDepotSystem = _ref.isDepotSystem;
|
|
28059
|
-
|
|
28060
|
-
|
|
28061
|
-
|
|
28062
|
-
|
|
28063
|
-
|
|
28064
|
-
|
|
28065
|
-
|
|
28066
|
-
|
|
28067
|
-
|
|
28068
|
-
|
|
28069
|
-
|
|
28070
|
-
|
|
28071
|
-
|
|
28072
|
-
|
|
28073
|
-
|
|
28074
|
-
|
|
28075
|
-
|
|
28076
|
-
|
|
28077
|
-
getContainerBounds = _useItemSlotDragAndDr.getContainerBounds,
|
|
28078
|
-
onDraggableStart = _useItemSlotDragAndDr.onDraggableStart,
|
|
28079
|
-
onDraggableProgress = _useItemSlotDragAndDr.onDraggableProgress,
|
|
28080
|
-
onDraggableStop = _useItemSlotDragAndDr.onDraggableStop;
|
|
28081
|
-
var _useItemSlotTooltip = useItemSlotTooltip(),
|
|
28082
|
-
updateItemDetails = _useItemSlotTooltip.updateItemDetails,
|
|
28083
|
-
itemDetails = _useItemSlotTooltip.itemDetails;
|
|
28084
|
-
var _useCursorPosition = useCursorPosition({
|
|
28085
|
-
scale: dragScale
|
|
27892
|
+
// Centralized state using a single useState hook
|
|
27893
|
+
var _useState = React.useState({
|
|
27894
|
+
isTooltipVisible: false,
|
|
27895
|
+
isTooltipMobileVisible: false,
|
|
27896
|
+
isContextMenuVisible: false,
|
|
27897
|
+
contextMenuPosition: {
|
|
27898
|
+
x: 0,
|
|
27899
|
+
y: 0
|
|
27900
|
+
},
|
|
27901
|
+
isFocused: false,
|
|
27902
|
+
wasDragged: false,
|
|
27903
|
+
dragPosition: {
|
|
27904
|
+
x: 0,
|
|
27905
|
+
y: 0
|
|
27906
|
+
},
|
|
27907
|
+
dropPosition: null,
|
|
27908
|
+
contextActions: [],
|
|
27909
|
+
draggingDistance: 0
|
|
28086
27910
|
}),
|
|
28087
|
-
|
|
28088
|
-
|
|
27911
|
+
state = _useState[0],
|
|
27912
|
+
setState = _useState[1];
|
|
27913
|
+
var isTooltipVisible = state.isTooltipVisible,
|
|
27914
|
+
isTooltipMobileVisible = state.isTooltipMobileVisible,
|
|
27915
|
+
isContextMenuVisible = state.isContextMenuVisible,
|
|
27916
|
+
contextMenuPosition = state.contextMenuPosition,
|
|
27917
|
+
isFocused = state.isFocused,
|
|
27918
|
+
wasDragged = state.wasDragged,
|
|
27919
|
+
dragPosition = state.dragPosition,
|
|
27920
|
+
dropPosition = state.dropPosition,
|
|
27921
|
+
contextActions = state.contextActions;
|
|
27922
|
+
var dragContainer = React.useRef(null);
|
|
27923
|
+
var _useDragging = useDragging(),
|
|
27924
|
+
draggingItem = _useDragging.item,
|
|
27925
|
+
setDraggingItem = _useDragging.setDraggingItem;
|
|
28089
27926
|
React.useEffect(function () {
|
|
27927
|
+
// Reset drag position and focus when item changes
|
|
27928
|
+
setState(function (prevState) {
|
|
27929
|
+
return _extends({}, prevState, {
|
|
27930
|
+
dragPosition: {
|
|
27931
|
+
x: 0,
|
|
27932
|
+
y: 0
|
|
27933
|
+
},
|
|
27934
|
+
isFocused: false
|
|
27935
|
+
});
|
|
27936
|
+
});
|
|
27937
|
+
// Update context actions when item or depot system changes
|
|
28090
27938
|
if (item && containerType) {
|
|
28091
|
-
|
|
28092
|
-
|
|
28093
|
-
|
|
28094
|
-
|
|
28095
|
-
|
|
27939
|
+
setState(function (prevState) {
|
|
27940
|
+
return _extends({}, prevState, {
|
|
27941
|
+
contextActions: generateContextMenu(item, containerType, isDepotSystem)
|
|
27942
|
+
});
|
|
27943
|
+
});
|
|
27944
|
+
} else {
|
|
27945
|
+
setState(function (prevState) {
|
|
27946
|
+
return _extends({}, prevState, {
|
|
27947
|
+
contextActions: []
|
|
27948
|
+
});
|
|
28096
27949
|
});
|
|
28097
27950
|
}
|
|
28098
27951
|
}, [item, isDepotSystem]);
|
|
28099
|
-
|
|
28100
|
-
|
|
28101
|
-
|
|
28102
|
-
|
|
28103
|
-
|
|
28104
|
-
|
|
28105
|
-
|
|
28106
|
-
|
|
28107
|
-
|
|
28108
|
-
|
|
27952
|
+
React.useEffect(function () {
|
|
27953
|
+
// Handle outside drop
|
|
27954
|
+
if (onDrop && item && dropPosition) {
|
|
27955
|
+
onDrop(item, dropPosition);
|
|
27956
|
+
}
|
|
27957
|
+
}, [dropPosition]);
|
|
27958
|
+
var resetItem = function resetItem() {
|
|
27959
|
+
setState(function (prevState) {
|
|
27960
|
+
return _extends({}, prevState, {
|
|
27961
|
+
isTooltipVisible: false,
|
|
27962
|
+
wasDragged: false
|
|
27963
|
+
});
|
|
27964
|
+
});
|
|
27965
|
+
};
|
|
27966
|
+
var onSuccessfulDrag = function onSuccessfulDrag(quantity) {
|
|
27967
|
+
resetItem();
|
|
27968
|
+
if (quantity === -1) {
|
|
27969
|
+
setState(function (prevState) {
|
|
27970
|
+
return _extends({}, prevState, {
|
|
27971
|
+
dragPosition: {
|
|
27972
|
+
x: 0,
|
|
27973
|
+
y: 0
|
|
27974
|
+
},
|
|
27975
|
+
isFocused: false
|
|
27976
|
+
});
|
|
27977
|
+
});
|
|
27978
|
+
} else if (item) {
|
|
27979
|
+
onDragEnd == null ? void 0 : onDragEnd(quantity);
|
|
27980
|
+
}
|
|
27981
|
+
};
|
|
27982
|
+
var onDraggableStop = function onDraggableStop(e, data) {
|
|
27983
|
+
console.log('>>> ON_DRAGGABLE_STOP');
|
|
27984
|
+
// Stop the dragging state
|
|
27985
|
+
console.log('setDraggingItem(null)');
|
|
27986
|
+
setDraggingItem(null);
|
|
27987
|
+
var target = e.target;
|
|
27988
|
+
console.log('handleShortcutSetter(target)');
|
|
27989
|
+
handleShortcutSetter(target);
|
|
27990
|
+
console.log('removeDraggingClass(target)');
|
|
27991
|
+
removeDraggingClass(target);
|
|
27992
|
+
console.log('shouldHandleDraggedItem()');
|
|
27993
|
+
if (shouldHandleDraggedItem()) {
|
|
27994
|
+
console.log('handleDraggedItem(e, data)');
|
|
27995
|
+
handleDraggedItem(e, data);
|
|
27996
|
+
} else if (item && !wasDragged) {
|
|
27997
|
+
console.log('handleContextMenuOrTooltip(e)');
|
|
27998
|
+
handleContextMenuOrTooltip(e);
|
|
27999
|
+
}
|
|
28000
|
+
};
|
|
28001
|
+
/**
|
|
28002
|
+
* Handles the shortcut setter logic if the target element is a shortcut setter.
|
|
28003
|
+
*/
|
|
28004
|
+
var handleShortcutSetter = function handleShortcutSetter(target) {
|
|
28005
|
+
if (target != null && target.id.includes('shortcutSetter') && setItemShortcut && item) {
|
|
28006
|
+
var index = parseInt(target.id.split('_')[1], 10);
|
|
28007
|
+
if (!isNaN(index)) {
|
|
28008
|
+
setItemShortcut(item, index);
|
|
28109
28009
|
}
|
|
28110
28010
|
}
|
|
28111
|
-
|
|
28112
|
-
|
|
28113
|
-
|
|
28114
|
-
|
|
28115
|
-
|
|
28116
|
-
|
|
28117
|
-
|
|
28118
|
-
|
|
28119
|
-
|
|
28120
|
-
|
|
28121
|
-
|
|
28122
|
-
|
|
28123
|
-
|
|
28124
|
-
|
|
28011
|
+
};
|
|
28012
|
+
/**
|
|
28013
|
+
* Removes the dragging CSS class from the target element.
|
|
28014
|
+
*/
|
|
28015
|
+
var removeDraggingClass = function removeDraggingClass(target) {
|
|
28016
|
+
target.classList.remove('react-draggable-dragging');
|
|
28017
|
+
};
|
|
28018
|
+
/**
|
|
28019
|
+
* Determines whether the dragged item should be processed.
|
|
28020
|
+
*/
|
|
28021
|
+
var shouldHandleDraggedItem = function shouldHandleDraggedItem() {
|
|
28022
|
+
console.log("Debug: shouldHandleDraggedItem()", "wasDragged: " + wasDragged, "item: " + item, "isSelectingShortcut: " + isSelectingShortcut);
|
|
28023
|
+
return !!(wasDragged && item && !isSelectingShortcut);
|
|
28024
|
+
};
|
|
28025
|
+
/**
|
|
28026
|
+
* Handles the logic when an item has been dragged.
|
|
28027
|
+
*/
|
|
28028
|
+
var handleDraggedItem = function handleDraggedItem(e, data) {
|
|
28029
|
+
var targetClasses = Array.from(e.target.classList);
|
|
28030
|
+
var isOutsideDrop = targetClasses.some(function (elm) {
|
|
28031
|
+
return elm.includes('rpgui-content');
|
|
28032
|
+
}) || targetClasses.length === 0;
|
|
28033
|
+
if (isOutsideDrop) {
|
|
28034
|
+
setState(function (prevState) {
|
|
28035
|
+
return _extends({}, prevState, {
|
|
28036
|
+
dropPosition: {
|
|
28037
|
+
x: data.x,
|
|
28038
|
+
y: data.y
|
|
28039
|
+
}
|
|
28040
|
+
});
|
|
28125
28041
|
});
|
|
28126
|
-
|
|
28127
|
-
|
|
28128
|
-
|
|
28129
|
-
|
|
28130
|
-
|
|
28042
|
+
}
|
|
28043
|
+
setState(function (prevState) {
|
|
28044
|
+
return _extends({}, prevState, {
|
|
28045
|
+
wasDragged: false
|
|
28046
|
+
});
|
|
28047
|
+
});
|
|
28048
|
+
var targetElement = dragContainer.current;
|
|
28049
|
+
if (!targetElement) return;
|
|
28050
|
+
var _getElementTransform = getElementTransform(targetElement),
|
|
28051
|
+
x = _getElementTransform.x,
|
|
28052
|
+
y = _getElementTransform.y;
|
|
28053
|
+
setState(function (prevState) {
|
|
28054
|
+
return _extends({}, prevState, {
|
|
28055
|
+
dragPosition: {
|
|
28056
|
+
x: x,
|
|
28057
|
+
y: y
|
|
28131
28058
|
}
|
|
28132
28059
|
});
|
|
28060
|
+
});
|
|
28061
|
+
// Delay to ensure state updates before proceeding
|
|
28062
|
+
setTimeout(function () {
|
|
28063
|
+
processDragEnd(item);
|
|
28064
|
+
}, 50);
|
|
28065
|
+
};
|
|
28066
|
+
/**
|
|
28067
|
+
* Retrieves the current transform position of the dragged element.
|
|
28068
|
+
*/
|
|
28069
|
+
var getElementTransform = function getElementTransform(element) {
|
|
28070
|
+
var style = window.getComputedStyle(element);
|
|
28071
|
+
var matrix = new DOMMatrixReadOnly(style.transform);
|
|
28072
|
+
return {
|
|
28073
|
+
x: matrix.m41,
|
|
28074
|
+
y: matrix.m42
|
|
28075
|
+
};
|
|
28076
|
+
};
|
|
28077
|
+
/**
|
|
28078
|
+
* Processes the end of a drag event, handling quantity selection or resetting state.
|
|
28079
|
+
*/
|
|
28080
|
+
var processDragEnd = function processDragEnd(item) {
|
|
28081
|
+
console.log("Debug: processDragEnd(item)", "item: " + item);
|
|
28082
|
+
if (checkIfItemCanBeMoved != null && checkIfItemCanBeMoved()) {
|
|
28083
|
+
console.log("Debug: checkIfItemCanBeMoved()", "result: " + checkIfItemCanBeMoved());
|
|
28084
|
+
if (checkIfItemShouldDragEnd && !checkIfItemShouldDragEnd()) return;
|
|
28085
|
+
console.log("Debug: checkIfItemShouldDragEnd()", "result: " + (checkIfItemShouldDragEnd == null ? void 0 : checkIfItemShouldDragEnd()));
|
|
28086
|
+
if (item.stackQty && item.stackQty !== 1 && openQuantitySelector) {
|
|
28087
|
+
console.log("Debug: openQuantitySelector(item.stackQty, onSuccessfulDrag)");
|
|
28088
|
+
openQuantitySelector(item.stackQty, onSuccessfulDrag);
|
|
28089
|
+
} else {
|
|
28090
|
+
console.log("Debug: onSuccessfulDrag(item.stackQty)");
|
|
28091
|
+
onSuccessfulDrag(item.stackQty);
|
|
28092
|
+
}
|
|
28093
|
+
} else {
|
|
28094
|
+
console.log("Debug: resetItem()");
|
|
28095
|
+
resetItem();
|
|
28096
|
+
setState(function (prevState) {
|
|
28097
|
+
return _extends({}, prevState, {
|
|
28098
|
+
isFocused: false,
|
|
28099
|
+
dragPosition: {
|
|
28100
|
+
x: 0,
|
|
28101
|
+
y: 0
|
|
28102
|
+
}
|
|
28103
|
+
});
|
|
28104
|
+
});
|
|
28105
|
+
}
|
|
28106
|
+
};
|
|
28107
|
+
/**
|
|
28108
|
+
* Handles the context menu or tooltip display after dragging stops without a drop.
|
|
28109
|
+
*/
|
|
28110
|
+
var handleContextMenuOrTooltip = function handleContextMenuOrTooltip(e) {
|
|
28111
|
+
var isTouchEvent = false;
|
|
28112
|
+
if (!isContextMenuDisabled && e.type === 'touchend' && !isSelectingShortcut) {
|
|
28113
|
+
isTouchEvent = true;
|
|
28114
|
+
setState(function (prevState) {
|
|
28115
|
+
return _extends({}, prevState, {
|
|
28116
|
+
isTooltipMobileVisible: true
|
|
28117
|
+
});
|
|
28118
|
+
});
|
|
28119
|
+
}
|
|
28120
|
+
if (!isContextMenuDisabled && !isSelectingShortcut && !isTouchEvent) {
|
|
28121
|
+
setState(function (prevState) {
|
|
28122
|
+
return _extends({}, prevState, {
|
|
28123
|
+
isContextMenuVisible: !prevState.isContextMenuVisible,
|
|
28124
|
+
contextMenuPosition: {
|
|
28125
|
+
x: e.clientX - 10,
|
|
28126
|
+
y: e.clientY - 5
|
|
28127
|
+
}
|
|
28128
|
+
});
|
|
28129
|
+
});
|
|
28130
|
+
}
|
|
28131
|
+
if (item) {
|
|
28132
|
+
onPointerDown(item.type, containerType != null ? containerType : null, item);
|
|
28133
|
+
}
|
|
28134
|
+
};
|
|
28135
|
+
var onDraggableStart = function onDraggableStart() {
|
|
28136
|
+
if (!item || isSelectingShortcut) {
|
|
28137
|
+
return;
|
|
28138
|
+
}
|
|
28139
|
+
if (onDragStart && containerType) {
|
|
28140
|
+
onDragStart(item, slotIndex, containerType);
|
|
28141
|
+
}
|
|
28142
|
+
};
|
|
28143
|
+
var onDraggableProgress = function onDraggableProgress(_e, _data) {
|
|
28144
|
+
// increment draggingDistance by 1
|
|
28145
|
+
setState(function (prevState) {
|
|
28146
|
+
return _extends({}, prevState, {
|
|
28147
|
+
draggingDistance: prevState.draggingDistance + 1
|
|
28148
|
+
});
|
|
28149
|
+
});
|
|
28150
|
+
if (state.draggingDistance > 10) {
|
|
28151
|
+
setState(function (prevState) {
|
|
28152
|
+
return _extends({}, prevState, {
|
|
28153
|
+
wasDragged: true,
|
|
28154
|
+
isFocused: true
|
|
28155
|
+
});
|
|
28156
|
+
});
|
|
28157
|
+
}
|
|
28158
|
+
if (!draggingItem) {
|
|
28159
|
+
setDraggingItem(item);
|
|
28133
28160
|
}
|
|
28134
|
-
}
|
|
28135
|
-
return React__default.createElement(Container$
|
|
28161
|
+
};
|
|
28162
|
+
return React__default.createElement(Container$b, {
|
|
28136
28163
|
isDraggingItem: !!draggingItem,
|
|
28137
28164
|
item: item,
|
|
28138
28165
|
className: "rpgui-icon empty-slot",
|
|
28139
|
-
|
|
28140
|
-
onMouseDown: handleInteraction,
|
|
28141
|
-
onTouchStart: handleInteraction,
|
|
28142
|
-
onMouseUp: function onMouseUp(e) {
|
|
28143
|
-
handleInteractionEnd(e);
|
|
28166
|
+
onMouseUp: function onMouseUp() {
|
|
28144
28167
|
var data = item ? item : null;
|
|
28145
|
-
if (onPlaceDrop && containerType
|
|
28146
|
-
onPlaceDrop(data, slotIndex, containerType);
|
|
28147
|
-
}
|
|
28168
|
+
if (onPlaceDrop && containerType) onPlaceDrop(data, slotIndex, containerType);
|
|
28148
28169
|
},
|
|
28149
28170
|
onTouchEnd: function onTouchEnd(e) {
|
|
28150
|
-
var _document$
|
|
28171
|
+
var _document$elementFrom;
|
|
28151
28172
|
var _e$changedTouches$ = e.changedTouches[0],
|
|
28152
28173
|
clientX = _e$changedTouches$.clientX,
|
|
28153
28174
|
clientY = _e$changedTouches$.clientY;
|
|
@@ -28156,12 +28177,12 @@ var ItemSlot = /*#__PURE__*/React__default.memo( /*#__PURE__*/mobxReactLite.obse
|
|
|
28156
28177
|
clientY: clientY,
|
|
28157
28178
|
bubbles: true
|
|
28158
28179
|
});
|
|
28159
|
-
(_document$
|
|
28180
|
+
(_document$elementFrom = document.elementFromPoint(clientX, clientY)) == null ? void 0 : _document$elementFrom.dispatchEvent(simulatedEvent);
|
|
28160
28181
|
},
|
|
28161
28182
|
onPointerDown: onDragStart !== undefined && onDragEnd !== undefined ? undefined : function () {
|
|
28162
28183
|
if (item) onPointerDown(item.type, containerType != null ? containerType : null, item);
|
|
28163
28184
|
},
|
|
28164
|
-
|
|
28185
|
+
isSelectingShortcut: isSelectingShortcut && ((item == null ? void 0 : item.type) === shared.ItemType.Consumable || (item == null ? void 0 : item.type) === shared.ItemType.Tool || (item == null ? void 0 : item.subType) === shared.ItemSubType.Seed)
|
|
28165
28186
|
}, React__default.createElement(Draggable, {
|
|
28166
28187
|
axis: isSelectingShortcut ? 'none' : 'both',
|
|
28167
28188
|
defaultClassName: item ? 'draggable' : 'empty-slot',
|
|
@@ -28170,30 +28191,30 @@ var ItemSlot = /*#__PURE__*/React__default.memo( /*#__PURE__*/mobxReactLite.obse
|
|
|
28170
28191
|
onStop: onDraggableStop,
|
|
28171
28192
|
onStart: onDraggableStart,
|
|
28172
28193
|
onDrag: onDraggableProgress,
|
|
28173
|
-
position:
|
|
28194
|
+
position: dragPosition,
|
|
28174
28195
|
cancel: ".empty-slot",
|
|
28175
|
-
bounds:
|
|
28196
|
+
bounds: ".item-container-body, .equipment-container-body"
|
|
28176
28197
|
}, React__default.createElement(ItemContainer, {
|
|
28177
28198
|
ref: dragContainer,
|
|
28178
|
-
isFocused:
|
|
28179
|
-
onMouseOver: function onMouseOver() {
|
|
28180
|
-
_onMouseOver == null ? void 0 : _onMouseOver(
|
|
28199
|
+
isFocused: isFocused,
|
|
28200
|
+
onMouseOver: function onMouseOver(event) {
|
|
28201
|
+
_onMouseOver == null ? void 0 : _onMouseOver(event, slotIndex, item, event.clientX, event.clientY);
|
|
28202
|
+
},
|
|
28203
|
+
onMouseOut: function onMouseOut() {
|
|
28204
|
+
if (_onMouseOut) _onMouseOut();
|
|
28181
28205
|
},
|
|
28182
|
-
onMouseOut: onMouseOut,
|
|
28183
28206
|
onMouseEnter: function onMouseEnter() {
|
|
28184
|
-
|
|
28185
|
-
|
|
28186
|
-
|
|
28187
|
-
|
|
28188
|
-
}
|
|
28207
|
+
setState(function (prevState) {
|
|
28208
|
+
return _extends({}, prevState, {
|
|
28209
|
+
isTooltipVisible: true
|
|
28210
|
+
});
|
|
28189
28211
|
});
|
|
28190
28212
|
},
|
|
28191
28213
|
onMouseLeave: function onMouseLeave() {
|
|
28192
|
-
|
|
28193
|
-
|
|
28194
|
-
|
|
28195
|
-
|
|
28196
|
-
}
|
|
28214
|
+
setState(function (prevState) {
|
|
28215
|
+
return _extends({}, prevState, {
|
|
28216
|
+
isTooltipVisible: false
|
|
28217
|
+
});
|
|
28197
28218
|
});
|
|
28198
28219
|
}
|
|
28199
28220
|
}, React__default.createElement(ItemSlotRenderer, {
|
|
@@ -28202,12 +28223,54 @@ var ItemSlot = /*#__PURE__*/React__default.memo( /*#__PURE__*/mobxReactLite.obse
|
|
|
28202
28223
|
atlasIMG: atlasIMG,
|
|
28203
28224
|
atlasJSON: atlasJSON,
|
|
28204
28225
|
containerType: containerType
|
|
28205
|
-
})))
|
|
28206
|
-
|
|
28207
|
-
|
|
28226
|
+
}))), React__default.createElement(ItemSlotToolTips, {
|
|
28227
|
+
isTooltipVisible: isTooltipVisible,
|
|
28228
|
+
isTooltipMobileVisible: isTooltipMobileVisible,
|
|
28229
|
+
setIsTooltipMobileVisible: function setIsTooltipMobileVisible(value) {
|
|
28230
|
+
return setState(function (prevState) {
|
|
28231
|
+
return _extends({}, prevState, {
|
|
28232
|
+
isTooltipMobileVisible: value
|
|
28233
|
+
});
|
|
28234
|
+
});
|
|
28235
|
+
},
|
|
28236
|
+
isFocused: isFocused,
|
|
28237
|
+
isContextMenuVisible: isContextMenuVisible,
|
|
28238
|
+
isContextMenuDisabled: isContextMenuDisabled,
|
|
28239
|
+
item: item,
|
|
28240
|
+
contextActions: contextActions,
|
|
28241
|
+
contextMenuPosition: contextMenuPosition,
|
|
28242
|
+
dragScale: dragScale,
|
|
28243
|
+
setIsContextMenuVisible: function setIsContextMenuVisible(value) {
|
|
28244
|
+
return setState(function (prevState) {
|
|
28245
|
+
return _extends({}, prevState, {
|
|
28246
|
+
isContextMenuVisible: value
|
|
28247
|
+
});
|
|
28248
|
+
});
|
|
28249
|
+
},
|
|
28250
|
+
onSelected: function onSelected(optionId, item) {
|
|
28251
|
+
setState(function (prevState) {
|
|
28252
|
+
return _extends({}, prevState, {
|
|
28253
|
+
isContextMenuVisible: false
|
|
28254
|
+
});
|
|
28255
|
+
});
|
|
28256
|
+
if (_onSelected) _onSelected(optionId, item);
|
|
28257
|
+
},
|
|
28258
|
+
atlasIMG: atlasIMG,
|
|
28259
|
+
atlasJSON: atlasJSON,
|
|
28260
|
+
equipmentSet: equipmentSet,
|
|
28261
|
+
setIsTooltipVisible: function setIsTooltipVisible(value) {
|
|
28262
|
+
return setState(function (prevState) {
|
|
28263
|
+
return _extends({}, prevState, {
|
|
28264
|
+
isTooltipVisible: value
|
|
28265
|
+
});
|
|
28266
|
+
});
|
|
28267
|
+
}
|
|
28268
|
+
}));
|
|
28269
|
+
});
|
|
28270
|
+
var Container$b = /*#__PURE__*/styled__default.div.withConfig({
|
|
28208
28271
|
displayName: "ItemSlot__Container",
|
|
28209
28272
|
componentId: "sc-l2j5ef-0"
|
|
28210
|
-
})(["margin:0.1rem
|
|
28273
|
+
})(["margin:0.1rem;*{border:1px solid blue;}.react-draggable-dragging{opacity:", ";}position:relative;.sprite-from-atlas-img--item{position:relative;top:1.5rem;left:1.5rem;border-color:", ";box-shadow:", " inset,", ";}&::before{content:'';position:absolute;top:0;left:0;width:100%;height:100%;z-index:1;border-radius:12px;pointer-events:none;animation:", ";@keyframes bg-color-change{0%{background-color:rgba(255 255 255 / 0.5);}50%{background-color:transparent;}100%{background-color:rgba(255 255 255 / 0.5);}}}"], function (_ref2) {
|
|
28211
28274
|
var isDraggingItem = _ref2.isDraggingItem;
|
|
28212
28275
|
return isDraggingItem ? 0 : 1;
|
|
28213
28276
|
}, function (_ref3) {
|
|
@@ -28320,7 +28383,7 @@ var ItemInfo = function ItemInfo(_ref) {
|
|
|
28320
28383
|
});
|
|
28321
28384
|
};
|
|
28322
28385
|
var skillName = (_item$minRequirements = item.minRequirements) == null ? void 0 : (_item$minRequirements2 = _item$minRequirements.skill) == null ? void 0 : _item$minRequirements2.name;
|
|
28323
|
-
return React__default.createElement(Container$
|
|
28386
|
+
return React__default.createElement(Container$c, {
|
|
28324
28387
|
item: item
|
|
28325
28388
|
}, React__default.createElement(Header, null, React__default.createElement("div", null, React__default.createElement(Title$1, null, item.name), item.rarity !== 'Common' && React__default.createElement(Rarity, {
|
|
28326
28389
|
item: item
|
|
@@ -28334,7 +28397,7 @@ var ItemInfo = function ItemInfo(_ref) {
|
|
|
28334
28397
|
"$isSpecial": true
|
|
28335
28398
|
}, "Two handed"), React__default.createElement(Description, null, item.description), item.maxStackSize && item.maxStackSize !== 1 && React__default.createElement(StackInfo, null, "x", Math.round(((_item$stackQty = item.stackQty) != null ? _item$stackQty : 1) * 100) / 100, "(", item.maxStackSize, ")"), renderMissingStatistic().length > 0 && React__default.createElement(MissingStatistics, null, React__default.createElement(Statistic, null, "Equipped Diff"), itemToCompare && renderMissingStatistic()));
|
|
28336
28399
|
};
|
|
28337
|
-
var Container$
|
|
28400
|
+
var Container$c = /*#__PURE__*/styled__default.div.withConfig({
|
|
28338
28401
|
displayName: "ItemInfo__Container",
|
|
28339
28402
|
componentId: "sc-1xm4q8k-0"
|
|
28340
28403
|
})(["color:white;background-color:#222;border-radius:5px;padding:0.5rem;font-size:", ";border:3px solid ", ";height:max-content;width:18rem;@media (max-width:640px){width:80vw;}"], uiFonts.size.small, function (_ref2) {
|
|
@@ -28480,7 +28543,7 @@ var ItemTooltip = function ItemTooltip(_ref) {
|
|
|
28480
28543
|
}
|
|
28481
28544
|
return;
|
|
28482
28545
|
}, []);
|
|
28483
|
-
return React__default.createElement(ModalPortal, null, React__default.createElement(Container$
|
|
28546
|
+
return React__default.createElement(ModalPortal, null, React__default.createElement(Container$d, {
|
|
28484
28547
|
ref: ref
|
|
28485
28548
|
}, React__default.createElement(ItemInfoDisplay, {
|
|
28486
28549
|
item: item,
|
|
@@ -28489,67 +28552,11 @@ var ItemTooltip = function ItemTooltip(_ref) {
|
|
|
28489
28552
|
equipmentSet: equipmentSet
|
|
28490
28553
|
})));
|
|
28491
28554
|
};
|
|
28492
|
-
var Container$
|
|
28555
|
+
var Container$d = /*#__PURE__*/styled__default.div.withConfig({
|
|
28493
28556
|
displayName: "ItemTooltip__Container",
|
|
28494
28557
|
componentId: "sc-11d9r7x-0"
|
|
28495
28558
|
})(["position:absolute;z-index:100;pointer-events:none;left:0;top:0;opacity:0;transition:opacity 0.08s;"]);
|
|
28496
28559
|
|
|
28497
|
-
var MobileItemTooltip = function MobileItemTooltip(_ref) {
|
|
28498
|
-
var item = _ref.item,
|
|
28499
|
-
atlasIMG = _ref.atlasIMG,
|
|
28500
|
-
atlasJSON = _ref.atlasJSON,
|
|
28501
|
-
closeTooltip = _ref.closeTooltip,
|
|
28502
|
-
equipmentSet = _ref.equipmentSet,
|
|
28503
|
-
_ref$scale = _ref.scale,
|
|
28504
|
-
scale = _ref$scale === void 0 ? 1 : _ref$scale,
|
|
28505
|
-
options = _ref.options,
|
|
28506
|
-
onSelected = _ref.onSelected;
|
|
28507
|
-
var ref = React.useRef(null);
|
|
28508
|
-
var handleFadeOut = function handleFadeOut() {
|
|
28509
|
-
var _ref$current;
|
|
28510
|
-
(_ref$current = ref.current) == null ? void 0 : _ref$current.classList.add('fadeOut');
|
|
28511
|
-
};
|
|
28512
|
-
return React__default.createElement(ModalPortal, null, React__default.createElement(Container$c, {
|
|
28513
|
-
ref: ref,
|
|
28514
|
-
onTouchEnd: function onTouchEnd() {
|
|
28515
|
-
handleFadeOut();
|
|
28516
|
-
setTimeout(function () {
|
|
28517
|
-
closeTooltip();
|
|
28518
|
-
}, 100);
|
|
28519
|
-
},
|
|
28520
|
-
scale: scale
|
|
28521
|
-
}, React__default.createElement(ItemInfoDisplay, {
|
|
28522
|
-
item: item,
|
|
28523
|
-
atlasIMG: atlasIMG,
|
|
28524
|
-
atlasJSON: atlasJSON,
|
|
28525
|
-
equipmentSet: equipmentSet,
|
|
28526
|
-
isMobile: true
|
|
28527
|
-
}), React__default.createElement(OptionsContainer, null, options == null ? void 0 : options.map(function (option) {
|
|
28528
|
-
return React__default.createElement(Option, {
|
|
28529
|
-
key: option.id,
|
|
28530
|
-
onTouchEnd: function onTouchEnd() {
|
|
28531
|
-
handleFadeOut();
|
|
28532
|
-
setTimeout(function () {
|
|
28533
|
-
onSelected == null ? void 0 : onSelected(option.id);
|
|
28534
|
-
closeTooltip();
|
|
28535
|
-
}, 100);
|
|
28536
|
-
}
|
|
28537
|
-
}, option.text);
|
|
28538
|
-
}))));
|
|
28539
|
-
};
|
|
28540
|
-
var Container$c = /*#__PURE__*/styled__default.div.withConfig({
|
|
28541
|
-
displayName: "MobileItemTooltip__Container",
|
|
28542
|
-
componentId: "sc-ku4p1j-0"
|
|
28543
|
-
})(["position:absolute;z-index:100;left:0;top:0;width:100vw;height:100vh;background-color:rgba(0 0 0 / 0.5);display:flex;justify-content:center;align-items:center;gap:0.5rem;transition:opacity 0.08s;animation:fadeIn 0.1s forwards;@keyframes fadeIn{0%{opacity:0;}100%{opacity:0.92;}}@keyframes fadeOut{0%{opacity:0.92;}100%{opacity:0;}}&.fadeOut{animation:fadeOut 0.1s forwards;}@media (max-width:640px){flex-direction:column;}"]);
|
|
28544
|
-
var OptionsContainer = /*#__PURE__*/styled__default.div.withConfig({
|
|
28545
|
-
displayName: "MobileItemTooltip__OptionsContainer",
|
|
28546
|
-
componentId: "sc-ku4p1j-1"
|
|
28547
|
-
})(["display:flex;flex-direction:column;gap:0.5rem;flex-wrap:wrap;@media (max-width:640px){flex-direction:row;justify-content:center;}"]);
|
|
28548
|
-
var Option = /*#__PURE__*/styled__default.button.withConfig({
|
|
28549
|
-
displayName: "MobileItemTooltip__Option",
|
|
28550
|
-
componentId: "sc-ku4p1j-2"
|
|
28551
|
-
})(["padding:1rem;background-color:#333;color:white;border:none;border-radius:3px;width:8rem;transition:background-color 0.1s;&:hover{background-color:#555;}@media (max-width:640px){padding:1rem 0.5rem;}"]);
|
|
28552
|
-
|
|
28553
28560
|
var ItemInfoWrapper = function ItemInfoWrapper(_ref) {
|
|
28554
28561
|
var children = _ref.children,
|
|
28555
28562
|
atlasIMG = _ref.atlasIMG,
|
|
@@ -28904,7 +28911,7 @@ var Dropdown = function Dropdown(_ref) {
|
|
|
28904
28911
|
onChange(selectedValue);
|
|
28905
28912
|
}
|
|
28906
28913
|
}, [selectedValue]);
|
|
28907
|
-
return React__default.createElement(Container$
|
|
28914
|
+
return React__default.createElement(Container$e, {
|
|
28908
28915
|
onMouseLeave: function onMouseLeave() {
|
|
28909
28916
|
return setOpened(false);
|
|
28910
28917
|
},
|
|
@@ -28932,7 +28939,7 @@ var Dropdown = function Dropdown(_ref) {
|
|
|
28932
28939
|
}, option.option);
|
|
28933
28940
|
})));
|
|
28934
28941
|
};
|
|
28935
|
-
var Container$
|
|
28942
|
+
var Container$e = /*#__PURE__*/styled__default.div.withConfig({
|
|
28936
28943
|
displayName: "Dropdown__Container",
|
|
28937
28944
|
componentId: "sc-8arn65-0"
|
|
28938
28945
|
})(["position:relative;width:", ";"], function (props) {
|
|
@@ -28974,6 +28981,57 @@ var Details = /*#__PURE__*/styled__default.p.withConfig({
|
|
|
28974
28981
|
componentId: "sc-kaa0h9-0"
|
|
28975
28982
|
})(["font-size:", " !important;"], uiFonts.size.xsmall);
|
|
28976
28983
|
|
|
28984
|
+
var useCursorPosition = function useCursorPosition(_ref) {
|
|
28985
|
+
var _ref$scale = _ref.scale,
|
|
28986
|
+
scale = _ref$scale === void 0 ? 1 : _ref$scale;
|
|
28987
|
+
var _useState = React.useState({
|
|
28988
|
+
x: 0,
|
|
28989
|
+
y: 0
|
|
28990
|
+
}),
|
|
28991
|
+
position = _useState[0],
|
|
28992
|
+
setPosition = _useState[1];
|
|
28993
|
+
var scalePosition = React.useCallback(function (x, y) {
|
|
28994
|
+
return {
|
|
28995
|
+
x: (x - shared.GRID_WIDTH / 2) / scale + shared.GRID_WIDTH / 2,
|
|
28996
|
+
y: (y - shared.GRID_HEIGHT / 2) / scale + shared.GRID_HEIGHT / 2
|
|
28997
|
+
};
|
|
28998
|
+
}, [scale]);
|
|
28999
|
+
var setFromEvent = React.useCallback(function (e) {
|
|
29000
|
+
var x, y;
|
|
29001
|
+
if ('touches' in e) {
|
|
29002
|
+
x = e.touches[0].clientX;
|
|
29003
|
+
y = e.touches[0].clientY;
|
|
29004
|
+
} else {
|
|
29005
|
+
x = e.clientX;
|
|
29006
|
+
y = e.clientY;
|
|
29007
|
+
}
|
|
29008
|
+
var scaledPosition = scalePosition(x, y);
|
|
29009
|
+
setPosition(scaledPosition);
|
|
29010
|
+
}, [scale, scalePosition]);
|
|
29011
|
+
var cleanup = React.useCallback(function () {
|
|
29012
|
+
setPosition({
|
|
29013
|
+
x: 0,
|
|
29014
|
+
y: 0
|
|
29015
|
+
});
|
|
29016
|
+
}, []);
|
|
29017
|
+
React.useEffect(function () {
|
|
29018
|
+
var handleEvent = function handleEvent(e) {
|
|
29019
|
+
return setFromEvent(e);
|
|
29020
|
+
};
|
|
29021
|
+
window.addEventListener('mousemove', handleEvent);
|
|
29022
|
+
window.addEventListener('touchmove', handleEvent);
|
|
29023
|
+
window.addEventListener('mouseup', cleanup);
|
|
29024
|
+
window.addEventListener('touchend', cleanup);
|
|
29025
|
+
return function () {
|
|
29026
|
+
window.removeEventListener('mousemove', handleEvent);
|
|
29027
|
+
window.removeEventListener('touchmove', handleEvent);
|
|
29028
|
+
window.removeEventListener('mouseup', cleanup);
|
|
29029
|
+
window.removeEventListener('touchend', cleanup);
|
|
29030
|
+
};
|
|
29031
|
+
}, [setFromEvent, cleanup]);
|
|
29032
|
+
return position;
|
|
29033
|
+
};
|
|
29034
|
+
|
|
28977
29035
|
var CONTAINER_SIZE = 32;
|
|
28978
29036
|
var OFFSET = CONTAINER_SIZE / 2;
|
|
28979
29037
|
var DraggedItem = function DraggedItem(_ref) {
|
|
@@ -28981,8 +29039,8 @@ var DraggedItem = function DraggedItem(_ref) {
|
|
|
28981
29039
|
var atlasJSON = _ref.atlasJSON,
|
|
28982
29040
|
atlasIMG = _ref.atlasIMG,
|
|
28983
29041
|
scale = _ref.scale;
|
|
28984
|
-
var
|
|
28985
|
-
item =
|
|
29042
|
+
var _useDragging = useDragging(),
|
|
29043
|
+
item = _useDragging.item;
|
|
28986
29044
|
var _useCursorPosition = useCursorPosition({
|
|
28987
29045
|
scale: scale
|
|
28988
29046
|
}),
|
|
@@ -28997,7 +29055,7 @@ var DraggedItem = function DraggedItem(_ref) {
|
|
|
28997
29055
|
var centeredX = x - OFFSET;
|
|
28998
29056
|
var centeredY = y - OFFSET;
|
|
28999
29057
|
var stackInfo = onRenderStackInfo((_item$_id = item == null ? void 0 : item._id) != null ? _item$_id : '', (_item$stackQty = item == null ? void 0 : item.stackQty) != null ? _item$stackQty : 0);
|
|
29000
|
-
return React__default.createElement(Container$
|
|
29058
|
+
return React__default.createElement(Container$f, null, React__default.createElement(SpriteContainer, {
|
|
29001
29059
|
x: centeredX,
|
|
29002
29060
|
y: centeredY
|
|
29003
29061
|
}, React__default.createElement(SpriteFromAtlas, {
|
|
@@ -29015,7 +29073,7 @@ var DraggedItem = function DraggedItem(_ref) {
|
|
|
29015
29073
|
}), stackInfo));
|
|
29016
29074
|
};
|
|
29017
29075
|
var pulse = "\n @keyframes pulse {\n 0%, 100% {\n transform: scale(1) rotate(-3deg);\n }\n 50% {\n transform: scale(0.95) rotate(-3deg);\n }\n }\n";
|
|
29018
|
-
var Container$
|
|
29076
|
+
var Container$f = /*#__PURE__*/styled__default.div.withConfig({
|
|
29019
29077
|
displayName: "DraggedItem__Container",
|
|
29020
29078
|
componentId: "sc-mlzzcp-0"
|
|
29021
29079
|
})(["position:relative;"]);
|
|
@@ -29031,127 +29089,11 @@ var SpriteContainer = /*#__PURE__*/styled__default.div.attrs(function (props) {
|
|
|
29031
29089
|
componentId: "sc-mlzzcp-1"
|
|
29032
29090
|
})(["", " position:absolute;z-index:100;pointer-events:none;width:", "px;height:", "px;transform:rotate(-3deg);filter:grayscale(100%);opacity:0.35;animation:pulse 2s infinite;.item-slot-qty{position:absolute;bottom:0;margin-left:0.8rem;}"], pulse, CONTAINER_SIZE, CONTAINER_SIZE);
|
|
29033
29091
|
|
|
29034
|
-
var RelativeListMenu = function RelativeListMenu(_ref) {
|
|
29035
|
-
var options = _ref.options,
|
|
29036
|
-
onSelected = _ref.onSelected,
|
|
29037
|
-
onOutsideClick = _ref.onOutsideClick,
|
|
29038
|
-
_ref$fontSize = _ref.fontSize,
|
|
29039
|
-
fontSize = _ref$fontSize === void 0 ? 0.8 : _ref$fontSize,
|
|
29040
|
-
pos = _ref.pos;
|
|
29041
|
-
var ref = React.useRef(null);
|
|
29042
|
-
useOutsideClick(ref, 'relative-context-menu');
|
|
29043
|
-
React.useEffect(function () {
|
|
29044
|
-
document.addEventListener('clickOutside', function (event) {
|
|
29045
|
-
var e = event;
|
|
29046
|
-
if (e.detail.id === 'relative-context-menu') {
|
|
29047
|
-
if (onOutsideClick) {
|
|
29048
|
-
onOutsideClick();
|
|
29049
|
-
}
|
|
29050
|
-
}
|
|
29051
|
-
});
|
|
29052
|
-
return function () {
|
|
29053
|
-
document.removeEventListener('clickOutside', function (_e) {});
|
|
29054
|
-
};
|
|
29055
|
-
}, []);
|
|
29056
|
-
return React__default.createElement(ModalPortal, null, React__default.createElement(Container$f, Object.assign({
|
|
29057
|
-
fontSize: fontSize,
|
|
29058
|
-
ref: ref
|
|
29059
|
-
}, pos), React__default.createElement("ul", {
|
|
29060
|
-
className: "rpgui-list-imp",
|
|
29061
|
-
style: {
|
|
29062
|
-
overflow: 'hidden'
|
|
29063
|
-
}
|
|
29064
|
-
}, options.map(function (params, index) {
|
|
29065
|
-
return React__default.createElement(ListElement$2, {
|
|
29066
|
-
key: (params == null ? void 0 : params.id) || index,
|
|
29067
|
-
onPointerDown: function onPointerDown() {
|
|
29068
|
-
onSelected(params == null ? void 0 : params.id);
|
|
29069
|
-
}
|
|
29070
|
-
}, (params == null ? void 0 : params.text) || 'No text');
|
|
29071
|
-
}))));
|
|
29072
|
-
};
|
|
29073
|
-
var Container$f = /*#__PURE__*/styled__default.div.withConfig({
|
|
29074
|
-
displayName: "RelativeListMenu__Container",
|
|
29075
|
-
componentId: "sc-7hohf-0"
|
|
29076
|
-
})(["position:absolute;top:", "px;left:", "px;display:flex;flex-direction:column;width:max-content;justify-content:start;align-items:flex-start;li{font-size:", "em;}"], function (props) {
|
|
29077
|
-
return props.y;
|
|
29078
|
-
}, function (props) {
|
|
29079
|
-
return props.x;
|
|
29080
|
-
}, function (props) {
|
|
29081
|
-
return props.fontSize;
|
|
29082
|
-
});
|
|
29083
|
-
var ListElement$2 = /*#__PURE__*/styled__default.li.withConfig({
|
|
29084
|
-
displayName: "RelativeListMenu__ListElement",
|
|
29085
|
-
componentId: "sc-7hohf-1"
|
|
29086
|
-
})(["margin-right:0.5rem;"]);
|
|
29087
|
-
|
|
29088
|
-
var ItemSlotToolTips = function ItemSlotToolTips(_ref) {
|
|
29089
|
-
var _itemDetails$tooltip, _itemDetails$tooltip2, _itemDetails$contextM, _itemDetails$contextM2;
|
|
29090
|
-
var isFocused = _ref.isFocused,
|
|
29091
|
-
isContextMenuDisabled = _ref.isContextMenuDisabled,
|
|
29092
|
-
dragScale = _ref.dragScale,
|
|
29093
|
-
onSelected = _ref.onSelected,
|
|
29094
|
-
atlasIMG = _ref.atlasIMG,
|
|
29095
|
-
atlasJSON = _ref.atlasJSON,
|
|
29096
|
-
equipmentSet = _ref.equipmentSet;
|
|
29097
|
-
var _useItemSlotTooltip = useItemSlotTooltip(),
|
|
29098
|
-
itemDetails = _useItemSlotTooltip.itemDetails,
|
|
29099
|
-
updateItemDetails = _useItemSlotTooltip.updateItemDetails;
|
|
29100
|
-
var item = itemDetails.item;
|
|
29101
|
-
var handleCloseTooltip = function handleCloseTooltip() {
|
|
29102
|
-
updateItemDetails({
|
|
29103
|
-
item: item,
|
|
29104
|
-
tooltip: {
|
|
29105
|
-
mobileVisible: false
|
|
29106
|
-
}
|
|
29107
|
-
});
|
|
29108
|
-
};
|
|
29109
|
-
var handleContextMenuSelect = function handleContextMenuSelect(optionId) {
|
|
29110
|
-
updateItemDetails({
|
|
29111
|
-
item: item,
|
|
29112
|
-
contextMenu: {
|
|
29113
|
-
visible: false
|
|
29114
|
-
}
|
|
29115
|
-
});
|
|
29116
|
-
if (item) {
|
|
29117
|
-
onSelected == null ? void 0 : onSelected(optionId, item);
|
|
29118
|
-
}
|
|
29119
|
-
};
|
|
29120
|
-
var handleOutsideClick = function handleOutsideClick() {
|
|
29121
|
-
updateItemDetails({
|
|
29122
|
-
item: item,
|
|
29123
|
-
contextMenu: {
|
|
29124
|
-
visible: false
|
|
29125
|
-
}
|
|
29126
|
-
});
|
|
29127
|
-
};
|
|
29128
|
-
// monitor why mobileVisible is not working
|
|
29129
|
-
return React__default.createElement(React__default.Fragment, null, ((_itemDetails$tooltip = itemDetails.tooltip) == null ? void 0 : _itemDetails$tooltip.visible) && item && !isFocused && React__default.createElement(ItemTooltip, {
|
|
29130
|
-
item: item,
|
|
29131
|
-
atlasIMG: atlasIMG,
|
|
29132
|
-
atlasJSON: atlasJSON,
|
|
29133
|
-
equipmentSet: equipmentSet
|
|
29134
|
-
}), ((_itemDetails$tooltip2 = itemDetails.tooltip) == null ? void 0 : _itemDetails$tooltip2.mobileVisible) && item && React__default.createElement(MobileItemTooltip, {
|
|
29135
|
-
item: item,
|
|
29136
|
-
atlasIMG: atlasIMG,
|
|
29137
|
-
atlasJSON: atlasJSON,
|
|
29138
|
-
equipmentSet: equipmentSet,
|
|
29139
|
-
closeTooltip: handleCloseTooltip,
|
|
29140
|
-
scale: dragScale,
|
|
29141
|
-
options: ((_itemDetails$contextM = itemDetails.contextMenu) == null ? void 0 : _itemDetails$contextM.actions) || [],
|
|
29142
|
-
onSelected: handleContextMenuSelect
|
|
29143
|
-
}), !isContextMenuDisabled && ((_itemDetails$contextM2 = itemDetails.contextMenu) == null ? void 0 : _itemDetails$contextM2.visible) && itemDetails.contextMenu.actions && React__default.createElement(RelativeListMenu, {
|
|
29144
|
-
options: itemDetails.contextMenu.actions,
|
|
29145
|
-
onSelected: handleContextMenuSelect,
|
|
29146
|
-
onOutsideClick: handleOutsideClick,
|
|
29147
|
-
pos: itemDetails.contextMenu.position
|
|
29148
|
-
}));
|
|
29149
|
-
};
|
|
29150
|
-
|
|
29151
29092
|
var EquipmentSet = function EquipmentSet(_ref) {
|
|
29152
29093
|
var equipmentSet = _ref.equipmentSet,
|
|
29153
29094
|
onClose = _ref.onClose,
|
|
29154
29095
|
_onMouseOver = _ref.onMouseOver,
|
|
29096
|
+
_onSelected = _ref.onSelected,
|
|
29155
29097
|
onItemClick = _ref.onItemClick,
|
|
29156
29098
|
atlasIMG = _ref.atlasIMG,
|
|
29157
29099
|
atlasJSON = _ref.atlasJSON,
|
|
@@ -29160,11 +29102,11 @@ var EquipmentSet = function EquipmentSet(_ref) {
|
|
|
29160
29102
|
onItemPlaceDrop = _ref.onItemPlaceDrop,
|
|
29161
29103
|
onItemOutsideDrop = _ref.onItemOutsideDrop,
|
|
29162
29104
|
checkIfItemCanBeMoved = _ref.checkIfItemCanBeMoved,
|
|
29105
|
+
checkIfItemShouldDragEnd = _ref.checkIfItemShouldDragEnd,
|
|
29163
29106
|
scale = _ref.scale,
|
|
29164
29107
|
initialPosition = _ref.initialPosition,
|
|
29165
29108
|
onPositionChangeEnd = _ref.onPositionChangeEnd,
|
|
29166
|
-
onPositionChangeStart = _ref.onPositionChangeStart
|
|
29167
|
-
_onSelected = _ref.onSelected;
|
|
29109
|
+
onPositionChangeStart = _ref.onPositionChangeStart;
|
|
29168
29110
|
var neck = equipmentSet.neck,
|
|
29169
29111
|
leftHand = equipmentSet.leftHand,
|
|
29170
29112
|
ring = equipmentSet.ring,
|
|
@@ -29177,10 +29119,6 @@ var EquipmentSet = function EquipmentSet(_ref) {
|
|
|
29177
29119
|
accessory = equipmentSet.accessory;
|
|
29178
29120
|
var equipmentData = [neck, leftHand, ring, head, armor, legs, boot, inventory, rightHand, accessory];
|
|
29179
29121
|
var equipmentMaskSlots = [shared.ItemSlotType.Neck, shared.ItemSlotType.LeftHand, shared.ItemSlotType.Ring, shared.ItemSlotType.Head, shared.ItemSlotType.Torso, shared.ItemSlotType.Legs, shared.ItemSlotType.Feet, shared.ItemSlotType.Inventory, shared.ItemSlotType.RightHand, shared.ItemSlotType.Accessory];
|
|
29180
|
-
var _useItemSlotDragging = useItemSlotDragging(),
|
|
29181
|
-
dragState = _useItemSlotDragging.dragState;
|
|
29182
|
-
var _useItemSlotTooltip = useItemSlotTooltip(),
|
|
29183
|
-
updateItemDetails = _useItemSlotTooltip.updateItemDetails;
|
|
29184
29122
|
var onRenderEquipmentSlotRange = function onRenderEquipmentSlotRange(start, end) {
|
|
29185
29123
|
var equipmentRange = equipmentData.slice(start, end);
|
|
29186
29124
|
var slotMaksRange = equipmentMaskSlots.slice(start, end);
|
|
@@ -29201,6 +29139,9 @@ var EquipmentSet = function EquipmentSet(_ref) {
|
|
|
29201
29139
|
onPointerDown: function onPointerDown(itemType, ContainerType) {
|
|
29202
29140
|
if (onItemClick) onItemClick(itemType, item, ContainerType);
|
|
29203
29141
|
},
|
|
29142
|
+
onSelected: function onSelected(optionId) {
|
|
29143
|
+
if (_onSelected) _onSelected(optionId);
|
|
29144
|
+
},
|
|
29204
29145
|
onDragStart: function onDragStart(item, slotIndex, itemContainerType) {
|
|
29205
29146
|
if (!item) {
|
|
29206
29147
|
return;
|
|
@@ -29212,6 +29153,7 @@ var EquipmentSet = function EquipmentSet(_ref) {
|
|
|
29212
29153
|
},
|
|
29213
29154
|
dragScale: scale,
|
|
29214
29155
|
checkIfItemCanBeMoved: checkIfItemCanBeMoved,
|
|
29156
|
+
checkIfItemShouldDragEnd: checkIfItemShouldDragEnd,
|
|
29215
29157
|
onPlaceDrop: function onPlaceDrop(item, slotIndex, itemContainerType) {
|
|
29216
29158
|
if (onItemPlaceDrop) onItemPlaceDrop(item, slotIndex, itemContainerType);
|
|
29217
29159
|
},
|
|
@@ -29223,7 +29165,7 @@ var EquipmentSet = function EquipmentSet(_ref) {
|
|
|
29223
29165
|
});
|
|
29224
29166
|
});
|
|
29225
29167
|
};
|
|
29226
|
-
return React__default.createElement(
|
|
29168
|
+
return React__default.createElement(DraggingProvider, null, React__default.createElement(DraggedItem, {
|
|
29227
29169
|
atlasIMG: atlasIMG,
|
|
29228
29170
|
atlasJSON: atlasJSON,
|
|
29229
29171
|
scale: scale
|
|
@@ -29241,23 +29183,7 @@ var EquipmentSet = function EquipmentSet(_ref) {
|
|
|
29241
29183
|
onPositionChangeStart: onPositionChangeStart
|
|
29242
29184
|
}, React__default.createElement(EquipmentSetContainer, {
|
|
29243
29185
|
className: "equipment-container-body"
|
|
29244
|
-
}, React__default.createElement(EquipmentColumn, null, onRenderEquipmentSlotRange(0, 3)), React__default.createElement(EquipmentColumn, null, onRenderEquipmentSlotRange(3, 7)), React__default.createElement(EquipmentColumn, null, onRenderEquipmentSlotRange(7, 10))))
|
|
29245
|
-
isFocused: dragState.isFocused,
|
|
29246
|
-
isContextMenuDisabled: shared.isMobile(),
|
|
29247
|
-
dragScale: scale,
|
|
29248
|
-
onSelected: function onSelected(optionId, item) {
|
|
29249
|
-
updateItemDetails({
|
|
29250
|
-
item: item,
|
|
29251
|
-
contextMenu: {
|
|
29252
|
-
visible: false
|
|
29253
|
-
}
|
|
29254
|
-
});
|
|
29255
|
-
if (_onSelected) _onSelected(optionId);
|
|
29256
|
-
},
|
|
29257
|
-
atlasIMG: atlasIMG,
|
|
29258
|
-
atlasJSON: atlasJSON,
|
|
29259
|
-
equipmentSet: equipmentSet
|
|
29260
|
-
})));
|
|
29186
|
+
}, React__default.createElement(EquipmentColumn, null, onRenderEquipmentSlotRange(0, 3)), React__default.createElement(EquipmentColumn, null, onRenderEquipmentSlotRange(3, 7)), React__default.createElement(EquipmentColumn, null, onRenderEquipmentSlotRange(7, 10)))));
|
|
29261
29187
|
};
|
|
29262
29188
|
var EquipmentSetContainer = /*#__PURE__*/styled__default.div.withConfig({
|
|
29263
29189
|
displayName: "EquipmentSet__EquipmentSetContainer",
|
|
@@ -30687,6 +30613,7 @@ var ItemContainer$1 = function ItemContainer(_ref) {
|
|
|
30687
30613
|
_onOutsideDrop = _ref.onOutsideDrop,
|
|
30688
30614
|
checkIfItemCanBeMoved = _ref.checkIfItemCanBeMoved,
|
|
30689
30615
|
initialPosition = _ref.initialPosition,
|
|
30616
|
+
checkIfItemShouldDragEnd = _ref.checkIfItemShouldDragEnd,
|
|
30690
30617
|
scale = _ref.scale,
|
|
30691
30618
|
shortcuts = _ref.shortcuts,
|
|
30692
30619
|
setItemShortcut = _ref.setItemShortcut,
|
|
@@ -30767,10 +30694,14 @@ var ItemContainer$1 = function ItemContainer(_ref) {
|
|
|
30767
30694
|
onItemClick(item, itemType, containerType);
|
|
30768
30695
|
}
|
|
30769
30696
|
},
|
|
30697
|
+
onSelected: function onSelected(optionId, item) {
|
|
30698
|
+
if (_onSelected) _onSelected(optionId, item);
|
|
30699
|
+
},
|
|
30770
30700
|
onDragStart: onDragStart,
|
|
30771
30701
|
onDragEnd: onDragEnd,
|
|
30772
30702
|
dragScale: scale,
|
|
30773
30703
|
checkIfItemCanBeMoved: checkIfItemCanBeMoved,
|
|
30704
|
+
checkIfItemShouldDragEnd: checkIfItemShouldDragEnd,
|
|
30774
30705
|
openQuantitySelector: function openQuantitySelector(maxQuantity, callback) {
|
|
30775
30706
|
setQuantitySelect({
|
|
30776
30707
|
isOpen: true,
|
|
@@ -30795,17 +30726,14 @@ var ItemContainer$1 = function ItemContainer(_ref) {
|
|
|
30795
30726
|
atlasIMG: atlasIMG,
|
|
30796
30727
|
atlasJSON: atlasJSON,
|
|
30797
30728
|
isSelectingShortcut: settingShortcutIndex !== -1,
|
|
30729
|
+
equipmentSet: equipmentSet,
|
|
30798
30730
|
setItemShortcut: type === shared.ItemContainerType.Inventory ? handleSetShortcut : undefined,
|
|
30799
30731
|
isDepotSystem: isDepotSystem
|
|
30800
30732
|
}));
|
|
30801
30733
|
}
|
|
30802
30734
|
return slots;
|
|
30803
30735
|
};
|
|
30804
|
-
|
|
30805
|
-
updateItemDetails = _useItemSlotTooltip.updateItemDetails;
|
|
30806
|
-
var _useItemSlotDragging = useItemSlotDragging(),
|
|
30807
|
-
dragState = _useItemSlotDragging.dragState;
|
|
30808
|
-
return React__default.createElement(ItemSlotDraggingProvider, null, React__default.createElement(ItemSlotTooltipProvider, null, React__default.createElement(DraggedItem, {
|
|
30736
|
+
return React__default.createElement(DraggingProvider, null, React__default.createElement(DraggedItem, {
|
|
30809
30737
|
atlasIMG: atlasIMG,
|
|
30810
30738
|
atlasJSON: atlasJSON,
|
|
30811
30739
|
scale: scale
|
|
@@ -30830,26 +30758,10 @@ var ItemContainer$1 = function ItemContainer(_ref) {
|
|
|
30830
30758
|
ref: containerRef,
|
|
30831
30759
|
isScrollable: itemContainer.slotQty > MIN_SLOTS_FOR_SCROLL,
|
|
30832
30760
|
isFullScreen: isFullScreen
|
|
30833
|
-
}, onRenderSlots())), React__default.createElement(
|
|
30834
|
-
isFocused: dragState.isFocused,
|
|
30835
|
-
isContextMenuDisabled: disableContextMenu,
|
|
30836
|
-
dragScale: scale,
|
|
30837
|
-
onSelected: function onSelected(optionId, item) {
|
|
30838
|
-
updateItemDetails({
|
|
30839
|
-
item: item,
|
|
30840
|
-
contextMenu: {
|
|
30841
|
-
visible: false
|
|
30842
|
-
}
|
|
30843
|
-
});
|
|
30844
|
-
if (_onSelected) _onSelected(optionId, item);
|
|
30845
|
-
},
|
|
30846
|
-
atlasIMG: atlasIMG,
|
|
30847
|
-
atlasJSON: atlasJSON,
|
|
30848
|
-
equipmentSet: equipmentSet
|
|
30849
|
-
}), quantitySelect.isOpen && React__default.createElement(ItemQuantitySelectorModal, {
|
|
30761
|
+
}, onRenderSlots())), quantitySelect.isOpen && React__default.createElement(ItemQuantitySelectorModal, {
|
|
30850
30762
|
quantitySelect: quantitySelect,
|
|
30851
30763
|
setQuantitySelect: setQuantitySelect
|
|
30852
|
-
}))
|
|
30764
|
+
}));
|
|
30853
30765
|
};
|
|
30854
30766
|
var ItemsContainer = /*#__PURE__*/styled__default.div.withConfig({
|
|
30855
30767
|
displayName: "ItemContainer__ItemsContainer",
|