@rpg-engine/long-bow 0.7.75 → 0.7.77
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 +25 -0
- package/dist/components/Item/Inventory/context/ItemSlotDetailsContext.d.ts +1 -1
- package/dist/long-bow.cjs.development.js +14 -12
- 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 +14 -12
- package/dist/long-bow.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/components/Item/Inventory/ItemSlot.tsx +63 -21
- package/src/components/Item/Inventory/context/ItemSlotDetailsContext.tsx +7 -3
package/package.json
CHANGED
|
@@ -76,6 +76,50 @@ interface IProps {
|
|
|
76
76
|
isDepotSystem?: boolean;
|
|
77
77
|
}
|
|
78
78
|
|
|
79
|
+
interface IProps {
|
|
80
|
+
slotIndex: number;
|
|
81
|
+
item: IItem | null;
|
|
82
|
+
itemContainer?: IItemContainer | null;
|
|
83
|
+
itemContainerType?: ItemContainerType | null;
|
|
84
|
+
slotSpriteMask?: ItemSlotType | null;
|
|
85
|
+
onMouseOver?: (
|
|
86
|
+
event: any,
|
|
87
|
+
slotIndex: number,
|
|
88
|
+
item: IItem | null,
|
|
89
|
+
x: number,
|
|
90
|
+
y: number
|
|
91
|
+
) => void;
|
|
92
|
+
onMouseOut?: () => void;
|
|
93
|
+
onPointerDown: (
|
|
94
|
+
ItemType: ItemType,
|
|
95
|
+
itemContainerType: ItemContainerType | null,
|
|
96
|
+
item: IItem
|
|
97
|
+
) => void;
|
|
98
|
+
onDragStart?: (
|
|
99
|
+
item: IItem,
|
|
100
|
+
slotIndex: number,
|
|
101
|
+
itemContainerType: ItemContainerType | null
|
|
102
|
+
) => void;
|
|
103
|
+
onDragEnd?: (quantity?: number) => void;
|
|
104
|
+
onOutsideDrop?: (item: IItem, position: IPosition) => void;
|
|
105
|
+
dragScale?: number;
|
|
106
|
+
checkIfItemCanBeMoved?: () => boolean;
|
|
107
|
+
checkIfItemShouldDragEnd?: () => boolean;
|
|
108
|
+
openQuantitySelector?: (maxQuantity: number, callback: () => void) => void;
|
|
109
|
+
onPlaceDrop?: (
|
|
110
|
+
item: IItem | null,
|
|
111
|
+
slotIndex: number,
|
|
112
|
+
itemContainerType: ItemContainerType | null
|
|
113
|
+
) => void;
|
|
114
|
+
atlasJSON: any;
|
|
115
|
+
atlasIMG: any;
|
|
116
|
+
isContextMenuDisabled?: boolean;
|
|
117
|
+
isSelectingShortcut?: boolean;
|
|
118
|
+
equipmentSet?: IEquipmentSet | null;
|
|
119
|
+
setItemShortcut?: (item: IItem, shortcutIndex: number) => void;
|
|
120
|
+
isDepotSystem?: boolean;
|
|
121
|
+
}
|
|
122
|
+
|
|
79
123
|
export const ItemSlot: React.FC<IProps> = observer(
|
|
80
124
|
({
|
|
81
125
|
slotIndex,
|
|
@@ -107,11 +151,7 @@ export const ItemSlot: React.FC<IProps> = observer(
|
|
|
107
151
|
setContextActions,
|
|
108
152
|
} = useItemSlotDetails();
|
|
109
153
|
|
|
110
|
-
const {
|
|
111
|
-
isContextMenuVisible,
|
|
112
|
-
|
|
113
|
-
clearContextActions,
|
|
114
|
-
} = detailsState;
|
|
154
|
+
const { isContextMenuVisible, clearContextActions } = detailsState;
|
|
115
155
|
|
|
116
156
|
const dragContainer = useRef<HTMLDivElement>(null);
|
|
117
157
|
|
|
@@ -130,36 +170,27 @@ export const ItemSlot: React.FC<IProps> = observer(
|
|
|
130
170
|
|
|
131
171
|
useEffect(() => {
|
|
132
172
|
// Reset drag position and focus when item changes
|
|
133
|
-
|
|
134
173
|
updateDraggingState({
|
|
135
174
|
position: { x: 0, y: 0 },
|
|
136
175
|
isFocused: false,
|
|
137
176
|
});
|
|
138
|
-
|
|
139
|
-
// Update context actions when item or depot system changes
|
|
140
|
-
if (item && containerType && !isContextMenuDisabled) {
|
|
141
|
-
setContextActions(
|
|
142
|
-
item,
|
|
143
|
-
containerType as ItemContainerType,
|
|
144
|
-
isDepotSystem ?? false
|
|
145
|
-
);
|
|
146
|
-
} else {
|
|
147
|
-
clearContextActions();
|
|
148
|
-
}
|
|
149
177
|
}, [
|
|
150
|
-
item,
|
|
151
178
|
containerType,
|
|
152
179
|
isDepotSystem,
|
|
153
180
|
setContextActions,
|
|
154
181
|
clearContextActions,
|
|
182
|
+
isContextMenuDisabled, // Added missing dependency
|
|
155
183
|
]);
|
|
156
184
|
|
|
157
185
|
useEffect(() => {
|
|
158
186
|
// Handle outside drop
|
|
159
|
-
if (onDrop && item && dropPosition) {
|
|
160
|
-
|
|
187
|
+
if (onDrop && draggingState.item && dropPosition) {
|
|
188
|
+
console.log('ITEM SLOT: Outside drop', draggingState.item.key);
|
|
189
|
+
onDrop(draggingState.item, dropPosition);
|
|
190
|
+
|
|
191
|
+
clearDraggingState();
|
|
161
192
|
}
|
|
162
|
-
}, [dropPosition]);
|
|
193
|
+
}, [dropPosition, onDrop, draggingState.item]);
|
|
163
194
|
|
|
164
195
|
const resetItem = () => {
|
|
165
196
|
clearDraggingState();
|
|
@@ -182,6 +213,15 @@ export const ItemSlot: React.FC<IProps> = observer(
|
|
|
182
213
|
}
|
|
183
214
|
};
|
|
184
215
|
|
|
216
|
+
const refreshContextActions = () => {
|
|
217
|
+
setContextActions(
|
|
218
|
+
item,
|
|
219
|
+
containerType as ItemContainerType,
|
|
220
|
+
isDepotSystem ?? false,
|
|
221
|
+
isContextMenuDisabled
|
|
222
|
+
);
|
|
223
|
+
};
|
|
224
|
+
|
|
185
225
|
const onDraggableStop: DraggableEventHandler = (e, data) => {
|
|
186
226
|
requestAnimationFrame(() => {
|
|
187
227
|
updateDraggingState({
|
|
@@ -338,6 +378,8 @@ export const ItemSlot: React.FC<IProps> = observer(
|
|
|
338
378
|
return;
|
|
339
379
|
}
|
|
340
380
|
|
|
381
|
+
refreshContextActions();
|
|
382
|
+
|
|
341
383
|
if (onDragStart && containerType) {
|
|
342
384
|
onDragStart(item, slotIndex, containerType);
|
|
343
385
|
}
|
|
@@ -31,7 +31,8 @@ interface IItemSlotDetailsContext {
|
|
|
31
31
|
setContextActions: (
|
|
32
32
|
item: IItem | null,
|
|
33
33
|
containerType: string | null,
|
|
34
|
-
isDepotSystem: boolean
|
|
34
|
+
isDepotSystem: boolean,
|
|
35
|
+
isContextMenuDisabled: boolean
|
|
35
36
|
) => void;
|
|
36
37
|
clearContextActions: () => void;
|
|
37
38
|
}
|
|
@@ -85,14 +86,17 @@ export const ItemSlotDetailsProvider: React.FC<IProps> = ({ children }) => {
|
|
|
85
86
|
(
|
|
86
87
|
item: IItem | null,
|
|
87
88
|
containerType: string | null,
|
|
88
|
-
isDepotSystem: boolean
|
|
89
|
+
isDepotSystem: boolean,
|
|
90
|
+
isContextMenuDisabled: boolean
|
|
89
91
|
): void => {
|
|
90
|
-
|
|
92
|
+
console.log('ITEM SLOT: Set context actions for', item?.key);
|
|
93
|
+
if (item && containerType && !isContextMenuDisabled) {
|
|
91
94
|
const newContextActions = generateContextMenu(
|
|
92
95
|
item,
|
|
93
96
|
containerType as ItemContainerType,
|
|
94
97
|
isDepotSystem
|
|
95
98
|
);
|
|
99
|
+
console.log('ITEM SLOT: New context actions:', newContextActions);
|
|
96
100
|
updateDetailsState({ contextActions: newContextActions });
|
|
97
101
|
} else {
|
|
98
102
|
updateDetailsState({ contextActions: [] });
|