@rpg-engine/long-bow 0.7.68 → 0.7.70
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 +2 -4
- package/dist/components/Item/Inventory/ItemSlotTooltips.d.ts +2 -10
- package/dist/components/Item/Inventory/context/{DraggingContext.d.ts → ItemSlotDraggingContext.d.ts} +6 -6
- package/dist/components/Item/Inventory/context/ItemSlotTooltipContext.d.ts +28 -0
- package/dist/components/Item/Inventory/hooks/useItemSlotDragAndDrop.d.ts +2 -6
- package/dist/hooks/useCursorPosition.d.ts +1 -1
- package/dist/long-bow.cjs.development.js +433 -365
- 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 +435 -367
- package/dist/long-bow.esm.js.map +1 -1
- package/package.json +3 -2
- package/src/components/Equipment/EquipmentSet.tsx +61 -29
- package/src/components/Item/Inventory/DraggedItem.tsx +2 -2
- package/src/components/Item/Inventory/ItemContainer.tsx +68 -44
- package/src/components/Item/Inventory/ItemSlot.tsx +46 -65
- package/src/components/Item/Inventory/ItemSlotTooltips.tsx +48 -42
- package/src/components/Item/Inventory/context/{DraggingContext.tsx → ItemSlotDraggingContext.tsx} +10 -10
- package/src/components/Item/Inventory/context/ItemSlotTooltipContext.tsx +95 -0
- package/src/components/Item/Inventory/hooks/useItemSlotDragAndDrop.ts +50 -30
- package/src/hooks/useCursorPosition.ts +29 -20
- package/src/mocks/skills.mocks.ts +0 -4
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rpg-engine/long-bow",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.70",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"typings": "dist/index.d.ts",
|
|
@@ -30,7 +30,8 @@
|
|
|
30
30
|
"storybook": "start-storybook -p 6006",
|
|
31
31
|
"build-storybook": "build-storybook",
|
|
32
32
|
"configure": "./environment/download-credentials.sh",
|
|
33
|
-
"update:shared-deps": "yarn add @rpg-engine/shared"
|
|
33
|
+
"update:shared-deps": "yarn add @rpg-engine/shared",
|
|
34
|
+
"prepublish": "yarn tsc"
|
|
34
35
|
},
|
|
35
36
|
"peerDependencies": {
|
|
36
37
|
"react": ">=16"
|
|
@@ -2,6 +2,7 @@ import {
|
|
|
2
2
|
IEquipmentSet,
|
|
3
3
|
IItem,
|
|
4
4
|
IItemContainer,
|
|
5
|
+
isMobile,
|
|
5
6
|
ItemContainerType,
|
|
6
7
|
ItemSlotType,
|
|
7
8
|
ItemType,
|
|
@@ -10,9 +11,17 @@ import React from 'react';
|
|
|
10
11
|
import styled from 'styled-components';
|
|
11
12
|
import { IPosition } from '../../types/eventTypes';
|
|
12
13
|
import { DraggableContainer } from '../DraggableContainer';
|
|
14
|
+
import {
|
|
15
|
+
ItemSlotDraggingProvider,
|
|
16
|
+
useItemSlotDragging,
|
|
17
|
+
} from '../Item/Inventory/context/ItemSlotDraggingContext';
|
|
18
|
+
import {
|
|
19
|
+
ItemSlotTooltipProvider,
|
|
20
|
+
useItemSlotTooltip,
|
|
21
|
+
} from '../Item/Inventory/context/ItemSlotTooltipContext';
|
|
13
22
|
import DraggedItem from '../Item/Inventory/DraggedItem';
|
|
14
23
|
import { ItemSlot } from '../Item/Inventory/ItemSlot';
|
|
15
|
-
import {
|
|
24
|
+
import { ItemSlotToolTips } from '../Item/Inventory/ItemSlotTooltips';
|
|
16
25
|
import { RPGUIContainerTypes } from '../RPGUI/RPGUIContainer';
|
|
17
26
|
|
|
18
27
|
export interface IEquipmentSetProps {
|
|
@@ -52,7 +61,6 @@ export const EquipmentSet: React.FC<IEquipmentSetProps> = ({
|
|
|
52
61
|
equipmentSet,
|
|
53
62
|
onClose,
|
|
54
63
|
onMouseOver,
|
|
55
|
-
onSelected,
|
|
56
64
|
onItemClick,
|
|
57
65
|
atlasIMG,
|
|
58
66
|
atlasJSON,
|
|
@@ -61,11 +69,11 @@ export const EquipmentSet: React.FC<IEquipmentSetProps> = ({
|
|
|
61
69
|
onItemPlaceDrop,
|
|
62
70
|
onItemOutsideDrop,
|
|
63
71
|
checkIfItemCanBeMoved,
|
|
64
|
-
checkIfItemShouldDragEnd,
|
|
65
72
|
scale,
|
|
66
73
|
initialPosition,
|
|
67
74
|
onPositionChangeEnd,
|
|
68
75
|
onPositionChangeStart,
|
|
76
|
+
onSelected,
|
|
69
77
|
}) => {
|
|
70
78
|
const {
|
|
71
79
|
neck,
|
|
@@ -106,6 +114,10 @@ export const EquipmentSet: React.FC<IEquipmentSetProps> = ({
|
|
|
106
114
|
ItemSlotType.Accessory,
|
|
107
115
|
];
|
|
108
116
|
|
|
117
|
+
const { dragState } = useItemSlotDragging();
|
|
118
|
+
|
|
119
|
+
const { updateItemDetails } = useItemSlotTooltip();
|
|
120
|
+
|
|
109
121
|
const onRenderEquipmentSlotRange = (start: number, end: number) => {
|
|
110
122
|
const equipmentRange = equipmentData.slice(start, end);
|
|
111
123
|
const slotMaksRange = equipmentMaskSlots.slice(start, end);
|
|
@@ -129,9 +141,6 @@ export const EquipmentSet: React.FC<IEquipmentSetProps> = ({
|
|
|
129
141
|
onPointerDown={(itemType, ContainerType) => {
|
|
130
142
|
if (onItemClick) onItemClick(itemType, item, ContainerType);
|
|
131
143
|
}}
|
|
132
|
-
onSelected={(optionId: string) => {
|
|
133
|
-
if (onSelected) onSelected(optionId);
|
|
134
|
-
}}
|
|
135
144
|
onDragStart={(item, slotIndex, itemContainerType) => {
|
|
136
145
|
if (!item) {
|
|
137
146
|
return;
|
|
@@ -145,7 +154,6 @@ export const EquipmentSet: React.FC<IEquipmentSetProps> = ({
|
|
|
145
154
|
}}
|
|
146
155
|
dragScale={scale}
|
|
147
156
|
checkIfItemCanBeMoved={checkIfItemCanBeMoved}
|
|
148
|
-
checkIfItemShouldDragEnd={checkIfItemShouldDragEnd}
|
|
149
157
|
onPlaceDrop={(item, slotIndex, itemContainerType) => {
|
|
150
158
|
if (onItemPlaceDrop)
|
|
151
159
|
onItemPlaceDrop(item, slotIndex, itemContainerType);
|
|
@@ -161,28 +169,52 @@ export const EquipmentSet: React.FC<IEquipmentSetProps> = ({
|
|
|
161
169
|
};
|
|
162
170
|
|
|
163
171
|
return (
|
|
164
|
-
<
|
|
165
|
-
<
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
<
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
172
|
+
<ItemSlotDraggingProvider>
|
|
173
|
+
<ItemSlotTooltipProvider>
|
|
174
|
+
<DraggedItem atlasIMG={atlasIMG} atlasJSON={atlasJSON} scale={scale} />
|
|
175
|
+
<DraggableContainer
|
|
176
|
+
title={'Equipments'}
|
|
177
|
+
type={RPGUIContainerTypes.Framed}
|
|
178
|
+
onCloseButton={() => {
|
|
179
|
+
if (onClose) onClose();
|
|
180
|
+
}}
|
|
181
|
+
width="330px"
|
|
182
|
+
cancelDrag=".equipment-container-body"
|
|
183
|
+
scale={scale}
|
|
184
|
+
initialPosition={initialPosition}
|
|
185
|
+
onPositionChangeEnd={onPositionChangeEnd}
|
|
186
|
+
onPositionChangeStart={onPositionChangeStart}
|
|
187
|
+
>
|
|
188
|
+
<EquipmentSetContainer className="equipment-container-body">
|
|
189
|
+
<EquipmentColumn>
|
|
190
|
+
{onRenderEquipmentSlotRange(0, 3)}
|
|
191
|
+
</EquipmentColumn>
|
|
192
|
+
<EquipmentColumn>
|
|
193
|
+
{onRenderEquipmentSlotRange(3, 7)}
|
|
194
|
+
</EquipmentColumn>
|
|
195
|
+
<EquipmentColumn>
|
|
196
|
+
{onRenderEquipmentSlotRange(7, 10)}
|
|
197
|
+
</EquipmentColumn>
|
|
198
|
+
</EquipmentSetContainer>
|
|
199
|
+
</DraggableContainer>
|
|
200
|
+
|
|
201
|
+
<ItemSlotToolTips
|
|
202
|
+
isFocused={dragState.isFocused}
|
|
203
|
+
isContextMenuDisabled={isMobile()}
|
|
204
|
+
dragScale={scale}
|
|
205
|
+
onSelected={(optionId: string, item: IItem) => {
|
|
206
|
+
updateItemDetails({
|
|
207
|
+
item,
|
|
208
|
+
contextMenu: { visible: false },
|
|
209
|
+
});
|
|
210
|
+
if (onSelected) onSelected(optionId);
|
|
211
|
+
}}
|
|
212
|
+
atlasIMG={atlasIMG}
|
|
213
|
+
atlasJSON={atlasJSON}
|
|
214
|
+
equipmentSet={equipmentSet}
|
|
215
|
+
/>
|
|
216
|
+
</ItemSlotTooltipProvider>
|
|
217
|
+
</ItemSlotDraggingProvider>
|
|
186
218
|
);
|
|
187
219
|
};
|
|
188
220
|
|
|
@@ -4,7 +4,7 @@ import styled from 'styled-components';
|
|
|
4
4
|
import { useCursorPosition } from '../../../hooks/useCursorPosition';
|
|
5
5
|
import { SpriteFromAtlas } from '../../shared/SpriteFromAtlas';
|
|
6
6
|
import { onRenderStackInfo } from './ItemSlotQty/ItemSlotQty';
|
|
7
|
-
import {
|
|
7
|
+
import { useItemSlotDragging } from './context/ItemSlotDraggingContext';
|
|
8
8
|
|
|
9
9
|
const CONTAINER_SIZE = 32;
|
|
10
10
|
const OFFSET = CONTAINER_SIZE / 2;
|
|
@@ -20,7 +20,7 @@ export const DraggedItem = ({
|
|
|
20
20
|
atlasIMG,
|
|
21
21
|
scale,
|
|
22
22
|
}: IProps): JSX.Element | null => {
|
|
23
|
-
const { item } =
|
|
23
|
+
const { item } = useItemSlotDragging();
|
|
24
24
|
|
|
25
25
|
const { x, y } = useCursorPosition({
|
|
26
26
|
scale,
|
|
@@ -14,10 +14,18 @@ import { SlotsContainer } from '../../Abstractions/SlotsContainer';
|
|
|
14
14
|
import { useScrollOnDrag } from '../../../hooks/useScrollOnDrag';
|
|
15
15
|
import { IPosition } from '../../../types/eventTypes';
|
|
16
16
|
import { ShortcutsSetter } from '../../Shortcuts/ShortcutsSetter';
|
|
17
|
+
import {
|
|
18
|
+
ItemSlotDraggingProvider,
|
|
19
|
+
useItemSlotDragging,
|
|
20
|
+
} from './context/ItemSlotDraggingContext';
|
|
21
|
+
import {
|
|
22
|
+
ItemSlotTooltipProvider,
|
|
23
|
+
useItemSlotTooltip,
|
|
24
|
+
} from './context/ItemSlotTooltipContext';
|
|
17
25
|
import { DraggedItem } from './DraggedItem';
|
|
18
26
|
import { ItemQuantitySelectorModal } from './ItemQuantitySelectorModal';
|
|
19
27
|
import { ItemSlot } from './ItemSlot';
|
|
20
|
-
import {
|
|
28
|
+
import { ItemSlotToolTips } from './ItemSlotTooltips';
|
|
21
29
|
|
|
22
30
|
export interface IItemContainerProps {
|
|
23
31
|
itemContainer: IItemContainer;
|
|
@@ -144,7 +152,6 @@ export const ItemContainer: React.FC<IItemContainerProps> = ({
|
|
|
144
152
|
}, [handleMouseMove, onItemDragStart, stopScrolling]);
|
|
145
153
|
|
|
146
154
|
const onDragStart: onDragStart = (item, slotIndex, itemContainerType) => {
|
|
147
|
-
console.log('DRAG START');
|
|
148
155
|
if (onItemDragStart) {
|
|
149
156
|
onItemDragStart(item, slotIndex, itemContainerType);
|
|
150
157
|
}
|
|
@@ -153,7 +160,6 @@ export const ItemContainer: React.FC<IItemContainerProps> = ({
|
|
|
153
160
|
};
|
|
154
161
|
|
|
155
162
|
const onDragEnd: onDragEnd = quantity => {
|
|
156
|
-
console.log('DRAG END');
|
|
157
163
|
if (onItemDragEnd) {
|
|
158
164
|
onItemDragEnd(quantity);
|
|
159
165
|
}
|
|
@@ -183,9 +189,6 @@ export const ItemContainer: React.FC<IItemContainerProps> = ({
|
|
|
183
189
|
onItemClick(item, itemType, containerType);
|
|
184
190
|
}
|
|
185
191
|
}}
|
|
186
|
-
onSelected={(optionId: string, item: IItem) => {
|
|
187
|
-
if (onSelected) onSelected(optionId, item);
|
|
188
|
-
}}
|
|
189
192
|
onDragStart={onDragStart}
|
|
190
193
|
onDragEnd={onDragEnd}
|
|
191
194
|
dragScale={scale}
|
|
@@ -218,7 +221,6 @@ export const ItemContainer: React.FC<IItemContainerProps> = ({
|
|
|
218
221
|
atlasIMG={atlasIMG}
|
|
219
222
|
atlasJSON={atlasJSON}
|
|
220
223
|
isSelectingShortcut={settingShortcutIndex !== -1}
|
|
221
|
-
equipmentSet={equipmentSet}
|
|
222
224
|
setItemShortcut={
|
|
223
225
|
type === ItemContainerType.Inventory ? handleSetShortcut : undefined
|
|
224
226
|
}
|
|
@@ -229,47 +231,69 @@ export const ItemContainer: React.FC<IItemContainerProps> = ({
|
|
|
229
231
|
return slots;
|
|
230
232
|
};
|
|
231
233
|
|
|
234
|
+
const { updateItemDetails } = useItemSlotTooltip();
|
|
235
|
+
const { dragState } = useItemSlotDragging();
|
|
236
|
+
|
|
232
237
|
return (
|
|
233
|
-
<
|
|
234
|
-
<
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
opacity={opacity}
|
|
244
|
-
>
|
|
245
|
-
{type === ItemContainerType.Inventory &&
|
|
246
|
-
shortcuts &&
|
|
247
|
-
removeShortcut && (
|
|
248
|
-
<ShortcutsSetter
|
|
249
|
-
setSettingShortcutIndex={setSettingShortcutIndex}
|
|
250
|
-
settingShortcutIndex={settingShortcutIndex}
|
|
251
|
-
shortcuts={shortcuts}
|
|
252
|
-
removeShortcut={removeShortcut}
|
|
253
|
-
atlasIMG={atlasIMG}
|
|
254
|
-
atlasJSON={atlasJSON}
|
|
255
|
-
/>
|
|
256
|
-
)}
|
|
257
|
-
<ItemsContainer
|
|
258
|
-
className="item-container-body"
|
|
259
|
-
ref={containerRef}
|
|
260
|
-
isScrollable={itemContainer.slotQty > MIN_SLOTS_FOR_SCROLL}
|
|
238
|
+
<ItemSlotDraggingProvider>
|
|
239
|
+
<ItemSlotTooltipProvider>
|
|
240
|
+
<DraggedItem atlasIMG={atlasIMG} atlasJSON={atlasJSON} scale={scale} />
|
|
241
|
+
<SlotsContainer
|
|
242
|
+
title={itemContainer.name || 'Container'}
|
|
243
|
+
onClose={onClose}
|
|
244
|
+
initialPosition={initialPosition}
|
|
245
|
+
scale={scale}
|
|
246
|
+
onPositionChangeEnd={onPositionChangeEnd}
|
|
247
|
+
onPositionChangeStart={onPositionChangeStart}
|
|
261
248
|
isFullScreen={isFullScreen}
|
|
249
|
+
opacity={opacity}
|
|
262
250
|
>
|
|
263
|
-
{
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
251
|
+
{type === ItemContainerType.Inventory &&
|
|
252
|
+
shortcuts &&
|
|
253
|
+
removeShortcut && (
|
|
254
|
+
<ShortcutsSetter
|
|
255
|
+
setSettingShortcutIndex={setSettingShortcutIndex}
|
|
256
|
+
settingShortcutIndex={settingShortcutIndex}
|
|
257
|
+
shortcuts={shortcuts}
|
|
258
|
+
removeShortcut={removeShortcut}
|
|
259
|
+
atlasIMG={atlasIMG}
|
|
260
|
+
atlasJSON={atlasJSON}
|
|
261
|
+
/>
|
|
262
|
+
)}
|
|
263
|
+
<ItemsContainer
|
|
264
|
+
className="item-container-body"
|
|
265
|
+
ref={containerRef}
|
|
266
|
+
isScrollable={itemContainer.slotQty > MIN_SLOTS_FOR_SCROLL}
|
|
267
|
+
isFullScreen={isFullScreen}
|
|
268
|
+
>
|
|
269
|
+
{onRenderSlots()}
|
|
270
|
+
</ItemsContainer>
|
|
271
|
+
</SlotsContainer>
|
|
272
|
+
|
|
273
|
+
<ItemSlotToolTips
|
|
274
|
+
isFocused={dragState.isFocused}
|
|
275
|
+
isContextMenuDisabled={disableContextMenu}
|
|
276
|
+
dragScale={scale}
|
|
277
|
+
onSelected={(optionId: string, item: IItem) => {
|
|
278
|
+
updateItemDetails({
|
|
279
|
+
item,
|
|
280
|
+
contextMenu: { visible: false },
|
|
281
|
+
});
|
|
282
|
+
if (onSelected) onSelected(optionId, item);
|
|
283
|
+
}}
|
|
284
|
+
atlasIMG={atlasIMG}
|
|
285
|
+
atlasJSON={atlasJSON}
|
|
286
|
+
equipmentSet={equipmentSet}
|
|
270
287
|
/>
|
|
271
|
-
|
|
272
|
-
|
|
288
|
+
|
|
289
|
+
{quantitySelect.isOpen && (
|
|
290
|
+
<ItemQuantitySelectorModal
|
|
291
|
+
quantitySelect={quantitySelect}
|
|
292
|
+
setQuantitySelect={setQuantitySelect}
|
|
293
|
+
/>
|
|
294
|
+
)}
|
|
295
|
+
</ItemSlotTooltipProvider>
|
|
296
|
+
</ItemSlotDraggingProvider>
|
|
273
297
|
);
|
|
274
298
|
};
|
|
275
299
|
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import {
|
|
2
|
-
IEquipmentSet,
|
|
3
2
|
IItem,
|
|
4
3
|
IItemContainer,
|
|
5
4
|
ItemContainerType,
|
|
@@ -9,15 +8,16 @@ import {
|
|
|
9
8
|
} from '@rpg-engine/shared';
|
|
10
9
|
|
|
11
10
|
import { observer } from 'mobx-react-lite';
|
|
12
|
-
import React, { useCallback, useEffect
|
|
11
|
+
import React, { useCallback, useEffect } from 'react';
|
|
13
12
|
import Draggable from 'react-draggable';
|
|
14
13
|
import styled from 'styled-components';
|
|
14
|
+
import { useCursorPosition } from '../../../hooks/useCursorPosition';
|
|
15
15
|
import { IPosition } from '../../../types/eventTypes';
|
|
16
16
|
import { rarityColor } from './ItemSlotRarity';
|
|
17
17
|
import { ItemSlotRenderer } from './ItemSlotRenderer';
|
|
18
|
-
import {
|
|
18
|
+
import { useItemSlotTooltip } from './context/ItemSlotTooltipContext';
|
|
19
19
|
import { useItemSlotDragAndDrop } from './hooks/useItemSlotDragAndDrop';
|
|
20
|
-
import {
|
|
20
|
+
import { generateContextMenu } from './itemContainerHelper';
|
|
21
21
|
|
|
22
22
|
export const EquipmentSlotSpriteByType: any = {
|
|
23
23
|
Neck: 'accessories/corruption-necklace.png',
|
|
@@ -38,7 +38,6 @@ interface IProps {
|
|
|
38
38
|
itemContainer?: IItemContainer | null;
|
|
39
39
|
itemContainerType?: ItemContainerType | null;
|
|
40
40
|
slotSpriteMask?: ItemSlotType | null;
|
|
41
|
-
onSelected?: (selectedOption: string, item: IItem) => void;
|
|
42
41
|
onMouseOver?: (
|
|
43
42
|
event: any,
|
|
44
43
|
slotIndex: number,
|
|
@@ -71,7 +70,6 @@ interface IProps {
|
|
|
71
70
|
atlasIMG: any;
|
|
72
71
|
isContextMenuDisabled?: boolean;
|
|
73
72
|
isSelectingShortcut?: boolean;
|
|
74
|
-
equipmentSet?: IEquipmentSet | null;
|
|
75
73
|
setItemShortcut?: (item: IItem, shortcutIndex: number) => void;
|
|
76
74
|
isDepotSystem?: boolean;
|
|
77
75
|
}
|
|
@@ -103,7 +101,6 @@ export const ItemSlot = React.memo(
|
|
|
103
101
|
onMouseOver,
|
|
104
102
|
onMouseOut,
|
|
105
103
|
onPointerDown,
|
|
106
|
-
onSelected,
|
|
107
104
|
atlasJSON,
|
|
108
105
|
atlasIMG,
|
|
109
106
|
isContextMenuDisabled = false,
|
|
@@ -115,25 +112,10 @@ export const ItemSlot = React.memo(
|
|
|
115
112
|
openQuantitySelector,
|
|
116
113
|
dragScale,
|
|
117
114
|
isSelectingShortcut,
|
|
118
|
-
|
|
115
|
+
|
|
119
116
|
setItemShortcut,
|
|
120
117
|
isDepotSystem,
|
|
121
118
|
}: IProps): JSX.Element => {
|
|
122
|
-
const [tooltipState, setTooltipState] = useState<TooltipState>({
|
|
123
|
-
visible: false,
|
|
124
|
-
mobileVisible: false,
|
|
125
|
-
});
|
|
126
|
-
const [contextMenuState, setContextMenuState] = useState<
|
|
127
|
-
ContextMenuState
|
|
128
|
-
>({
|
|
129
|
-
visible: false,
|
|
130
|
-
position: { x: 0, y: 0 },
|
|
131
|
-
});
|
|
132
|
-
|
|
133
|
-
const [contextActions, setContextActions] = useState<IContextMenuItem[]>(
|
|
134
|
-
[]
|
|
135
|
-
);
|
|
136
|
-
|
|
137
119
|
const {
|
|
138
120
|
dragContainer,
|
|
139
121
|
dragState,
|
|
@@ -156,16 +138,22 @@ export const ItemSlot = React.memo(
|
|
|
156
138
|
slotIndex,
|
|
157
139
|
openQuantitySelector: openQuantitySelector ?? (() => {}),
|
|
158
140
|
isContextMenuDisabled,
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
141
|
+
});
|
|
142
|
+
|
|
143
|
+
const { updateItemDetails, itemDetails } = useItemSlotTooltip();
|
|
144
|
+
|
|
145
|
+
const { x: cursorX, y: cursorY } = useCursorPosition({
|
|
146
|
+
scale: dragScale,
|
|
162
147
|
});
|
|
163
148
|
|
|
164
149
|
useEffect(() => {
|
|
165
150
|
if (item && containerType) {
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
151
|
+
updateItemDetails({
|
|
152
|
+
item,
|
|
153
|
+
contextMenu: {
|
|
154
|
+
actions: generateContextMenu(item, containerType, isDepotSystem),
|
|
155
|
+
},
|
|
156
|
+
});
|
|
169
157
|
}
|
|
170
158
|
}, [item, isDepotSystem]);
|
|
171
159
|
|
|
@@ -175,8 +163,7 @@ export const ItemSlot = React.memo(
|
|
|
175
163
|
(event: React.MouseEvent | React.TouchEvent) => {
|
|
176
164
|
event.stopPropagation();
|
|
177
165
|
|
|
178
|
-
|
|
179
|
-
'touches' in event ? event.touches[0] : event;
|
|
166
|
+
console.log('handleInteraction');
|
|
180
167
|
|
|
181
168
|
if (item && containerType) {
|
|
182
169
|
if (onPlaceDrop && draggingItem) {
|
|
@@ -191,8 +178,7 @@ export const ItemSlot = React.memo(
|
|
|
191
178
|
}
|
|
192
179
|
}
|
|
193
180
|
|
|
194
|
-
|
|
195
|
-
onMouseOver?.(event, slotIndex, item, clientX, clientY);
|
|
181
|
+
onMouseOver?.(event, slotIndex, item, cursorX, cursorY);
|
|
196
182
|
},
|
|
197
183
|
[
|
|
198
184
|
item,
|
|
@@ -203,6 +189,8 @@ export const ItemSlot = React.memo(
|
|
|
203
189
|
onMouseOver,
|
|
204
190
|
onDragStart,
|
|
205
191
|
onDragEnd,
|
|
192
|
+
cursorX,
|
|
193
|
+
cursorY,
|
|
206
194
|
]
|
|
207
195
|
);
|
|
208
196
|
|
|
@@ -211,22 +199,28 @@ export const ItemSlot = React.memo(
|
|
|
211
199
|
event.preventDefault();
|
|
212
200
|
event.stopPropagation();
|
|
213
201
|
|
|
214
|
-
|
|
202
|
+
console.log('handleInteractionEnd');
|
|
203
|
+
|
|
204
|
+
console.log('itemDetails', itemDetails);
|
|
215
205
|
onMouseOut?.();
|
|
216
206
|
|
|
217
|
-
if (event.type === 'touchend'
|
|
218
|
-
const { clientX, clientY } = event.changedTouches[0];
|
|
207
|
+
if (event.type === 'touchend') {
|
|
219
208
|
const simulatedEvent = new MouseEvent('mouseup', {
|
|
220
|
-
clientX,
|
|
221
|
-
clientY,
|
|
209
|
+
clientX: cursorX,
|
|
210
|
+
clientY: cursorY,
|
|
222
211
|
bubbles: true,
|
|
223
212
|
});
|
|
224
213
|
document
|
|
225
|
-
.elementFromPoint(
|
|
214
|
+
.elementFromPoint(cursorX, cursorY)
|
|
226
215
|
?.dispatchEvent(simulatedEvent);
|
|
216
|
+
|
|
217
|
+
updateItemDetails({
|
|
218
|
+
item,
|
|
219
|
+
tooltip: { visible: false },
|
|
220
|
+
});
|
|
227
221
|
}
|
|
228
222
|
},
|
|
229
|
-
[onMouseOut]
|
|
223
|
+
[onMouseOut, cursorX, cursorY]
|
|
230
224
|
);
|
|
231
225
|
|
|
232
226
|
return (
|
|
@@ -285,21 +279,27 @@ export const ItemSlot = React.memo(
|
|
|
285
279
|
<ItemContainer
|
|
286
280
|
ref={dragContainer}
|
|
287
281
|
isFocused={dragState.isFocused}
|
|
288
|
-
onMouseOver={
|
|
282
|
+
onMouseOver={() => {
|
|
289
283
|
onMouseOver?.(
|
|
290
|
-
|
|
284
|
+
{} as React.MouseEvent,
|
|
291
285
|
slotIndex,
|
|
292
286
|
item,
|
|
293
|
-
|
|
294
|
-
|
|
287
|
+
cursorX,
|
|
288
|
+
cursorY
|
|
295
289
|
);
|
|
296
290
|
}}
|
|
297
291
|
onMouseOut={onMouseOut}
|
|
298
292
|
onMouseEnter={() => {
|
|
299
|
-
|
|
293
|
+
updateItemDetails({
|
|
294
|
+
item,
|
|
295
|
+
tooltip: { visible: true },
|
|
296
|
+
});
|
|
300
297
|
}}
|
|
301
298
|
onMouseLeave={() => {
|
|
302
|
-
|
|
299
|
+
updateItemDetails({
|
|
300
|
+
item,
|
|
301
|
+
tooltip: { visible: false },
|
|
302
|
+
});
|
|
303
303
|
}}
|
|
304
304
|
>
|
|
305
305
|
<ItemSlotRenderer
|
|
@@ -311,25 +311,6 @@ export const ItemSlot = React.memo(
|
|
|
311
311
|
/>
|
|
312
312
|
</ItemContainer>
|
|
313
313
|
</Draggable>
|
|
314
|
-
|
|
315
|
-
<ItemSlotToolTips
|
|
316
|
-
tooltipState={tooltipState}
|
|
317
|
-
setTooltipState={setTooltipState}
|
|
318
|
-
contextMenuState={contextMenuState}
|
|
319
|
-
setContextMenuState={setContextMenuState}
|
|
320
|
-
isFocused={dragState.isFocused}
|
|
321
|
-
isContextMenuDisabled={isContextMenuDisabled}
|
|
322
|
-
item={item}
|
|
323
|
-
contextActions={contextActions}
|
|
324
|
-
dragScale={dragScale}
|
|
325
|
-
onSelected={(optionId: string, item: IItem) => {
|
|
326
|
-
setContextMenuState(prev => ({ ...prev, visible: false }));
|
|
327
|
-
if (onSelected) onSelected(optionId, item);
|
|
328
|
-
}}
|
|
329
|
-
atlasIMG={atlasIMG}
|
|
330
|
-
atlasJSON={atlasJSON}
|
|
331
|
-
equipmentSet={equipmentSet}
|
|
332
|
-
/>
|
|
333
314
|
</Container>
|
|
334
315
|
);
|
|
335
316
|
}
|