@rpg-engine/long-bow 0.7.53 → 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 +283 -300
- 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 +283 -300
- 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 +107 -306
- 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,318 +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];
|
|
27945
|
-
var _useState7 = React.useState(false),
|
|
27946
|
-
isDragging = _useState7[0],
|
|
27947
|
-
setIsDragging = _useState7[1]; // New state to track dragging
|
|
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;
|
|
27948
28142
|
React.useEffect(function () {
|
|
27949
|
-
setDragState(function (prev) {
|
|
27950
|
-
return _extends({}, prev, {
|
|
27951
|
-
position: {
|
|
27952
|
-
x: 0,
|
|
27953
|
-
y: 0
|
|
27954
|
-
},
|
|
27955
|
-
isFocused: false
|
|
27956
|
-
});
|
|
27957
|
-
});
|
|
27958
28143
|
if (item && containerType) {
|
|
27959
28144
|
setContextActions(generateContextMenu(item, containerType, isDepotSystem));
|
|
27960
28145
|
}
|
|
27961
28146
|
}, [item, isDepotSystem]);
|
|
27962
|
-
|
|
27963
|
-
|
|
27964
|
-
|
|
27965
|
-
|
|
27966
|
-
|
|
27967
|
-
|
|
27968
|
-
|
|
27969
|
-
|
|
27970
|
-
|
|
27971
|
-
}, [dragState.dropPosition]);
|
|
27972
|
-
var getContainerBounds = React.useCallback(function () {
|
|
27973
|
-
var container = dragContainer.current;
|
|
27974
|
-
if (!container) return {
|
|
27975
|
-
left: 0,
|
|
27976
|
-
top: 0,
|
|
27977
|
-
right: 0,
|
|
27978
|
-
bottom: 0
|
|
27979
|
-
};
|
|
27980
|
-
var rect = container.getBoundingClientRect();
|
|
27981
|
-
return {
|
|
27982
|
-
left: rect.left,
|
|
27983
|
-
top: rect.top,
|
|
27984
|
-
right: window.innerWidth - rect.right,
|
|
27985
|
-
bottom: window.innerHeight - rect.bottom
|
|
27986
|
-
};
|
|
27987
|
-
}, [dragContainer]);
|
|
27988
|
-
var resetItem = function resetItem() {
|
|
27989
|
-
setTooltipState(function (prev) {
|
|
27990
|
-
return _extends({}, prev, {
|
|
27991
|
-
visible: false,
|
|
27992
|
-
mobileVisible: false
|
|
27993
|
-
});
|
|
27994
|
-
});
|
|
27995
|
-
setDragState(function (prev) {
|
|
27996
|
-
return _extends({}, prev, {
|
|
27997
|
-
wasDragged: false
|
|
27998
|
-
});
|
|
27999
|
-
});
|
|
28000
|
-
setIsDragging(false); // Reset dragging flag
|
|
28001
|
-
};
|
|
28002
|
-
var onSuccessfulDrag = function onSuccessfulDrag(quantity) {
|
|
28003
|
-
resetItem();
|
|
28004
|
-
if (quantity === -1) {
|
|
28005
|
-
setDragState(function (prev) {
|
|
28006
|
-
return _extends({}, prev, {
|
|
28007
|
-
position: {
|
|
28008
|
-
x: 0,
|
|
28009
|
-
y: 0
|
|
28010
|
-
},
|
|
28011
|
-
isFocused: false
|
|
28012
|
-
});
|
|
28013
|
-
});
|
|
28014
|
-
} else if (item) {
|
|
28015
|
-
onDragEnd == null ? void 0 : onDragEnd(quantity);
|
|
28016
|
-
}
|
|
28017
|
-
};
|
|
28018
|
-
var onDraggableStop = function onDraggableStop(e, data) {
|
|
28019
|
-
setDraggingItem(null);
|
|
28020
|
-
var target = e.target;
|
|
28021
|
-
if (!target) return;
|
|
28022
|
-
if (target != null && target.id.includes('shortcutSetter') && setItemShortcut && item) {
|
|
28023
|
-
var index = parseInt(target.id.split('_')[1]);
|
|
28024
|
-
if (!isNaN(index)) {
|
|
28025
|
-
setItemShortcut(item, index);
|
|
28026
|
-
}
|
|
28027
|
-
}
|
|
28028
|
-
// Remove the class react-draggable-dragging from the element
|
|
28029
|
-
// to prevent the item from being dragged again
|
|
28030
|
-
target.classList.remove('react-draggable-dragging');
|
|
28031
|
-
var isTouch = e.type.startsWith('touch');
|
|
28032
|
-
if (isTouch) {
|
|
28033
|
-
var touchEvent = e;
|
|
28034
|
-
var touch = touchEvent.changedTouches[0];
|
|
28035
|
-
var touchEndTime = new Date().getTime();
|
|
28036
|
-
var touchDuration = touchStartTime ? touchEndTime - touchStartTime : 0;
|
|
28037
|
-
// Check if it's a short tap (less than 200ms) and hasn't moved much
|
|
28038
|
-
var isShortTap = touchDuration < 200;
|
|
28039
|
-
var hasMovedSignificantly = touchStartPosition && (Math.abs(touch.clientX - touchStartPosition.x) > 10 || Math.abs(touch.clientY - touchStartPosition.y) > 10);
|
|
28040
|
-
if (isShortTap && !hasMovedSignificantly) {
|
|
28041
|
-
// Handle as a tap/click
|
|
28042
|
-
if (item) {
|
|
28043
|
-
setTooltipState(function (prev) {
|
|
28044
|
-
return _extends({}, prev, {
|
|
28045
|
-
mobileVisible: true
|
|
28046
|
-
});
|
|
28047
|
-
});
|
|
28048
|
-
onPointerDown(item.type, containerType != null ? containerType : null, item);
|
|
28049
|
-
}
|
|
28050
|
-
return;
|
|
28051
|
-
}
|
|
28052
|
-
}
|
|
28053
|
-
// Threshold for considering a tap/click as a drag
|
|
28054
|
-
var dragThreshold = 5; // pixels
|
|
28055
|
-
var isDrag = Math.abs(data.x) > dragThreshold || Math.abs(data.y) > dragThreshold;
|
|
28056
|
-
if (dragState.wasDragged && item && !isSelectingShortcut) {
|
|
28057
|
-
var _e$target;
|
|
28058
|
-
//@ts-ignore
|
|
28059
|
-
var classes = Array.from((_e$target = e.target) == null ? void 0 : _e$target.classList);
|
|
28060
|
-
var isOutsideDrop = classes.some(function (elm) {
|
|
28061
|
-
return elm.includes('rpgui-content');
|
|
28062
|
-
}) || classes.length === 0;
|
|
28063
|
-
if (isOutsideDrop) {
|
|
28064
|
-
setDragState(function (prev) {
|
|
28065
|
-
return _extends({}, prev, {
|
|
28066
|
-
dropPosition: {
|
|
28067
|
-
x: data.x,
|
|
28068
|
-
y: data.y
|
|
28069
|
-
}
|
|
28070
|
-
});
|
|
28071
|
-
});
|
|
28072
|
-
}
|
|
28073
|
-
setDragState(function (prev) {
|
|
28074
|
-
return _extends({}, prev, {
|
|
28075
|
-
wasDragged: false
|
|
28076
|
-
});
|
|
28077
|
-
});
|
|
28078
|
-
var _target = dragContainer.current;
|
|
28079
|
-
if (!_target || !dragState.wasDragged) return;
|
|
28080
|
-
var style = window.getComputedStyle(_target);
|
|
28081
|
-
var matrix = new DOMMatrixReadOnly(style.transform);
|
|
28082
|
-
var x = matrix.m41;
|
|
28083
|
-
var y = matrix.m42;
|
|
28084
|
-
setDragState(function (prev) {
|
|
28085
|
-
return _extends({}, prev, {
|
|
28086
|
-
position: {
|
|
28087
|
-
x: x,
|
|
28088
|
-
y: y
|
|
28089
|
-
}
|
|
28090
|
-
});
|
|
28091
|
-
});
|
|
28092
|
-
setTimeout(function () {
|
|
28093
|
-
if (checkIfItemCanBeMoved && checkIfItemCanBeMoved()) {
|
|
28094
|
-
if (checkIfItemShouldDragEnd && !checkIfItemShouldDragEnd()) return;
|
|
28095
|
-
if (item.stackQty && item.stackQty !== 1 && openQuantitySelector) {
|
|
28096
|
-
openQuantitySelector(item.stackQty, onSuccessfulDrag);
|
|
28097
|
-
} else onSuccessfulDrag(item.stackQty);
|
|
28098
|
-
} else {
|
|
28099
|
-
resetItem();
|
|
28100
|
-
setDragState(function (prev) {
|
|
28101
|
-
return _extends({}, prev, {
|
|
28102
|
-
isFocused: false,
|
|
28103
|
-
position: {
|
|
28104
|
-
x: 0,
|
|
28105
|
-
y: 0
|
|
28106
|
-
}
|
|
28107
|
-
});
|
|
28108
|
-
});
|
|
28109
|
-
}
|
|
28110
|
-
}, 50);
|
|
28111
|
-
} else if (item) {
|
|
28112
|
-
if (isTouch && isDragging) {
|
|
28113
|
-
// If it's a touch and we were dragging, do not show context menu
|
|
28114
|
-
return;
|
|
28115
|
-
} else if (isTouch && !isDrag) {
|
|
28116
|
-
// Handle as a tap/click
|
|
28117
|
-
setTooltipState(function (prev) {
|
|
28118
|
-
return _extends({}, prev, {
|
|
28119
|
-
mobileVisible: true
|
|
28120
|
-
});
|
|
28121
|
-
});
|
|
28122
|
-
onPointerDown(item.type, containerType != null ? containerType : null, item);
|
|
28123
|
-
} else if (!isTouch && !isContextMenuDisabled && !isSelectingShortcut) {
|
|
28124
|
-
// Handle as context menu for mouse devices
|
|
28125
|
-
setContextMenuState(function (prev) {
|
|
28126
|
-
return _extends({}, prev, {
|
|
28127
|
-
visible: !contextMenuState.visible
|
|
28128
|
-
});
|
|
28129
|
-
});
|
|
28130
|
-
var event = e;
|
|
28131
|
-
if (event.clientX && event.clientY) {
|
|
28132
|
-
setContextMenuState(function (prev) {
|
|
28133
|
-
return _extends({}, prev, {
|
|
28134
|
-
position: {
|
|
28135
|
-
x: event.clientX - 10,
|
|
28136
|
-
y: event.clientY - 5
|
|
28137
|
-
}
|
|
28138
|
-
});
|
|
28139
|
-
});
|
|
28140
|
-
}
|
|
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);
|
|
28141
28156
|
}
|
|
28142
|
-
if (
|
|
28143
|
-
|
|
28144
|
-
onPointerDown(item.type, containerType != null ? containerType : null, item);
|
|
28157
|
+
if (onPointerDown && onDragStart === undefined && onDragEnd === undefined) {
|
|
28158
|
+
onPointerDown(item.type, containerType, item);
|
|
28145
28159
|
}
|
|
28146
28160
|
}
|
|
28147
|
-
|
|
28161
|
+
setTooltipState(function (prev) {
|
|
28148
28162
|
return _extends({}, prev, {
|
|
28149
|
-
|
|
28163
|
+
visible: true
|
|
28150
28164
|
});
|
|
28151
28165
|
});
|
|
28152
|
-
|
|
28153
|
-
};
|
|
28154
|
-
var
|
|
28155
|
-
|
|
28156
|
-
|
|
28157
|
-
|
|
28158
|
-
|
|
28159
|
-
|
|
28160
|
-
}
|
|
28161
|
-
setIsDragging(true); // Set dragging flag on start
|
|
28162
|
-
};
|
|
28163
|
-
var onDraggableProgress = function onDraggableProgress(_e, data) {
|
|
28164
|
-
if (Math.abs(data.x - dragState.position.x) > 5 || Math.abs(data.y - dragState.position.y) > 5) {
|
|
28165
|
-
setDragState(function (prev) {
|
|
28166
|
-
return _extends({}, prev, {
|
|
28167
|
-
wasDragged: true,
|
|
28168
|
-
isFocused: true
|
|
28169
|
-
});
|
|
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
|
|
28170
28174
|
});
|
|
28171
|
-
}
|
|
28172
|
-
if (!draggingItem) {
|
|
28173
|
-
setDraggingItem(item);
|
|
28174
|
-
}
|
|
28175
|
-
};
|
|
28176
|
-
var onTouchStartHandler = function onTouchStartHandler(e) {
|
|
28177
|
-
setTouchStartTime(new Date().getTime());
|
|
28178
|
-
setTouchStartPosition({
|
|
28179
|
-
x: e.touches[0].clientX,
|
|
28180
|
-
y: e.touches[0].clientY
|
|
28181
28175
|
});
|
|
28182
|
-
|
|
28183
|
-
|
|
28184
|
-
// Only prevent default if not dragging
|
|
28185
|
-
if (!isDragging) {
|
|
28186
|
-
e.preventDefault();
|
|
28187
|
-
}
|
|
28188
|
-
var touch = e.changedTouches[0];
|
|
28189
|
-
var touchEndTime = new Date().getTime();
|
|
28190
|
-
var touchDuration = touchStartTime ? touchEndTime - touchStartTime : 0;
|
|
28191
|
-
// Check if it's a short tap (less than 200ms) and hasn't moved much
|
|
28192
|
-
var isShortTap = touchDuration < 200;
|
|
28193
|
-
var hasMovedSignificantly = touchStartPosition && (Math.abs(touch.clientX - touchStartPosition.x) > 10 || Math.abs(touch.clientY - touchStartPosition.y) > 10);
|
|
28194
|
-
if (isShortTap && !hasMovedSignificantly) {
|
|
28195
|
-
// Handle as a tap/click
|
|
28196
|
-
if (item) {
|
|
28197
|
-
setTooltipState(function (prev) {
|
|
28198
|
-
return _extends({}, prev, {
|
|
28199
|
-
mobileVisible: true
|
|
28200
|
-
});
|
|
28201
|
-
});
|
|
28202
|
-
onPointerDown(item.type, containerType != null ? containerType : null, item);
|
|
28203
|
-
}
|
|
28204
|
-
} else {
|
|
28176
|
+
onMouseOut == null ? void 0 : onMouseOut();
|
|
28177
|
+
if (event.type === 'touchend' && 'changedTouches' in event) {
|
|
28205
28178
|
var _document$elementFrom;
|
|
28206
|
-
|
|
28179
|
+
var _event$changedTouches = event.changedTouches[0],
|
|
28180
|
+
clientX = _event$changedTouches.clientX,
|
|
28181
|
+
clientY = _event$changedTouches.clientY;
|
|
28207
28182
|
var simulatedEvent = new MouseEvent('mouseup', {
|
|
28208
|
-
clientX:
|
|
28209
|
-
clientY:
|
|
28183
|
+
clientX: clientX,
|
|
28184
|
+
clientY: clientY,
|
|
28210
28185
|
bubbles: true
|
|
28211
28186
|
});
|
|
28212
|
-
(_document$elementFrom = document.elementFromPoint(
|
|
28187
|
+
(_document$elementFrom = document.elementFromPoint(clientX, clientY)) == null ? void 0 : _document$elementFrom.dispatchEvent(simulatedEvent);
|
|
28213
28188
|
}
|
|
28214
|
-
|
|
28215
|
-
};
|
|
28216
|
-
var bounds = getContainerBounds();
|
|
28189
|
+
}, [onMouseOut]);
|
|
28217
28190
|
return React__default.createElement(Container$b, {
|
|
28218
28191
|
isDraggingItem: !!draggingItem,
|
|
28219
28192
|
item: item,
|
|
28220
28193
|
className: "rpgui-icon empty-slot",
|
|
28221
|
-
|
|
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);
|
|
28222
28199
|
var data = item ? item : null;
|
|
28223
|
-
if (onPlaceDrop && containerType) {
|
|
28200
|
+
if (onPlaceDrop && containerType && draggingItem) {
|
|
28224
28201
|
onPlaceDrop(data, slotIndex, containerType);
|
|
28225
28202
|
}
|
|
28226
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
|
+
},
|
|
28227
28217
|
onPointerDown: onDragStart !== undefined && onDragEnd !== undefined ? undefined : function () {
|
|
28228
28218
|
if (item) onPointerDown(item.type, containerType != null ? containerType : null, item);
|
|
28229
28219
|
},
|
|
28230
|
-
|
|
28231
|
-
onTouchStart: onTouchStartHandler,
|
|
28232
|
-
onTouchEnd: onTouchEndHandler
|
|
28220
|
+
onMouseLeave: handleInteractionEnd
|
|
28233
28221
|
}, React__default.createElement(Draggable, {
|
|
28234
28222
|
axis: isSelectingShortcut ? 'none' : 'both',
|
|
28235
28223
|
defaultClassName: item ? 'draggable' : 'empty-slot',
|
|
@@ -28247,9 +28235,7 @@ var ItemSlot = /*#__PURE__*/React__default.memo( /*#__PURE__*/mobxReactLite.obse
|
|
|
28247
28235
|
onMouseOver: function onMouseOver(event) {
|
|
28248
28236
|
_onMouseOver == null ? void 0 : _onMouseOver(event, slotIndex, item, event.clientX, event.clientY);
|
|
28249
28237
|
},
|
|
28250
|
-
onMouseOut:
|
|
28251
|
-
if (_onMouseOut) _onMouseOut();
|
|
28252
|
-
},
|
|
28238
|
+
onMouseOut: onMouseOut,
|
|
28253
28239
|
onMouseEnter: function onMouseEnter() {
|
|
28254
28240
|
setTooltipState(function (prev) {
|
|
28255
28241
|
return _extends({}, prev, {
|
|
@@ -28296,28 +28282,27 @@ var ItemSlot = /*#__PURE__*/React__default.memo( /*#__PURE__*/mobxReactLite.obse
|
|
|
28296
28282
|
var Container$b = /*#__PURE__*/styled__default.div.withConfig({
|
|
28297
28283
|
displayName: "ItemSlot__Container",
|
|
28298
28284
|
componentId: "sc-l2j5ef-0"
|
|
28299
|
-
})(["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 (
|
|
28300
|
-
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;
|
|
28301
28287
|
return isDraggingItem ? 0 : 1;
|
|
28302
|
-
}, function (_ref3) {
|
|
28303
|
-
var item = _ref3.item;
|
|
28304
|
-
return rarityColor(item);
|
|
28305
28288
|
}, function (_ref4) {
|
|
28306
28289
|
var item = _ref4.item;
|
|
28307
|
-
return
|
|
28290
|
+
return rarityColor(item);
|
|
28308
28291
|
}, function (_ref5) {
|
|
28309
28292
|
var item = _ref5.item;
|
|
28310
|
-
return "0 0
|
|
28293
|
+
return "0 0 5px 2px " + rarityColor(item);
|
|
28311
28294
|
}, function (_ref6) {
|
|
28312
|
-
var
|
|
28295
|
+
var item = _ref6.item;
|
|
28296
|
+
return "0 0 4px 3px " + rarityColor(item);
|
|
28297
|
+
}, function (_ref7) {
|
|
28298
|
+
var isSelectingShortcut = _ref7.isSelectingShortcut;
|
|
28313
28299
|
return isSelectingShortcut ? 'bg-color-change 1s infinite' : 'none';
|
|
28314
28300
|
});
|
|
28315
28301
|
var ItemContainer = /*#__PURE__*/styled__default.div.withConfig({
|
|
28316
28302
|
displayName: "ItemSlot__ItemContainer",
|
|
28317
28303
|
componentId: "sc-l2j5ef-1"
|
|
28318
|
-
})(["width:64px;height:64px;position:relative;", ";"], function (
|
|
28319
|
-
|
|
28320
|
-
return isFocused ? 'z-index: 100; pointer-events: none;' : '';
|
|
28304
|
+
})(["width:64px;height:64px;position:relative;", ";"], function (props) {
|
|
28305
|
+
return props.isFocused && 'z-index: 100; pointer-events: none;';
|
|
28321
28306
|
});
|
|
28322
28307
|
|
|
28323
28308
|
var statisticsToDisplay = [{
|
|
@@ -30640,7 +30625,6 @@ var ItemContainer$1 = function ItemContainer(_ref) {
|
|
|
30640
30625
|
_onOutsideDrop = _ref.onOutsideDrop,
|
|
30641
30626
|
checkIfItemCanBeMoved = _ref.checkIfItemCanBeMoved,
|
|
30642
30627
|
initialPosition = _ref.initialPosition,
|
|
30643
|
-
checkIfItemShouldDragEnd = _ref.checkIfItemShouldDragEnd,
|
|
30644
30628
|
scale = _ref.scale,
|
|
30645
30629
|
shortcuts = _ref.shortcuts,
|
|
30646
30630
|
setItemShortcut = _ref.setItemShortcut,
|
|
@@ -30730,7 +30714,6 @@ var ItemContainer$1 = function ItemContainer(_ref) {
|
|
|
30730
30714
|
onDragEnd: onDragEnd,
|
|
30731
30715
|
dragScale: scale,
|
|
30732
30716
|
checkIfItemCanBeMoved: checkIfItemCanBeMoved,
|
|
30733
|
-
checkIfItemShouldDragEnd: checkIfItemShouldDragEnd,
|
|
30734
30717
|
openQuantitySelector: function openQuantitySelector(maxQuantity, callback) {
|
|
30735
30718
|
setQuantitySelect({
|
|
30736
30719
|
isOpen: true,
|