@rpg-engine/long-bow 0.7.39 → 0.7.41
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 +17 -1
- package/dist/components/Item/Inventory/ItemSlotTooltips.d.ts +7 -10
- package/dist/long-bow.cjs.development.js +197 -101
- 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 +198 -102
- package/dist/long-bow.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/components/Equipment/EquipmentSet.tsx +1 -0
- package/src/components/Item/Inventory/ItemContainer.tsx +3 -1
- package/src/components/Item/Inventory/ItemSlot.tsx +330 -268
- package/src/components/Item/Inventory/ItemSlotTooltips.tsx +18 -22
- package/src/stories/UI/containers/ItemContainer.stories.tsx +11 -1
|
@@ -1,24 +1,21 @@
|
|
|
1
1
|
import { IEquipmentSet, IItem } from '@rpg-engine/shared';
|
|
2
2
|
import React from 'react';
|
|
3
|
-
import { IPosition } from '../../../types/eventTypes';
|
|
4
3
|
import { RelativeListMenu } from '../../RelativeListMenu';
|
|
5
4
|
import { ItemTooltip } from '../Cards/ItemTooltip';
|
|
6
5
|
import { MobileItemTooltip } from '../Cards/MobileItemTooltip';
|
|
7
6
|
import { IContextMenuItem } from './itemContainerHelper';
|
|
7
|
+
import type { ContextMenuState, TooltipState } from './ItemSlot';
|
|
8
8
|
|
|
9
9
|
interface IProps {
|
|
10
|
-
|
|
10
|
+
tooltipState: TooltipState;
|
|
11
|
+
setTooltipState: React.Dispatch<React.SetStateAction<TooltipState>>;
|
|
12
|
+
contextMenuState: ContextMenuState;
|
|
13
|
+
setContextMenuState: React.Dispatch<React.SetStateAction<ContextMenuState>>;
|
|
11
14
|
isFocused: boolean;
|
|
12
|
-
isContextMenuVisible: boolean;
|
|
13
15
|
isContextMenuDisabled: boolean;
|
|
14
16
|
item: IItem | null;
|
|
15
|
-
isTooltipMobileVisible: boolean;
|
|
16
17
|
contextActions: IContextMenuItem[];
|
|
17
|
-
contextMenuPosition: IPosition;
|
|
18
18
|
dragScale: number | undefined;
|
|
19
|
-
setIsContextMenuVisible: (visible: boolean) => void;
|
|
20
|
-
setIsTooltipMobileVisible: (visible: boolean) => void;
|
|
21
|
-
setIsTooltipVisible: (visible: boolean) => void;
|
|
22
19
|
onSelected?: (optionId: string, item: IItem) => void;
|
|
23
20
|
atlasIMG: any;
|
|
24
21
|
atlasJSON: any;
|
|
@@ -26,17 +23,15 @@ interface IProps {
|
|
|
26
23
|
}
|
|
27
24
|
|
|
28
25
|
export const ItemSlotToolTips = ({
|
|
29
|
-
|
|
26
|
+
tooltipState,
|
|
27
|
+
setTooltipState,
|
|
28
|
+
contextMenuState,
|
|
29
|
+
setContextMenuState,
|
|
30
30
|
isFocused,
|
|
31
|
-
isContextMenuVisible,
|
|
32
31
|
isContextMenuDisabled,
|
|
33
32
|
item,
|
|
34
33
|
contextActions,
|
|
35
|
-
contextMenuPosition,
|
|
36
34
|
dragScale,
|
|
37
|
-
setIsContextMenuVisible,
|
|
38
|
-
setIsTooltipMobileVisible,
|
|
39
|
-
isTooltipMobileVisible,
|
|
40
35
|
onSelected,
|
|
41
36
|
atlasIMG,
|
|
42
37
|
atlasJSON,
|
|
@@ -44,7 +39,7 @@ export const ItemSlotToolTips = ({
|
|
|
44
39
|
}: IProps): JSX.Element => {
|
|
45
40
|
return (
|
|
46
41
|
<>
|
|
47
|
-
{
|
|
42
|
+
{tooltipState.visible && item && !isFocused && (
|
|
48
43
|
<ItemTooltip
|
|
49
44
|
item={item}
|
|
50
45
|
atlasIMG={atlasIMG}
|
|
@@ -53,19 +48,19 @@ export const ItemSlotToolTips = ({
|
|
|
53
48
|
/>
|
|
54
49
|
)}
|
|
55
50
|
|
|
56
|
-
{
|
|
51
|
+
{tooltipState.mobileVisible && item && (
|
|
57
52
|
<MobileItemTooltip
|
|
58
53
|
item={item}
|
|
59
54
|
atlasIMG={atlasIMG}
|
|
60
55
|
atlasJSON={atlasJSON}
|
|
61
56
|
equipmentSet={equipmentSet}
|
|
62
57
|
closeTooltip={() => {
|
|
63
|
-
|
|
58
|
+
setTooltipState(prev => ({ ...prev, mobileVisible: false }));
|
|
64
59
|
}}
|
|
65
60
|
scale={dragScale}
|
|
66
61
|
options={contextActions}
|
|
67
62
|
onSelected={(optionId: string) => {
|
|
68
|
-
|
|
63
|
+
setContextMenuState(prev => ({ ...prev, visible: false }));
|
|
69
64
|
if (item) {
|
|
70
65
|
onSelected?.(optionId, item);
|
|
71
66
|
}
|
|
@@ -73,19 +68,20 @@ export const ItemSlotToolTips = ({
|
|
|
73
68
|
/>
|
|
74
69
|
)}
|
|
75
70
|
|
|
76
|
-
{!isContextMenuDisabled &&
|
|
71
|
+
{!isContextMenuDisabled && contextMenuState.visible && contextActions && (
|
|
77
72
|
<RelativeListMenu
|
|
78
73
|
options={contextActions}
|
|
79
74
|
onSelected={(optionId: string) => {
|
|
80
|
-
|
|
75
|
+
setContextMenuState(prev => ({ ...prev, visible: false }));
|
|
76
|
+
|
|
81
77
|
if (item) {
|
|
82
78
|
onSelected?.(optionId, item);
|
|
83
79
|
}
|
|
84
80
|
}}
|
|
85
81
|
onOutsideClick={() => {
|
|
86
|
-
|
|
82
|
+
setContextMenuState(prev => ({ ...prev, visible: false }));
|
|
87
83
|
}}
|
|
88
|
-
pos={
|
|
84
|
+
pos={contextMenuState.position}
|
|
89
85
|
/>
|
|
90
86
|
)}
|
|
91
87
|
</>
|
|
@@ -23,7 +23,7 @@ export default meta;
|
|
|
23
23
|
|
|
24
24
|
const onMouseOver = (_event: any, slotIndex: number, item: IItem | null) => {
|
|
25
25
|
if (!item) {
|
|
26
|
-
|
|
26
|
+
console.log(`Free at ${slotIndex}`);
|
|
27
27
|
return;
|
|
28
28
|
}
|
|
29
29
|
console.log(`${item.name} at ${slotIndex}`);
|
|
@@ -115,12 +115,22 @@ const Template: Story<IItemContainerProps & ITemplateProps> = ({
|
|
|
115
115
|
onItemPlaceDrop={(item, slotIndex) => {
|
|
116
116
|
// THIS IS ONLY LONG-BOW EXAMPLE FOR DRAG AND DROP
|
|
117
117
|
|
|
118
|
+
console.log({
|
|
119
|
+
item: item?.name,
|
|
120
|
+
sI: slotIndex,
|
|
121
|
+
dragK: dragItem?.key,
|
|
122
|
+
itemK: item?.key,
|
|
123
|
+
dragSlot,
|
|
124
|
+
slotIndex,
|
|
125
|
+
});
|
|
126
|
+
|
|
118
127
|
if (!item || (dragItem?.key === item?.key && dragSlot !== slotIndex)) {
|
|
119
128
|
console.log('allow');
|
|
120
129
|
allowedToDrop = true;
|
|
121
130
|
dropSlot = slotIndex;
|
|
122
131
|
dropItem = item ? item : null;
|
|
123
132
|
} else {
|
|
133
|
+
console.log('not allowing drop');
|
|
124
134
|
allowedToDrop = false;
|
|
125
135
|
dropSlot = -1;
|
|
126
136
|
dropItem = null;
|