@rpg-engine/long-bow 0.7.52 → 0.7.60
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 +1 -2
- package/dist/components/Item/Inventory/hooks/useItemSlotDragAndDrop.d.ts +43 -0
- package/dist/long-bow.cjs.development.js +281 -282
- 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 +281 -282
- package/dist/long-bow.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/components/Item/Inventory/ItemContainer.tsx +0 -2
- package/src/components/Item/Inventory/ItemSlot.tsx +106 -286
- package/src/components/Item/Inventory/hooks/useItemSlotDragAndDrop.ts +226 -0
|
@@ -27741,6 +27741,200 @@ var DraggingProvider = function DraggingProvider(_ref) {
|
|
|
27741
27741
|
}, children);
|
|
27742
27742
|
};
|
|
27743
27743
|
|
|
27744
|
+
var useItemSlotDragAndDrop = function useItemSlotDragAndDrop(_ref) {
|
|
27745
|
+
var isDepotSystem = _ref.isDepotSystem,
|
|
27746
|
+
item = _ref.item,
|
|
27747
|
+
onDrop = _ref.onDrop,
|
|
27748
|
+
onDragEnd = _ref.onDragEnd,
|
|
27749
|
+
checkIfItemCanBeMoved = _ref.checkIfItemCanBeMoved,
|
|
27750
|
+
checkIfItemShouldDragEnd = _ref.checkIfItemShouldDragEnd,
|
|
27751
|
+
setItemShortcut = _ref.setItemShortcut,
|
|
27752
|
+
isSelectingShortcut = _ref.isSelectingShortcut,
|
|
27753
|
+
onDragStart = _ref.onDragStart,
|
|
27754
|
+
onPointerDown = _ref.onPointerDown,
|
|
27755
|
+
containerType = _ref.containerType,
|
|
27756
|
+
slotIndex = _ref.slotIndex,
|
|
27757
|
+
openQuantitySelector = _ref.openQuantitySelector,
|
|
27758
|
+
isContextMenuDisabled = _ref.isContextMenuDisabled,
|
|
27759
|
+
setTooltipState = _ref.setTooltipState,
|
|
27760
|
+
setContextMenuState = _ref.setContextMenuState;
|
|
27761
|
+
var dragContainer = React.useRef(null);
|
|
27762
|
+
var _useDragging = useDragging(),
|
|
27763
|
+
draggingItem = _useDragging.item,
|
|
27764
|
+
setDraggingItem = _useDragging.setDraggingItem;
|
|
27765
|
+
var _useState = React.useState({
|
|
27766
|
+
isFocused: false,
|
|
27767
|
+
wasDragged: false,
|
|
27768
|
+
position: {
|
|
27769
|
+
x: 0,
|
|
27770
|
+
y: 0
|
|
27771
|
+
},
|
|
27772
|
+
dropPosition: null
|
|
27773
|
+
}),
|
|
27774
|
+
dragState = _useState[0],
|
|
27775
|
+
setDragState = _useState[1];
|
|
27776
|
+
React.useEffect(function () {
|
|
27777
|
+
setDragState(function (prev) {
|
|
27778
|
+
return _extends({}, prev, {
|
|
27779
|
+
position: {
|
|
27780
|
+
x: 0,
|
|
27781
|
+
y: 0
|
|
27782
|
+
},
|
|
27783
|
+
isFocused: false
|
|
27784
|
+
});
|
|
27785
|
+
});
|
|
27786
|
+
}, [item, isDepotSystem]);
|
|
27787
|
+
React.useEffect(function () {
|
|
27788
|
+
if (onDrop && item && dragState.dropPosition) {
|
|
27789
|
+
onDrop(item, dragState.dropPosition);
|
|
27790
|
+
setDragState(function (prev) {
|
|
27791
|
+
return _extends({}, prev, {
|
|
27792
|
+
dropPosition: null
|
|
27793
|
+
});
|
|
27794
|
+
});
|
|
27795
|
+
}
|
|
27796
|
+
}, [dragState.dropPosition, item, onDrop]);
|
|
27797
|
+
var getContainerBounds = React.useCallback(function () {
|
|
27798
|
+
var container = dragContainer.current;
|
|
27799
|
+
if (!container) return {
|
|
27800
|
+
left: 0,
|
|
27801
|
+
top: 0,
|
|
27802
|
+
right: 0,
|
|
27803
|
+
bottom: 0
|
|
27804
|
+
};
|
|
27805
|
+
var rect = container.getBoundingClientRect();
|
|
27806
|
+
return {
|
|
27807
|
+
left: rect.left,
|
|
27808
|
+
top: rect.top,
|
|
27809
|
+
right: window.innerWidth - rect.right,
|
|
27810
|
+
bottom: window.innerHeight - rect.bottom
|
|
27811
|
+
};
|
|
27812
|
+
}, []);
|
|
27813
|
+
var resetDragState = React.useCallback(function () {
|
|
27814
|
+
setTooltipState(function (prev) {
|
|
27815
|
+
return _extends({}, prev, {
|
|
27816
|
+
visible: false
|
|
27817
|
+
});
|
|
27818
|
+
});
|
|
27819
|
+
setDragState(function (prev) {
|
|
27820
|
+
return _extends({}, prev, {
|
|
27821
|
+
wasDragged: false,
|
|
27822
|
+
isFocused: false,
|
|
27823
|
+
position: {
|
|
27824
|
+
x: 0,
|
|
27825
|
+
y: 0
|
|
27826
|
+
}
|
|
27827
|
+
});
|
|
27828
|
+
});
|
|
27829
|
+
}, [setTooltipState]);
|
|
27830
|
+
var handleSuccessfulDrag = React.useCallback(function (quantity) {
|
|
27831
|
+
resetDragState();
|
|
27832
|
+
if (quantity !== -1 && item) {
|
|
27833
|
+
onDragEnd == null ? void 0 : onDragEnd(quantity);
|
|
27834
|
+
}
|
|
27835
|
+
}, [item, onDragEnd, resetDragState]);
|
|
27836
|
+
var onDraggableStart = React.useCallback(function () {
|
|
27837
|
+
if (!item || isSelectingShortcut) return;
|
|
27838
|
+
if (onDragStart && containerType) {
|
|
27839
|
+
onDragStart(item, slotIndex, containerType);
|
|
27840
|
+
}
|
|
27841
|
+
}, [item, isSelectingShortcut, onDragStart, containerType, slotIndex]);
|
|
27842
|
+
var onDraggableProgress = React.useCallback(function (_e, data) {
|
|
27843
|
+
var _dragState$position = dragState.position,
|
|
27844
|
+
x = _dragState$position.x,
|
|
27845
|
+
y = _dragState$position.y;
|
|
27846
|
+
if (Math.abs(data.x - x) > 5 || Math.abs(data.y - y) > 5) {
|
|
27847
|
+
setDragState(function (prev) {
|
|
27848
|
+
return _extends({}, prev, {
|
|
27849
|
+
wasDragged: true,
|
|
27850
|
+
isFocused: true
|
|
27851
|
+
});
|
|
27852
|
+
});
|
|
27853
|
+
}
|
|
27854
|
+
if (!draggingItem) {
|
|
27855
|
+
setDraggingItem(item);
|
|
27856
|
+
}
|
|
27857
|
+
}, [dragState.position, draggingItem, item, setDraggingItem]);
|
|
27858
|
+
var onDraggableStop = React.useCallback(function (e, data) {
|
|
27859
|
+
setTimeout(function () {
|
|
27860
|
+
setDraggingItem(null);
|
|
27861
|
+
}, 50);
|
|
27862
|
+
var target = e.target;
|
|
27863
|
+
if (!target) return;
|
|
27864
|
+
target.classList.remove('react-draggable-dragging');
|
|
27865
|
+
if (target != null && target.id.includes('shortcutSetter') && setItemShortcut && item) {
|
|
27866
|
+
var index = parseInt(target.id.split('_')[1]);
|
|
27867
|
+
if (!isNaN(index)) {
|
|
27868
|
+
setItemShortcut(item, index);
|
|
27869
|
+
}
|
|
27870
|
+
}
|
|
27871
|
+
if (dragState.wasDragged && item && !isSelectingShortcut) {
|
|
27872
|
+
var classes = Array.from(target.classList);
|
|
27873
|
+
var isOutsideDrop = classes.some(function (elm) {
|
|
27874
|
+
return elm.includes('rpgui-content');
|
|
27875
|
+
}) || classes.length === 0;
|
|
27876
|
+
if (isOutsideDrop) {
|
|
27877
|
+
setDragState(function (prev) {
|
|
27878
|
+
return _extends({}, prev, {
|
|
27879
|
+
dropPosition: {
|
|
27880
|
+
x: data.x,
|
|
27881
|
+
y: data.y
|
|
27882
|
+
}
|
|
27883
|
+
});
|
|
27884
|
+
});
|
|
27885
|
+
}
|
|
27886
|
+
setDragState(function (prev) {
|
|
27887
|
+
return _extends({}, prev, {
|
|
27888
|
+
wasDragged: false
|
|
27889
|
+
});
|
|
27890
|
+
});
|
|
27891
|
+
setTimeout(function () {
|
|
27892
|
+
if (checkIfItemCanBeMoved != null && checkIfItemCanBeMoved() && (!checkIfItemShouldDragEnd || checkIfItemShouldDragEnd())) {
|
|
27893
|
+
if (item.stackQty && item.stackQty !== 1 && openQuantitySelector) {
|
|
27894
|
+
openQuantitySelector(item.stackQty, handleSuccessfulDrag);
|
|
27895
|
+
} else {
|
|
27896
|
+
handleSuccessfulDrag(item.stackQty);
|
|
27897
|
+
}
|
|
27898
|
+
} else {
|
|
27899
|
+
resetDragState();
|
|
27900
|
+
}
|
|
27901
|
+
}, 50);
|
|
27902
|
+
} else if (item) {
|
|
27903
|
+
var isTouch = e.type === 'touchend';
|
|
27904
|
+
if (!isContextMenuDisabled && isTouch && !isSelectingShortcut) {
|
|
27905
|
+
setTooltipState(function (prev) {
|
|
27906
|
+
return _extends({}, prev, {
|
|
27907
|
+
mobileVisible: true
|
|
27908
|
+
});
|
|
27909
|
+
});
|
|
27910
|
+
} else if (!isContextMenuDisabled && !isSelectingShortcut && !isTouch) {
|
|
27911
|
+
var event = e;
|
|
27912
|
+
setContextMenuState(function (prev) {
|
|
27913
|
+
return {
|
|
27914
|
+
visible: !prev.visible,
|
|
27915
|
+
position: {
|
|
27916
|
+
x: event.clientX - 10,
|
|
27917
|
+
y: event.clientY - 5
|
|
27918
|
+
}
|
|
27919
|
+
};
|
|
27920
|
+
});
|
|
27921
|
+
}
|
|
27922
|
+
onPointerDown == null ? void 0 : onPointerDown(item.type, containerType != null ? containerType : null, item);
|
|
27923
|
+
}
|
|
27924
|
+
}, [dragState.wasDragged, item, isSelectingShortcut, checkIfItemCanBeMoved, checkIfItemShouldDragEnd, openQuantitySelector, handleSuccessfulDrag, resetDragState, isContextMenuDisabled, setTooltipState, setContextMenuState, onPointerDown, containerType, setItemShortcut]);
|
|
27925
|
+
return {
|
|
27926
|
+
dragContainer: dragContainer,
|
|
27927
|
+
dragState: dragState,
|
|
27928
|
+
draggingItem: draggingItem,
|
|
27929
|
+
setDraggingItem: setDraggingItem,
|
|
27930
|
+
getContainerBounds: getContainerBounds,
|
|
27931
|
+
onDraggableStart: onDraggableStart,
|
|
27932
|
+
onDraggableProgress: onDraggableProgress,
|
|
27933
|
+
onDraggableStop: onDraggableStop,
|
|
27934
|
+
resetItem: resetDragState
|
|
27935
|
+
};
|
|
27936
|
+
};
|
|
27937
|
+
|
|
27744
27938
|
var generateContextMenuListOptions = function generateContextMenuListOptions(actionsByTypeList) {
|
|
27745
27939
|
var contextMenu = actionsByTypeList.map(function (action) {
|
|
27746
27940
|
return {
|
|
@@ -27884,7 +28078,7 @@ var ItemSlot = /*#__PURE__*/React__default.memo( /*#__PURE__*/mobxReactLite.obse
|
|
|
27884
28078
|
containerType = _ref.itemContainerType,
|
|
27885
28079
|
slotSpriteMask = _ref.slotSpriteMask,
|
|
27886
28080
|
_onMouseOver = _ref.onMouseOver,
|
|
27887
|
-
|
|
28081
|
+
onMouseOut = _ref.onMouseOut,
|
|
27888
28082
|
onPointerDown = _ref.onPointerDown,
|
|
27889
28083
|
_onSelected = _ref.onSelected,
|
|
27890
28084
|
atlasJSON = _ref.atlasJSON,
|
|
@@ -27897,7 +28091,6 @@ var ItemSlot = /*#__PURE__*/React__default.memo( /*#__PURE__*/mobxReactLite.obse
|
|
|
27897
28091
|
onDrop = _ref.onOutsideDrop,
|
|
27898
28092
|
checkIfItemCanBeMoved = _ref.checkIfItemCanBeMoved,
|
|
27899
28093
|
openQuantitySelector = _ref.openQuantitySelector,
|
|
27900
|
-
checkIfItemShouldDragEnd = _ref.checkIfItemShouldDragEnd,
|
|
27901
28094
|
dragScale = _ref.dragScale,
|
|
27902
28095
|
isSelectingShortcut = _ref.isSelectingShortcut,
|
|
27903
28096
|
equipmentSet = _ref.equipmentSet,
|
|
@@ -27918,303 +28111,113 @@ var ItemSlot = /*#__PURE__*/React__default.memo( /*#__PURE__*/mobxReactLite.obse
|
|
|
27918
28111
|
}),
|
|
27919
28112
|
contextMenuState = _useState2[0],
|
|
27920
28113
|
setContextMenuState = _useState2[1];
|
|
27921
|
-
var _useState3 = React.useState(
|
|
27922
|
-
|
|
27923
|
-
|
|
27924
|
-
|
|
27925
|
-
|
|
27926
|
-
|
|
27927
|
-
},
|
|
27928
|
-
|
|
28114
|
+
var _useState3 = React.useState([]),
|
|
28115
|
+
contextActions = _useState3[0],
|
|
28116
|
+
setContextActions = _useState3[1];
|
|
28117
|
+
var _useItemSlotDragAndDr = useItemSlotDragAndDrop({
|
|
28118
|
+
isDepotSystem: !!isDepotSystem,
|
|
28119
|
+
item: item,
|
|
28120
|
+
onDrop: onDrop != null ? onDrop : function () {},
|
|
28121
|
+
onDragEnd: onDragEnd,
|
|
28122
|
+
checkIfItemCanBeMoved: checkIfItemCanBeMoved,
|
|
28123
|
+
setItemShortcut: setItemShortcut,
|
|
28124
|
+
isSelectingShortcut: isSelectingShortcut,
|
|
28125
|
+
onDragStart: onDragStart,
|
|
28126
|
+
onPointerDown: onPointerDown,
|
|
28127
|
+
containerType: containerType,
|
|
28128
|
+
slotIndex: slotIndex,
|
|
28129
|
+
openQuantitySelector: openQuantitySelector != null ? openQuantitySelector : function () {},
|
|
28130
|
+
isContextMenuDisabled: isContextMenuDisabled,
|
|
28131
|
+
setTooltipState: setTooltipState,
|
|
28132
|
+
contextMenuState: contextMenuState,
|
|
28133
|
+
setContextMenuState: setContextMenuState
|
|
27929
28134
|
}),
|
|
27930
|
-
|
|
27931
|
-
|
|
27932
|
-
|
|
27933
|
-
|
|
27934
|
-
|
|
27935
|
-
|
|
27936
|
-
|
|
27937
|
-
contextActions = _useState4[0],
|
|
27938
|
-
setContextActions = _useState4[1];
|
|
27939
|
-
var _useState5 = React.useState(null),
|
|
27940
|
-
touchStartTime = _useState5[0],
|
|
27941
|
-
setTouchStartTime = _useState5[1];
|
|
27942
|
-
var _useState6 = React.useState(null),
|
|
27943
|
-
touchStartPosition = _useState6[0],
|
|
27944
|
-
setTouchStartPosition = _useState6[1];
|
|
28135
|
+
dragContainer = _useItemSlotDragAndDr.dragContainer,
|
|
28136
|
+
dragState = _useItemSlotDragAndDr.dragState,
|
|
28137
|
+
draggingItem = _useItemSlotDragAndDr.draggingItem,
|
|
28138
|
+
getContainerBounds = _useItemSlotDragAndDr.getContainerBounds,
|
|
28139
|
+
onDraggableStart = _useItemSlotDragAndDr.onDraggableStart,
|
|
28140
|
+
onDraggableProgress = _useItemSlotDragAndDr.onDraggableProgress,
|
|
28141
|
+
onDraggableStop = _useItemSlotDragAndDr.onDraggableStop;
|
|
27945
28142
|
React.useEffect(function () {
|
|
27946
|
-
setDragState(function (prev) {
|
|
27947
|
-
return _extends({}, prev, {
|
|
27948
|
-
position: {
|
|
27949
|
-
x: 0,
|
|
27950
|
-
y: 0
|
|
27951
|
-
},
|
|
27952
|
-
isFocused: false
|
|
27953
|
-
});
|
|
27954
|
-
});
|
|
27955
28143
|
if (item && containerType) {
|
|
27956
28144
|
setContextActions(generateContextMenu(item, containerType, isDepotSystem));
|
|
27957
28145
|
}
|
|
27958
28146
|
}, [item, isDepotSystem]);
|
|
27959
|
-
|
|
27960
|
-
|
|
27961
|
-
|
|
27962
|
-
|
|
27963
|
-
|
|
27964
|
-
|
|
27965
|
-
|
|
27966
|
-
|
|
27967
|
-
|
|
27968
|
-
}, [dragState.dropPosition]);
|
|
27969
|
-
var getContainerBounds = React.useCallback(function () {
|
|
27970
|
-
var container = dragContainer.current;
|
|
27971
|
-
if (!container) return {
|
|
27972
|
-
left: 0,
|
|
27973
|
-
top: 0,
|
|
27974
|
-
right: 0,
|
|
27975
|
-
bottom: 0
|
|
27976
|
-
};
|
|
27977
|
-
var rect = container.getBoundingClientRect();
|
|
27978
|
-
return {
|
|
27979
|
-
left: rect.left,
|
|
27980
|
-
top: rect.top,
|
|
27981
|
-
right: window.innerWidth - rect.right,
|
|
27982
|
-
bottom: window.innerHeight - rect.bottom
|
|
27983
|
-
};
|
|
27984
|
-
}, [dragContainer]);
|
|
27985
|
-
var resetItem = function resetItem() {
|
|
27986
|
-
setTooltipState(function (prev) {
|
|
27987
|
-
return _extends({}, prev, {
|
|
27988
|
-
visible: false
|
|
27989
|
-
});
|
|
27990
|
-
});
|
|
27991
|
-
setDragState(function (prev) {
|
|
27992
|
-
return _extends({}, prev, {
|
|
27993
|
-
wasDragged: false
|
|
27994
|
-
});
|
|
27995
|
-
});
|
|
27996
|
-
};
|
|
27997
|
-
var onSuccessfulDrag = function onSuccessfulDrag(quantity) {
|
|
27998
|
-
resetItem();
|
|
27999
|
-
if (quantity === -1) {
|
|
28000
|
-
setDragState(function (prev) {
|
|
28001
|
-
return _extends({}, prev, {
|
|
28002
|
-
position: {
|
|
28003
|
-
x: 0,
|
|
28004
|
-
y: 0
|
|
28005
|
-
},
|
|
28006
|
-
isFocused: false
|
|
28007
|
-
});
|
|
28008
|
-
});
|
|
28009
|
-
} else if (item) {
|
|
28010
|
-
onDragEnd == null ? void 0 : onDragEnd(quantity);
|
|
28011
|
-
}
|
|
28012
|
-
};
|
|
28013
|
-
var onDraggableStop = function onDraggableStop(e, data) {
|
|
28014
|
-
setDraggingItem(null);
|
|
28015
|
-
var target = e.target;
|
|
28016
|
-
if (!target) return;
|
|
28017
|
-
if (target != null && target.id.includes('shortcutSetter') && setItemShortcut && item) {
|
|
28018
|
-
var index = parseInt(target.id.split('_')[1]);
|
|
28019
|
-
if (!isNaN(index)) {
|
|
28020
|
-
setItemShortcut(item, index);
|
|
28021
|
-
}
|
|
28022
|
-
}
|
|
28023
|
-
// remove the class react-draggable-dragging from the element
|
|
28024
|
-
// to prevent the item from being dragged again
|
|
28025
|
-
target.classList.remove('react-draggable-dragging');
|
|
28026
|
-
var isTouch = e.type.startsWith('touch');
|
|
28027
|
-
if (isTouch) {
|
|
28028
|
-
var touchEvent = e;
|
|
28029
|
-
var touch = touchEvent.changedTouches[0];
|
|
28030
|
-
var touchEndTime = new Date().getTime();
|
|
28031
|
-
var touchDuration = touchStartTime ? touchEndTime - touchStartTime : 0;
|
|
28032
|
-
// Check if it's a short tap (less than 200ms) and hasn't moved much
|
|
28033
|
-
var isShortTap = touchDuration < 200;
|
|
28034
|
-
var hasMovedSignificantly = touchStartPosition && (Math.abs(touch.clientX - touchStartPosition.x) > 10 || Math.abs(touch.clientY - touchStartPosition.y) > 10);
|
|
28035
|
-
if (isShortTap && !hasMovedSignificantly) {
|
|
28036
|
-
// Handle as a tap/click
|
|
28037
|
-
if (item) {
|
|
28038
|
-
setTooltipState(function (prev) {
|
|
28039
|
-
return _extends({}, prev, {
|
|
28040
|
-
mobileVisible: true
|
|
28041
|
-
});
|
|
28042
|
-
});
|
|
28043
|
-
onPointerDown(item.type, containerType != null ? containerType : null, item);
|
|
28044
|
-
}
|
|
28045
|
-
return;
|
|
28046
|
-
}
|
|
28047
|
-
}
|
|
28048
|
-
// Threshold for considering a tap/click as a drag
|
|
28049
|
-
var dragThreshold = 5; // pixels
|
|
28050
|
-
var isDrag = Math.abs(data.x) > dragThreshold || Math.abs(data.y) > dragThreshold;
|
|
28051
|
-
if (dragState.wasDragged && item && !isSelectingShortcut) {
|
|
28052
|
-
var _e$target;
|
|
28053
|
-
//@ts-ignore
|
|
28054
|
-
var classes = Array.from((_e$target = e.target) == null ? void 0 : _e$target.classList);
|
|
28055
|
-
var isOutsideDrop = classes.some(function (elm) {
|
|
28056
|
-
return elm.includes('rpgui-content');
|
|
28057
|
-
}) || classes.length === 0;
|
|
28058
|
-
if (isOutsideDrop) {
|
|
28059
|
-
setDragState(function (prev) {
|
|
28060
|
-
return _extends({}, prev, {
|
|
28061
|
-
dropPosition: {
|
|
28062
|
-
x: data.x,
|
|
28063
|
-
y: data.y
|
|
28064
|
-
}
|
|
28065
|
-
});
|
|
28066
|
-
});
|
|
28067
|
-
}
|
|
28068
|
-
setDragState(function (prev) {
|
|
28069
|
-
return _extends({}, prev, {
|
|
28070
|
-
wasDragged: false
|
|
28071
|
-
});
|
|
28072
|
-
});
|
|
28073
|
-
var _target = dragContainer.current;
|
|
28074
|
-
if (!_target || !dragState.wasDragged) return;
|
|
28075
|
-
var style = window.getComputedStyle(_target);
|
|
28076
|
-
var matrix = new DOMMatrixReadOnly(style.transform);
|
|
28077
|
-
var x = matrix.m41;
|
|
28078
|
-
var y = matrix.m42;
|
|
28079
|
-
setDragState(function (prev) {
|
|
28080
|
-
return _extends({}, prev, {
|
|
28081
|
-
position: {
|
|
28082
|
-
x: x,
|
|
28083
|
-
y: y
|
|
28084
|
-
}
|
|
28085
|
-
});
|
|
28086
|
-
});
|
|
28087
|
-
setTimeout(function () {
|
|
28088
|
-
if (checkIfItemCanBeMoved && checkIfItemCanBeMoved()) {
|
|
28089
|
-
if (checkIfItemShouldDragEnd && !checkIfItemShouldDragEnd()) return;
|
|
28090
|
-
if (item.stackQty && item.stackQty !== 1 && openQuantitySelector) {
|
|
28091
|
-
openQuantitySelector(item.stackQty, onSuccessfulDrag);
|
|
28092
|
-
} else onSuccessfulDrag(item.stackQty);
|
|
28093
|
-
} else {
|
|
28094
|
-
resetItem();
|
|
28095
|
-
setDragState(function (prev) {
|
|
28096
|
-
return _extends({}, prev, {
|
|
28097
|
-
isFocused: false,
|
|
28098
|
-
position: {
|
|
28099
|
-
x: 0,
|
|
28100
|
-
y: 0
|
|
28101
|
-
}
|
|
28102
|
-
});
|
|
28103
|
-
});
|
|
28104
|
-
}
|
|
28105
|
-
}, 50);
|
|
28106
|
-
} else if (item) {
|
|
28107
|
-
if (isTouch && !isDrag) {
|
|
28108
|
-
setTooltipState(function (prev) {
|
|
28109
|
-
return _extends({}, prev, {
|
|
28110
|
-
mobileVisible: true
|
|
28111
|
-
});
|
|
28112
|
-
});
|
|
28113
|
-
} else if (!isTouch && !isContextMenuDisabled && !isSelectingShortcut) {
|
|
28114
|
-
setContextMenuState(function (prev) {
|
|
28115
|
-
return _extends({}, prev, {
|
|
28116
|
-
visible: !contextMenuState.visible
|
|
28117
|
-
});
|
|
28118
|
-
});
|
|
28119
|
-
var event = e;
|
|
28120
|
-
if (event.clientX && event.clientY) {
|
|
28121
|
-
setContextMenuState(function (prev) {
|
|
28122
|
-
return _extends({}, prev, {
|
|
28123
|
-
position: {
|
|
28124
|
-
x: event.clientX - 10,
|
|
28125
|
-
y: event.clientY - 5
|
|
28126
|
-
}
|
|
28127
|
-
});
|
|
28128
|
-
});
|
|
28129
|
-
}
|
|
28147
|
+
var bounds = getContainerBounds();
|
|
28148
|
+
var handleInteraction = React.useCallback(function (event) {
|
|
28149
|
+
event.stopPropagation();
|
|
28150
|
+
var _ref2 = 'touches' in event ? event.touches[0] : event,
|
|
28151
|
+
clientX = _ref2.clientX,
|
|
28152
|
+
clientY = _ref2.clientY;
|
|
28153
|
+
if (item && containerType) {
|
|
28154
|
+
if (onPlaceDrop && draggingItem) {
|
|
28155
|
+
onPlaceDrop(item, slotIndex, containerType);
|
|
28130
28156
|
}
|
|
28131
|
-
if (
|
|
28132
|
-
|
|
28133
|
-
onPointerDown(item.type, containerType != null ? containerType : null, item);
|
|
28157
|
+
if (onPointerDown && onDragStart === undefined && onDragEnd === undefined) {
|
|
28158
|
+
onPointerDown(item.type, containerType, item);
|
|
28134
28159
|
}
|
|
28135
28160
|
}
|
|
28136
|
-
|
|
28161
|
+
setTooltipState(function (prev) {
|
|
28137
28162
|
return _extends({}, prev, {
|
|
28138
|
-
|
|
28163
|
+
visible: true
|
|
28139
28164
|
});
|
|
28140
28165
|
});
|
|
28141
|
-
|
|
28142
|
-
};
|
|
28143
|
-
var
|
|
28144
|
-
|
|
28145
|
-
|
|
28146
|
-
|
|
28147
|
-
|
|
28148
|
-
|
|
28149
|
-
}
|
|
28150
|
-
};
|
|
28151
|
-
var onDraggableProgress = function onDraggableProgress(_e, data) {
|
|
28152
|
-
if (Math.abs(data.x - dragState.position.x) > 5 || Math.abs(data.y - dragState.position.y) > 5) {
|
|
28153
|
-
setDragState(function (prev) {
|
|
28154
|
-
return _extends({}, prev, {
|
|
28155
|
-
wasDragged: true,
|
|
28156
|
-
isFocused: true
|
|
28157
|
-
});
|
|
28166
|
+
_onMouseOver == null ? void 0 : _onMouseOver(event, slotIndex, item, clientX, clientY);
|
|
28167
|
+
}, [item, containerType, slotIndex, onPlaceDrop, onPointerDown, _onMouseOver, onDragStart, onDragEnd]);
|
|
28168
|
+
var handleInteractionEnd = React.useCallback(function (event) {
|
|
28169
|
+
event.preventDefault();
|
|
28170
|
+
event.stopPropagation();
|
|
28171
|
+
setTooltipState(function (prev) {
|
|
28172
|
+
return _extends({}, prev, {
|
|
28173
|
+
visible: false
|
|
28158
28174
|
});
|
|
28159
|
-
}
|
|
28160
|
-
if (!draggingItem) {
|
|
28161
|
-
setDraggingItem(item);
|
|
28162
|
-
}
|
|
28163
|
-
};
|
|
28164
|
-
var onTouchStart = function onTouchStart(e) {
|
|
28165
|
-
setTouchStartTime(new Date().getTime());
|
|
28166
|
-
setTouchStartPosition({
|
|
28167
|
-
x: e.touches[0].clientX,
|
|
28168
|
-
y: e.touches[0].clientY
|
|
28169
28175
|
});
|
|
28170
|
-
|
|
28171
|
-
|
|
28172
|
-
// Prevent default to stop potential unwanted behaviors
|
|
28173
|
-
e.preventDefault();
|
|
28174
|
-
var touch = e.changedTouches[0];
|
|
28175
|
-
var touchEndTime = new Date().getTime();
|
|
28176
|
-
var touchDuration = touchStartTime ? touchEndTime - touchStartTime : 0;
|
|
28177
|
-
// Check if it's a short tap (less than 200ms) and hasn't moved much
|
|
28178
|
-
var isShortTap = touchDuration < 200;
|
|
28179
|
-
var hasMovedSignificantly = touchStartPosition && (Math.abs(touch.clientX - touchStartPosition.x) > 10 || Math.abs(touch.clientY - touchStartPosition.y) > 10);
|
|
28180
|
-
if (isShortTap && !hasMovedSignificantly) {
|
|
28181
|
-
// Handle as a tap/click
|
|
28182
|
-
if (item) {
|
|
28183
|
-
setTooltipState(function (prev) {
|
|
28184
|
-
return _extends({}, prev, {
|
|
28185
|
-
mobileVisible: true
|
|
28186
|
-
});
|
|
28187
|
-
});
|
|
28188
|
-
onPointerDown(item.type, containerType != null ? containerType : null, item);
|
|
28189
|
-
}
|
|
28190
|
-
} else {
|
|
28176
|
+
onMouseOut == null ? void 0 : onMouseOut();
|
|
28177
|
+
if (event.type === 'touchend' && 'changedTouches' in event) {
|
|
28191
28178
|
var _document$elementFrom;
|
|
28192
|
-
|
|
28179
|
+
var _event$changedTouches = event.changedTouches[0],
|
|
28180
|
+
clientX = _event$changedTouches.clientX,
|
|
28181
|
+
clientY = _event$changedTouches.clientY;
|
|
28193
28182
|
var simulatedEvent = new MouseEvent('mouseup', {
|
|
28194
|
-
clientX:
|
|
28195
|
-
clientY:
|
|
28183
|
+
clientX: clientX,
|
|
28184
|
+
clientY: clientY,
|
|
28196
28185
|
bubbles: true
|
|
28197
28186
|
});
|
|
28198
|
-
(_document$elementFrom = document.elementFromPoint(
|
|
28187
|
+
(_document$elementFrom = document.elementFromPoint(clientX, clientY)) == null ? void 0 : _document$elementFrom.dispatchEvent(simulatedEvent);
|
|
28199
28188
|
}
|
|
28200
|
-
};
|
|
28201
|
-
var bounds = getContainerBounds();
|
|
28189
|
+
}, [onMouseOut]);
|
|
28202
28190
|
return React__default.createElement(Container$b, {
|
|
28203
28191
|
isDraggingItem: !!draggingItem,
|
|
28204
28192
|
item: item,
|
|
28205
28193
|
className: "rpgui-icon empty-slot",
|
|
28206
|
-
|
|
28194
|
+
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),
|
|
28195
|
+
onMouseDown: handleInteraction,
|
|
28196
|
+
onTouchStart: handleInteraction,
|
|
28197
|
+
onMouseUp: function onMouseUp(e) {
|
|
28198
|
+
handleInteractionEnd(e);
|
|
28207
28199
|
var data = item ? item : null;
|
|
28208
|
-
if (onPlaceDrop && containerType) {
|
|
28200
|
+
if (onPlaceDrop && containerType && draggingItem) {
|
|
28209
28201
|
onPlaceDrop(data, slotIndex, containerType);
|
|
28210
28202
|
}
|
|
28211
28203
|
},
|
|
28204
|
+
onTouchEnd: function onTouchEnd(e) {
|
|
28205
|
+
var _document$elementFrom2;
|
|
28206
|
+
handleInteractionEnd(e);
|
|
28207
|
+
var _e$changedTouches$ = e.changedTouches[0],
|
|
28208
|
+
clientX = _e$changedTouches$.clientX,
|
|
28209
|
+
clientY = _e$changedTouches$.clientY;
|
|
28210
|
+
var simulatedEvent = new MouseEvent('mouseup', {
|
|
28211
|
+
clientX: clientX,
|
|
28212
|
+
clientY: clientY,
|
|
28213
|
+
bubbles: true
|
|
28214
|
+
});
|
|
28215
|
+
(_document$elementFrom2 = document.elementFromPoint(clientX, clientY)) == null ? void 0 : _document$elementFrom2.dispatchEvent(simulatedEvent);
|
|
28216
|
+
},
|
|
28212
28217
|
onPointerDown: onDragStart !== undefined && onDragEnd !== undefined ? undefined : function () {
|
|
28213
28218
|
if (item) onPointerDown(item.type, containerType != null ? containerType : null, item);
|
|
28214
28219
|
},
|
|
28215
|
-
|
|
28216
|
-
onTouchStart: onTouchStart,
|
|
28217
|
-
onTouchEnd: onTouchEnd
|
|
28220
|
+
onMouseLeave: handleInteractionEnd
|
|
28218
28221
|
}, React__default.createElement(Draggable, {
|
|
28219
28222
|
axis: isSelectingShortcut ? 'none' : 'both',
|
|
28220
28223
|
defaultClassName: item ? 'draggable' : 'empty-slot',
|
|
@@ -28232,9 +28235,7 @@ var ItemSlot = /*#__PURE__*/React__default.memo( /*#__PURE__*/mobxReactLite.obse
|
|
|
28232
28235
|
onMouseOver: function onMouseOver(event) {
|
|
28233
28236
|
_onMouseOver == null ? void 0 : _onMouseOver(event, slotIndex, item, event.clientX, event.clientY);
|
|
28234
28237
|
},
|
|
28235
|
-
onMouseOut:
|
|
28236
|
-
if (_onMouseOut) _onMouseOut();
|
|
28237
|
-
},
|
|
28238
|
+
onMouseOut: onMouseOut,
|
|
28238
28239
|
onMouseEnter: function onMouseEnter() {
|
|
28239
28240
|
setTooltipState(function (prev) {
|
|
28240
28241
|
return _extends({}, prev, {
|
|
@@ -28281,20 +28282,20 @@ var ItemSlot = /*#__PURE__*/React__default.memo( /*#__PURE__*/mobxReactLite.obse
|
|
|
28281
28282
|
var Container$b = /*#__PURE__*/styled__default.div.withConfig({
|
|
28282
28283
|
displayName: "ItemSlot__Container",
|
|
28283
28284
|
componentId: "sc-l2j5ef-0"
|
|
28284
|
-
})(["margin:0.1rem;.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 (
|
|
28285
|
-
var isDraggingItem =
|
|
28285
|
+
})(["margin:0.1rem;.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 (_ref3) {
|
|
28286
|
+
var isDraggingItem = _ref3.isDraggingItem;
|
|
28286
28287
|
return isDraggingItem ? 0 : 1;
|
|
28287
|
-
}, function (_ref3) {
|
|
28288
|
-
var item = _ref3.item;
|
|
28289
|
-
return rarityColor(item);
|
|
28290
28288
|
}, function (_ref4) {
|
|
28291
28289
|
var item = _ref4.item;
|
|
28292
|
-
return
|
|
28290
|
+
return rarityColor(item);
|
|
28293
28291
|
}, function (_ref5) {
|
|
28294
28292
|
var item = _ref5.item;
|
|
28295
|
-
return "0 0
|
|
28293
|
+
return "0 0 5px 2px " + rarityColor(item);
|
|
28296
28294
|
}, function (_ref6) {
|
|
28297
|
-
var
|
|
28295
|
+
var item = _ref6.item;
|
|
28296
|
+
return "0 0 4px 3px " + rarityColor(item);
|
|
28297
|
+
}, function (_ref7) {
|
|
28298
|
+
var isSelectingShortcut = _ref7.isSelectingShortcut;
|
|
28298
28299
|
return isSelectingShortcut ? 'bg-color-change 1s infinite' : 'none';
|
|
28299
28300
|
});
|
|
28300
28301
|
var ItemContainer = /*#__PURE__*/styled__default.div.withConfig({
|
|
@@ -30624,7 +30625,6 @@ var ItemContainer$1 = function ItemContainer(_ref) {
|
|
|
30624
30625
|
_onOutsideDrop = _ref.onOutsideDrop,
|
|
30625
30626
|
checkIfItemCanBeMoved = _ref.checkIfItemCanBeMoved,
|
|
30626
30627
|
initialPosition = _ref.initialPosition,
|
|
30627
|
-
checkIfItemShouldDragEnd = _ref.checkIfItemShouldDragEnd,
|
|
30628
30628
|
scale = _ref.scale,
|
|
30629
30629
|
shortcuts = _ref.shortcuts,
|
|
30630
30630
|
setItemShortcut = _ref.setItemShortcut,
|
|
@@ -30714,7 +30714,6 @@ var ItemContainer$1 = function ItemContainer(_ref) {
|
|
|
30714
30714
|
onDragEnd: onDragEnd,
|
|
30715
30715
|
dragScale: scale,
|
|
30716
30716
|
checkIfItemCanBeMoved: checkIfItemCanBeMoved,
|
|
30717
|
-
checkIfItemShouldDragEnd: checkIfItemShouldDragEnd,
|
|
30718
30717
|
openQuantitySelector: function openQuantitySelector(maxQuantity, callback) {
|
|
30719
30718
|
setQuantitySelect({
|
|
30720
30719
|
isOpen: true,
|