@rpg-engine/long-bow 0.5.23 → 0.5.26
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 +6 -0
- package/dist/hooks/useShortcuts.d.ts +12 -0
- package/dist/long-bow.cjs.development.js +41 -40
- 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 +41 -40
- package/dist/long-bow.esm.js.map +1 -1
- package/dist/mocks/itemContainer.mocks.d.ts +1 -1
- package/dist/stories/ItemContainer.stories.d.ts +8 -1
- package/package.json +1 -1
- package/src/components/Equipment/EquipmentSet.tsx +1 -1
- package/src/components/Item/Inventory/DraggedItem.tsx +6 -2
- package/src/components/Item/Inventory/ItemContainer.tsx +1 -1
- package/src/components/Item/Inventory/ItemSlotRenderer.tsx +2 -0
- 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 +46 -0
- package/src/hooks/useShortcuts.ts +50 -0
- package/src/mocks/itemContainer.mocks.ts +38 -31
- package/src/stories/ItemContainer.stories.tsx +118 -146
- package/dist/hooks/useMousePosition.d.ts +0 -6
- package/src/hooks/useMousePosition.ts +0 -49
|
@@ -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;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { IItem, IShortcut } from '@rpg-engine/shared';
|
|
2
|
+
interface IUseShortcuts {
|
|
3
|
+
itemContainer: {
|
|
4
|
+
slots: Record<number, IItem | null | undefined>;
|
|
5
|
+
};
|
|
6
|
+
}
|
|
7
|
+
export declare const useShortcuts: ({ itemContainer }: IUseShortcuts) => {
|
|
8
|
+
shortcuts: IShortcut[];
|
|
9
|
+
setItemShortcut: (key: string, index: number) => void;
|
|
10
|
+
removeShortcut: (index: number) => void;
|
|
11
|
+
};
|
|
12
|
+
export {};
|
|
@@ -13479,6 +13479,8 @@ var ItemSlotRenderer = function ItemSlotRenderer(_ref) {
|
|
|
13479
13479
|
return renderEquipment(itemToRender);
|
|
13480
13480
|
case shared.ItemContainerType.Inventory:
|
|
13481
13481
|
return renderItem(itemToRender);
|
|
13482
|
+
case shared.ItemContainerType.Depot:
|
|
13483
|
+
return renderItem(itemToRender);
|
|
13482
13484
|
default:
|
|
13483
13485
|
return null;
|
|
13484
13486
|
}
|
|
@@ -14755,49 +14757,43 @@ var Details = /*#__PURE__*/styled.p.withConfig({
|
|
|
14755
14757
|
componentId: "sc-kaa0h9-0"
|
|
14756
14758
|
})(["font-size:", " !important;"], uiFonts.size.xsmall);
|
|
14757
14759
|
|
|
14758
|
-
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;
|
|
14759
14763
|
var _useState = React.useState({
|
|
14760
14764
|
x: 0,
|
|
14761
14765
|
y: 0
|
|
14762
14766
|
}),
|
|
14763
|
-
|
|
14764
|
-
|
|
14765
|
-
|
|
14766
|
-
var
|
|
14767
|
-
var
|
|
14768
|
-
|
|
14769
|
-
|
|
14770
|
-
|
|
14771
|
-
|
|
14772
|
-
|
|
14773
|
-
|
|
14774
|
-
|
|
14775
|
-
|
|
14776
|
-
|
|
14777
|
-
|
|
14778
|
-
|
|
14779
|
-
|
|
14780
|
-
|
|
14781
|
-
var handleTouchMove = function handleTouchMove(event) {
|
|
14782
|
-
// Prevent default touch behavior (like scrolling)
|
|
14783
|
-
event.preventDefault();
|
|
14784
|
-
if (event.touches.length > 0) {
|
|
14785
|
-
var touch = event.touches[0];
|
|
14786
|
-
updateCursorPosition(touch.clientX, touch.clientY);
|
|
14787
|
-
}
|
|
14788
|
-
};
|
|
14789
|
-
window.addEventListener('mousemove', handleMouseMove);
|
|
14790
|
-
window.addEventListener('touchmove', handleTouchMove, {
|
|
14791
|
-
passive: false
|
|
14767
|
+
position = _useState[0],
|
|
14768
|
+
setPosition = _useState[1];
|
|
14769
|
+
var setFromEvent = function setFromEvent(e) {
|
|
14770
|
+
var x, y;
|
|
14771
|
+
var viewportCenterX = window.innerWidth / 2 - shared.GRID_WIDTH;
|
|
14772
|
+
var viewportCenterY = window.innerHeight / -shared.GRID_HEIGHT;
|
|
14773
|
+
if ('touches' in e) {
|
|
14774
|
+
x = e.touches[0].clientX;
|
|
14775
|
+
y = e.touches[0].clientY;
|
|
14776
|
+
} else {
|
|
14777
|
+
x = e.clientX;
|
|
14778
|
+
y = e.clientY;
|
|
14779
|
+
}
|
|
14780
|
+
// Adjusting for the global scale
|
|
14781
|
+
// Assuming the element is centrally located
|
|
14782
|
+
setPosition({
|
|
14783
|
+
x: (x - viewportCenterX) / scale + viewportCenterX,
|
|
14784
|
+
y: (y - viewportCenterY) / scale + viewportCenterY
|
|
14792
14785
|
});
|
|
14793
|
-
|
|
14786
|
+
};
|
|
14787
|
+
React.useEffect(function () {
|
|
14788
|
+
window.addEventListener('mousemove', setFromEvent);
|
|
14789
|
+
window.addEventListener('touchmove', setFromEvent);
|
|
14790
|
+
console.log("SCALE IS ", scale);
|
|
14794
14791
|
return function () {
|
|
14795
|
-
window.removeEventListener('mousemove',
|
|
14796
|
-
window.removeEventListener('touchmove',
|
|
14797
|
-
cancelAnimationFrame(animationFrameId);
|
|
14792
|
+
window.removeEventListener('mousemove', setFromEvent);
|
|
14793
|
+
window.removeEventListener('touchmove', setFromEvent);
|
|
14798
14794
|
};
|
|
14799
|
-
}, []);
|
|
14800
|
-
return
|
|
14795
|
+
}, [scale]);
|
|
14796
|
+
return position;
|
|
14801
14797
|
};
|
|
14802
14798
|
|
|
14803
14799
|
var CONTAINER_SIZE = 32;
|
|
@@ -14805,10 +14801,13 @@ var OFFSET = CONTAINER_SIZE / 2;
|
|
|
14805
14801
|
var DraggedItem = function DraggedItem(_ref) {
|
|
14806
14802
|
var _item$_id, _item$stackQty;
|
|
14807
14803
|
var atlasJSON = _ref.atlasJSON,
|
|
14808
|
-
atlasIMG = _ref.atlasIMG
|
|
14804
|
+
atlasIMG = _ref.atlasIMG,
|
|
14805
|
+
scale = _ref.scale;
|
|
14809
14806
|
var _useDragging = useDragging(),
|
|
14810
14807
|
item = _useDragging.item;
|
|
14811
|
-
var _useCursorPosition = useCursorPosition(
|
|
14808
|
+
var _useCursorPosition = useCursorPosition({
|
|
14809
|
+
scale: scale
|
|
14810
|
+
}),
|
|
14812
14811
|
x = _useCursorPosition.x,
|
|
14813
14812
|
y = _useCursorPosition.y;
|
|
14814
14813
|
if (!item) {
|
|
@@ -14929,7 +14928,8 @@ var EquipmentSet = function EquipmentSet(_ref) {
|
|
|
14929
14928
|
};
|
|
14930
14929
|
return React__default.createElement(DraggingProvider, null, React__default.createElement(DraggedItem, {
|
|
14931
14930
|
atlasIMG: atlasIMG,
|
|
14932
|
-
atlasJSON: atlasJSON
|
|
14931
|
+
atlasJSON: atlasJSON,
|
|
14932
|
+
scale: scale
|
|
14933
14933
|
}), React__default.createElement(DraggableContainer, {
|
|
14934
14934
|
title: 'Equipments',
|
|
14935
14935
|
type: exports.RPGUIContainerTypes.Framed,
|
|
@@ -16006,7 +16006,8 @@ var ItemContainer$1 = function ItemContainer(_ref) {
|
|
|
16006
16006
|
};
|
|
16007
16007
|
return React__default.createElement(DraggingProvider, null, React__default.createElement(DraggedItem, {
|
|
16008
16008
|
atlasIMG: atlasIMG,
|
|
16009
|
-
atlasJSON: atlasJSON
|
|
16009
|
+
atlasJSON: atlasJSON,
|
|
16010
|
+
scale: scale
|
|
16010
16011
|
}), React__default.createElement(SlotsContainer, {
|
|
16011
16012
|
title: itemContainer.name || 'Container',
|
|
16012
16013
|
onClose: onClose,
|