@rpg-engine/long-bow 0.5.24 → 0.5.27
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/DraggedItem.d.ts +2 -1
- package/dist/components/shared/ScalableContainer.d.ts +7 -0
- package/dist/constants/uiBreakpoints.d.ts +2 -0
- package/dist/hooks/useCursorPosition.d.ts +5 -5
- package/dist/long-bow.cjs.development.js +49 -21
- 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 +50 -22
- package/dist/long-bow.esm.js.map +1 -1
- package/dist/stories/ItemContainer.stories.d.ts +2 -0
- package/package.json +2 -2
- package/src/components/Equipment/EquipmentSet.tsx +1 -1
- package/src/components/Item/Inventory/DraggedItem.tsx +10 -1
- package/src/components/Item/Inventory/ItemContainer.tsx +1 -1
- package/src/components/Item/Inventory/ItemSlot.tsx +2 -2
- package/src/components/Spellbook/constants.ts +1 -1
- package/src/components/shared/ScalableContainer.tsx +22 -0
- package/src/constants/uiBreakpoints.ts +3 -0
- package/src/hooks/useCursorPosition.ts +41 -16
- package/src/stories/ItemContainer.stories.tsx +94 -70
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
interface IProps {
|
|
3
3
|
atlasJSON: any;
|
|
4
4
|
atlasIMG: any;
|
|
5
|
+
scale?: number;
|
|
5
6
|
}
|
|
6
|
-
export declare const DraggedItem: ({ atlasJSON, atlasIMG, }: IProps) => JSX.Element | null;
|
|
7
|
+
export declare const DraggedItem: ({ atlasJSON, atlasIMG, scale, }: IProps) => JSX.Element | null;
|
|
7
8
|
export default DraggedItem;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
}
|
|
5
|
-
export declare const useCursorPosition: () =>
|
|
1
|
+
import { IPosition } from '../types/eventTypes';
|
|
2
|
+
interface ICursorPositionProps {
|
|
3
|
+
scale?: number;
|
|
4
|
+
}
|
|
5
|
+
export declare const useCursorPosition: ({ scale }: ICursorPositionProps) => IPosition;
|
|
6
6
|
export {};
|
|
@@ -13987,8 +13987,8 @@ var ItemSlot = /*#__PURE__*/mobxReactLite.observer(function (_ref) {
|
|
|
13987
13987
|
if (!item || isSelectingShortcut) {
|
|
13988
13988
|
return;
|
|
13989
13989
|
}
|
|
13990
|
-
setDraggingItem(item);
|
|
13991
13990
|
if (onDragStart && containerType) {
|
|
13991
|
+
setDraggingItem(item);
|
|
13992
13992
|
onDragStart(item, slotIndex, containerType);
|
|
13993
13993
|
}
|
|
13994
13994
|
},
|
|
@@ -14757,34 +14757,54 @@ var Details = /*#__PURE__*/styled.p.withConfig({
|
|
|
14757
14757
|
componentId: "sc-kaa0h9-0"
|
|
14758
14758
|
})(["font-size:", " !important;"], uiFonts.size.xsmall);
|
|
14759
14759
|
|
|
14760
|
-
var useCursorPosition = function useCursorPosition() {
|
|
14760
|
+
var useCursorPosition = function useCursorPosition(_ref) {
|
|
14761
|
+
var _ref$scale = _ref.scale,
|
|
14762
|
+
scale = _ref$scale === void 0 ? 1 : _ref$scale;
|
|
14761
14763
|
var _useState = React.useState({
|
|
14762
14764
|
x: 0,
|
|
14763
14765
|
y: 0
|
|
14764
14766
|
}),
|
|
14765
14767
|
position = _useState[0],
|
|
14766
14768
|
setPosition = _useState[1];
|
|
14767
|
-
var
|
|
14769
|
+
var scalePosition = React.useCallback(function (x, y) {
|
|
14770
|
+
return {
|
|
14771
|
+
x: (x - shared.GRID_WIDTH / 2) / scale + shared.GRID_WIDTH / 2,
|
|
14772
|
+
y: (y - shared.GRID_HEIGHT / 2) / scale + shared.GRID_HEIGHT / 2
|
|
14773
|
+
};
|
|
14774
|
+
}, [scale]);
|
|
14775
|
+
var setFromEvent = React.useCallback(function (e) {
|
|
14776
|
+
var x, y;
|
|
14768
14777
|
if ('touches' in e) {
|
|
14769
|
-
|
|
14770
|
-
|
|
14771
|
-
y: e.touches[0].clientY
|
|
14772
|
-
});
|
|
14778
|
+
x = e.touches[0].clientX;
|
|
14779
|
+
y = e.touches[0].clientY;
|
|
14773
14780
|
} else {
|
|
14774
|
-
|
|
14775
|
-
|
|
14776
|
-
y: e.clientY
|
|
14777
|
-
});
|
|
14781
|
+
x = e.clientX;
|
|
14782
|
+
y = e.clientY;
|
|
14778
14783
|
}
|
|
14779
|
-
|
|
14784
|
+
var scaledPosition = scalePosition(x, y);
|
|
14785
|
+
setPosition(scaledPosition);
|
|
14786
|
+
}, [scale, scalePosition]);
|
|
14787
|
+
var cleanup = React.useCallback(function () {
|
|
14788
|
+
setPosition({
|
|
14789
|
+
x: 0,
|
|
14790
|
+
y: 0
|
|
14791
|
+
});
|
|
14792
|
+
}, []);
|
|
14780
14793
|
React.useEffect(function () {
|
|
14781
|
-
|
|
14782
|
-
|
|
14794
|
+
var handleEvent = function handleEvent(e) {
|
|
14795
|
+
return setFromEvent(e);
|
|
14796
|
+
};
|
|
14797
|
+
window.addEventListener('mousemove', handleEvent);
|
|
14798
|
+
window.addEventListener('touchmove', handleEvent);
|
|
14799
|
+
window.addEventListener('mouseup', cleanup);
|
|
14800
|
+
window.addEventListener('touchend', cleanup);
|
|
14783
14801
|
return function () {
|
|
14784
|
-
window.removeEventListener('mousemove',
|
|
14785
|
-
window.removeEventListener('touchmove',
|
|
14802
|
+
window.removeEventListener('mousemove', handleEvent);
|
|
14803
|
+
window.removeEventListener('touchmove', handleEvent);
|
|
14804
|
+
window.removeEventListener('mouseup', cleanup);
|
|
14805
|
+
window.removeEventListener('touchend', cleanup);
|
|
14786
14806
|
};
|
|
14787
|
-
}, []);
|
|
14807
|
+
}, [setFromEvent, cleanup]);
|
|
14788
14808
|
return position;
|
|
14789
14809
|
};
|
|
14790
14810
|
|
|
@@ -14793,15 +14813,21 @@ var OFFSET = CONTAINER_SIZE / 2;
|
|
|
14793
14813
|
var DraggedItem = function DraggedItem(_ref) {
|
|
14794
14814
|
var _item$_id, _item$stackQty;
|
|
14795
14815
|
var atlasJSON = _ref.atlasJSON,
|
|
14796
|
-
atlasIMG = _ref.atlasIMG
|
|
14816
|
+
atlasIMG = _ref.atlasIMG,
|
|
14817
|
+
scale = _ref.scale;
|
|
14797
14818
|
var _useDragging = useDragging(),
|
|
14798
14819
|
item = _useDragging.item;
|
|
14799
|
-
var _useCursorPosition = useCursorPosition(
|
|
14820
|
+
var _useCursorPosition = useCursorPosition({
|
|
14821
|
+
scale: scale
|
|
14822
|
+
}),
|
|
14800
14823
|
x = _useCursorPosition.x,
|
|
14801
14824
|
y = _useCursorPosition.y;
|
|
14802
14825
|
if (!item) {
|
|
14803
14826
|
return null;
|
|
14804
14827
|
}
|
|
14828
|
+
if (x === 0 && y === 0) {
|
|
14829
|
+
return null;
|
|
14830
|
+
}
|
|
14805
14831
|
var centeredX = x - OFFSET;
|
|
14806
14832
|
var centeredY = y - OFFSET;
|
|
14807
14833
|
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);
|
|
@@ -14917,7 +14943,8 @@ var EquipmentSet = function EquipmentSet(_ref) {
|
|
|
14917
14943
|
};
|
|
14918
14944
|
return React__default.createElement(DraggingProvider, null, React__default.createElement(DraggedItem, {
|
|
14919
14945
|
atlasIMG: atlasIMG,
|
|
14920
|
-
atlasJSON: atlasJSON
|
|
14946
|
+
atlasJSON: atlasJSON,
|
|
14947
|
+
scale: scale
|
|
14921
14948
|
}), React__default.createElement(DraggableContainer, {
|
|
14922
14949
|
title: 'Equipments',
|
|
14923
14950
|
type: exports.RPGUIContainerTypes.Framed,
|
|
@@ -15994,7 +16021,8 @@ var ItemContainer$1 = function ItemContainer(_ref) {
|
|
|
15994
16021
|
};
|
|
15995
16022
|
return React__default.createElement(DraggingProvider, null, React__default.createElement(DraggedItem, {
|
|
15996
16023
|
atlasIMG: atlasIMG,
|
|
15997
|
-
atlasJSON: atlasJSON
|
|
16024
|
+
atlasJSON: atlasJSON,
|
|
16025
|
+
scale: scale
|
|
15998
16026
|
}), React__default.createElement(SlotsContainer, {
|
|
15999
16027
|
title: itemContainer.name || 'Container',
|
|
16000
16028
|
onClose: onClose,
|